blob: 703a64b4681a0bc1bc07afe82aa1e6c8accadb9b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* packet.h: Rx packet layout and definitions
2 *
David Howells63b6be52007-04-26 15:55:48 -07003 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_RXRPC_PACKET_H
13#define _LINUX_RXRPC_PACKET_H
14
David Howells63b6be52007-04-26 15:55:48 -070015typedef u32 rxrpc_seq_t; /* Rx message sequence number */
16typedef u32 rxrpc_serial_t; /* Rx message serial number */
17typedef __be32 rxrpc_seq_net_t; /* on-the-wire Rx message sequence number */
18typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/*****************************************************************************/
21/*
22 * on-the-wire Rx packet header
23 * - all multibyte fields should be in network byte order
24 */
David Howells0d12f8a2016-03-04 15:53:46 +000025struct rxrpc_wire_header {
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 __be32 epoch; /* client boot timestamp */
David Howells5f2d9c42016-09-02 22:39:45 +010027#define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29 __be32 cid; /* connection and channel ID */
30#define RXRPC_MAXCALLS 4 /* max active calls per conn */
31#define RXRPC_CHANNELMASK (RXRPC_MAXCALLS-1) /* mask for channel ID */
32#define RXRPC_CIDMASK (~RXRPC_CHANNELMASK) /* mask for connection ID */
David Howells17926a72007-04-26 15:48:28 -070033#define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */
34#define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36 __be32 callNumber; /* call ID (0 for connection-level packets) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 __be32 seq; /* sequence number of pkt in call stream */
38 __be32 serial; /* serial number of pkt sent to network */
39
40 uint8_t type; /* packet type */
41#define RXRPC_PACKET_TYPE_DATA 1 /* data */
42#define RXRPC_PACKET_TYPE_ACK 2 /* ACK */
43#define RXRPC_PACKET_TYPE_BUSY 3 /* call reject */
44#define RXRPC_PACKET_TYPE_ABORT 4 /* call/connection abort */
45#define RXRPC_PACKET_TYPE_ACKALL 5 /* ACK all outstanding packets on call */
46#define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */
47#define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */
48#define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */
David Howells44ba0692015-04-01 16:31:26 +010049#define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */
50#define RXRPC_N_PACKET_TYPES 14 /* number of packet types (incl type 0) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 uint8_t flags; /* packet flags */
53#define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */
54#define RXRPC_REQUEST_ACK 0x02 /* request an unconditional ACK of this packet */
55#define RXRPC_LAST_PACKET 0x04 /* the last packet from this side for this call */
56#define RXRPC_MORE_PACKETS 0x08 /* more packets to come */
57#define RXRPC_JUMBO_PACKET 0x20 /* [DATA] this is a jumbo packet */
58#define RXRPC_SLOW_START_OK 0x20 /* [ACK] slow start supported */
59
60 uint8_t userStatus; /* app-layer defined status */
61 uint8_t securityIndex; /* security protocol ID */
David Howells17926a72007-04-26 15:48:28 -070062 union {
63 __be16 _rsvd; /* reserved */
64 __be16 cksum; /* kerberos security checksum */
65 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 __be16 serviceId; /* service ID */
67
Eric Dumazetbc105022010-06-03 03:21:52 -070068} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
David Howells351c1e62016-03-04 15:56:06 +000070#define RXRPC_SUPPORTED_PACKET_TYPES ( \
71 (1 << RXRPC_PACKET_TYPE_DATA) | \
72 (1 << RXRPC_PACKET_TYPE_ACK) | \
73 (1 << RXRPC_PACKET_TYPE_BUSY) | \
74 (1 << RXRPC_PACKET_TYPE_ABORT) | \
75 (1 << RXRPC_PACKET_TYPE_ACKALL) | \
76 (1 << RXRPC_PACKET_TYPE_CHALLENGE) | \
77 (1 << RXRPC_PACKET_TYPE_RESPONSE) | \
78 /*(1 << RXRPC_PACKET_TYPE_DEBUG) | */ \
79 (1 << RXRPC_PACKET_TYPE_VERSION))
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081/*****************************************************************************/
82/*
83 * jumbo packet secondary header
84 * - can be mapped to read header by:
85 * - new_serial = serial + 1
86 * - new_seq = seq + 1
87 * - new_flags = j_flags
88 * - new__rsvd = j__rsvd
89 * - duplicating all other fields
90 */
David Howells63b6be52007-04-26 15:55:48 -070091struct rxrpc_jumbo_header {
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 uint8_t flags; /* packet flags (as per rxrpc_header) */
93 uint8_t pad;
David Howells18f13872016-09-08 11:10:11 +010094 union {
95 __be16 _rsvd; /* reserved */
96 __be16 cksum; /* kerberos security checksum */
97 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070098};
99
100#define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */
David Howells18f13872016-09-08 11:10:11 +0100101#define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103/*****************************************************************************/
104/*
105 * on-the-wire Rx ACK packet data payload
106 * - all multibyte fields should be in network byte order
107 */
David Howells63b6be52007-04-26 15:55:48 -0700108struct rxrpc_ackpacket {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 __be16 bufferSpace; /* number of packet buffers available */
110 __be16 maxSkew; /* diff between serno being ACK'd and highest serial no
111 * received */
112 __be32 firstPacket; /* sequence no of first ACK'd packet in attached list */
113 __be32 previousPacket; /* sequence no of previous packet received */
114 __be32 serial; /* serial no of packet that prompted this ACK */
115
116 uint8_t reason; /* reason for ACK */
117#define RXRPC_ACK_REQUESTED 1 /* ACK was requested on packet */
118#define RXRPC_ACK_DUPLICATE 2 /* duplicate packet received */
119#define RXRPC_ACK_OUT_OF_SEQUENCE 3 /* out of sequence packet received */
120#define RXRPC_ACK_EXCEEDS_WINDOW 4 /* packet received beyond end of ACK window */
121#define RXRPC_ACK_NOSPACE 5 /* packet discarded due to lack of buffer space */
122#define RXRPC_ACK_PING 6 /* keep alive ACK */
123#define RXRPC_ACK_PING_RESPONSE 7 /* response to RXRPC_ACK_PING */
124#define RXRPC_ACK_DELAY 8 /* nothing happened since received packet */
125#define RXRPC_ACK_IDLE 9 /* ACK due to fully received ACK window */
David Howells9c7ad432016-09-23 13:50:40 +0100126#define RXRPC_ACK__INVALID 10 /* Representation of invalid ACK reason */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 uint8_t nAcks; /* number of ACKs */
129#define RXRPC_MAXACKS 255
130
131 uint8_t acks[0]; /* list of ACK/NAKs */
132#define RXRPC_ACK_TYPE_NACK 0
133#define RXRPC_ACK_TYPE_ACK 1
134
Eric Dumazetbc105022010-06-03 03:21:52 -0700135} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
David Howells248f2192016-09-08 11:10:12 +0100137/* Some ACKs refer to specific packets and some are general and can be updated. */
138#define RXRPC_ACK_UPDATEABLE ((1 << RXRPC_ACK_REQUESTED) | \
139 (1 << RXRPC_ACK_PING_RESPONSE) | \
140 (1 << RXRPC_ACK_DELAY) | \
141 (1 << RXRPC_ACK_IDLE))
142
143
David Howells17926a72007-04-26 15:48:28 -0700144/*
145 * ACK packets can have a further piece of information tagged on the end
146 */
147struct rxrpc_ackinfo {
148 __be32 rxMTU; /* maximum Rx MTU size (bytes) [AFS 3.3] */
149 __be32 maxMTU; /* maximum interface MTU size (bytes) [AFS 3.3] */
150 __be32 rwind; /* Rx window size (packets) [AFS 3.4] */
151 __be32 jumbo_max; /* max packets to stick into a jumbo packet [AFS 3.5] */
152};
153
154/*****************************************************************************/
155/*
156 * Kerberos security type-2 challenge packet
157 */
158struct rxkad_challenge {
159 __be32 version; /* version of this challenge type */
160 __be32 nonce; /* encrypted random number */
161 __be32 min_level; /* minimum security level */
162 __be32 __padding; /* padding to 8-byte boundary */
Eric Dumazetbc105022010-06-03 03:21:52 -0700163} __packed;
David Howells17926a72007-04-26 15:48:28 -0700164
165/*****************************************************************************/
166/*
167 * Kerberos security type-2 response packet
168 */
169struct rxkad_response {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300170 __be32 version; /* version of this response type */
David Howells17926a72007-04-26 15:48:28 -0700171 __be32 __pad;
172
173 /* encrypted bit of the response */
174 struct {
175 __be32 epoch; /* current epoch */
176 __be32 cid; /* parent connection ID */
177 __be32 checksum; /* checksum */
178 __be32 securityIndex; /* security type */
179 __be32 call_id[4]; /* encrypted call IDs */
180 __be32 inc_nonce; /* challenge nonce + 1 */
181 __be32 level; /* desired level */
182 } encrypted;
183
184 __be32 kvno; /* Kerberos key version number */
185 __be32 ticket_len; /* Kerberos ticket length */
Eric Dumazetbc105022010-06-03 03:21:52 -0700186} __packed;
David Howells17926a72007-04-26 15:48:28 -0700187
188/*****************************************************************************/
189/*
190 * RxRPC-level abort codes
191 */
192#define RX_CALL_DEAD -1 /* call/conn has been inactive and is shut down */
193#define RX_INVALID_OPERATION -2 /* invalid operation requested / attempted */
194#define RX_CALL_TIMEOUT -3 /* call timeout exceeded */
195#define RX_EOF -4 /* unexpected end of data on read op */
196#define RX_PROTOCOL_ERROR -5 /* low-level protocol error */
197#define RX_USER_ABORT -6 /* generic user abort */
198#define RX_ADDRINUSE -7 /* UDP port in use */
199#define RX_DEBUGI_BADTYPE -8 /* bad debugging packet type */
200
201/*
David Howells651350d2007-04-26 15:50:17 -0700202 * (un)marshalling abort codes (rxgen)
203 */
204#define RXGEN_CC_MARSHAL -450
205#define RXGEN_CC_UNMARSHAL -451
206#define RXGEN_SS_MARSHAL -452
207#define RXGEN_SS_UNMARSHAL -453
208#define RXGEN_DECODE -454
209#define RXGEN_OPCODE -455
210#define RXGEN_SS_XDRFREE -456
211#define RXGEN_CC_XDRFREE -457
212
213/*
David Howells17926a72007-04-26 15:48:28 -0700214 * Rx kerberos security abort codes
215 * - unfortunately we have no generalised security abort codes to say things
216 * like "unsupported security", so we have to use these instead and hope the
217 * other side understands
218 */
219#define RXKADINCONSISTENCY 19270400 /* security module structure inconsistent */
220#define RXKADPACKETSHORT 19270401 /* packet too short for security challenge */
221#define RXKADLEVELFAIL 19270402 /* security level negotiation failed */
222#define RXKADTICKETLEN 19270403 /* ticket length too short or too long */
223#define RXKADOUTOFSEQUENCE 19270404 /* packet had bad sequence number */
224#define RXKADNOAUTH 19270405 /* caller not authorised */
225#define RXKADBADKEY 19270406 /* illegal key: bad parity or weak */
226#define RXKADBADTICKET 19270407 /* security object was passed a bad ticket */
227#define RXKADUNKNOWNKEY 19270408 /* ticket contained unknown key version number */
228#define RXKADEXPIRED 19270409 /* authentication expired */
229#define RXKADSEALEDINCON 19270410 /* sealed data inconsistent */
230#define RXKADDATALEN 19270411 /* user data too long */
231#define RXKADILLEGALLEVEL 19270412 /* caller not authorised to use encrypted conns */
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233#endif /* _LINUX_RXRPC_PACKET_H */