Phonet: use socket destination in pipe protocol
[deliverable/linux.git] / include / net / phonet / pep.h
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
23 #ifndef NET_PHONET_PEP_H
24 #define NET_PHONET_PEP_H
25
26 struct pep_sock {
27 struct pn_sock pn_sk;
28
29 /* XXX: union-ify listening vs connected stuff ? */
30 /* Listening socket stuff: */
31 struct hlist_head ackq;
32 struct hlist_head hlist;
33
34 /* Connected socket stuff: */
35 struct sock *listener;
36 struct sk_buff_head ctrlreq_queue;
37 #define PNPIPE_CTRLREQ_MAX 10
38 atomic_t tx_credits;
39 int ifindex;
40 u16 peer_type; /* peer type/subtype */
41 u8 pipe_handle;
42
43 u8 rx_credits;
44 u8 rx_fc; /* RX flow control */
45 u8 tx_fc; /* TX flow control */
46 u8 init_enable; /* auto-enable at creation */
47 u8 aligned;
48 #ifdef CONFIG_PHONET_PIPECTRLR
49 u8 pipe_state;
50 #endif
51 };
52
53 static inline struct pep_sock *pep_sk(struct sock *sk)
54 {
55 return (struct pep_sock *)sk;
56 }
57
58 extern const struct proto_ops phonet_stream_ops;
59
60 /* Pipe protocol definitions */
61 struct pnpipehdr {
62 u8 utid; /* transaction ID */
63 u8 message_id;
64 u8 pipe_handle;
65 union {
66 u8 state_after_connect; /* connect request */
67 u8 state_after_reset; /* reset request */
68 u8 error_code; /* any response */
69 u8 pep_type; /* status indication */
70 u8 data[1];
71 };
72 };
73 #define other_pep_type data[1]
74
75 static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
76 {
77 return (struct pnpipehdr *)skb_transport_header(skb);
78 }
79
80 #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
81
82 enum {
83 PNS_PIPE_CREATE_REQ = 0x00,
84 PNS_PIPE_CREATE_RESP,
85 PNS_PIPE_REMOVE_REQ,
86 PNS_PIPE_REMOVE_RESP,
87
88 PNS_PIPE_DATA = 0x20,
89 PNS_PIPE_ALIGNED_DATA,
90
91 PNS_PEP_CONNECT_REQ = 0x40,
92 PNS_PEP_CONNECT_RESP,
93 PNS_PEP_DISCONNECT_REQ,
94 PNS_PEP_DISCONNECT_RESP,
95 PNS_PEP_RESET_REQ,
96 PNS_PEP_RESET_RESP,
97 PNS_PEP_ENABLE_REQ,
98 PNS_PEP_ENABLE_RESP,
99 PNS_PEP_CTRL_REQ,
100 PNS_PEP_CTRL_RESP,
101 PNS_PEP_DISABLE_REQ = 0x4C,
102 PNS_PEP_DISABLE_RESP,
103
104 PNS_PEP_STATUS_IND = 0x60,
105 PNS_PIPE_CREATED_IND,
106 PNS_PIPE_RESET_IND = 0x63,
107 PNS_PIPE_ENABLED_IND,
108 PNS_PIPE_REDIRECTED_IND,
109 PNS_PIPE_DISABLED_IND = 0x66,
110 };
111
112 #define PN_PIPE_INVALID_HANDLE 0xff
113 #define PN_PEP_TYPE_COMMON 0x00
114
115 /* Phonet pipe status indication */
116 enum {
117 PN_PEP_IND_FLOW_CONTROL,
118 PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
119 };
120
121 /* Phonet pipe error codes */
122 enum {
123 PN_PIPE_NO_ERROR,
124 PN_PIPE_ERR_INVALID_PARAM,
125 PN_PIPE_ERR_INVALID_HANDLE,
126 PN_PIPE_ERR_INVALID_CTRL_ID,
127 PN_PIPE_ERR_NOT_ALLOWED,
128 PN_PIPE_ERR_PEP_IN_USE,
129 PN_PIPE_ERR_OVERLOAD,
130 PN_PIPE_ERR_DEV_DISCONNECTED,
131 PN_PIPE_ERR_TIMEOUT,
132 PN_PIPE_ERR_ALL_PIPES_IN_USE,
133 PN_PIPE_ERR_GENERAL,
134 PN_PIPE_ERR_NOT_SUPPORTED,
135 };
136
137 /* Phonet pipe states */
138 enum {
139 PN_PIPE_DISABLE,
140 PN_PIPE_ENABLE,
141 };
142
143 /* Phonet pipe sub-block types */
144 enum {
145 PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
146 PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
147 PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
148 PN_PIPE_SB_NEGOTIATED_FC,
149 PN_PIPE_SB_REQUIRED_FC_TX,
150 PN_PIPE_SB_PREFERRED_FC_RX,
151 PN_PIPE_SB_ALIGNED_DATA,
152 };
153
154 /* Phonet pipe flow control models */
155 enum {
156 PN_NO_FLOW_CONTROL,
157 PN_LEGACY_FLOW_CONTROL,
158 PN_ONE_CREDIT_FLOW_CONTROL,
159 PN_MULTI_CREDIT_FLOW_CONTROL,
160 };
161
162 #define pn_flow_safe(fc) ((fc) >> 1)
163
164 /* Phonet pipe flow control states */
165 enum {
166 PEP_IND_EMPTY,
167 PEP_IND_BUSY,
168 PEP_IND_READY,
169 };
170
171 #ifdef CONFIG_PHONET_PIPECTRLR
172 #define PNS_PEP_CONNECT_UTID 0x02
173 #define PNS_PIPE_CREATED_IND_UTID 0x04
174 #define PNS_PIPE_ENABLE_UTID 0x0A
175 #define PNS_PIPE_ENABLED_IND_UTID 0x0C
176 #define PNS_PIPE_DISABLE_UTID 0x0F
177 #define PNS_PIPE_DISABLED_IND_UTID 0x11
178 #define PNS_PEP_DISCONNECT_UTID 0x06
179
180 /* Used for tracking state of a pipe */
181 enum {
182 PIPE_IDLE,
183 PIPE_DISABLED,
184 PIPE_ENABLED,
185 };
186 #endif /* CONFIG_PHONET_PIPECTRLR */
187
188 #endif
This page took 0.041006 seconds and 5 git commands to generate.