protocol.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #ifndef _LINUX_RXRPC_PACKET_H
  12. #define _LINUX_RXRPC_PACKET_H
  13. typedef u32 rxrpc_seq_t; /* Rx message sequence number */
  14. typedef u32 rxrpc_serial_t; /* Rx message serial number */
  15. typedef __be32 rxrpc_seq_net_t; /* on-the-wire Rx message sequence number */
  16. typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */
  17. /*****************************************************************************/
  18. /*
  19. * on-the-wire Rx packet header
  20. * - all multibyte fields should be in network byte order
  21. */
  22. struct rxrpc_wire_header {
  23. __be32 epoch; /* client boot timestamp */
  24. #define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */
  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 */
  29. #define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */
  30. #define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */
  31. __be32 callNumber; /* call ID (0 for connection-level packets) */
  32. __be32 seq; /* sequence number of pkt in call stream */
  33. __be32 serial; /* serial number of pkt sent to network */
  34. uint8_t type; /* packet type */
  35. #define RXRPC_PACKET_TYPE_DATA 1 /* data */
  36. #define RXRPC_PACKET_TYPE_ACK 2 /* ACK */
  37. #define RXRPC_PACKET_TYPE_BUSY 3 /* call reject */
  38. #define RXRPC_PACKET_TYPE_ABORT 4 /* call/connection abort */
  39. #define RXRPC_PACKET_TYPE_ACKALL 5 /* ACK all outstanding packets on call */
  40. #define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */
  41. #define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */
  42. #define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */
  43. #define RXRPC_PACKET_TYPE_PARAMS 9 /* Parameter negotiation (unspec'd, ignore) */
  44. #define RXRPC_PACKET_TYPE_10 10 /* Ignored */
  45. #define RXRPC_PACKET_TYPE_11 11 /* Ignored */
  46. #define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */
  47. uint8_t flags; /* packet flags */
  48. #define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */
  49. #define RXRPC_REQUEST_ACK 0x02 /* request an unconditional ACK of this packet */
  50. #define RXRPC_LAST_PACKET 0x04 /* the last packet from this side for this call */
  51. #define RXRPC_MORE_PACKETS 0x08 /* more packets to come */
  52. #define RXRPC_JUMBO_PACKET 0x20 /* [DATA] this is a jumbo packet */
  53. #define RXRPC_SLOW_START_OK 0x20 /* [ACK] slow start supported */
  54. uint8_t userStatus; /* app-layer defined status */
  55. #define RXRPC_USERSTATUS_SERVICE_UPGRADE 0x01 /* AuriStor service upgrade request */
  56. uint8_t securityIndex; /* security protocol ID */
  57. union {
  58. __be16 _rsvd; /* reserved */
  59. __be16 cksum; /* kerberos security checksum */
  60. };
  61. __be16 serviceId; /* service ID */
  62. } __packed;
  63. /*****************************************************************************/
  64. /*
  65. * jumbo packet secondary header
  66. * - can be mapped to read header by:
  67. * - new_serial = serial + 1
  68. * - new_seq = seq + 1
  69. * - new_flags = j_flags
  70. * - new__rsvd = j__rsvd
  71. * - duplicating all other fields
  72. */
  73. struct rxrpc_jumbo_header {
  74. uint8_t flags; /* packet flags (as per rxrpc_header) */
  75. uint8_t pad;
  76. union {
  77. __be16 _rsvd; /* reserved */
  78. __be16 cksum; /* kerberos security checksum */
  79. };
  80. };
  81. #define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */
  82. #define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header))
  83. /*****************************************************************************/
  84. /*
  85. * on-the-wire Rx ACK packet data payload
  86. * - all multibyte fields should be in network byte order
  87. */
  88. struct rxrpc_ackpacket {
  89. __be16 bufferSpace; /* number of packet buffers available */
  90. __be16 maxSkew; /* diff between serno being ACK'd and highest serial no
  91. * received */
  92. __be32 firstPacket; /* sequence no of first ACK'd packet in attached list */
  93. __be32 previousPacket; /* sequence no of previous packet received */
  94. __be32 serial; /* serial no of packet that prompted this ACK */
  95. uint8_t reason; /* reason for ACK */
  96. #define RXRPC_ACK_REQUESTED 1 /* ACK was requested on packet */
  97. #define RXRPC_ACK_DUPLICATE 2 /* duplicate packet received */
  98. #define RXRPC_ACK_OUT_OF_SEQUENCE 3 /* out of sequence packet received */
  99. #define RXRPC_ACK_EXCEEDS_WINDOW 4 /* packet received beyond end of ACK window */
  100. #define RXRPC_ACK_NOSPACE 5 /* packet discarded due to lack of buffer space */
  101. #define RXRPC_ACK_PING 6 /* keep alive ACK */
  102. #define RXRPC_ACK_PING_RESPONSE 7 /* response to RXRPC_ACK_PING */
  103. #define RXRPC_ACK_DELAY 8 /* nothing happened since received packet */
  104. #define RXRPC_ACK_IDLE 9 /* ACK due to fully received ACK window */
  105. #define RXRPC_ACK__INVALID 10 /* Representation of invalid ACK reason */
  106. uint8_t nAcks; /* number of ACKs */
  107. #define RXRPC_MAXACKS 255
  108. uint8_t acks[0]; /* list of ACK/NAKs */
  109. #define RXRPC_ACK_TYPE_NACK 0
  110. #define RXRPC_ACK_TYPE_ACK 1
  111. } __packed;
  112. /* Some ACKs refer to specific packets and some are general and can be updated. */
  113. #define RXRPC_ACK_UPDATEABLE ((1 << RXRPC_ACK_REQUESTED) | \
  114. (1 << RXRPC_ACK_PING_RESPONSE) | \
  115. (1 << RXRPC_ACK_DELAY) | \
  116. (1 << RXRPC_ACK_IDLE))
  117. /*
  118. * ACK packets can have a further piece of information tagged on the end
  119. */
  120. struct rxrpc_ackinfo {
  121. __be32 rxMTU; /* maximum Rx MTU size (bytes) [AFS 3.3] */
  122. __be32 maxMTU; /* maximum interface MTU size (bytes) [AFS 3.3] */
  123. __be32 rwind; /* Rx window size (packets) [AFS 3.4] */
  124. __be32 jumbo_max; /* max packets to stick into a jumbo packet [AFS 3.5] */
  125. };
  126. /*****************************************************************************/
  127. /*
  128. * Kerberos security type-2 challenge packet
  129. */
  130. struct rxkad_challenge {
  131. __be32 version; /* version of this challenge type */
  132. __be32 nonce; /* encrypted random number */
  133. __be32 min_level; /* minimum security level */
  134. __be32 __padding; /* padding to 8-byte boundary */
  135. } __packed;
  136. /*****************************************************************************/
  137. /*
  138. * Kerberos security type-2 response packet
  139. */
  140. struct rxkad_response {
  141. __be32 version; /* version of this response type */
  142. __be32 __pad;
  143. /* encrypted bit of the response */
  144. struct {
  145. __be32 epoch; /* current epoch */
  146. __be32 cid; /* parent connection ID */
  147. __be32 checksum; /* checksum */
  148. __be32 securityIndex; /* security type */
  149. __be32 call_id[4]; /* encrypted call IDs */
  150. __be32 inc_nonce; /* challenge nonce + 1 */
  151. __be32 level; /* desired level */
  152. } encrypted;
  153. __be32 kvno; /* Kerberos key version number */
  154. __be32 ticket_len; /* Kerberos ticket length */
  155. } __packed;
  156. #endif /* _LINUX_RXRPC_PACKET_H */