tcpr.h 57 KB

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