1 /* packet.h: Rx packet layout and definitions
3 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
12 #ifndef _LINUX_RXRPC_PACKET_H
13 #define _LINUX_RXRPC_PACKET_H
15 typedef u32 rxrpc_seq_t
; /* Rx message sequence number */
16 typedef u32 rxrpc_serial_t
; /* Rx message serial number */
17 typedef __be32 rxrpc_seq_net_t
; /* on-the-wire Rx message sequence number */
18 typedef __be32 rxrpc_serial_net_t
; /* on-the-wire Rx message serial number */
20 /*****************************************************************************/
22 * on-the-wire Rx packet header
23 * - all multibyte fields should be in network byte order
25 struct rxrpc_wire_header
{
26 __be32 epoch
; /* client boot timestamp */
27 #define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */
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 */
33 #define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */
34 #define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */
36 __be32 callNumber
; /* call ID (0 for connection-level packets) */
37 __be32 seq
; /* sequence number of pkt in call stream */
38 __be32 serial
; /* serial number of pkt sent to network */
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 */
49 #define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */
50 #define RXRPC_N_PACKET_TYPES 14 /* number of packet types (incl type 0) */
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 */
60 uint8_t userStatus
; /* app-layer defined status */
61 #define RXRPC_USERSTATUS_SERVICE_UPGRADE 0x01 /* AuriStor service upgrade request */
63 uint8_t securityIndex
; /* security protocol ID */
65 __be16 _rsvd
; /* reserved */
66 __be16 cksum
; /* kerberos security checksum */
68 __be16 serviceId
; /* service ID */
72 #define RXRPC_SUPPORTED_PACKET_TYPES ( \
73 (1 << RXRPC_PACKET_TYPE_DATA) | \
74 (1 << RXRPC_PACKET_TYPE_ACK) | \
75 (1 << RXRPC_PACKET_TYPE_BUSY) | \
76 (1 << RXRPC_PACKET_TYPE_ABORT) | \
77 (1 << RXRPC_PACKET_TYPE_ACKALL) | \
78 (1 << RXRPC_PACKET_TYPE_CHALLENGE) | \
79 (1 << RXRPC_PACKET_TYPE_RESPONSE) | \
80 /*(1 << RXRPC_PACKET_TYPE_DEBUG) | */ \
81 (1 << RXRPC_PACKET_TYPE_VERSION))
83 /*****************************************************************************/
85 * jumbo packet secondary header
86 * - can be mapped to read header by:
87 * - new_serial = serial + 1
89 * - new_flags = j_flags
90 * - new__rsvd = j__rsvd
91 * - duplicating all other fields
93 struct rxrpc_jumbo_header
{
94 uint8_t flags
; /* packet flags (as per rxrpc_header) */
97 __be16 _rsvd
; /* reserved */
98 __be16 cksum
; /* kerberos security checksum */
102 #define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */
103 #define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header))
105 /*****************************************************************************/
107 * on-the-wire Rx ACK packet data payload
108 * - all multibyte fields should be in network byte order
110 struct rxrpc_ackpacket
{
111 __be16 bufferSpace
; /* number of packet buffers available */
112 __be16 maxSkew
; /* diff between serno being ACK'd and highest serial no
114 __be32 firstPacket
; /* sequence no of first ACK'd packet in attached list */
115 __be32 previousPacket
; /* sequence no of previous packet received */
116 __be32 serial
; /* serial no of packet that prompted this ACK */
118 uint8_t reason
; /* reason for ACK */
119 #define RXRPC_ACK_REQUESTED 1 /* ACK was requested on packet */
120 #define RXRPC_ACK_DUPLICATE 2 /* duplicate packet received */
121 #define RXRPC_ACK_OUT_OF_SEQUENCE 3 /* out of sequence packet received */
122 #define RXRPC_ACK_EXCEEDS_WINDOW 4 /* packet received beyond end of ACK window */
123 #define RXRPC_ACK_NOSPACE 5 /* packet discarded due to lack of buffer space */
124 #define RXRPC_ACK_PING 6 /* keep alive ACK */
125 #define RXRPC_ACK_PING_RESPONSE 7 /* response to RXRPC_ACK_PING */
126 #define RXRPC_ACK_DELAY 8 /* nothing happened since received packet */
127 #define RXRPC_ACK_IDLE 9 /* ACK due to fully received ACK window */
128 #define RXRPC_ACK__INVALID 10 /* Representation of invalid ACK reason */
130 uint8_t nAcks
; /* number of ACKs */
131 #define RXRPC_MAXACKS 255
133 uint8_t acks
[0]; /* list of ACK/NAKs */
134 #define RXRPC_ACK_TYPE_NACK 0
135 #define RXRPC_ACK_TYPE_ACK 1
139 /* Some ACKs refer to specific packets and some are general and can be updated. */
140 #define RXRPC_ACK_UPDATEABLE ((1 << RXRPC_ACK_REQUESTED) | \
141 (1 << RXRPC_ACK_PING_RESPONSE) | \
142 (1 << RXRPC_ACK_DELAY) | \
143 (1 << RXRPC_ACK_IDLE))
147 * ACK packets can have a further piece of information tagged on the end
149 struct rxrpc_ackinfo
{
150 __be32 rxMTU
; /* maximum Rx MTU size (bytes) [AFS 3.3] */
151 __be32 maxMTU
; /* maximum interface MTU size (bytes) [AFS 3.3] */
152 __be32 rwind
; /* Rx window size (packets) [AFS 3.4] */
153 __be32 jumbo_max
; /* max packets to stick into a jumbo packet [AFS 3.5] */
156 /*****************************************************************************/
158 * Kerberos security type-2 challenge packet
160 struct rxkad_challenge
{
161 __be32 version
; /* version of this challenge type */
162 __be32 nonce
; /* encrypted random number */
163 __be32 min_level
; /* minimum security level */
164 __be32 __padding
; /* padding to 8-byte boundary */
167 /*****************************************************************************/
169 * Kerberos security type-2 response packet
171 struct rxkad_response
{
172 __be32 version
; /* version of this response type */
175 /* encrypted bit of the response */
177 __be32 epoch
; /* current epoch */
178 __be32 cid
; /* parent connection ID */
179 __be32 checksum
; /* checksum */
180 __be32 securityIndex
; /* security type */
181 __be32 call_id
[4]; /* encrypted call IDs */
182 __be32 inc_nonce
; /* challenge nonce + 1 */
183 __be32 level
; /* desired level */
186 __be32 kvno
; /* Kerberos key version number */
187 __be32 ticket_len
; /* Kerberos ticket length */
190 #endif /* _LINUX_RXRPC_PACKET_H */