tcpr.h 57 KB

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