pep.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * File: pep.h
  3. *
  4. * Phonet Pipe End Point sockets definitions
  5. *
  6. * Copyright (C) 2008 Nokia Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #ifndef NET_PHONET_PEP_H
  23. #define NET_PHONET_PEP_H
  24. struct pep_sock {
  25. struct pn_sock pn_sk;
  26. /* XXX: union-ify listening vs connected stuff ? */
  27. /* Listening socket stuff: */
  28. struct hlist_head hlist;
  29. /* Connected socket stuff: */
  30. struct sock *listener;
  31. struct sk_buff_head ctrlreq_queue;
  32. #define PNPIPE_CTRLREQ_MAX 10
  33. atomic_t tx_credits;
  34. int ifindex;
  35. u16 peer_type; /* peer type/subtype */
  36. u8 pipe_handle;
  37. u8 rx_credits;
  38. u8 rx_fc; /* RX flow control */
  39. u8 tx_fc; /* TX flow control */
  40. u8 init_enable; /* auto-enable at creation */
  41. u8 aligned;
  42. };
  43. static inline struct pep_sock *pep_sk(struct sock *sk)
  44. {
  45. return (struct pep_sock *)sk;
  46. }
  47. extern const struct proto_ops phonet_stream_ops;
  48. /* Pipe protocol definitions */
  49. struct pnpipehdr {
  50. u8 utid; /* transaction ID */
  51. u8 message_id;
  52. u8 pipe_handle;
  53. union {
  54. u8 state_after_connect; /* connect request */
  55. u8 state_after_reset; /* reset request */
  56. u8 error_code; /* any response */
  57. u8 pep_type; /* status indication */
  58. u8 data0; /* anything else */
  59. };
  60. u8 data[];
  61. };
  62. #define other_pep_type data[0]
  63. static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
  64. {
  65. return (struct pnpipehdr *)skb_transport_header(skb);
  66. }
  67. #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
  68. enum {
  69. PNS_PIPE_CREATE_REQ = 0x00,
  70. PNS_PIPE_CREATE_RESP,
  71. PNS_PIPE_REMOVE_REQ,
  72. PNS_PIPE_REMOVE_RESP,
  73. PNS_PIPE_DATA = 0x20,
  74. PNS_PIPE_ALIGNED_DATA,
  75. PNS_PEP_CONNECT_REQ = 0x40,
  76. PNS_PEP_CONNECT_RESP,
  77. PNS_PEP_DISCONNECT_REQ,
  78. PNS_PEP_DISCONNECT_RESP,
  79. PNS_PEP_RESET_REQ,
  80. PNS_PEP_RESET_RESP,
  81. PNS_PEP_ENABLE_REQ,
  82. PNS_PEP_ENABLE_RESP,
  83. PNS_PEP_CTRL_REQ,
  84. PNS_PEP_CTRL_RESP,
  85. PNS_PEP_DISABLE_REQ = 0x4C,
  86. PNS_PEP_DISABLE_RESP,
  87. PNS_PEP_STATUS_IND = 0x60,
  88. PNS_PIPE_CREATED_IND,
  89. PNS_PIPE_RESET_IND = 0x63,
  90. PNS_PIPE_ENABLED_IND,
  91. PNS_PIPE_REDIRECTED_IND,
  92. PNS_PIPE_DISABLED_IND = 0x66,
  93. };
  94. #define PN_PIPE_INVALID_HANDLE 0xff
  95. #define PN_PEP_TYPE_COMMON 0x00
  96. /* Phonet pipe status indication */
  97. enum {
  98. PN_PEP_IND_FLOW_CONTROL,
  99. PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
  100. };
  101. /* Phonet pipe error codes */
  102. enum {
  103. PN_PIPE_NO_ERROR,
  104. PN_PIPE_ERR_INVALID_PARAM,
  105. PN_PIPE_ERR_INVALID_HANDLE,
  106. PN_PIPE_ERR_INVALID_CTRL_ID,
  107. PN_PIPE_ERR_NOT_ALLOWED,
  108. PN_PIPE_ERR_PEP_IN_USE,
  109. PN_PIPE_ERR_OVERLOAD,
  110. PN_PIPE_ERR_DEV_DISCONNECTED,
  111. PN_PIPE_ERR_TIMEOUT,
  112. PN_PIPE_ERR_ALL_PIPES_IN_USE,
  113. PN_PIPE_ERR_GENERAL,
  114. PN_PIPE_ERR_NOT_SUPPORTED,
  115. };
  116. /* Phonet pipe states */
  117. enum {
  118. PN_PIPE_DISABLE,
  119. PN_PIPE_ENABLE,
  120. };
  121. /* Phonet pipe sub-block types */
  122. enum {
  123. PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
  124. PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
  125. PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
  126. PN_PIPE_SB_NEGOTIATED_FC,
  127. PN_PIPE_SB_REQUIRED_FC_TX,
  128. PN_PIPE_SB_PREFERRED_FC_RX,
  129. PN_PIPE_SB_ALIGNED_DATA,
  130. };
  131. /* Phonet pipe flow control models */
  132. enum {
  133. PN_NO_FLOW_CONTROL,
  134. PN_LEGACY_FLOW_CONTROL,
  135. PN_ONE_CREDIT_FLOW_CONTROL,
  136. PN_MULTI_CREDIT_FLOW_CONTROL,
  137. PN_MAX_FLOW_CONTROL,
  138. };
  139. #define pn_flow_safe(fc) ((fc) >> 1)
  140. /* Phonet pipe flow control states */
  141. enum {
  142. PEP_IND_EMPTY,
  143. PEP_IND_BUSY,
  144. PEP_IND_READY,
  145. };
  146. #endif