Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* packet.h: Rx packet layout and definitions |
| 3 | * |
David Howells | 63b6be5 | 2007-04-26 15:55:48 -0700 | [diff] [blame] | 4 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Written by David Howells (dhowells@redhat.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _LINUX_RXRPC_PACKET_H |
| 9 | #define _LINUX_RXRPC_PACKET_H |
| 10 | |
David Howells | 63b6be5 | 2007-04-26 15:55:48 -0700 | [diff] [blame] | 11 | typedef u32 rxrpc_seq_t; /* Rx message sequence number */ |
| 12 | typedef u32 rxrpc_serial_t; /* Rx message serial number */ |
| 13 | typedef __be32 rxrpc_seq_net_t; /* on-the-wire Rx message sequence number */ |
| 14 | typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | /*****************************************************************************/ |
| 17 | /* |
| 18 | * on-the-wire Rx packet header |
| 19 | * - all multibyte fields should be in network byte order |
| 20 | */ |
David Howells | 0d12f8a | 2016-03-04 15:53:46 +0000 | [diff] [blame] | 21 | struct rxrpc_wire_header { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | __be32 epoch; /* client boot timestamp */ |
David Howells | 5f2d9c4 | 2016-09-02 22:39:45 +0100 | [diff] [blame] | 23 | #define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | __be32 cid; /* connection and channel ID */ |
| 26 | #define RXRPC_MAXCALLS 4 /* max active calls per conn */ |
| 27 | #define RXRPC_CHANNELMASK (RXRPC_MAXCALLS-1) /* mask for channel ID */ |
| 28 | #define RXRPC_CIDMASK (~RXRPC_CHANNELMASK) /* mask for connection ID */ |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 29 | #define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */ |
| 30 | #define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | __be32 callNumber; /* call ID (0 for connection-level packets) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | __be32 seq; /* sequence number of pkt in call stream */ |
| 34 | __be32 serial; /* serial number of pkt sent to network */ |
| 35 | |
| 36 | uint8_t type; /* packet type */ |
| 37 | #define RXRPC_PACKET_TYPE_DATA 1 /* data */ |
| 38 | #define RXRPC_PACKET_TYPE_ACK 2 /* ACK */ |
| 39 | #define RXRPC_PACKET_TYPE_BUSY 3 /* call reject */ |
| 40 | #define RXRPC_PACKET_TYPE_ABORT 4 /* call/connection abort */ |
| 41 | #define RXRPC_PACKET_TYPE_ACKALL 5 /* ACK all outstanding packets on call */ |
| 42 | #define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */ |
| 43 | #define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */ |
| 44 | #define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */ |
David Howells | b41d7cf | 2018-04-02 23:51:39 +0100 | [diff] [blame] | 45 | #define RXRPC_PACKET_TYPE_PARAMS 9 /* Parameter negotiation (unspec'd, ignore) */ |
| 46 | #define RXRPC_PACKET_TYPE_10 10 /* Ignored */ |
| 47 | #define RXRPC_PACKET_TYPE_11 11 /* Ignored */ |
David Howells | 44ba069 | 2015-04-01 16:31:26 +0100 | [diff] [blame] | 48 | #define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | uint8_t flags; /* packet flags */ |
| 51 | #define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ |
| 52 | #define RXRPC_REQUEST_ACK 0x02 /* request an unconditional ACK of this packet */ |
| 53 | #define RXRPC_LAST_PACKET 0x04 /* the last packet from this side for this call */ |
| 54 | #define RXRPC_MORE_PACKETS 0x08 /* more packets to come */ |
| 55 | #define RXRPC_JUMBO_PACKET 0x20 /* [DATA] this is a jumbo packet */ |
| 56 | #define RXRPC_SLOW_START_OK 0x20 /* [ACK] slow start supported */ |
| 57 | |
| 58 | uint8_t userStatus; /* app-layer defined status */ |
David Howells | 4722974 | 2017-06-05 14:30:49 +0100 | [diff] [blame] | 59 | #define RXRPC_USERSTATUS_SERVICE_UPGRADE 0x01 /* AuriStor service upgrade request */ |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | uint8_t securityIndex; /* security protocol ID */ |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 62 | union { |
| 63 | __be16 _rsvd; /* reserved */ |
| 64 | __be16 cksum; /* kerberos security checksum */ |
| 65 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | __be16 serviceId; /* service ID */ |
| 67 | |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 68 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /*****************************************************************************/ |
| 71 | /* |
| 72 | * jumbo packet secondary header |
| 73 | * - can be mapped to read header by: |
| 74 | * - new_serial = serial + 1 |
| 75 | * - new_seq = seq + 1 |
| 76 | * - new_flags = j_flags |
| 77 | * - new__rsvd = j__rsvd |
| 78 | * - duplicating all other fields |
| 79 | */ |
David Howells | 63b6be5 | 2007-04-26 15:55:48 -0700 | [diff] [blame] | 80 | struct rxrpc_jumbo_header { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | uint8_t flags; /* packet flags (as per rxrpc_header) */ |
| 82 | uint8_t pad; |
David Howells | 18f1387 | 2016-09-08 11:10:11 +0100 | [diff] [blame] | 83 | union { |
| 84 | __be16 _rsvd; /* reserved */ |
| 85 | __be16 cksum; /* kerberos security checksum */ |
| 86 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | #define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */ |
David Howells | 18f1387 | 2016-09-08 11:10:11 +0100 | [diff] [blame] | 90 | #define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
David Howells | c3c9e3d | 2019-08-19 09:25:37 +0100 | [diff] [blame] | 92 | /* |
| 93 | * The maximum number of subpackets that can possibly fit in a UDP packet is: |
| 94 | * |
| 95 | * ((max_IP - IP_hdr - UDP_hdr) / RXRPC_JUMBO_SUBPKTLEN) + 1 |
| 96 | * = ((65535 - 28 - 28) / 1416) + 1 |
| 97 | * = 46 non-terminal packets and 1 terminal packet. |
| 98 | */ |
| 99 | #define RXRPC_MAX_NR_JUMBO 47 |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /*****************************************************************************/ |
| 102 | /* |
| 103 | * on-the-wire Rx ACK packet data payload |
| 104 | * - all multibyte fields should be in network byte order |
| 105 | */ |
David Howells | 63b6be5 | 2007-04-26 15:55:48 -0700 | [diff] [blame] | 106 | struct rxrpc_ackpacket { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | __be16 bufferSpace; /* number of packet buffers available */ |
| 108 | __be16 maxSkew; /* diff between serno being ACK'd and highest serial no |
| 109 | * received */ |
| 110 | __be32 firstPacket; /* sequence no of first ACK'd packet in attached list */ |
| 111 | __be32 previousPacket; /* sequence no of previous packet received */ |
| 112 | __be32 serial; /* serial no of packet that prompted this ACK */ |
| 113 | |
| 114 | uint8_t reason; /* reason for ACK */ |
| 115 | #define RXRPC_ACK_REQUESTED 1 /* ACK was requested on packet */ |
| 116 | #define RXRPC_ACK_DUPLICATE 2 /* duplicate packet received */ |
| 117 | #define RXRPC_ACK_OUT_OF_SEQUENCE 3 /* out of sequence packet received */ |
| 118 | #define RXRPC_ACK_EXCEEDS_WINDOW 4 /* packet received beyond end of ACK window */ |
| 119 | #define RXRPC_ACK_NOSPACE 5 /* packet discarded due to lack of buffer space */ |
| 120 | #define RXRPC_ACK_PING 6 /* keep alive ACK */ |
| 121 | #define RXRPC_ACK_PING_RESPONSE 7 /* response to RXRPC_ACK_PING */ |
| 122 | #define RXRPC_ACK_DELAY 8 /* nothing happened since received packet */ |
| 123 | #define RXRPC_ACK_IDLE 9 /* ACK due to fully received ACK window */ |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame] | 124 | #define RXRPC_ACK__INVALID 10 /* Representation of invalid ACK reason */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
| 126 | uint8_t nAcks; /* number of ACKs */ |
| 127 | #define RXRPC_MAXACKS 255 |
| 128 | |
| 129 | uint8_t acks[0]; /* list of ACK/NAKs */ |
| 130 | #define RXRPC_ACK_TYPE_NACK 0 |
| 131 | #define RXRPC_ACK_TYPE_ACK 1 |
| 132 | |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 133 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 135 | /* Some ACKs refer to specific packets and some are general and can be updated. */ |
| 136 | #define RXRPC_ACK_UPDATEABLE ((1 << RXRPC_ACK_REQUESTED) | \ |
| 137 | (1 << RXRPC_ACK_PING_RESPONSE) | \ |
| 138 | (1 << RXRPC_ACK_DELAY) | \ |
| 139 | (1 << RXRPC_ACK_IDLE)) |
| 140 | |
| 141 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 142 | /* |
| 143 | * ACK packets can have a further piece of information tagged on the end |
| 144 | */ |
| 145 | struct rxrpc_ackinfo { |
| 146 | __be32 rxMTU; /* maximum Rx MTU size (bytes) [AFS 3.3] */ |
| 147 | __be32 maxMTU; /* maximum interface MTU size (bytes) [AFS 3.3] */ |
| 148 | __be32 rwind; /* Rx window size (packets) [AFS 3.4] */ |
| 149 | __be32 jumbo_max; /* max packets to stick into a jumbo packet [AFS 3.5] */ |
| 150 | }; |
| 151 | |
| 152 | /*****************************************************************************/ |
| 153 | /* |
| 154 | * Kerberos security type-2 challenge packet |
| 155 | */ |
| 156 | struct rxkad_challenge { |
| 157 | __be32 version; /* version of this challenge type */ |
| 158 | __be32 nonce; /* encrypted random number */ |
| 159 | __be32 min_level; /* minimum security level */ |
| 160 | __be32 __padding; /* padding to 8-byte boundary */ |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 161 | } __packed; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 162 | |
| 163 | /*****************************************************************************/ |
| 164 | /* |
| 165 | * Kerberos security type-2 response packet |
| 166 | */ |
| 167 | struct rxkad_response { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 168 | __be32 version; /* version of this response type */ |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 169 | __be32 __pad; |
| 170 | |
| 171 | /* encrypted bit of the response */ |
| 172 | struct { |
| 173 | __be32 epoch; /* current epoch */ |
| 174 | __be32 cid; /* parent connection ID */ |
| 175 | __be32 checksum; /* checksum */ |
| 176 | __be32 securityIndex; /* security type */ |
| 177 | __be32 call_id[4]; /* encrypted call IDs */ |
| 178 | __be32 inc_nonce; /* challenge nonce + 1 */ |
| 179 | __be32 level; /* desired level */ |
| 180 | } encrypted; |
| 181 | |
| 182 | __be32 kvno; /* Kerberos key version number */ |
| 183 | __be32 ticket_len; /* Kerberos ticket length */ |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 184 | } __packed; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | #endif /* _LINUX_RXRPC_PACKET_H */ |