tcpr.h 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  5. *
  6. * The Tcpreplay Suite of tools is free software: you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or with the authors permission any later version.
  10. *
  11. * The Tcpreplay Suite is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * This header is heavily based off of (in other words basically stolen from)
  21. * libnet 1.1.3's libnet-headers.h. Many thanks to Mike D. Schiffman for doing
  22. * all this work so I basically just needed to do a search and replace to get
  23. * things to work.
  24. */
  25. #pragma once
  26. #ifdef HAVE_SYS_TYPES_H
  27. #include <sys/types.h>
  28. #endif
  29. #ifdef WIN32
  30. #include "msvc_inttypes.h"
  31. #include "msvc_stdint.h"
  32. #else
  33. #ifdef HAVE_INTTYPES_H
  34. #include <inttypes.h>
  35. #endif
  36. #ifdef HAVE_STDINT_H
  37. #include <stdint.h>
  38. #endif
  39. #endif
  40. #ifdef HAVE_NETINET_IN_H
  41. #include <netinet/in.h>
  42. #endif
  43. #ifdef HAVE_NETINET_IN_SYSTM_H
  44. #include <netinet/in_systm.h>
  45. #endif
  46. #include "config.h"
  47. #define ETHER_ADDR_LEN 0x6
  48. #define FDDI_ADDR_LEN 0x6
  49. #define TOKEN_RING_ADDR_LEN 0x6
  50. #define TCPR_ORG_CODE_SIZE 0x3
  51. /**
  52. * Libnet defines header sizes for every builder function exported.
  53. */
  54. #define TCPR_802_1Q_H 0x12 /**< 802.1Q header: 18 bytes */
  55. #define TCPR_802_1X_H 0x04 /**< 802.1X header: 4 bytes */
  56. #define TCPR_802_2_H 0x03 /**< 802.2 LLC header: 3 bytes */
  57. #define TCPR_802_2SNAP_H 0x08 /**< 802.2 LLC/SNAP header:8 bytes */
  58. #define TCPR_802_3_H 0x0e /**< 802.3 header: 14 bytes */
  59. #define TCPR_ARP_H 0x08 /**< ARP header w/o addrs: 8 bytes */
  60. #define TCPR_ARP_ETH_IP_H 0x1c /**< ARP w/ ETH and IP: 28 bytes */
  61. #define TCPR_BGP4_HEADER_H 0x13 /**< BGP header: 19 bytes */
  62. #define TCPR_BGP4_OPEN_H 0x0a /**< BGP open header: 10 bytes */
  63. #define TCPR_BGP4_UPDATE_H 0x04 /**< BGP open header: 4 bytes */
  64. #define TCPR_BGP4_NOTIFICATION_H 0x02 /**< BGP notif. header: 2 bytes */
  65. #define TCPR_CDP_H 0x08 /**< CDP header base: 8 bytes */
  66. #define TCPR_DHCPV4_H 0xf0 /**< DHCP v4 header: 240 bytes */
  67. #define TCPR_UDP_DNSV4_H 0x0c /**< UDP DNS v4 header: 12 bytes */
  68. #define TCPR_TCP_DNSV4_H 0x0e /**< TCP DNS v4 header: 14 bytes */
  69. #define TCPR_ETH_H 0x0e /**< Ethernet header: 14 bytes */
  70. #define TCPR_ETH_MTU 1500 /**< Ethernet MTU size: 1500 bytes */
  71. #define TCPR_FDDI_H 0x15 /**< FDDI header: 21 bytes */
  72. #define TCPR_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */
  73. #define TCPR_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */
  74. #define TCPR_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */
  75. #define TCPR_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */
  76. #define TCPR_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */
  77. #define TCPR_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */
  78. #define TCPR_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */
  79. #define TCPR_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */
  80. #define TCPR_IGMP_H 0x08 /**< IGMP header: 8 bytes */
  81. #define TCPR_IPV4_H 0x14 /**< IPv4 header: 20 bytes */
  82. #define TCPR_IPV6_H 0x28 /**< IPv6 header: 40 bytes */
  83. #define TCPR_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */
  84. #define TCPR_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */
  85. #define TCPR_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */
  86. #define TCPR_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */
  87. #define TCPR_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */
  88. #define TCPR_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */
  89. #define TCPR_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */
  90. #define TCPR_ISL_H 0x1a /**< ISL header: 26 bytes */
  91. #define TCPR_GRE_H 0x04 /**< GRE header: 4 bytes */
  92. #define TCPR_GRE_SRE_H 0x04 /**< GRE SRE header: 4 bytes */
  93. #define TCPR_MPLS_H 0x04 /**< MPLS header: 4 bytes */
  94. #define TCPR_OSPF_H 0x10 /**< OSPF header: 16 bytes */
  95. #define TCPR_OSPF_HELLO_H 0x18 /**< OSPF hello header: 24 bytes */
  96. #define TCPR_OSPF_DBD_H 0x08 /**< OSPF DBD header: 8 bytes */
  97. #define TCPR_OSPF_LSR_H 0x0c /**< OSPF LSR header: 12 bytes */
  98. #define TCPR_OSPF_LSU_H 0x04 /**< OSPF LSU header: 4 bytes */
  99. #define TCPR_OSPF_LSA_H 0x14 /**< OSPF LSA header: 20 bytes */
  100. #define TCPR_OSPF_AUTH_H 0x08 /**< OSPF AUTH header: 8 bytes */
  101. #define TCPR_OSPF_CKSUM 0x10 /**< OSPF CKSUM header: 16 bytes */
  102. #define TCPR_OSPF_LS_RTR_H 0x10 /**< OSPF LS RTR header: 16 bytes */
  103. #define TCPR_OSPF_LS_NET_H 0x08 /**< OSPF LS NET header: 8 bytes */
  104. #define TCPR_OSPF_LS_SUM_H 0x0c /**< OSPF LS SUM header: 12 bytes */
  105. #define TCPR_OSPF_LS_AS_EXT_H 0x10 /**< OSPF LS AS header: 16 bytes */
  106. #define TCPR_NTP_H 0x30 /**< NTP header: 48 bytes */
  107. #define TCPR_RIP_H 0x18 /**< RIP header base: 24 bytes */
  108. #define TCPR_RPC_CALL_H \
  109. 0x28 /**< RPC header: 40 bytes \
  110. * (assuming 8 byte auth header) \
  111. */
  112. #define TCPR_RPC_CALL_TCP_H \
  113. 0x2c /**< RPC header: 44 bytes \
  114. * (with record marking) \
  115. */
  116. #define TCPR_SEBEK_H 0x30 /* sebek header: 48 bytes */
  117. #define TCPR_STP_CONF_H 0x23 /**< STP conf header: 35 bytes */
  118. #define TCPR_STP_TCN_H 0x04 /**< STP tcn header: 4 bytes */
  119. #define TCPR_TOKEN_RING_H 0x16 /**< Token Ring header: 22 bytes */
  120. #define TCPR_TCP_H 0x14 /**< TCP header: 20 bytes */
  121. #define TCPR_UDP_H 0x08 /**< UDP header: 8 bytes */
  122. #define TCPR_VRRP_H 0x08 /**< VRRP header: 8 bytes */
  123. #define TCPR_HSRP_H 0x14 /**< HSRP header: 8 bytes */
  124. /**
  125. * IEEE 802.1Q (Virtual Local Area Network) VLAN headr
  126. * size: 8 bytes
  127. */
  128. struct tcpr_802_1q_hdr {
  129. uint16_t vlan_tci; /* VLAN TCI */
  130. uint16_t vlan_tpid; /* Next ETH_TYPE */
  131. #define TCPR_802_1Q_PRIMASK 0xe000 /**< priority mask */
  132. #define TCPR_802_1Q_CFIMASK 0x1000 /**< CFI mask */
  133. #define TCPR_802_1Q_VIDMASK 0x0fff /**< vid mask */
  134. };
  135. /**
  136. * IEEE 802.1X EAP (Extensible Authentication Protocol) header, static header
  137. * size: 4 bytes
  138. */
  139. struct tcpr_802_1x_hdr {
  140. uint8_t dot1x_version; /**< protocol version */
  141. uint8_t dot1x_type; /**< frame type */
  142. #define TCPR_802_1X_PACKET 0x00 /**< 802.1x packet */
  143. #define TCPR_802_1X_START 0x01 /**< 802.1x start */
  144. #define TCPR_802_1X_LOGOFF 0x02 /**< 802.1x logoff */
  145. #define TCPR_802_1X_KEY 0x03 /**< 802.1x key */
  146. #define TCPR_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */
  147. uint16_t dot1x_length; /**< total frame length */
  148. };
  149. /*
  150. * IEEE 802.2 LLC header
  151. * Link Layer Control
  152. * static header size: 4 bytes
  153. */
  154. struct tcpr_802_2_hdr {
  155. uint8_t llc_dsap; /* destination service access point */
  156. uint8_t llc_ssap; /* source service access point */
  157. #define TCPR_SAP_STP 0x42
  158. #define TCPR_SAP_SNAP 0xaa
  159. uint16_t llc_control; /* control field */
  160. };
  161. /*
  162. * IEEE 802.2 LLC/SNAP header
  163. * SubNetwork Attachment Point
  164. * static header size: 8 bytes
  165. */
  166. struct tcpr_802_2snap_hdr {
  167. uint8_t snap_dsap; /* destination service access point */
  168. uint8_t snap_ssap; /* destination service access point */
  169. uint8_t snap_control; /* control field */
  170. uint8_t snap_oui[3]; /* OUI */
  171. uint16_t snap_type; /* type */
  172. };
  173. /*
  174. * 802.3 header
  175. * IEEE Ethernet
  176. * Static header size: 14 bytes
  177. */
  178. struct tcpr_802_3_hdr {
  179. uint8_t _802_3_dhost[ETHER_ADDR_LEN]; /* destination ethernet address */
  180. uint8_t _802_3_shost[ETHER_ADDR_LEN]; /* source ethernet address */
  181. uint16_t _802_3_len; /* packet type ID */
  182. };
  183. /*
  184. * ARP header
  185. * Address Resolution Protocol
  186. * Base header size: 8 bytes
  187. */
  188. struct tcpr_arp_hdr {
  189. uint16_t ar_hrd; /* format of hardware address */
  190. #define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
  191. #define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
  192. #define ARPHRD_EETHER 2 /* Experimental Ethernet */
  193. #define ARPHRD_AX25 3 /* AX.25 Level 2 */
  194. #define ARPHRD_PRONET 4 /* PROnet token ring */
  195. #define ARPHRD_CHAOS 5 /* Chaosnet */
  196. #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
  197. #define ARPHRD_ARCNET 7 /* ARCnet */
  198. #define ARPHRD_APPLETLK 8 /* APPLEtalk */
  199. #define ARPHRD_LANSTAR 9 /* Lanstar */
  200. #define ARPHRD_DLCI 15 /* Frame Relay DLCI */
  201. #define ARPHRD_ATM 19 /* ATM */
  202. #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
  203. #define ARPHRD_IPSEC 31 /* IPsec tunnel */
  204. #define ARPHRD_LOOPBACK 772 /* Loopback device */
  205. uint16_t ar_pro; /* format of protocol address */
  206. uint8_t ar_hln; /* length of hardware address */
  207. uint8_t ar_pln; /* length of protocol address */
  208. uint16_t ar_op; /* operation type */
  209. #define ARPOP_REQUEST 1 /* req to resolve address */
  210. #define ARPOP_REPLY 2 /* resp to previous request */
  211. #define ARPOP_REVREQUEST 3 /* req protocol address given hardware */
  212. #define ARPOP_REVREPLY 4 /* resp giving protocol address */
  213. #define ARPOP_INVREQUEST 8 /* req to identify peer */
  214. #define ARPOP_INVREPLY 9 /* resp identifying peer */
  215. /* address information allocated dynamically */
  216. };
  217. /*
  218. * BGP4 header
  219. * Border Gateway Protocol 4
  220. * Base header size : 19 bytes
  221. */
  222. struct tcpr_bgp4_header_hdr {
  223. #define TCPR_BGP4_MARKER_SIZE 16
  224. uint8_t marker[TCPR_BGP4_MARKER_SIZE];
  225. uint16_t len;
  226. uint8_t type;
  227. #define TCPR_BGP4_OPEN 1
  228. #define TCPR_BGP4_UPDATE 2
  229. #define TCPR_BGP4_NOTIFICATION 3
  230. #define TCPR_BGP4_KEEPALIVE 4
  231. };
  232. /*
  233. * BGP4 open header
  234. * Border Gateway Protocol 4
  235. * Base header size : 10 bytes
  236. */
  237. struct tcpr_bgp4_open_hdr {
  238. uint8_t version;
  239. uint16_t src_as;
  240. uint16_t hold_time;
  241. uint32_t bgp_id;
  242. uint8_t opt_len;
  243. };
  244. /*
  245. * BGP4 notification message
  246. *
  247. * Border Gateway Protocol 4
  248. * Base header size : 2 bytes
  249. *
  250. * Use payload if you need data
  251. */
  252. struct tcpr_bgp4_notification_hdr {
  253. #define TCPR_BGP4_MESSAGE_HEADER_ERROR 1
  254. #define TCPR_BGP4_OPEN_MESSAGE_ERROR 2
  255. #define TCPR_BGP4_UPDATE_MESSAGE_ERROR 3
  256. #define TCPR_BGP4_HOLD_TIMER_EXPIRED 4
  257. #define TCPR_BGP4_FINITE_STATE__ERROR 5
  258. #define TCPR_BGP4_CEASE 6
  259. uint8_t err_code;
  260. /* Message Header Error subcodes */
  261. #define TCPR_BGP4_CONNECTION_NOT_SYNCHRONIZED 1
  262. #define TCPR_BGP4_BAD_MESSAGE_LENGTH 2
  263. #define TCPR_BGP4_BAD_MESSAGE_TYPE 3
  264. /* OPEN Message Error subcodes */
  265. #define TCPR_BGP4_UNSUPPORTED_VERSION_NUMBER 1
  266. #define TCPR_BGP4_BAD_PEER_AS 2
  267. #define TCPR_BGP4_BAD_BGP_IDENTIFIER 3
  268. #define TCPR_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
  269. #define TCPR_BGP4_AUTHENTICATION_FAILURE 5
  270. #define TCPR_BGP4_UNACCEPTABLE_HOLD_TIME 6
  271. /* UPDATE Message Error subcodes */
  272. #define TCPR_BGP4_MALFORMED_ATTRIBUTE_LIST
  273. #define TCPR_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
  274. #define TCPR_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
  275. #define TCPR_BGP4_ATTRIBUTE_FLAGS_ERROR
  276. #define TCPR_BGP4_ATTRIBUTE_LENGTH_ERROR
  277. #define TCPR_BGP4_INVALID_ORIGIN_ATTRIBUTE
  278. #define TCPR_BGP4_AS_ROUTING_LOOP
  279. #define TCPR_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
  280. #define TCPR_BGP4_OPTIONAL_ATTRIBUTE_ERROR
  281. #define TCPR_BGP4_INVALID_NETWORK_FIELD
  282. #define TCPR_BGP4_MALFORMED_AS_PATH
  283. uint8_t err_subcode;
  284. };
  285. /*
  286. * CDP header
  287. * Cisco Discovery Protocol
  288. * Base header size: 8 bytes
  289. */
  290. /*
  291. * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
  292. * Let's hope this one stays that way for a while!
  293. */
  294. #define TCPR_PROTO_CDP 200
  295. struct tcpr_cdp_hdr {
  296. uint8_t cdp_version; /* version (should always be 0x01) */
  297. uint8_t cdp_ttl; /* time receiver should hold info in this packet */
  298. uint16_t cdp_sum; /* checksum */
  299. uint16_t cdp_type; /* type */
  300. #define TCPR_CDP_DEVID 0x1 /* device id */
  301. #define TCPR_CDP_ADDRESS 0x2 /* address */
  302. #define TCPR_CDP_PORTID 0x3 /* port id */
  303. #define TCPR_CDP_CAPABIL 0x4 /* capabilities */
  304. #define TCPR_CDP_VERSION 0x5 /* version */
  305. #define TCPR_CDP_PLATFORM 0x6 /* platform */
  306. #define TCPR_CDP_IPPREFIX 0x7 /* ip prefix */
  307. uint16_t cdp_len; /* type + length + value */
  308. /* value information done dynamically */
  309. /* CDP capabilities */
  310. #define TCPR_CDP_CAP_L3R 0x01 /* performs level 3 routing */
  311. #define TCPR_CDP_CAP_L2B 0x02 /* performs level 2 transparent bridging */
  312. #define TCPR_CDP_CAP_L2SRB 0x04 /* performs level 2 sourceroute bridging */
  313. #define TCPR_CDP_CAP_L2S 0x08 /* performs level 2 switching */
  314. #define TCPR_CDP_CAP_SR 0x10 /* sends and receives packets on a network */
  315. #define TCPR_CDP_CAP_NOI 0x20 /* does not forward IGMP on non-router ports */
  316. #define TCPR_CDP_CAP_L1F 0x40 /* provides level 1 functionality */
  317. };
  318. /*
  319. * Used as an overlay for type/len/values
  320. */
  321. struct tcpr_cdp_value_hdr {
  322. uint16_t cdp_type;
  323. uint16_t cdp_len;
  324. };
  325. /*
  326. * DHCP header
  327. * Dynamic Host Configuration Protocol
  328. * Static header size: f0 bytes
  329. */
  330. struct tcpr_dhcpv4_hdr {
  331. uint8_t dhcp_opcode; /* opcode */
  332. #define TCPR_DHCP_REQUEST 0x1
  333. #define TCPR_DHCP_REPLY 0x2
  334. uint8_t dhcp_htype; /* hardware address type */
  335. uint8_t dhcp_hlen; /* hardware address length */
  336. uint8_t dhcp_hopcount; /* used by proxy servers */
  337. uint32_t dhcp_xid; /* transaction ID */
  338. uint16_t dhcp_secs; /* number of seconds since trying to bootstrap */
  339. uint16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */
  340. uint32_t dhcp_cip; /* client's IP */
  341. uint32_t dhcp_yip; /* your IP */
  342. uint32_t dhcp_sip; /* server's IP */
  343. uint32_t dhcp_gip; /* gateway IP */
  344. uint8_t dhcp_chaddr[16]; /* client hardware address */
  345. uint8_t dhcp_sname[64]; /* server host name */
  346. uint8_t dhcp_file[128]; /* boot file name */
  347. uint32_t dhcp_magic; /* BOOTP magic header */
  348. #define DHCP_MAGIC 0x63825363
  349. #define TCPR_BOOTP_MIN_LEN 0x12c
  350. #define TCPR_DHCP_PAD 0x00
  351. #define TCPR_DHCP_SUBNETMASK 0x01
  352. #define TCPR_DHCP_TIMEOFFSET 0x02
  353. #define TCPR_DHCP_ROUTER 0x03
  354. #define TCPR_DHCP_TIMESERVER 0x04
  355. #define TCPR_DHCP_NAMESERVER 0x05
  356. #define TCPR_DHCP_DNS 0x06
  357. #define TCPR_DHCP_LOGSERV 0x07
  358. #define TCPR_DHCP_COOKIESERV 0x08
  359. #define TCPR_DHCP_LPRSERV 0x09
  360. #define TCPR_DHCP_IMPSERV 0x0a
  361. #define TCPR_DHCP_RESSERV 0x0b
  362. #define TCPR_DHCP_HOSTNAME 0x0c
  363. #define TCPR_DHCP_BOOTFILESIZE 0x0d
  364. #define TCPR_DHCP_DUMPFILE 0x0e
  365. #define TCPR_DHCP_DOMAINNAME 0x0f
  366. #define TCPR_DHCP_SWAPSERV 0x10
  367. #define TCPR_DHCP_ROOTPATH 0x11
  368. #define TCPR_DHCP_EXTENPATH 0x12
  369. #define TCPR_DHCP_IPFORWARD 0x13
  370. #define TCPR_DHCP_SRCROUTE 0x14
  371. #define TCPR_DHCP_POLICYFILTER 0x15
  372. #define TCPR_DHCP_MAXASMSIZE 0x16
  373. #define TCPR_DHCP_IPTTL 0x17
  374. #define TCPR_DHCP_MTUTIMEOUT 0x18
  375. #define TCPR_DHCP_MTUTABLE 0x19
  376. #define TCPR_DHCP_MTUSIZE 0x1a
  377. #define TCPR_DHCP_LOCALSUBNETS 0x1b
  378. #define TCPR_DHCP_BROADCASTADDR 0x1c
  379. #define TCPR_DHCP_DOMASKDISCOV 0x1d
  380. #define TCPR_DHCP_MASKSUPPLY 0x1e
  381. #define TCPR_DHCP_DOROUTEDISC 0x1f
  382. #define TCPR_DHCP_ROUTERSOLICIT 0x20
  383. #define TCPR_DHCP_STATICROUTE 0x21
  384. #define TCPR_DHCP_TRAILERENCAP 0x22
  385. #define TCPR_DHCP_ARPTIMEOUT 0x23
  386. #define TCPR_DHCP_ETHERENCAP 0x24
  387. #define TCPR_DHCP_TCPTTL 0x25
  388. #define TCPR_DHCP_TCPKEEPALIVE 0x26
  389. #define TCPR_DHCP_TCPALIVEGARBAGE 0x27
  390. #define TCPR_DHCP_NISDOMAIN 0x28
  391. #define TCPR_DHCP_NISSERVERS 0x29
  392. #define TCPR_DHCP_NISTIMESERV 0x2a
  393. #define TCPR_DHCP_VENDSPECIFIC 0x2b
  394. #define TCPR_DHCP_NBNS 0x2c
  395. #define TCPR_DHCP_NBDD 0x2d
  396. #define TCPR_DHCP_NBTCPIP 0x2e
  397. #define TCPR_DHCP_NBTCPSCOPE 0x2f
  398. #define TCPR_DHCP_XFONT 0x30
  399. #define TCPR_DHCP_XDISPLAYMGR 0x31
  400. #define TCPR_DHCP_DISCOVERADDR 0x32
  401. #define TCPR_DHCP_LEASETIME 0x33
  402. #define TCPR_DHCP_OPTIONOVERLOAD 0x34
  403. #define TCPR_DHCP_MESSAGETYPE 0x35
  404. #define TCPR_DHCP_SERVIDENT 0x36
  405. #define TCPR_DHCP_PARAMREQUEST 0x37
  406. #define TCPR_DHCP_MESSAGE 0x38
  407. #define TCPR_DHCP_MAXMSGSIZE 0x39
  408. #define TCPR_DHCP_RENEWTIME 0x3a
  409. #define TCPR_DHCP_REBINDTIME 0x3b
  410. #define TCPR_DHCP_CLASSSID 0x3c
  411. #define TCPR_DHCP_CLIENTID 0x3d
  412. #define TCPR_DHCP_NISPLUSDOMAIN 0x40
  413. #define TCPR_DHCP_NISPLUSSERVERS 0x41
  414. #define TCPR_DHCP_MOBILEIPAGENT 0x44
  415. #define TCPR_DHCP_SMTPSERVER 0x45
  416. #define TCPR_DHCP_POP3SERVER 0x46
  417. #define TCPR_DHCP_NNTPSERVER 0x47
  418. #define TCPR_DHCP_WWWSERVER 0x48
  419. #define TCPR_DHCP_FINGERSERVER 0x49
  420. #define TCPR_DHCP_IRCSERVER 0x4a
  421. #define TCPR_DHCP_STSERVER 0x4b
  422. #define TCPR_DHCP_STDASERVER 0x4c
  423. #define TCPR_DHCP_END 0xff
  424. #define TCPR_DHCP_MSGDISCOVER 0x01
  425. #define TCPR_DHCP_MSGOFFER 0x02
  426. #define TCPR_DHCP_MSGREQUEST 0x03
  427. #define TCPR_DHCP_MSGDECLINE 0x04
  428. #define TCPR_DHCP_MSGACK 0x05
  429. #define TCPR_DHCP_MSGNACK 0x06
  430. #define TCPR_DHCP_MSGRELEASE 0x07
  431. #define TCPR_DHCP_MSGINFORM 0x08
  432. };
  433. /*
  434. * Base DNSv4 header
  435. * Domain Name System
  436. * Base header size: 12/14 bytes
  437. */
  438. struct tcpr_dnsv4_hdr {
  439. uint16_t h_len; /* length of the packet - only used with TCP */
  440. uint16_t id; /* DNS packet ID */
  441. uint16_t flags; /* DNS flags */
  442. uint16_t num_q; /* Number of questions */
  443. uint16_t num_answ_rr; /* Number of answer resource records */
  444. uint16_t num_auth_rr; /* Number of authority resource records */
  445. uint16_t num_addi_rr; /* Number of additional resource records */
  446. };
  447. #define TCPR_DNS_H TCPR_UDP_DNSV4_H
  448. struct tcpr_dnsv4udp_hdr {
  449. uint16_t id; /* DNS packet ID */
  450. uint16_t flags; /* DNS flags */
  451. uint16_t num_q; /* Number of questions */
  452. uint16_t num_answ_rr; /* Number of answer resource records */
  453. uint16_t num_auth_rr; /* Number of authority resource records */
  454. uint16_t num_addi_rr; /* Number of additional resource records */
  455. };
  456. /*
  457. * PPP over Serial with HDLC encapsulation for NetBSD
  458. */
  459. struct tcpr_pppserial_hdr {
  460. uint8_t address;
  461. uint8_t control;
  462. uint16_t protocol;
  463. };
  464. /*
  465. * Ethernet II header
  466. * Static header size: 14 bytes
  467. */
  468. struct tcpr_ethernet_hdr {
  469. uint8_t ether_dhost[ETHER_ADDR_LEN]; /* destination ethernet address */
  470. uint8_t ether_shost[ETHER_ADDR_LEN]; /* source ethernet address */
  471. uint16_t ether_type; /* protocol */
  472. };
  473. #ifndef ETHERTYPE_PUP
  474. #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
  475. #endif
  476. #ifndef ETHERTYPE_IP
  477. #define ETHERTYPE_IP 0x0800 /* IP protocol */
  478. #endif
  479. #ifndef ETHERTYPE_ARP
  480. #define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */
  481. #endif
  482. #ifndef ETHERTYPE_REVARP
  483. #define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
  484. #endif
  485. #ifndef ETHERTYPE_VLAN
  486. #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
  487. #endif
  488. #ifndef ETHERTYPE_EAP
  489. #define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */
  490. #endif
  491. #ifndef ETHERTYPE_MPLS
  492. #define ETHERTYPE_MPLS 0x8847 /* MPLS */
  493. #endif
  494. #ifndef ETHERTYPE_LOOPBACK
  495. #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
  496. #endif
  497. #ifndef ETHERTYPE_IP6
  498. #define ETHERTYPE_IP6 0x86DD /* IPv6 */
  499. #endif
  500. #ifndef ETHERTYPE_Q_IN_Q
  501. #define ETHERTYPE_Q_IN_Q 0x88A8 /* 802.1ad Service VLAN */
  502. #endif
  503. #ifndef ETHERTYPE_8021QINQ
  504. #define ETHERTYPE_8021QINQ 0x9100 /* 802.1Q in Q VLAN */
  505. #endif
  506. #ifndef ETHERTYPE_MPLS_MULTI
  507. #define ETHERTYPE_MPLS_MULTI 0x8848 /* MPLS multicast packet */
  508. #endif
  509. struct tcpr_ether_addr {
  510. uint8_t ether_addr_octet[6]; /* Ethernet address */
  511. };
  512. /*
  513. * Fiber Distributed Data Interface header
  514. *
  515. * Static header size: 21 bytes (LLC and 48-bit address addr only)
  516. *
  517. * Note: Organization field is 3 bytes which throws off the
  518. * alignment of type. Therefore fddi_type (19 bytes in)
  519. * is specified as two uint8_ts.
  520. */
  521. struct tcpr_fddi_hdr {
  522. uint8_t fddi_frame_control; /* Class/Format/Priority */
  523. #define TCPR_FDDI_LLC_FRAME 0x10
  524. #define TCPR_FDDI_48BIT_ADDR 0x40
  525. #define TCPR_FDDI_FC_REQD TCPR_FDDI_LLC_FRAME | TCPR_FDDI_48BIT_ADDR
  526. uint8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */
  527. uint8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */
  528. uint8_t fddi_llc_dsap; /* DSAP */
  529. uint8_t fddi_llc_ssap; /* SSAP */
  530. uint8_t fddi_llc_control_field; /* Class/Format/Priority */
  531. uint8_t fddi_llc_org_code[TCPR_ORG_CODE_SIZE]; /* Organization Code 3-bytes */
  532. uint8_t fddi_type; /* Protocol Type */
  533. uint8_t fddi_type1; /* see note above. */
  534. #define FDDI_TYPE_IP 0x0800 /* IP protocol */
  535. #define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */
  536. #define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
  537. };
  538. struct tcpr_fddi_addr {
  539. uint8_t fddi_addr_octet[6]; /* FDDI address */
  540. };
  541. /*
  542. * GRE header - RFC 1701 & 2637
  543. * Generic Routing Encapsulation (GRE)
  544. * Base header size: 4 bytes
  545. */
  546. struct tcpr_gre_hdr {
  547. uint16_t flags_ver;
  548. #define GRE_CSUM 0x8000
  549. #define GRE_ROUTING 0x4000
  550. #define GRE_KEY 0x2000
  551. #define GRE_SEQ 0x1000
  552. #define GRE_STRICT 0x0800
  553. #define GRE_REC 0x0700
  554. #define GRE_ACK 0x0080
  555. #define GRE_FLAGS_MASK 0x00F8
  556. #define GRE_VERSION_MASK 0x0007
  557. #define GRE_VERSION_0 0x0000
  558. #define GRE_VERSION_1 0x0001
  559. uint16_t type;
  560. #define GRE_SNA 0x0004
  561. #define GRE_OSI_NETWORK_LAYER 0x00FE
  562. #define GRE_PUP 0x0200
  563. #define GRE_XNS 0x0600
  564. #define GRE_IP 0x0800
  565. #define GRE_CHAOS 0x0804
  566. #define GRE_RFC_826_ARP 0x0806
  567. #define GRE_FRAME_RELAY_ARP 0x0808
  568. #define GRE_VINES 0x0BAD
  569. #define GRE_VINES_ECHO 0x0BAE
  570. #define GRE_VINES_LOOPBACK 0x0BAF
  571. #define GRE_DECNET 0x6003
  572. #define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558
  573. #define GRE_RAW_FRAME_RELAY 0x6559
  574. #define GRE_APOLLO_DOMAIN 0x8019
  575. #define GRE_ETHERTALK 0x809B
  576. #define GRE_NOVELL_IPX 0x8137
  577. #define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B
  578. #define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C
  579. #define GRE_SECURE_DATA 0x876D
  580. #define GRE_PPP 0x880b /* taken from RFC 2637 */
  581. union {
  582. struct {
  583. uint16_t sum; /* optional */
  584. uint16_t offset; /* optional */
  585. uint32_t key; /* optional */
  586. uint32_t seq; /* optional */
  587. } _gre;
  588. struct {
  589. uint16_t payload_s; /* optional */
  590. uint16_t callID; /* optional */
  591. uint32_t seq; /* optional */
  592. uint32_t ack; /* optional */
  593. } _egre;
  594. } _data;
  595. #define gre_sum _data._gre.sum
  596. #define gre_offset _data._gre.offset
  597. #define gre_key _data._gre.key
  598. #define gre_seq _data._gre.seq
  599. #define egre_payload_s _data._egre.payload_s
  600. #define egre_callID _data._egre.callID
  601. #define egre_seq _data._egre.seq
  602. #define egre_ack _data._egre.ack
  603. };
  604. #ifndef IPPROTO_GRE
  605. #define IPPROTO_GRE 47
  606. #endif
  607. /*
  608. * Source Route Entries (SRE)
  609. * This is used for GRE as the Routing field is a list of SREs - RFC 1701
  610. * Base header size: 4 bytes
  611. */
  612. struct tcpr_gre_sre_hdr {
  613. uint16_t af; /* address family */
  614. uint8_t sre_offset;
  615. uint8_t sre_length;
  616. uint8_t *routing;
  617. };
  618. /*
  619. * IPv4 header
  620. * Internet Protocol, version 4
  621. * Static header size: 20 bytes
  622. */
  623. struct tcpr_ipv4_hdr {
  624. #ifdef WORDS_BIGENDIAN
  625. uint8_t ip_v:4, /* version */
  626. ip_hl:4; /* header length */
  627. #else
  628. uint8_t ip_hl:4, /* header length */
  629. ip_v:4; /* version */
  630. #endif
  631. uint8_t ip_tos; /* type of service */
  632. #ifndef IPTOS_LOWDELAY
  633. #define IPTOS_LOWDELAY 0x10
  634. #endif
  635. #ifndef IPTOS_THROUGHPUT
  636. #define IPTOS_THROUGHPUT 0x08
  637. #endif
  638. #ifndef IPTOS_RELIABILITY
  639. #define IPTOS_RELIABILITY 0x04
  640. #endif
  641. #ifndef IPTOS_LOWCOST
  642. #define IPTOS_LOWCOST 0x02
  643. #endif
  644. uint16_t ip_len; /* total length */
  645. uint16_t ip_id; /* identification */
  646. uint16_t ip_off;
  647. #ifndef IP_RF
  648. #define IP_RF 0x8000 /* reserved fragment flag */
  649. #endif
  650. #ifndef IP_DF
  651. #define IP_DF 0x4000 /* don't fragment flag */
  652. #endif
  653. #ifndef IP_MF
  654. #define IP_MF 0x2000 /* more fragments flag */
  655. #endif
  656. #ifndef IP_OFFMASK
  657. #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
  658. #endif
  659. uint8_t ip_ttl; /* time to live */
  660. uint8_t ip_p; /* protocol */
  661. uint16_t ip_sum; /* checksum */
  662. struct in_addr ip_src, ip_dst; /* source and dest address */
  663. };
  664. /*
  665. * IP options
  666. */
  667. #ifndef IPOPT_EOL
  668. #define IPOPT_EOL 0 /* end of option list */
  669. #endif
  670. #ifndef IPOPT_NOP
  671. #define IPOPT_NOP 1 /* no operation */
  672. #endif
  673. #ifndef IPOPT_RR
  674. #define IPOPT_RR 7 /* record packet route */
  675. #endif
  676. #ifndef IPOPT_TS
  677. #define IPOPT_TS 68 /* timestamp */
  678. #endif
  679. #ifndef IPOPT_SECURITY
  680. #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
  681. #endif
  682. #ifndef IPOPT_LSRR
  683. #define IPOPT_LSRR 131 /* loose source route */
  684. #endif
  685. #ifndef IPOPT_SATID
  686. #define IPOPT_SATID 136 /* satnet id */
  687. #endif
  688. #ifndef IPOPT_SSRR
  689. #define IPOPT_SSRR 137 /* strict source route */
  690. #endif
  691. struct tcpr_in6_addr {
  692. union {
  693. u_int8_t __u6_addr8[16];
  694. u_int16_t __u6_addr16[8];
  695. u_int32_t __u6_addr32[4];
  696. } __u6_addr; /* 128-bit IP6 address */
  697. };
  698. #define tcpr_s6_addr __u6_addr.__u6_addr8
  699. #define tcpr_s6_addr8 __u6_addr.__u6_addr8
  700. #define tcpr_s6_addr16 __u6_addr.__u6_addr16
  701. #define tcpr_s6_addr32 __u6_addr.__u6_addr32
  702. /*
  703. * IPv6 header
  704. * Internet Protocol, version 6
  705. * Static header size: 40 bytes
  706. */
  707. struct tcpr_ipv6_hdr {
  708. uint8_t ip_flags[4]; /* version, traffic class, flow label */
  709. uint16_t ip_len; /* total length */
  710. uint8_t ip_nh; /* next header */
  711. uint8_t ip_hl; /* hop limit */
  712. struct tcpr_in6_addr ip_src, ip_dst; /* source and dest address */
  713. };
  714. struct tcpr_ipv6_ext_hdr_base {
  715. uint8_t ip_nh; /* next header */
  716. uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
  717. /* some more bytes are always here, but we don't know what kind */
  718. };
  719. #define TCPR_IPV6_NH_NO_NEXT 59
  720. #define TCPR_IPV6_NH_IPV6 41
  721. #define TCPR_IPV6_NH_ESP 50
  722. #define TCPR_IPV6_NH_AH 51
  723. /*
  724. * IPv6 frag header
  725. * Internet Protocol, version 6
  726. * Static header size: 8 bytes
  727. */
  728. #define TCPR_IPV6_NH_FRAGMENT 44
  729. struct tcpr_ipv6_frag_hdr {
  730. uint8_t ip_nh; /* next header */
  731. uint8_t ip_reserved; /* reserved */
  732. uint16_t ip_frag; /* fragmentation stuff */
  733. uint32_t ip_id; /* id */
  734. };
  735. /*
  736. * IPv6 routing header
  737. * Internet Protocol, version 6
  738. * Base header size: 4 bytes
  739. */
  740. #define TCPR_IPV6_NH_ROUTING 43
  741. struct tcpr_ipv6_routing_hdr {
  742. uint8_t ip_nh; /* next header */
  743. uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
  744. uint8_t ip_rtype; /* routing type */
  745. uint8_t ip_segments; /* segments left */
  746. /* routing information allocated dynamically */
  747. };
  748. /*
  749. * IPv6 destination options header
  750. * Internet Protocol, version 6
  751. * Base header size: 2 bytes
  752. */
  753. #define TCPR_IPV6_NH_DESTOPTS 60
  754. struct tcpr_ipv6_destopts_hdr {
  755. uint8_t ip_nh; /* next header */
  756. uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
  757. /* destination options information allocated dynamically */
  758. };
  759. /*
  760. * IPv6 hop by hop options header
  761. * Internet Protocol, version 6
  762. * Base header size: 2 bytes
  763. */
  764. #define TCPR_IPV6_NH_HBH 0
  765. struct tcpr_ipv6_hbhopts_hdr {
  766. uint8_t ip_nh; /* next header */
  767. uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
  768. /* destination options information allocated dynamically */
  769. };
  770. /*
  771. * ICMP6 header
  772. * Internet Control Message Protocol v6
  773. * Base header size: 8 bytes
  774. */
  775. #ifndef IPPROTO_ICMP6
  776. #define IPPROTO_ICMP6 0x3a
  777. #endif
  778. struct tcpr_icmpv6_hdr {
  779. uint8_t icmp_type; /* ICMP type */
  780. #ifndef ICMP6_ECHO
  781. #define ICMP6_ECHO 128
  782. #endif
  783. #ifndef ICMP6_ECHOREPLY
  784. #define ICMP6_ECHOREPLY 129
  785. #endif
  786. #ifndef ICMP6_UNREACH
  787. #define ICMP6_UNREACH 1
  788. #endif
  789. #ifndef ICMP6_PKTTOOBIG
  790. #define ICMP6_PKTTOOBIG 2
  791. #endif
  792. #ifndef ICMP6_TIMXCEED
  793. #define ICMP6_TIMXCEED 3
  794. #endif
  795. #ifndef ICMP6_PARAMPROB
  796. #define ICMP6_PARAMPROB 4
  797. #endif
  798. uint8_t icmp_code; /* ICMP code */
  799. uint16_t icmp_sum; /* ICMP Checksum */
  800. uint16_t id; /* ICMP id */
  801. uint16_t seq; /* ICMP sequence number */
  802. };
  803. /*
  804. * ICMP header
  805. * Internet Control Message Protocol
  806. * Base header size: 4 bytes
  807. */
  808. struct tcpr_icmpv4_hdr {
  809. uint8_t icmp_type; /* ICMP type */
  810. #ifndef ICMP_ECHOREPLY
  811. #define ICMP_ECHOREPLY 0
  812. #endif
  813. #ifndef ICMP_UNREACH
  814. #define ICMP_UNREACH 3
  815. #endif
  816. #ifndef ICMP_SOURCEQUENCH
  817. #define ICMP_SOURCEQUENCH 4
  818. #endif
  819. #ifndef ICMP_REDIRECT
  820. #define ICMP_REDIRECT 5
  821. #endif
  822. #ifndef ICMP_ECHO
  823. #define ICMP_ECHO 8
  824. #endif
  825. #ifndef ICMP_ROUTERADVERT
  826. #define ICMP_ROUTERADVERT 9
  827. #endif
  828. #ifndef ICMP_ROUTERSOLICIT
  829. #define ICMP_ROUTERSOLICIT 10
  830. #endif
  831. #ifndef ICMP_TIMXCEED
  832. #define ICMP_TIMXCEED 11
  833. #endif
  834. #ifndef ICMP_PARAMPROB
  835. #define ICMP_PARAMPROB 12
  836. #endif
  837. #ifndef ICMP_TSTAMP
  838. #define ICMP_TSTAMP 13
  839. #endif
  840. #ifndef ICMP_TSTAMPREPLY
  841. #define ICMP_TSTAMPREPLY 14
  842. #endif
  843. #ifndef ICMP_IREQ
  844. #define ICMP_IREQ 15
  845. #endif
  846. #ifndef ICMP_IREQREPLY
  847. #define ICMP_IREQREPLY 16
  848. #endif
  849. #ifndef ICMP_MASKREQ
  850. #define ICMP_MASKREQ 17
  851. #endif
  852. #ifndef ICMP_MASKREPLY
  853. #define ICMP_MASKREPLY 18
  854. #endif
  855. uint8_t icmp_code; /* ICMP code */
  856. #ifndef ICMP_UNREACH_NET
  857. #define ICMP_UNREACH_NET 0
  858. #endif
  859. #ifndef ICMP_UNREACH_HOST
  860. #define ICMP_UNREACH_HOST 1
  861. #endif
  862. #ifndef ICMP_UNREACH_PROTOCOL
  863. #define ICMP_UNREACH_PROTOCOL 2
  864. #endif
  865. #ifndef ICMP_UNREACH_PORT
  866. #define ICMP_UNREACH_PORT 3
  867. #endif
  868. #ifndef ICMP_UNREACH_NEEDFRAG
  869. #define ICMP_UNREACH_NEEDFRAG 4
  870. #endif
  871. #ifndef ICMP_UNREACH_SRCFAIL
  872. #define ICMP_UNREACH_SRCFAIL 5
  873. #endif
  874. #ifndef ICMP_UNREACH_NET_UNKNOWN
  875. #define ICMP_UNREACH_NET_UNKNOWN 6
  876. #endif
  877. #ifndef ICMP_UNREACH_HOST_UNKNOWN
  878. #define ICMP_UNREACH_HOST_UNKNOWN 7
  879. #endif
  880. #ifndef ICMP_UNREACH_ISOLATED
  881. #define ICMP_UNREACH_ISOLATED 8
  882. #endif
  883. #ifndef ICMP_UNREACH_NET_PROHIB
  884. #define ICMP_UNREACH_NET_PROHIB 9
  885. #endif
  886. #ifndef ICMP_UNREACH_HOST_PROHIB
  887. #define ICMP_UNREACH_HOST_PROHIB 10
  888. #endif
  889. #ifndef ICMP_UNREACH_TOSNET
  890. #define ICMP_UNREACH_TOSNET 11
  891. #endif
  892. #ifndef ICMP_UNREACH_TOSHOST
  893. #define ICMP_UNREACH_TOSHOST 12
  894. #endif
  895. #ifndef ICMP_UNREACH_FILTER_PROHIB
  896. #define ICMP_UNREACH_FILTER_PROHIB 13
  897. #endif
  898. #ifndef ICMP_UNREACH_HOST_PRECEDENCE
  899. #define ICMP_UNREACH_HOST_PRECEDENCE 14
  900. #endif
  901. #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
  902. #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
  903. #endif
  904. #ifndef ICMP_REDIRECT_NET
  905. #define ICMP_REDIRECT_NET 0
  906. #endif
  907. #ifndef ICMP_REDIRECT_HOST
  908. #define ICMP_REDIRECT_HOST 1
  909. #endif
  910. #ifndef ICMP_REDIRECT_TOSNET
  911. #define ICMP_REDIRECT_TOSNET 2
  912. #endif
  913. #ifndef ICMP_REDIRECT_TOSHOST
  914. #define ICMP_REDIRECT_TOSHOST 3
  915. #endif
  916. #ifndef ICMP_TIMXCEED_INTRANS
  917. #define ICMP_TIMXCEED_INTRANS 0
  918. #endif
  919. #ifndef ICMP_TIMXCEED_REASS
  920. #define ICMP_TIMXCEED_REASS 1
  921. #endif
  922. #ifndef ICMP_PARAMPROB_OPTABSENT
  923. #define ICMP_PARAMPROB_OPTABSENT 1
  924. #endif
  925. uint16_t icmp_sum; /* ICMP Checksum */
  926. union {
  927. struct {
  928. uint16_t id; /* ICMP id */
  929. uint16_t seq; /* ICMP sequence number */
  930. } echo;
  931. #undef icmp_id
  932. #undef icmp_seq
  933. #define icmp_id hun.echo.id
  934. #define icmp_seq hun.echo.seq
  935. uint32_t gateway; /* gateway host */
  936. struct {
  937. uint16_t pad; /* padding */
  938. uint16_t mtu; /* MTU size */
  939. } frag;
  940. } hun;
  941. union {
  942. struct {
  943. uint32_t its_otime;
  944. uint32_t its_rtime;
  945. uint32_t its_ttime;
  946. } ts;
  947. struct {
  948. struct tcpr_ipv4_hdr idi_ip;
  949. /* options and then 64 bits of data */
  950. } ip;
  951. uint32_t mask;
  952. int8_t data[1];
  953. #undef icmp_mask
  954. #define icmp_mask dun.mask
  955. #undef icmp_data
  956. #define icmp_data dun.data
  957. #undef icmp_otime
  958. #define icmp_otime dun.ts.its_otime
  959. #undef icmp_rtime
  960. #define icmp_rtime dun.ts.its_rtime
  961. #undef icmp_ttime
  962. #define icmp_ttime dun.ts.its_ttime
  963. } dun;
  964. };
  965. /*
  966. * IGMP header
  967. * Internet Group Message Protocol
  968. * Static header size: 8 bytes
  969. */
  970. struct tcpr_igmp_hdr {
  971. uint8_t igmp_type; /* IGMP type */
  972. #ifndef IGMP_MEMBERSHIP_QUERY
  973. #define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */
  974. #endif
  975. #ifndef IGMP_V1_MEMBERSHIP_REPORT
  976. #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */
  977. #endif
  978. #ifndef IGMP_V2_MEMBERSHIP_REPORT
  979. #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */
  980. #endif
  981. #ifndef IGMP_LEAVE_GROUP
  982. #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
  983. #endif
  984. uint8_t igmp_code; /* IGMP code */
  985. uint16_t igmp_sum; /* IGMP checksum */
  986. struct in_addr igmp_group; /* IGMP host IP */
  987. };
  988. /*
  989. * IPSEC header
  990. * Internet Protocol Security Protocol
  991. * Encapsulating Security Payload Header Static header size: 12 bytes
  992. * Encapsulating Security Payload Footer Base header size: 2 bytes
  993. * Authentication Header Static Size: 16 bytes
  994. */
  995. #ifndef IPPROTO_ESP
  996. #define IPPROTO_ESP 50 /* not everyone's got this */
  997. #endif
  998. struct tcpr_esp_hdr {
  999. uint32_t esp_spi; /* security parameter index */
  1000. uint32_t esp_seq; /* ESP sequence number */
  1001. uint32_t esp_iv; /* initialization vector */
  1002. };
  1003. struct tcpr_esp_ftr {
  1004. uint8_t esp_pad_len; /* padding length */
  1005. uint8_t esp_nh; /* next header pointer */
  1006. int8_t *esp_auth; /* authentication data */
  1007. };
  1008. #ifndef IPPROTO_AH
  1009. #define IPPROTO_AH 51 /* not everyone's got this */
  1010. #endif
  1011. struct tcpr_ah_hdr {
  1012. uint8_t ah_nh; /* next header */
  1013. uint8_t ah_len; /* payload length */
  1014. uint16_t ah_res; /* reserved */
  1015. uint32_t ah_spi; /* security parameter index */
  1016. uint32_t ah_seq; /* AH sequence number */
  1017. uint32_t ah_auth; /* authentication data */
  1018. };
  1019. /*
  1020. * ISL header
  1021. * Cisco Inter-Switch Link
  1022. * Static header size: 26 bytes
  1023. */
  1024. /*
  1025. * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
  1026. * Let's hope this one stays that way for a while!
  1027. */
  1028. #define TCPR_PROTO_ISL 201
  1029. struct tcpr_isl_hdr {
  1030. uint8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */
  1031. #ifdef WORDS_BIGENDIAN
  1032. uint8_t isl_user:4, /* user defined bits */
  1033. isl_type:4; /* type of frame */
  1034. #else
  1035. uint8_t isl_type:4, /* type of frame */
  1036. isl_user:4; /* user defined bits */
  1037. #endif
  1038. uint8_t isl_shost[6]; /* source address */
  1039. uint16_t isl_len; /* total length of packet - 18 bytes */
  1040. uint8_t isl_snap[6]; /* 0xaaaa03 + vendor code */
  1041. uint16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */
  1042. uint16_t isl_index; /* port index */
  1043. uint16_t isl_reserved; /* used for FDDI and token ring */
  1044. /* ethernet frame and 4 byte isl crc */
  1045. };
  1046. #ifndef IPPROTO_OSPF
  1047. #define IPPROTO_OSPF 89 /* not everyone's got this */
  1048. #endif
  1049. #define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */
  1050. #define TCPR_MODX 4102 /* used in LSA checksum */
  1051. /*
  1052. * Options used in multiple OSPF packets
  1053. * More info can be found in section A.2 of RFC 2328.
  1054. */
  1055. #define TCPR_OPT_EBIT 0x02 /* describes the way AS-external-LSAs are flooded */
  1056. #define TCPR_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */
  1057. #define TCPR_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */
  1058. #define TCPR_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */
  1059. #define TCPR_OPT_DCBIT 0x20 /* describes handling of demand circuits */
  1060. /*
  1061. * MPLS header
  1062. * Multi-Protocol Label Switching
  1063. * Static header size: 4 bytes
  1064. */
  1065. struct tcpr_mpls_hdr {
  1066. uint32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, ttl */
  1067. #define TCPR_MPLS_BOS_ON 1
  1068. #define TCPR_MPLS_BOS_OFF 0
  1069. };
  1070. /*
  1071. * NTP header
  1072. * Network Time Protocol
  1073. * Static header size: 48 bytes
  1074. */
  1075. struct tcpr_ntp_hdr_l_fp /* int32_t floating point (64-bit) */
  1076. {
  1077. uint32_t integer; /* integer */
  1078. uint32_t fraction; /* fraction */
  1079. };
  1080. struct tcpr_ntp_hdr_s_fp /* int16_t floating point (32-bit) */
  1081. {
  1082. uint16_t integer; /* integer */
  1083. uint16_t fraction; /* fraction */
  1084. };
  1085. struct tcpr_ntp_hdr {
  1086. uint8_t ntp_li_vn_mode; /* leap indicator, version, mode */
  1087. #define TCPR_NTP_LI_NW 0x0 /* no warning */
  1088. #define TCPR_NTP_LI_AS 0x1 /* last minute has 61 seconds */
  1089. #define TCPR_NTP_LI_DS 0x2 /* last minute has 59 seconds */
  1090. #define TCPR_NTP_LI_AC 0x3 /* alarm condition */
  1091. #define TCPR_NTP_VN_2 0x2 /* version 2 */
  1092. #define TCPR_NTP_VN_3 0x3 /* version 3 */
  1093. #define TCPR_NTP_VN_4 0x4 /* version 4 */
  1094. #define TCPR_NTP_MODE_R 0x0 /* reserved */
  1095. #define TCPR_NTP_MODE_A 0x1 /* symmetric active */
  1096. #define TCPR_NTP_MODE_P 0x2 /* symmetric passive */
  1097. #define TCPR_NTP_MODE_C 0x3 /* client */
  1098. #define TCPR_NTP_MODE_S 0x4 /* server */
  1099. #define TCPR_NTP_MODE_B 0x5 /* broadcast */
  1100. #define TCPR_NTP_MODE_RC 0x6 /* reserved for NTP control message */
  1101. #define TCPR_NTP_MODE_RP 0x7 /* reserved for private use */
  1102. uint8_t ntp_stratum; /* stratum */
  1103. #define TCPR_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */
  1104. #define TCPR_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */
  1105. /* 2 - 15 is secondary */
  1106. /* 16 - 255 is reserved */
  1107. uint8_t ntp_poll; /* poll interval (should be 4 - 12) */
  1108. uint8_t ntp_precision; /* local clock precision */
  1109. struct tcpr_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */
  1110. struct tcpr_ntp_hdr_s_fp ntp_dispersion; /* nominal error */
  1111. uint32_t ntp_reference_id; /* reference source id */
  1112. #define TCPR_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */
  1113. #define TCPR_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second clock */
  1114. #define TCPR_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */
  1115. #define TCPR_NTP_REF_USNO 0x55534e4f /* USNO modem service */
  1116. #define TCPR_NTP_REF_PTB 0x50544200 /* PTB (German) modem service */
  1117. #define TCPR_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */
  1118. #define TCPR_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio */
  1119. #define TCPR_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */
  1120. #define TCPR_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */
  1121. #define TCPR_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */
  1122. #define TCPR_NTP_REF_WWVH 0x57575648 /* Kaui Hawaii (US) radio */
  1123. #define TCPR_NTP_REF_CHU 0x43485500 /* Ottaha (Canada) radio */
  1124. #define TCPR_NTP_REF_LORC 0x4c4f5243 /* LORAN-C radionavigation */
  1125. #define TCPR_NTP_REF_OMEG 0x4f4d4547 /* OMEGA radionavigation */
  1126. #define TCPR_NTP_REF_GPS 0x47505300 /* global positioning system */
  1127. #define TCPR_NTP_REF_GOES 0x474f4553 /* geostationary orbit env satellite */
  1128. struct tcpr_ntp_hdr_l_fp ntp_ref_ts; /* reference timestamp */
  1129. struct tcpr_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */
  1130. struct tcpr_ntp_hdr_l_fp ntp_rec_ts; /* receive timestamp */
  1131. struct tcpr_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */
  1132. };
  1133. /*
  1134. * OSPFv2 header
  1135. * Open Shortest Path First
  1136. * Static header size: 16 bytes
  1137. */
  1138. struct tcpr_ospf_hdr {
  1139. uint8_t ospf_v; /* version */
  1140. #define OSPFVERSION 2
  1141. uint8_t ospf_type; /* type */
  1142. #define TCPR_OSPF_UMD 0 /* UMd monitoring packet */
  1143. #define TCPR_OSPF_HELLO 1 /* HELLO packet */
  1144. #define TCPR_OSPF_DBD 2 /* dataBase description packet */
  1145. #define TCPR_OSPF_LSR 3 /* link state request packet */
  1146. #define TCPR_OSPF_LSU 4 /* link state Update Packet */
  1147. #define TCPR_OSPF_LSA 5 /* link state acknowledgement packet */
  1148. uint16_t ospf_len; /* length */
  1149. struct in_addr ospf_rtr_id; /* source router ID */
  1150. struct in_addr ospf_area_id; /* roam ID */
  1151. uint16_t ospf_sum; /* checksum */
  1152. uint16_t ospf_auth_type; /* authentication type */
  1153. #define TCPR_OSPF_AUTH_NULL 0 /* null password */
  1154. #define TCPR_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */
  1155. #define TCPR_OSPF_AUTH_MD5 2 /* MD5 */
  1156. };
  1157. /*
  1158. * OSPF authentication header
  1159. * Open Shortest Path First
  1160. * Static header size: 8 bytes
  1161. */
  1162. struct tcpr_auth_hdr {
  1163. uint16_t ospf_auth_null; /* NULL */
  1164. uint8_t ospf_auth_keyid; /* authentication key ID */
  1165. uint8_t ospf_auth_len; /* auth data length */
  1166. uint32_t ospf_auth_seq; /* cryptographic sequence number */
  1167. };
  1168. /*
  1169. * OSPF hello header
  1170. * Open Shortest Path First
  1171. * Static header size: 28 bytes
  1172. */
  1173. struct tcpr_ospf_hello_hdr {
  1174. struct in_addr hello_nmask; /* netmask associated with the interface */
  1175. uint16_t hello_intrvl; /* num of seconds between routers last packet */
  1176. uint8_t hello_opts; /* Options for HELLO packets (look above) */
  1177. uint8_t hello_rtr_pri; /* router's priority (if 0, can't be backup) */
  1178. uint32_t hello_dead_intvl; /* # of secs a router is silent till deemed down */
  1179. struct in_addr hello_des_rtr; /* Designated router on the network */
  1180. struct in_addr hello_bkup_rtr; /* Backup router */
  1181. struct in_addr hello_nbr; /* neighbor router, memcpy more as needed */
  1182. };
  1183. /*
  1184. * Database Description header.
  1185. */
  1186. struct tcpr_dbd_hdr {
  1187. uint16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can use */
  1188. uint8_t dbd_opts; /* DBD packet options (from above) */
  1189. uint8_t dbd_type; /* type of exchange occurring */
  1190. #define TCPR_DBD_IBI 0x01 /* init */
  1191. #define TCPR_DBD_MBIT 0x02 /* more DBD packets are to come */
  1192. #define TCPR_DBD_MSBIT 0x04 /* If 1, sender is the master in the exchange */
  1193. uint32_t dbd_seq; /* DBD sequence number */
  1194. };
  1195. /*
  1196. * used for the LS type field in all LS* headers
  1197. */
  1198. #define TCPR_LS_TYPE_RTR 1 /* router-LSA */
  1199. #define TCPR_LS_TYPE_NET 2 /* network-LSA */
  1200. #define TCPR_LS_TYPE_IP 3 /* summary-LSA (IP Network) */
  1201. #define TCPR_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */
  1202. #define TCPR_LS_TYPE_ASEXT 5 /* AS-external-LSA */
  1203. /*
  1204. * Link State Request header
  1205. */
  1206. struct tcpr_lsr_hdr {
  1207. uint32_t lsr_type; /* type of LS being requested */
  1208. uint32_t lsr_lsid; /* link state ID */
  1209. struct in_addr lsr_adrtr; /* advertising router (memcpy more as needed) */
  1210. };
  1211. /*
  1212. * Link State Update header
  1213. */
  1214. struct tcpr_lsu_hdr {
  1215. uint32_t lsu_num; /* number of LSAs that will be broadcasted */
  1216. };
  1217. /*
  1218. * Link State Acknowledgement header.
  1219. */
  1220. struct tcpr_lsa_hdr {
  1221. uint16_t lsa_age; /* time in seconds since the LSA was originated */
  1222. uint8_t lsa_opts; /* look above for OPTS_* */
  1223. uint8_t lsa_type; /* look below for LS_TYPE_* */
  1224. uint32_t lsa_id; /* link State ID */
  1225. struct in_addr lsa_adv; /* router ID of Advertising router */
  1226. uint32_t lsa_seq; /* LSA sequence number to detect old/bad ones */
  1227. uint16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age */
  1228. uint16_t lsa_len; /* length in bytes including the 20 byte header */
  1229. };
  1230. /*
  1231. * Router LSA data format
  1232. *
  1233. * Other stuff for TOS can be added for backward compatibility, for this
  1234. * version, only OSPFv2 is being FULLY supported.
  1235. */
  1236. struct tcpr_rtr_lsa_hdr {
  1237. uint16_t rtr_flags; /* set to help describe packet */
  1238. #define TCPR_RTR_FLAGS_W 0x0100 /* W bit */
  1239. #define TCPR_RTR_FLAGS_E 0x0200 /* E bit */
  1240. #define TCPR_RTR_FLAGS_B 0x0400 /* B bit */
  1241. uint16_t rtr_num; /* number of links within that packet */
  1242. uint32_t rtr_link_id; /* describes link_data (look below) */
  1243. #define TCPR_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 */
  1244. #define TCPR_LINK_ID_IP_DES 2 /* IP address of designated router */
  1245. #define TCPR_LINK_ID_SUB 3 /* IP subnet number */
  1246. uint32_t rtr_link_data; /* Depending on link_id, info is here */
  1247. uint8_t rtr_type; /* Description of router link */
  1248. #define TCPR_RTR_TYPE_PTP 1 /* Point-To-Point */
  1249. #define TCPR_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */
  1250. #define TCPR_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */
  1251. #define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */
  1252. uint8_t rtr_tos_num; /* number of different TOS metrics for this link */
  1253. uint16_t rtr_metric; /* the "cost" of using this link */
  1254. };
  1255. /*
  1256. * Network LSA data format.
  1257. */
  1258. struct tcpr_net_lsa_hdr {
  1259. struct in_addr net_nmask; /* Netmask for that network */
  1260. uint32_t net_rtr_id; /* ID of router attached to that network */
  1261. };
  1262. /*
  1263. * Summary LSA data format.
  1264. */
  1265. struct tcpr_sum_lsa_hdr {
  1266. struct in_addr sum_nmask; /* Netmask of destination IP address */
  1267. uint32_t sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24bit */
  1268. uint32_t sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metric */
  1269. };
  1270. /*
  1271. * AS External LSA data format.
  1272. * & 0xfff logic operator for as_metric to get last 24bits.
  1273. */
  1274. struct tcpr_as_lsa_hdr {
  1275. struct in_addr as_nmask; /* Netmask for advertised destination */
  1276. uint32_t as_metric; /* May have to set E bit in first 8bits */
  1277. #define TCPR_AS_E_BIT_ON 0x80000000 /* as_metric */
  1278. struct in_addr as_fwd_addr; /* Forwarding address */
  1279. uint32_t as_rte_tag; /* External route tag */
  1280. };
  1281. /*
  1282. * Base RIP header
  1283. * Routing Information Protocol
  1284. * Base header size: 24 bytes
  1285. */
  1286. struct tcpr_rip_hdr {
  1287. uint8_t rip_cmd; /* RIP command */
  1288. #define RIPCMD_REQUEST 1 /* want info */
  1289. #define RIPCMD_RESPONSE 2 /* responding to request */
  1290. #define RIPCMD_TRACEON 3 /* turn tracing on */
  1291. #define RIPCMD_TRACEOFF 4 /* turn it off */
  1292. #define RIPCMD_POLL 5 /* like request, but anyone answers */
  1293. #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */
  1294. #define RIPCMD_MAX 7 /* ? command */
  1295. uint8_t rip_ver; /* RIP version */
  1296. #define RIPVER_0 0
  1297. #define RIPVER_1 1
  1298. #define RIPVER_2 2
  1299. uint16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */
  1300. uint16_t rip_af; /* Address family */
  1301. uint16_t rip_rt; /* Zero (v1) or Route Tag (v2) */
  1302. uint32_t rip_addr; /* IP address */
  1303. uint32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */
  1304. uint32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */
  1305. uint32_t rip_metric; /* Metric */
  1306. };
  1307. /*
  1308. * RPC headers
  1309. * Remote Procedure Call
  1310. */
  1311. #define TCPR_RPC_CALL 0
  1312. #define TCPR_RPC_REPLY 1
  1313. #define TCPR_RPC_VERS 2
  1314. #define TCPR_RPC_LAST_FRAG 0x80000000
  1315. /*
  1316. * Portmap defines
  1317. */
  1318. #define TCPR_PMAP_PROGRAM 100000
  1319. #define TCPR_PMAP_PROC_NULL 0
  1320. #define TCPR_PMAP_PROC_SET 1
  1321. #define TCPR_PMAP_PROC_UNSET 2
  1322. #define TCPR_PMAP_PROC_GETADDR 3
  1323. #define TCPR_PMAP_PROC_DUMP 4
  1324. #define TCPR_PMAP_PROC_CALLIT 5
  1325. #define TCPR_PMAP_PROC_BCAST 5 /* Not a typo */
  1326. #define TCPR_PMAP_PROC_GETTIME 6
  1327. #define TCPR_PMAP_PROC_UADDR2TADDR 7
  1328. #define TCPR_PMAP_PROC_TADDR2UADDR 8
  1329. #define TCPR_PMAP_PROC_GETVERSADDR 9
  1330. #define TCPR_PMAP_PROC_INDIRECT 10
  1331. #define TCPR_PMAP_PROC_GETADDRLIST 11
  1332. #define TCPR_PMAP_PROC_GETSTAT 12
  1333. /* There will be more to add... */
  1334. struct tcpr_rpc_opaque_auth {
  1335. uint32_t rpc_auth_flavor;
  1336. uint32_t rpc_auth_length;
  1337. #if 0
  1338. uint8_t *rpc_auth_data;
  1339. #endif
  1340. };
  1341. struct tcpr_rpc_call {
  1342. uint32_t rpc_rpcvers; /* RPC version - must be 2 */
  1343. uint32_t rpc_prognum; /* Program Number */
  1344. uint32_t rpc_vers; /* Program Version */
  1345. uint32_t rpc_procedure; /* RPC procedure */
  1346. struct tcpr_rpc_opaque_auth rpc_credentials;
  1347. struct tcpr_rpc_opaque_auth rpc_verifier;
  1348. };
  1349. struct tcpr_rpc_call_hdr {
  1350. uint32_t rpc_xid; /* xid (transaction identifier) */
  1351. uint32_t rpc_type;
  1352. struct tcpr_rpc_call rpc_call;
  1353. };
  1354. struct tcpr_rpc_call_tcp_hdr {
  1355. uint32_t rpc_record_marking; /* used with byte stream protocols */
  1356. struct tcpr_rpc_call_hdr rpc_common;
  1357. };
  1358. /*
  1359. * STP configuration header
  1360. * Spanning Tree Protocol
  1361. * Static header size: 35 bytes
  1362. */
  1363. struct tcpr_stp_conf_hdr {
  1364. uint16_t stp_id; /* protocol id */
  1365. uint8_t stp_version; /* protocol version */
  1366. uint8_t stp_bpdu_type; /* bridge protocol data unit type */
  1367. uint8_t stp_flags; /* control flags */
  1368. uint8_t stp_rootid[8]; /* root id */
  1369. uint32_t stp_rootpc; /* root path cost */
  1370. uint8_t stp_bridgeid[8]; /* bridge id */
  1371. uint16_t stp_portid; /* port id */
  1372. uint16_t stp_mage; /* message age */
  1373. uint16_t stp_maxage; /* max age */
  1374. uint16_t stp_hellot; /* hello time */
  1375. uint16_t stp_fdelay; /* forward delay */
  1376. };
  1377. /*
  1378. * STP topology change notification header
  1379. * Spanning Tree Protocol
  1380. * Static header size: 4 bytes
  1381. */
  1382. struct tcpr_stp_tcn_hdr {
  1383. uint16_t stp_id; /* protocol id */
  1384. uint8_t stp_version; /* protocol version */
  1385. uint8_t stp_bpdu_type; /* bridge protocol data unit type */
  1386. };
  1387. /*
  1388. * TCP header
  1389. * Transmission Control Protocol
  1390. * Static header size: 20 bytes
  1391. */
  1392. struct tcpr_tcp_hdr {
  1393. uint16_t th_sport; /* source port */
  1394. uint16_t th_dport; /* destination port */
  1395. uint32_t th_seq; /* sequence number */
  1396. uint32_t th_ack; /* acknowledgement number */
  1397. #ifdef WORDS_BIGENDIAN
  1398. uint8_t th_off:4, /* data offset */
  1399. th_x2:4; /* (unused) */
  1400. #else
  1401. uint8_t th_x2:4, /* (unused) */
  1402. th_off:4; /* data offset */
  1403. #endif
  1404. uint8_t th_flags; /* control flags */
  1405. #ifndef TH_FIN
  1406. #define TH_FIN 0x01 /* finished send data */
  1407. #endif
  1408. #ifndef TH_SYN
  1409. #define TH_SYN 0x02 /* synchronize sequence numbers */
  1410. #endif
  1411. #ifndef TH_RST
  1412. #define TH_RST 0x04 /* reset the connection */
  1413. #endif
  1414. #ifndef TH_PUSH
  1415. #define TH_PUSH 0x08 /* push data to the app layer */
  1416. #endif
  1417. #ifndef TH_ACK
  1418. #define TH_ACK 0x10 /* acknowledge */
  1419. #endif
  1420. #ifndef TH_URG
  1421. #define TH_URG 0x20 /* urgent! */
  1422. #endif
  1423. #ifndef TH_ECE
  1424. #define TH_ECE 0x40
  1425. #endif
  1426. #ifndef TH_CWR
  1427. #define TH_CWR 0x80
  1428. #endif
  1429. uint16_t th_win; /* window */
  1430. uint16_t th_sum; /* checksum */
  1431. uint16_t th_urp; /* urgent pointer */
  1432. };
  1433. /*
  1434. * Token Ring Header
  1435. */
  1436. struct tcpr_token_ring_hdr {
  1437. uint8_t token_ring_access_control;
  1438. #define TCPR_TOKEN_RING_FRAME 0x10
  1439. uint8_t token_ring_frame_control;
  1440. #define TCPR_TOKEN_RING_LLC_FRAME 0x40
  1441. uint8_t token_ring_dhost[TOKEN_RING_ADDR_LEN];
  1442. uint8_t token_ring_shost[TOKEN_RING_ADDR_LEN];
  1443. uint8_t token_ring_llc_dsap;
  1444. uint8_t token_ring_llc_ssap;
  1445. uint8_t token_ring_llc_control_field;
  1446. uint8_t token_ring_llc_org_code[TCPR_ORG_CODE_SIZE];
  1447. uint16_t token_ring_type;
  1448. #define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */
  1449. #define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */
  1450. #define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
  1451. };
  1452. struct tcpr_token_ring_addr {
  1453. uint8_t token_ring_addr_octet[6]; /* Token Ring address */
  1454. };
  1455. /*
  1456. * UDP header
  1457. * User Data Protocol
  1458. * Static header size: 8 bytes
  1459. */
  1460. struct tcpr_udp_hdr {
  1461. uint16_t uh_sport; /* source port */
  1462. uint16_t uh_dport; /* destination port */
  1463. uint16_t uh_ulen; /* length */
  1464. uint16_t uh_sum; /* checksum */
  1465. };
  1466. /*
  1467. * Sebek header
  1468. * Static header size: 48 bytes
  1469. */
  1470. struct tcpr_sebek_hdr {
  1471. uint32_t magic; /* identify packets that should be hidden */
  1472. uint16_t version; /* protocol version, currently 1 */
  1473. #define SEBEK_PROTO_VERSION 1
  1474. uint16_t type; /* type of record (read data is type 0, write data is type 1) */
  1475. #define SEBEK_TYPE_READ 0 /* Currently, only read is supported */
  1476. #define SEBEK_TYPE_WRITE 1
  1477. uint32_t counter; /* PDU counter used to identify when packet are lost */
  1478. uint32_t time_sec; /* seconds since EPOCH according to the honeypot */
  1479. uint32_t time_usec; /* residual microseconds */
  1480. uint32_t pid; /* PID */
  1481. uint32_t uid; /* UID */
  1482. uint32_t fd; /* FD */
  1483. #define SEBEK_CMD_LENGTH 12
  1484. uint8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command */
  1485. uint32_t length; /* length in bytes of the PDU's body */
  1486. };
  1487. /*
  1488. * VRRP header
  1489. * Virtual Router Redundancy Protocol
  1490. * Static header size: 8 bytes
  1491. */
  1492. #ifndef IPPROTO_VRRP
  1493. #define IPPROTO_VRRP 112 /* not everyone's got this */
  1494. #endif
  1495. struct tcpr_vrrp_hdr {
  1496. #ifdef WORDS_BIGENDIAN
  1497. uint8_t vrrp_t:4, /* packet type */
  1498. vrrp_v:4; /* protocol version */
  1499. #else
  1500. uint8_t vrrp_v:4, /* protocol version */
  1501. vrrp_t:4; /* packet type */
  1502. #endif
  1503. #define TCPR_VRRP_VERSION_01 0x1
  1504. #define TCPR_VRRP_VERSION_02 0x2
  1505. #define TCPR_VRRP_TYPE_ADVERT 0x1
  1506. uint8_t vrrp_vrouter_id; /* virtual router id */
  1507. uint8_t vrrp_priority; /* priority */
  1508. uint8_t vrrp_ip_count; /* number of IP addresses */
  1509. uint8_t vrrp_auth_type; /* authorization type */
  1510. #define TCPR_VRRP_AUTH_NONE 0x1
  1511. #define TCPR_VRRP_AUTH_PASSWD 0x2
  1512. #define TCPR_VRRP_AUTH_IPAH 0x3
  1513. uint8_t vrrp_advert_int; /* advertisement interval */
  1514. uint16_t vrrp_sum; /* checksum */
  1515. /* additional addresses */
  1516. /* authentication info */
  1517. };
  1518. /*
  1519. * HSRP header
  1520. * Static header size: 20 bytes
  1521. */
  1522. struct tcpr_hsrp_hdr {
  1523. #define TCPR_HSRP_VERSION 0x0
  1524. uint8_t version; /* Version of the HSRP messages */
  1525. #define TCPR_HSRP_TYPE_HELLO 0x0
  1526. #define TCPR_HSRP_TYPE_COUP 0x1
  1527. #define TCPR_HSRP_TYPE_RESIGN 0x2
  1528. uint8_t opcode; /* Type of message */
  1529. #define TCPR_HSRP_STATE_INITIAL 0x0
  1530. #define TCPR_HSRP_STATE_LEARN 0x1
  1531. #define TCPR_HSRP_STATE_LISTEN 0x2
  1532. #define TCPR_HSRP_STATE_SPEAK 0x4
  1533. #define TCPR_HSRP_STATE_STANDBY 0x8
  1534. #define TCPR_HSRP_STATE_ACTIVE 0x10
  1535. uint8_t state; /* Current state of the router */
  1536. uint8_t hello_time; /* Period in seconds between hello messages */
  1537. uint8_t hold_time; /* Seconds that the current hello message is valid */
  1538. uint8_t priority; /* Priority for the election process */
  1539. uint8_t group; /* Standby group */
  1540. uint8_t reserved; /* Reserved field */
  1541. #define HSRP_AUTHDATA_LENGTH 8
  1542. uint8_t authdata[HSRP_AUTHDATA_LENGTH]; /* Password */
  1543. uint32_t virtual_ip; /* Virtual IP address */
  1544. };
  1545. /* MPLS label:: RFC 5462, RFC 3032
  1546. *
  1547. * 0 1 2 3
  1548. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1549. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1550. * | Label | TC |S| TTL |
  1551. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1552. *
  1553. * Label: Label Value, 20 bits
  1554. * TC: Traffic Class field, 3 bits
  1555. * S: Bottom of Stack, 1 bit
  1556. * TTL: Time to Live, 8 bits
  1557. */
  1558. struct tcpr_mpls_label {
  1559. uint32_t entry;
  1560. #define MPLS_LABEL_GACH 13
  1561. };
  1562. #ifndef MPLS_LS_LABEL_MASK
  1563. #define MPLS_LS_LABEL_MASK 0xFFFFF000
  1564. #endif
  1565. #ifndef MPLS_LS_LABEL_SHIFT
  1566. #define MPLS_LS_LABEL_SHIFT 12
  1567. #endif
  1568. #ifndef MPLS_LS_TC_MASK
  1569. #define MPLS_LS_TC_MASK 0x00000E00
  1570. #endif
  1571. #ifndef MPLS_LS_TC_SHIFT
  1572. #define MPLS_LS_TC_SHIFT 9
  1573. #endif
  1574. #ifndef MPLS_LS_S_MASK
  1575. #define MPLS_LS_S_MASK 0x00000100
  1576. #endif
  1577. #ifndef MPLS_LS_S_SHIFT
  1578. #define MPLS_LS_S_SHIFT 8
  1579. #endif
  1580. #ifndef MPLS_LS_TTL_MASK
  1581. #define MPLS_LS_TTL_MASK 0x000000FF
  1582. #endif
  1583. #ifndef MPLS_LS_TTL_SHIFT
  1584. #define MPLS_LS_TTL_SHIFT 0
  1585. #endif