pep.h 3.7 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 data[1];
  59. };
  60. };
  61. #define other_pep_type data[1]
  62. static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
  63. {
  64. return (struct pnpipehdr *)skb_transport_header(skb);
  65. }
  66. #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
  67. enum {
  68. PNS_PIPE_CREATE_REQ = 0x00,
  69. PNS_PIPE_CREATE_RESP,
  70. PNS_PIPE_REMOVE_REQ,
  71. PNS_PIPE_REMOVE_RESP,
  72. PNS_PIPE_DATA = 0x20,
  73. PNS_PIPE_ALIGNED_DATA,
  74. PNS_PEP_CONNECT_REQ = 0x40,
  75. PNS_PEP_CONNECT_RESP,
  76. PNS_PEP_DISCONNECT_REQ,
  77. PNS_PEP_DISCONNECT_RESP,
  78. PNS_PEP_RESET_REQ,
  79. PNS_PEP_RESET_RESP,
  80. PNS_PEP_ENABLE_REQ,
  81. PNS_PEP_ENABLE_RESP,
  82. PNS_PEP_CTRL_REQ,
  83. PNS_PEP_CTRL_RESP,
  84. PNS_PEP_DISABLE_REQ = 0x4C,
  85. PNS_PEP_DISABLE_RESP,
  86. PNS_PEP_STATUS_IND = 0x60,
  87. PNS_PIPE_CREATED_IND,
  88. PNS_PIPE_RESET_IND = 0x63,
  89. PNS_PIPE_ENABLED_IND,
  90. PNS_PIPE_REDIRECTED_IND,
  91. PNS_PIPE_DISABLED_IND = 0x66,
  92. };
  93. #define PN_PIPE_INVALID_HANDLE 0xff
  94. #define PN_PEP_TYPE_COMMON 0x00
  95. /* Phonet pipe status indication */
  96. enum {
  97. PN_PEP_IND_FLOW_CONTROL,
  98. PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
  99. };
  100. /* Phonet pipe error codes */
  101. enum {
  102. PN_PIPE_NO_ERROR,
  103. PN_PIPE_ERR_INVALID_PARAM,
  104. PN_PIPE_ERR_INVALID_HANDLE,
  105. PN_PIPE_ERR_INVALID_CTRL_ID,
  106. PN_PIPE_ERR_NOT_ALLOWED,
  107. PN_PIPE_ERR_PEP_IN_USE,
  108. PN_PIPE_ERR_OVERLOAD,
  109. PN_PIPE_ERR_DEV_DISCONNECTED,
  110. PN_PIPE_ERR_TIMEOUT,
  111. PN_PIPE_ERR_ALL_PIPES_IN_USE,
  112. PN_PIPE_ERR_GENERAL,
  113. PN_PIPE_ERR_NOT_SUPPORTED,
  114. };
  115. /* Phonet pipe states */
  116. enum {
  117. PN_PIPE_DISABLE,
  118. PN_PIPE_ENABLE,
  119. };
  120. /* Phonet pipe sub-block types */
  121. enum {
  122. PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
  123. PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
  124. PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
  125. PN_PIPE_SB_NEGOTIATED_FC,
  126. PN_PIPE_SB_REQUIRED_FC_TX,
  127. PN_PIPE_SB_PREFERRED_FC_RX,
  128. PN_PIPE_SB_ALIGNED_DATA,
  129. };
  130. /* Phonet pipe flow control models */
  131. enum {
  132. PN_NO_FLOW_CONTROL,
  133. PN_LEGACY_FLOW_CONTROL,
  134. PN_ONE_CREDIT_FLOW_CONTROL,
  135. PN_MULTI_CREDIT_FLOW_CONTROL,
  136. PN_MAX_FLOW_CONTROL,
  137. };
  138. #define pn_flow_safe(fc) ((fc) >> 1)
  139. /* Phonet pipe flow control states */
  140. enum {
  141. PEP_IND_EMPTY,
  142. PEP_IND_BUSY,
  143. PEP_IND_READY,
  144. };
  145. #endif