linux/include/rxrpc/packet.h
<<
>>
Prefs
   1/* packet.h: Rx packet layout and definitions
   2 *
   3 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
   4 * 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
  15typedef 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 */
  19
  20/*****************************************************************************/
  21/*
  22 * on-the-wire Rx packet header
  23 * - all multibyte fields should be in network byte order
  24 */
  25struct rxrpc_wire_header {
  26        __be32          epoch;          /* client boot timestamp */
  27
  28        __be32          cid;            /* connection and channel ID */
  29#define RXRPC_MAXCALLS          4                       /* max active calls per conn */
  30#define RXRPC_CHANNELMASK       (RXRPC_MAXCALLS-1)      /* mask for channel ID */
  31#define RXRPC_CIDMASK           (~RXRPC_CHANNELMASK)    /* mask for connection ID */
  32#define RXRPC_CIDSHIFT          ilog2(RXRPC_MAXCALLS)   /* shift for connection ID */
  33#define RXRPC_CID_INC           (1 << RXRPC_CIDSHIFT)   /* connection ID increment */
  34
  35        __be32          callNumber;     /* call ID (0 for connection-level packets) */
  36#define RXRPC_PROCESS_MAXCALLS  (1<<2)  /* maximum number of active calls per conn (power of 2) */
  37
  38        __be32          seq;            /* sequence number of pkt in call stream */
  39        __be32          serial;         /* serial number of pkt sent to network */
  40
  41        uint8_t         type;           /* packet type */
  42#define RXRPC_PACKET_TYPE_DATA          1       /* data */
  43#define RXRPC_PACKET_TYPE_ACK           2       /* ACK */
  44#define RXRPC_PACKET_TYPE_BUSY          3       /* call reject */
  45#define RXRPC_PACKET_TYPE_ABORT         4       /* call/connection abort */
  46#define RXRPC_PACKET_TYPE_ACKALL        5       /* ACK all outstanding packets on call */
  47#define RXRPC_PACKET_TYPE_CHALLENGE     6       /* connection security challenge (SRVR->CLNT) */
  48#define RXRPC_PACKET_TYPE_RESPONSE      7       /* connection secutity response (CLNT->SRVR) */
  49#define RXRPC_PACKET_TYPE_DEBUG         8       /* debug info request */
  50#define RXRPC_PACKET_TYPE_VERSION       13      /* version string request */
  51#define RXRPC_N_PACKET_TYPES            14      /* number of packet types (incl type 0) */
  52
  53        uint8_t         flags;          /* packet flags */
  54#define RXRPC_CLIENT_INITIATED  0x01            /* signifies a packet generated by a client */
  55#define RXRPC_REQUEST_ACK       0x02            /* request an unconditional ACK of this packet */
  56#define RXRPC_LAST_PACKET       0x04            /* the last packet from this side for this call */
  57#define RXRPC_MORE_PACKETS      0x08            /* more packets to come */
  58#define RXRPC_JUMBO_PACKET      0x20            /* [DATA] this is a jumbo packet */
  59#define RXRPC_SLOW_START_OK     0x20            /* [ACK] slow start supported */
  60
  61        uint8_t         userStatus;     /* app-layer defined status */
  62        uint8_t         securityIndex;  /* security protocol ID */
  63        union {
  64                __be16  _rsvd;          /* reserved */
  65                __be16  cksum;          /* kerberos security checksum */
  66        };
  67        __be16          serviceId;      /* service ID */
  68
  69} __packed;
  70
  71extern const char *rxrpc_pkts[];
  72
  73#define RXRPC_SUPPORTED_PACKET_TYPES (                  \
  74                (1 << RXRPC_PACKET_TYPE_DATA) |         \
  75                (1 << RXRPC_PACKET_TYPE_ACK) |          \
  76                (1 << RXRPC_PACKET_TYPE_BUSY) |         \
  77                (1 << RXRPC_PACKET_TYPE_ABORT) |        \
  78                (1 << RXRPC_PACKET_TYPE_ACKALL) |       \
  79                (1 << RXRPC_PACKET_TYPE_CHALLENGE) |    \
  80                (1 << RXRPC_PACKET_TYPE_RESPONSE) |     \
  81                /*(1 << RXRPC_PACKET_TYPE_DEBUG) | */   \
  82                (1 << RXRPC_PACKET_TYPE_VERSION))
  83
  84/*****************************************************************************/
  85/*
  86 * jumbo packet secondary header
  87 * - can be mapped to read header by:
  88 *   - new_serial = serial + 1
  89 *   - new_seq = seq + 1
  90 *   - new_flags = j_flags
  91 *   - new__rsvd = j__rsvd
  92 *   - duplicating all other fields
  93 */
  94struct rxrpc_jumbo_header {
  95        uint8_t         flags;          /* packet flags (as per rxrpc_header) */
  96        uint8_t         pad;
  97        __be16          _rsvd;          /* reserved (used by kerberos security as cksum) */
  98};
  99
 100#define RXRPC_JUMBO_DATALEN     1412    /* non-terminal jumbo packet data length */
 101
 102/*****************************************************************************/
 103/*
 104 * on-the-wire Rx ACK packet data payload
 105 * - all multibyte fields should be in network byte order
 106 */
 107struct rxrpc_ackpacket {
 108        __be16          bufferSpace;    /* number of packet buffers available */
 109        __be16          maxSkew;        /* diff between serno being ACK'd and highest serial no
 110                                         * received */
 111        __be32          firstPacket;    /* sequence no of first ACK'd packet in attached list */
 112        __be32          previousPacket; /* sequence no of previous packet received */
 113        __be32          serial;         /* serial no of packet that prompted this ACK */
 114
 115        uint8_t         reason;         /* reason for ACK */
 116#define RXRPC_ACK_REQUESTED             1       /* ACK was requested on packet */
 117#define RXRPC_ACK_DUPLICATE             2       /* duplicate packet received */
 118#define RXRPC_ACK_OUT_OF_SEQUENCE       3       /* out of sequence packet received */
 119#define RXRPC_ACK_EXCEEDS_WINDOW        4       /* packet received beyond end of ACK window */
 120#define RXRPC_ACK_NOSPACE               5       /* packet discarded due to lack of buffer space */
 121#define RXRPC_ACK_PING                  6       /* keep alive ACK */
 122#define RXRPC_ACK_PING_RESPONSE         7       /* response to RXRPC_ACK_PING */
 123#define RXRPC_ACK_DELAY                 8       /* nothing happened since received packet */
 124#define RXRPC_ACK_IDLE                  9       /* ACK due to fully received ACK window */
 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
 133} __packed;
 134
 135/*
 136 * ACK packets can have a further piece of information tagged on the end
 137 */
 138struct rxrpc_ackinfo {
 139        __be32          rxMTU;          /* maximum Rx MTU size (bytes) [AFS 3.3] */
 140        __be32          maxMTU;         /* maximum interface MTU size (bytes) [AFS 3.3] */
 141        __be32          rwind;          /* Rx window size (packets) [AFS 3.4] */
 142        __be32          jumbo_max;      /* max packets to stick into a jumbo packet [AFS 3.5] */
 143};
 144
 145/*****************************************************************************/
 146/*
 147 * Kerberos security type-2 challenge packet
 148 */
 149struct rxkad_challenge {
 150        __be32          version;        /* version of this challenge type */
 151        __be32          nonce;          /* encrypted random number */
 152        __be32          min_level;      /* minimum security level */
 153        __be32          __padding;      /* padding to 8-byte boundary */
 154} __packed;
 155
 156/*****************************************************************************/
 157/*
 158 * Kerberos security type-2 response packet
 159 */
 160struct rxkad_response {
 161        __be32          version;        /* version of this response type */
 162        __be32          __pad;
 163
 164        /* encrypted bit of the response */
 165        struct {
 166                __be32          epoch;          /* current epoch */
 167                __be32          cid;            /* parent connection ID */
 168                __be32          checksum;       /* checksum */
 169                __be32          securityIndex;  /* security type */
 170                __be32          call_id[4];     /* encrypted call IDs */
 171                __be32          inc_nonce;      /* challenge nonce + 1 */
 172                __be32          level;          /* desired level */
 173        } encrypted;
 174
 175        __be32          kvno;           /* Kerberos key version number */
 176        __be32          ticket_len;     /* Kerberos ticket length  */
 177} __packed;
 178
 179/*****************************************************************************/
 180/*
 181 * RxRPC-level abort codes
 182 */
 183#define RX_CALL_DEAD            -1      /* call/conn has been inactive and is shut down */
 184#define RX_INVALID_OPERATION    -2      /* invalid operation requested / attempted */
 185#define RX_CALL_TIMEOUT         -3      /* call timeout exceeded */
 186#define RX_EOF                  -4      /* unexpected end of data on read op */
 187#define RX_PROTOCOL_ERROR       -5      /* low-level protocol error */
 188#define RX_USER_ABORT           -6      /* generic user abort */
 189#define RX_ADDRINUSE            -7      /* UDP port in use */
 190#define RX_DEBUGI_BADTYPE       -8      /* bad debugging packet type */
 191
 192/*
 193 * (un)marshalling abort codes (rxgen)
 194 */
 195#define RXGEN_CC_MARSHAL    -450
 196#define RXGEN_CC_UNMARSHAL  -451
 197#define RXGEN_SS_MARSHAL    -452
 198#define RXGEN_SS_UNMARSHAL  -453
 199#define RXGEN_DECODE        -454
 200#define RXGEN_OPCODE        -455
 201#define RXGEN_SS_XDRFREE    -456
 202#define RXGEN_CC_XDRFREE    -457
 203
 204/*
 205 * Rx kerberos security abort codes
 206 * - unfortunately we have no generalised security abort codes to say things
 207 *   like "unsupported security", so we have to use these instead and hope the
 208 *   other side understands
 209 */
 210#define RXKADINCONSISTENCY      19270400        /* security module structure inconsistent */
 211#define RXKADPACKETSHORT        19270401        /* packet too short for security challenge */
 212#define RXKADLEVELFAIL          19270402        /* security level negotiation failed */
 213#define RXKADTICKETLEN          19270403        /* ticket length too short or too long */
 214#define RXKADOUTOFSEQUENCE      19270404        /* packet had bad sequence number */
 215#define RXKADNOAUTH             19270405        /* caller not authorised */
 216#define RXKADBADKEY             19270406        /* illegal key: bad parity or weak */
 217#define RXKADBADTICKET          19270407        /* security object was passed a bad ticket */
 218#define RXKADUNKNOWNKEY         19270408        /* ticket contained unknown key version number */
 219#define RXKADEXPIRED            19270409        /* authentication expired */
 220#define RXKADSEALEDINCON        19270410        /* sealed data inconsistent */
 221#define RXKADDATALEN            19270411        /* user data too long */
 222#define RXKADILLEGALLEVEL       19270412        /* caller not authorised to use encrypted conns */
 223
 224#endif /* _LINUX_RXRPC_PACKET_H */
 225