| Rémi Denis-Courmont | 9995a32 | 2008-10-05 11:14:48 -0700 | [diff] [blame] | 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 |  | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 29 | /* XXX: union-ify listening vs connected stuff ? */ | 
| Rémi Denis-Courmont | 9995a32 | 2008-10-05 11:14:48 -0700 | [diff] [blame] | 30 | /* Listening socket stuff: */ | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 31 | struct hlist_head	hlist; | 
| Rémi Denis-Courmont | 9995a32 | 2008-10-05 11:14:48 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | /* Connected socket stuff: */ | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 34 | struct sock		*listener; | 
| Rémi Denis-Courmont | c41bd97f8 | 2008-10-05 11:15:43 -0700 | [diff] [blame] | 35 | struct sk_buff_head	ctrlreq_queue; | 
|  | 36 | #define PNPIPE_CTRLREQ_MAX	10 | 
| Rémi Denis-Courmont | be67773 | 2008-12-17 15:48:31 -0800 | [diff] [blame] | 37 | atomic_t		tx_credits; | 
| Rémi Denis-Courmont | 02a4761 | 2008-10-05 11:16:16 -0700 | [diff] [blame] | 38 | int			ifindex; | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 39 | u16			peer_type;	/* peer type/subtype */ | 
|  | 40 | u8			pipe_handle; | 
|  | 41 |  | 
|  | 42 | u8			rx_credits; | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 43 | u8			rx_fc;	/* RX flow control */ | 
|  | 44 | u8			tx_fc;	/* TX flow control */ | 
|  | 45 | u8			init_enable;	/* auto-enable at creation */ | 
| Rémi Denis-Courmont | fea93ec | 2010-01-04 02:02:48 +0000 | [diff] [blame] | 46 | u8			aligned; | 
| Rémi Denis-Courmont | 9995a32 | 2008-10-05 11:14:48 -0700 | [diff] [blame] | 47 | }; | 
|  | 48 |  | 
|  | 49 | static inline struct pep_sock *pep_sk(struct sock *sk) | 
|  | 50 | { | 
|  | 51 | return (struct pep_sock *)sk; | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | extern const struct proto_ops phonet_stream_ops; | 
|  | 55 |  | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 56 | /* Pipe protocol definitions */ | 
|  | 57 | struct pnpipehdr { | 
|  | 58 | u8			utid; /* transaction ID */ | 
|  | 59 | u8			message_id; | 
|  | 60 | u8			pipe_handle; | 
|  | 61 | union { | 
|  | 62 | u8		state_after_connect;	/* connect request */ | 
|  | 63 | u8		state_after_reset;	/* reset request */ | 
|  | 64 | u8		error_code;		/* any response */ | 
|  | 65 | u8		pep_type;		/* status indication */ | 
|  | 66 | u8		data[1]; | 
|  | 67 | }; | 
|  | 68 | }; | 
|  | 69 | #define other_pep_type		data[1] | 
|  | 70 |  | 
|  | 71 | static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb) | 
|  | 72 | { | 
|  | 73 | return (struct pnpipehdr *)skb_transport_header(skb); | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 | #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4) | 
|  | 77 |  | 
|  | 78 | enum { | 
| Rémi Denis-Courmont | 6482f55 | 2010-09-15 12:19:53 +0000 | [diff] [blame] | 79 | PNS_PIPE_CREATE_REQ = 0x00, | 
|  | 80 | PNS_PIPE_CREATE_RESP, | 
|  | 81 | PNS_PIPE_REMOVE_REQ, | 
|  | 82 | PNS_PIPE_REMOVE_RESP, | 
|  | 83 |  | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 84 | PNS_PIPE_DATA = 0x20, | 
| Rémi Denis-Courmont | fc6a110 | 2010-01-04 02:02:47 +0000 | [diff] [blame] | 85 | PNS_PIPE_ALIGNED_DATA, | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 86 |  | 
|  | 87 | PNS_PEP_CONNECT_REQ = 0x40, | 
|  | 88 | PNS_PEP_CONNECT_RESP, | 
|  | 89 | PNS_PEP_DISCONNECT_REQ, | 
|  | 90 | PNS_PEP_DISCONNECT_RESP, | 
|  | 91 | PNS_PEP_RESET_REQ, | 
|  | 92 | PNS_PEP_RESET_RESP, | 
|  | 93 | PNS_PEP_ENABLE_REQ, | 
|  | 94 | PNS_PEP_ENABLE_RESP, | 
|  | 95 | PNS_PEP_CTRL_REQ, | 
|  | 96 | PNS_PEP_CTRL_RESP, | 
|  | 97 | PNS_PEP_DISABLE_REQ = 0x4C, | 
|  | 98 | PNS_PEP_DISABLE_RESP, | 
|  | 99 |  | 
|  | 100 | PNS_PEP_STATUS_IND = 0x60, | 
|  | 101 | PNS_PIPE_CREATED_IND, | 
|  | 102 | PNS_PIPE_RESET_IND = 0x63, | 
|  | 103 | PNS_PIPE_ENABLED_IND, | 
|  | 104 | PNS_PIPE_REDIRECTED_IND, | 
|  | 105 | PNS_PIPE_DISABLED_IND = 0x66, | 
|  | 106 | }; | 
|  | 107 |  | 
|  | 108 | #define PN_PIPE_INVALID_HANDLE	0xff | 
|  | 109 | #define PN_PEP_TYPE_COMMON	0x00 | 
|  | 110 |  | 
|  | 111 | /* Phonet pipe status indication */ | 
|  | 112 | enum { | 
|  | 113 | PN_PEP_IND_FLOW_CONTROL, | 
|  | 114 | PN_PEP_IND_ID_MCFC_GRANT_CREDITS, | 
|  | 115 | }; | 
|  | 116 |  | 
|  | 117 | /* Phonet pipe error codes */ | 
|  | 118 | enum { | 
|  | 119 | PN_PIPE_NO_ERROR, | 
|  | 120 | PN_PIPE_ERR_INVALID_PARAM, | 
|  | 121 | PN_PIPE_ERR_INVALID_HANDLE, | 
|  | 122 | PN_PIPE_ERR_INVALID_CTRL_ID, | 
|  | 123 | PN_PIPE_ERR_NOT_ALLOWED, | 
|  | 124 | PN_PIPE_ERR_PEP_IN_USE, | 
|  | 125 | PN_PIPE_ERR_OVERLOAD, | 
|  | 126 | PN_PIPE_ERR_DEV_DISCONNECTED, | 
|  | 127 | PN_PIPE_ERR_TIMEOUT, | 
|  | 128 | PN_PIPE_ERR_ALL_PIPES_IN_USE, | 
|  | 129 | PN_PIPE_ERR_GENERAL, | 
|  | 130 | PN_PIPE_ERR_NOT_SUPPORTED, | 
|  | 131 | }; | 
|  | 132 |  | 
|  | 133 | /* Phonet pipe states */ | 
|  | 134 | enum { | 
|  | 135 | PN_PIPE_DISABLE, | 
|  | 136 | PN_PIPE_ENABLE, | 
|  | 137 | }; | 
|  | 138 |  | 
|  | 139 | /* Phonet pipe sub-block types */ | 
|  | 140 | enum { | 
|  | 141 | PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE, | 
|  | 142 | PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE, | 
|  | 143 | PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE, | 
|  | 144 | PN_PIPE_SB_NEGOTIATED_FC, | 
|  | 145 | PN_PIPE_SB_REQUIRED_FC_TX, | 
|  | 146 | PN_PIPE_SB_PREFERRED_FC_RX, | 
| Rémi Denis-Courmont | fea93ec | 2010-01-04 02:02:48 +0000 | [diff] [blame] | 147 | PN_PIPE_SB_ALIGNED_DATA, | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 148 | }; | 
|  | 149 |  | 
|  | 150 | /* Phonet pipe flow control models */ | 
|  | 151 | enum { | 
|  | 152 | PN_NO_FLOW_CONTROL, | 
|  | 153 | PN_LEGACY_FLOW_CONTROL, | 
|  | 154 | PN_ONE_CREDIT_FLOW_CONTROL, | 
|  | 155 | PN_MULTI_CREDIT_FLOW_CONTROL, | 
| Rémi Denis-Courmont | 8f44fcc | 2011-02-24 23:15:01 +0000 | [diff] [blame] | 156 | PN_MAX_FLOW_CONTROL, | 
| Rémi Denis-Courmont | 9641458 | 2008-10-05 11:15:13 -0700 | [diff] [blame] | 157 | }; | 
|  | 158 |  | 
|  | 159 | #define pn_flow_safe(fc) ((fc) >> 1) | 
|  | 160 |  | 
|  | 161 | /* Phonet pipe flow control states */ | 
|  | 162 | enum { | 
|  | 163 | PEP_IND_EMPTY, | 
|  | 164 | PEP_IND_BUSY, | 
|  | 165 | PEP_IND_READY, | 
|  | 166 | }; | 
|  | 167 |  | 
| Rémi Denis-Courmont | 9995a32 | 2008-10-05 11:14:48 -0700 | [diff] [blame] | 168 | #endif |