]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/net/phonet/pep.h
4d79564850ae0a4a8ab73ace73409acba6d11077
[linux-2.6-omap-h63xx.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         u16                     peer_type;      /* peer type/subtype */
39         u8                      pipe_handle;
40
41         u8                      rx_credits;
42         u8                      tx_credits;
43         u8                      rx_fc;  /* RX flow control */
44         u8                      tx_fc;  /* TX flow control */
45         u8                      init_enable;    /* auto-enable at creation */
46 };
47
48 static inline struct pep_sock *pep_sk(struct sock *sk)
49 {
50         return (struct pep_sock *)sk;
51 }
52
53 extern const struct proto_ops phonet_stream_ops;
54
55 /* Pipe protocol definitions */
56 struct pnpipehdr {
57         u8                      utid; /* transaction ID */
58         u8                      message_id;
59         u8                      pipe_handle;
60         union {
61                 u8              state_after_connect;    /* connect request */
62                 u8              state_after_reset;      /* reset request */
63                 u8              error_code;             /* any response */
64                 u8              pep_type;               /* status indication */
65                 u8              data[1];
66         };
67 };
68 #define other_pep_type          data[1]
69
70 static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
71 {
72         return (struct pnpipehdr *)skb_transport_header(skb);
73 }
74
75 #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
76
77 enum {
78         PNS_PIPE_DATA = 0x20,
79
80         PNS_PEP_CONNECT_REQ = 0x40,
81         PNS_PEP_CONNECT_RESP,
82         PNS_PEP_DISCONNECT_REQ,
83         PNS_PEP_DISCONNECT_RESP,
84         PNS_PEP_RESET_REQ,
85         PNS_PEP_RESET_RESP,
86         PNS_PEP_ENABLE_REQ,
87         PNS_PEP_ENABLE_RESP,
88         PNS_PEP_CTRL_REQ,
89         PNS_PEP_CTRL_RESP,
90         PNS_PEP_DISABLE_REQ = 0x4C,
91         PNS_PEP_DISABLE_RESP,
92
93         PNS_PEP_STATUS_IND = 0x60,
94         PNS_PIPE_CREATED_IND,
95         PNS_PIPE_RESET_IND = 0x63,
96         PNS_PIPE_ENABLED_IND,
97         PNS_PIPE_REDIRECTED_IND,
98         PNS_PIPE_DISABLED_IND = 0x66,
99 };
100
101 #define PN_PIPE_INVALID_HANDLE  0xff
102 #define PN_PEP_TYPE_COMMON      0x00
103
104 /* Phonet pipe status indication */
105 enum {
106         PN_PEP_IND_FLOW_CONTROL,
107         PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
108 };
109
110 /* Phonet pipe error codes */
111 enum {
112         PN_PIPE_NO_ERROR,
113         PN_PIPE_ERR_INVALID_PARAM,
114         PN_PIPE_ERR_INVALID_HANDLE,
115         PN_PIPE_ERR_INVALID_CTRL_ID,
116         PN_PIPE_ERR_NOT_ALLOWED,
117         PN_PIPE_ERR_PEP_IN_USE,
118         PN_PIPE_ERR_OVERLOAD,
119         PN_PIPE_ERR_DEV_DISCONNECTED,
120         PN_PIPE_ERR_TIMEOUT,
121         PN_PIPE_ERR_ALL_PIPES_IN_USE,
122         PN_PIPE_ERR_GENERAL,
123         PN_PIPE_ERR_NOT_SUPPORTED,
124 };
125
126 /* Phonet pipe states */
127 enum {
128         PN_PIPE_DISABLE,
129         PN_PIPE_ENABLE,
130 };
131
132 /* Phonet pipe sub-block types */
133 enum {
134         PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
135         PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
136         PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
137         PN_PIPE_SB_NEGOTIATED_FC,
138         PN_PIPE_SB_REQUIRED_FC_TX,
139         PN_PIPE_SB_PREFERRED_FC_RX,
140 };
141
142 /* Phonet pipe flow control models */
143 enum {
144         PN_NO_FLOW_CONTROL,
145         PN_LEGACY_FLOW_CONTROL,
146         PN_ONE_CREDIT_FLOW_CONTROL,
147         PN_MULTI_CREDIT_FLOW_CONTROL,
148 };
149
150 #define pn_flow_safe(fc) ((fc) >> 1)
151
152 /* Phonet pipe flow control states */
153 enum {
154         PEP_IND_EMPTY,
155         PEP_IND_BUSY,
156         PEP_IND_READY,
157 };
158
159 #endif