162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* packet.h: Rx packet layout and definitions 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 562306a36Sopenharmony_ci * Written by David Howells (dhowells@redhat.com) 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _LINUX_RXRPC_PACKET_H 962306a36Sopenharmony_ci#define _LINUX_RXRPC_PACKET_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_citypedef u32 rxrpc_seq_t; /* Rx message sequence number */ 1262306a36Sopenharmony_citypedef u32 rxrpc_serial_t; /* Rx message serial number */ 1362306a36Sopenharmony_citypedef __be32 rxrpc_seq_net_t; /* on-the-wire Rx message sequence number */ 1462306a36Sopenharmony_citypedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/*****************************************************************************/ 1762306a36Sopenharmony_ci/* 1862306a36Sopenharmony_ci * on-the-wire Rx packet header 1962306a36Sopenharmony_ci * - all multibyte fields should be in network byte order 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_cistruct rxrpc_wire_header { 2262306a36Sopenharmony_ci __be32 epoch; /* client boot timestamp */ 2362306a36Sopenharmony_ci#define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci __be32 cid; /* connection and channel ID */ 2662306a36Sopenharmony_ci#define RXRPC_MAXCALLS 4 /* max active calls per conn */ 2762306a36Sopenharmony_ci#define RXRPC_CHANNELMASK (RXRPC_MAXCALLS-1) /* mask for channel ID */ 2862306a36Sopenharmony_ci#define RXRPC_CIDMASK (~RXRPC_CHANNELMASK) /* mask for connection ID */ 2962306a36Sopenharmony_ci#define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */ 3062306a36Sopenharmony_ci#define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */ 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci __be32 callNumber; /* call ID (0 for connection-level packets) */ 3362306a36Sopenharmony_ci __be32 seq; /* sequence number of pkt in call stream */ 3462306a36Sopenharmony_ci __be32 serial; /* serial number of pkt sent to network */ 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci uint8_t type; /* packet type */ 3762306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_DATA 1 /* data */ 3862306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_ACK 2 /* ACK */ 3962306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_BUSY 3 /* call reject */ 4062306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_ABORT 4 /* call/connection abort */ 4162306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_ACKALL 5 /* ACK all outstanding packets on call */ 4262306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */ 4362306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */ 4462306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */ 4562306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_PARAMS 9 /* Parameter negotiation (unspec'd, ignore) */ 4662306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_10 10 /* Ignored */ 4762306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_11 11 /* Ignored */ 4862306a36Sopenharmony_ci#define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */ 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci uint8_t flags; /* packet flags */ 5162306a36Sopenharmony_ci#define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ 5262306a36Sopenharmony_ci#define RXRPC_REQUEST_ACK 0x02 /* request an unconditional ACK of this packet */ 5362306a36Sopenharmony_ci#define RXRPC_LAST_PACKET 0x04 /* the last packet from this side for this call */ 5462306a36Sopenharmony_ci#define RXRPC_MORE_PACKETS 0x08 /* more packets to come */ 5562306a36Sopenharmony_ci#define RXRPC_JUMBO_PACKET 0x20 /* [DATA] this is a jumbo packet */ 5662306a36Sopenharmony_ci#define RXRPC_SLOW_START_OK 0x20 /* [ACK] slow start supported */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci uint8_t userStatus; /* app-layer defined status */ 5962306a36Sopenharmony_ci#define RXRPC_USERSTATUS_SERVICE_UPGRADE 0x01 /* AuriStor service upgrade request */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci uint8_t securityIndex; /* security protocol ID */ 6262306a36Sopenharmony_ci union { 6362306a36Sopenharmony_ci __be16 _rsvd; /* reserved */ 6462306a36Sopenharmony_ci __be16 cksum; /* kerberos security checksum */ 6562306a36Sopenharmony_ci }; 6662306a36Sopenharmony_ci __be16 serviceId; /* service ID */ 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci} __packed; 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/*****************************************************************************/ 7162306a36Sopenharmony_ci/* 7262306a36Sopenharmony_ci * jumbo packet secondary header 7362306a36Sopenharmony_ci * - can be mapped to read header by: 7462306a36Sopenharmony_ci * - new_serial = serial + 1 7562306a36Sopenharmony_ci * - new_seq = seq + 1 7662306a36Sopenharmony_ci * - new_flags = j_flags 7762306a36Sopenharmony_ci * - new__rsvd = j__rsvd 7862306a36Sopenharmony_ci * - duplicating all other fields 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_cistruct rxrpc_jumbo_header { 8162306a36Sopenharmony_ci uint8_t flags; /* packet flags (as per rxrpc_header) */ 8262306a36Sopenharmony_ci uint8_t pad; 8362306a36Sopenharmony_ci union { 8462306a36Sopenharmony_ci __be16 _rsvd; /* reserved */ 8562306a36Sopenharmony_ci __be16 cksum; /* kerberos security checksum */ 8662306a36Sopenharmony_ci }; 8762306a36Sopenharmony_ci} __packed; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */ 9062306a36Sopenharmony_ci#define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header)) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* 9362306a36Sopenharmony_ci * The maximum number of subpackets that can possibly fit in a UDP packet is: 9462306a36Sopenharmony_ci * 9562306a36Sopenharmony_ci * ((max_IP - IP_hdr - UDP_hdr) / RXRPC_JUMBO_SUBPKTLEN) + 1 9662306a36Sopenharmony_ci * = ((65535 - 28 - 28) / 1416) + 1 9762306a36Sopenharmony_ci * = 46 non-terminal packets and 1 terminal packet. 9862306a36Sopenharmony_ci */ 9962306a36Sopenharmony_ci#define RXRPC_MAX_NR_JUMBO 47 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/*****************************************************************************/ 10262306a36Sopenharmony_ci/* 10362306a36Sopenharmony_ci * on-the-wire Rx ACK packet data payload 10462306a36Sopenharmony_ci * - all multibyte fields should be in network byte order 10562306a36Sopenharmony_ci */ 10662306a36Sopenharmony_cistruct rxrpc_ackpacket { 10762306a36Sopenharmony_ci __be16 bufferSpace; /* number of packet buffers available */ 10862306a36Sopenharmony_ci __be16 maxSkew; /* diff between serno being ACK'd and highest serial no 10962306a36Sopenharmony_ci * received */ 11062306a36Sopenharmony_ci __be32 firstPacket; /* sequence no of first ACK'd packet in attached list */ 11162306a36Sopenharmony_ci __be32 previousPacket; /* sequence no of previous packet received */ 11262306a36Sopenharmony_ci __be32 serial; /* serial no of packet that prompted this ACK */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci uint8_t reason; /* reason for ACK */ 11562306a36Sopenharmony_ci#define RXRPC_ACK_REQUESTED 1 /* ACK was requested on packet */ 11662306a36Sopenharmony_ci#define RXRPC_ACK_DUPLICATE 2 /* duplicate packet received */ 11762306a36Sopenharmony_ci#define RXRPC_ACK_OUT_OF_SEQUENCE 3 /* out of sequence packet received */ 11862306a36Sopenharmony_ci#define RXRPC_ACK_EXCEEDS_WINDOW 4 /* packet received beyond end of ACK window */ 11962306a36Sopenharmony_ci#define RXRPC_ACK_NOSPACE 5 /* packet discarded due to lack of buffer space */ 12062306a36Sopenharmony_ci#define RXRPC_ACK_PING 6 /* keep alive ACK */ 12162306a36Sopenharmony_ci#define RXRPC_ACK_PING_RESPONSE 7 /* response to RXRPC_ACK_PING */ 12262306a36Sopenharmony_ci#define RXRPC_ACK_DELAY 8 /* nothing happened since received packet */ 12362306a36Sopenharmony_ci#define RXRPC_ACK_IDLE 9 /* ACK due to fully received ACK window */ 12462306a36Sopenharmony_ci#define RXRPC_ACK__INVALID 10 /* Representation of invalid ACK reason */ 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci uint8_t nAcks; /* number of ACKs */ 12762306a36Sopenharmony_ci#define RXRPC_MAXACKS 255 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci uint8_t acks[]; /* list of ACK/NAKs */ 13062306a36Sopenharmony_ci#define RXRPC_ACK_TYPE_NACK 0 13162306a36Sopenharmony_ci#define RXRPC_ACK_TYPE_ACK 1 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci} __packed; 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci/* 13662306a36Sopenharmony_ci * ACK packets can have a further piece of information tagged on the end 13762306a36Sopenharmony_ci */ 13862306a36Sopenharmony_cistruct rxrpc_ackinfo { 13962306a36Sopenharmony_ci __be32 rxMTU; /* maximum Rx MTU size (bytes) [AFS 3.3] */ 14062306a36Sopenharmony_ci __be32 maxMTU; /* maximum interface MTU size (bytes) [AFS 3.3] */ 14162306a36Sopenharmony_ci __be32 rwind; /* Rx window size (packets) [AFS 3.4] */ 14262306a36Sopenharmony_ci __be32 jumbo_max; /* max packets to stick into a jumbo packet [AFS 3.5] */ 14362306a36Sopenharmony_ci}; 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci/*****************************************************************************/ 14662306a36Sopenharmony_ci/* 14762306a36Sopenharmony_ci * Kerberos security type-2 challenge packet 14862306a36Sopenharmony_ci */ 14962306a36Sopenharmony_cistruct rxkad_challenge { 15062306a36Sopenharmony_ci __be32 version; /* version of this challenge type */ 15162306a36Sopenharmony_ci __be32 nonce; /* encrypted random number */ 15262306a36Sopenharmony_ci __be32 min_level; /* minimum security level */ 15362306a36Sopenharmony_ci __be32 __padding; /* padding to 8-byte boundary */ 15462306a36Sopenharmony_ci} __packed; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/*****************************************************************************/ 15762306a36Sopenharmony_ci/* 15862306a36Sopenharmony_ci * Kerberos security type-2 response packet 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_cistruct rxkad_response { 16162306a36Sopenharmony_ci __be32 version; /* version of this response type */ 16262306a36Sopenharmony_ci __be32 __pad; 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci /* encrypted bit of the response */ 16562306a36Sopenharmony_ci struct { 16662306a36Sopenharmony_ci __be32 epoch; /* current epoch */ 16762306a36Sopenharmony_ci __be32 cid; /* parent connection ID */ 16862306a36Sopenharmony_ci __be32 checksum; /* checksum */ 16962306a36Sopenharmony_ci __be32 securityIndex; /* security type */ 17062306a36Sopenharmony_ci __be32 call_id[4]; /* encrypted call IDs */ 17162306a36Sopenharmony_ci __be32 inc_nonce; /* challenge nonce + 1 */ 17262306a36Sopenharmony_ci __be32 level; /* desired level */ 17362306a36Sopenharmony_ci } encrypted; 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci __be32 kvno; /* Kerberos key version number */ 17662306a36Sopenharmony_ci __be32 ticket_len; /* Kerberos ticket length */ 17762306a36Sopenharmony_ci} __packed; 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci#endif /* _LINUX_RXRPC_PACKET_H */ 180