tcpr.h 57 KB

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