client_pm.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. This Source Code Form is subject to the terms of the Mozilla Public
  3. License, v. 2.0. If a copy of the MPL was not distributed with this
  4. file, You can obtain one at https://mozilla.org/MPL/2.0/.
  5. */
  6. package internal
  7. func NewClientPM() *ClientPM {
  8. return &ClientPM{}
  9. }
  10. type ClientPMState int
  11. const (
  12. ClientPMStateNihil ClientPMState = iota
  13. )
  14. /*
  15. Protocol machine for the IPC Client protocol.
  16. The CPM is a symmetric protocol used by IPC clients to
  17. communicate with the local IPC service. This protocol
  18. provides a means of requesting allocation of IPC resources
  19. by the network for communication with a target application
  20. process (AP), AP instance, application protocol machine
  21. (APM), or APM instance, contingent on criteria such as proof
  22. of prior registration (i.e. authentication) and whether the
  23. requested communication is permitted by the target (i.e.
  24. authorization).
  25. While authorization is somewhat expensive in our model (as
  26. we must allocate the requested resources in order to
  27. determine whether the target even exists, let alone whether
  28. it accepts the request), we can (and should) cache
  29. unfavorable, and only unfavorable, results until such time
  30. as the cache lifetime, as suggested by the target, expires.
  31. And since we expect other network elements in other
  32. administrative domains to abide by this lifetime, there is
  33. little point in attempting to bypass said lifetime in our
  34. own administrative domain.
  35. The same observation also applies to requests made by
  36. authorized clients, where the rate of successful requests
  37. for resources exceeds some network-wide "decorum" threshold,
  38. above which subsequent requests may be shaped, policed, or
  39. simply dropped outright for a period of time by upstream
  40. network elements. In the worst case, the target may choose
  41. to begin propagating authorization failures, resulting in
  42. precisely the same cached result situation as above. And, of
  43. course, network operators may always elect to drop all
  44. subsequent requests for all targets, indefinitely,
  45. commensurate with prior activity, until such time as the
  46. individual case can be reviewed and the equipment owner,
  47. contacted.
  48. */
  49. type ClientPM struct {
  50. state ClientPMState
  51. }
  52. /*
  53. Notify PM of an event, given by the provided buffer.
  54. Events are internal to the distributed IPC facility (DIF).
  55. Compare with the notion of "East-West" traffic, which is
  56. disanalogous insofar as our model allows for multiple
  57. discontiguous layers of equal rank yet differing scope.
  58. */
  59. func (pm *ClientPM) Event(e []byte) ([]byte, error) {
  60. return e, nil
  61. }
  62. /*
  63. Generate an allocation request SDU.
  64. Requests/responses are external to the distributed IPC
  65. facility (DIF) and occur within a single processing system
  66. (i.e. locally).
  67. Since requests/responses represent a transition from
  68. internal to external (and vice versa), and since the
  69. corresponding API forms a natural (indeed, the only)
  70. boundary between these two domains, many security
  71. considerations will naturally tend to concentrate here.
  72. While it is not the responsibility of the protocol to
  73. enforce constraints around these considerations, it must
  74. create affordances for the ambient implementation to do so.
  75. */
  76. func (pm *ClientPM) ReqAlloc(buf []byte) []byte {
  77. buf[0] = 1
  78. return buf[:8]
  79. }