forked from appneta/tcpreplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcpr.h
1758 lines (1608 loc) · 56.7 KB
/
tcpr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* $Id$ */
/*
* Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
* Copyright (c) 2013-2016 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
*
* The Tcpreplay Suite of tools is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or with the authors permission any later version.
*
* The Tcpreplay Suite is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This header is heavily based off of (in other words basically stolen from)
* libnet 1.1.3's libnet-headers.h. Many thanks to Mike D. Schiffman for doing
* all this work so I basically just needed to do a search and replace to get
* things to work.
*/
#ifndef _TCPR_H_
#define _TCPR_H_
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef WIN32
#include "msvc_inttypes.h"
#include "msvc_stdint.h"
#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
#include "config.h"
#define ETHER_ADDR_LEN 0x6
#define FDDI_ADDR_LEN 0x6
#define TOKEN_RING_ADDR_LEN 0x6
#define TCPR_ORG_CODE_SIZE 0x3
/**
* Libnet defines header sizes for every builder function exported.
*/
#define TCPR_802_1Q_H 0x12 /**< 802.1Q header: 18 bytes */
#define TCPR_802_1X_H 0x04 /**< 802.1X header: 4 bytes */
#define TCPR_802_2_H 0x03 /**< 802.2 LLC header: 3 bytes */
#define TCPR_802_2SNAP_H 0x08 /**< 802.2 LLC/SNAP header:8 bytes */
#define TCPR_802_3_H 0x0e /**< 802.3 header: 14 bytes */
#define TCPR_ARP_H 0x08 /**< ARP header w/o addrs: 8 bytes */
#define TCPR_ARP_ETH_IP_H 0x1c /**< ARP w/ ETH and IP: 28 bytes */
#define TCPR_BGP4_HEADER_H 0x13 /**< BGP header: 19 bytes */
#define TCPR_BGP4_OPEN_H 0x0a /**< BGP open header: 10 bytes */
#define TCPR_BGP4_UPDATE_H 0x04 /**< BGP open header: 4 bytes */
#define TCPR_BGP4_NOTIFICATION_H 0x02 /**< BGP notif. header: 2 bytes */
#define TCPR_CDP_H 0x08 /**< CDP header base: 8 bytes */
#define TCPR_DHCPV4_H 0xf0 /**< DHCP v4 header: 240 bytes */
#define TCPR_UDP_DNSV4_H 0x0c /**< UDP DNS v4 header: 12 bytes */
#define TCPR_TCP_DNSV4_H 0x0e /**< TCP DNS v4 header: 14 bytes */
#define TCPR_ETH_H 0x0e /**< Ethernet header: 14 bytes */
#define TCPR_ETH_MTU 1500 /**< Ethernet MTU size: 1500 bytes */
#define TCPR_FDDI_H 0x15 /**< FDDI header: 21 bytes */
#define TCPR_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */
#define TCPR_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */
#define TCPR_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */
#define TCPR_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */
#define TCPR_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */
#define TCPR_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */
#define TCPR_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */
#define TCPR_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */
#define TCPR_IGMP_H 0x08 /**< IGMP header: 8 bytes */
#define TCPR_IPV4_H 0x14 /**< IPv4 header: 20 bytes */
#define TCPR_IPV6_H 0x28 /**< IPv6 header: 40 bytes */
#define TCPR_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */
#define TCPR_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */
#define TCPR_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */
#define TCPR_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */
#define TCPR_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */
#define TCPR_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */
#define TCPR_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */
#define TCPR_ISL_H 0x1a /**< ISL header: 26 bytes */
#define TCPR_GRE_H 0x04 /**< GRE header: 4 bytes */
#define TCPR_GRE_SRE_H 0x04 /**< GRE SRE header: 4 bytes */
#define TCPR_MPLS_H 0x04 /**< MPLS header: 4 bytes */
#define TCPR_OSPF_H 0x10 /**< OSPF header: 16 bytes */
#define TCPR_OSPF_HELLO_H 0x18 /**< OSPF hello header: 24 bytes */
#define TCPR_OSPF_DBD_H 0x08 /**< OSPF DBD header: 8 bytes */
#define TCPR_OSPF_LSR_H 0x0c /**< OSPF LSR header: 12 bytes */
#define TCPR_OSPF_LSU_H 0x04 /**< OSPF LSU header: 4 bytes */
#define TCPR_OSPF_LSA_H 0x14 /**< OSPF LSA header: 20 bytes */
#define TCPR_OSPF_AUTH_H 0x08 /**< OSPF AUTH header: 8 bytes */
#define TCPR_OSPF_CKSUM 0x10 /**< OSPF CKSUM header: 16 bytes */
#define TCPR_OSPF_LS_RTR_H 0x10 /**< OSPF LS RTR header: 16 bytes */
#define TCPR_OSPF_LS_NET_H 0x08 /**< OSPF LS NET header: 8 bytes */
#define TCPR_OSPF_LS_SUM_H 0x0c /**< OSPF LS SUM header: 12 bytes */
#define TCPR_OSPF_LS_AS_EXT_H 0x10 /**< OSPF LS AS header: 16 bytes */
#define TCPR_NTP_H 0x30 /**< NTP header: 48 bytes */
#define TCPR_RIP_H 0x18 /**< RIP header base: 24 bytes */
#define TCPR_RPC_CALL_H 0x28 /**< RPC header: 40 bytes
* (assuming 8 byte auth header)
*/
#define TCPR_RPC_CALL_TCP_H 0x2c /**< RPC header: 44 bytes
* (with record marking)
*/
#define TCPR_SEBEK_H 0x30 /* sebek header: 48 bytes */
#define TCPR_STP_CONF_H 0x23 /**< STP conf header: 35 bytes */
#define TCPR_STP_TCN_H 0x04 /**< STP tcn header: 4 bytes */
#define TCPR_TOKEN_RING_H 0x16 /**< Token Ring header: 22 bytes */
#define TCPR_TCP_H 0x14 /**< TCP header: 20 bytes */
#define TCPR_UDP_H 0x08 /**< UDP header: 8 bytes */
#define TCPR_VRRP_H 0x08 /**< VRRP header: 8 bytes */
#define TCPR_HSRP_H 0x14 /**< HSRP header: 8 bytes */
/**
* IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header
* size: 8 bytes
*/
struct tcpr_802_1q_hdr
{
uint8_t vlan_dhost[ETHER_ADDR_LEN]; /**< destination ethernet address */
uint8_t vlan_shost[ETHER_ADDR_LEN]; /**< source ethernet address */
uint16_t vlan_tpi; /**< tag protocol ID */
uint16_t vlan_priority_c_vid; /**< priority | VLAN ID */
#define TCPR_802_1Q_PRIMASK 0x0007 /**< priority mask */
#define TCPR_802_1Q_CFIMASK 0x0001 /**< CFI mask */
#define TCPR_802_1Q_VIDMASK 0x0fff /**< vid mask */
uint16_t vlan_len; /**< length or type (802.3 / Eth 2) */
};
/**
* IEEE 802.1X EAP (Extensible Authentication Protocol) header, static header
* size: 4 bytes
*/
struct tcpr_802_1x_hdr
{
uint8_t dot1x_version; /**< protocol version */
uint8_t dot1x_type; /**< frame type */
#define TCPR_802_1X_PACKET 0x00 /**< 802.1x packet */
#define TCPR_802_1X_START 0x01 /**< 802.1x start */
#define TCPR_802_1X_LOGOFF 0x02 /**< 802.1x logoff */
#define TCPR_802_1X_KEY 0x03 /**< 802.1x key */
#define TCPR_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */
uint16_t dot1x_length; /**< total frame length */
};
/*
* IEEE 802.2 LLC header
* Link Layer Control
* static header size: 4 bytes
*/
struct tcpr_802_2_hdr
{
uint8_t llc_dsap; /* destination service access point */
uint8_t llc_ssap; /* source service access point */
#define TCPR_SAP_STP 0x42
#define TCPR_SAP_SNAP 0xaa
uint16_t llc_control; /* control field */
};
/*
* IEEE 802.2 LLC/SNAP header
* SubNetwork Attachment Point
* static header size: 8 bytes
*/
struct tcpr_802_2snap_hdr
{
uint8_t snap_dsap; /* destination service access point */
uint8_t snap_ssap; /* destination service access point */
uint8_t snap_control; /* control field */
uint8_t snap_oui[3]; /* OUI */
uint16_t snap_type; /* type */
};
/*
* 802.3 header
* IEEE Ethernet
* Static header size: 14 bytes
*/
struct tcpr_802_3_hdr
{
uint8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
uint8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */
uint16_t _802_3_len; /* packet type ID */
};
/*
* ARP header
* Address Resolution Protocol
* Base header size: 8 bytes
*/
struct tcpr_arp_hdr
{
uint16_t ar_hrd; /* format of hardware address */
#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
#define ARPHRD_EETHER 2 /* Experimental Ethernet */
#define ARPHRD_AX25 3 /* AX.25 Level 2 */
#define ARPHRD_PRONET 4 /* PROnet token ring */
#define ARPHRD_CHAOS 5 /* Chaosnet */
#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
#define ARPHRD_ARCNET 7 /* ARCnet */
#define ARPHRD_APPLETLK 8 /* APPLEtalk */
#define ARPHRD_LANSTAR 9 /* Lanstar */
#define ARPHRD_DLCI 15 /* Frame Relay DLCI */
#define ARPHRD_ATM 19 /* ATM */
#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
#define ARPHRD_IPSEC 31 /* IPsec tunnel */
#define ARPHRD_LOOPBACK 772 /* Loopback device */
uint16_t ar_pro; /* format of protocol address */
uint8_t ar_hln; /* length of hardware address */
uint8_t ar_pln; /* length of protocol addres */
uint16_t ar_op; /* operation type */
#define ARPOP_REQUEST 1 /* req to resolve address */
#define ARPOP_REPLY 2 /* resp to previous request */
#define ARPOP_REVREQUEST 3 /* req protocol address given hardware */
#define ARPOP_REVREPLY 4 /* resp giving protocol address */
#define ARPOP_INVREQUEST 8 /* req to identify peer */
#define ARPOP_INVREPLY 9 /* resp identifying peer */
/* address information allocated dynamically */
};
/*
* BGP4 header
* Border Gateway Protocol 4
* Base header size : 19 bytes
*/
struct tcpr_bgp4_header_hdr
{
#define TCPR_BGP4_MARKER_SIZE 16
uint8_t marker[TCPR_BGP4_MARKER_SIZE];
uint16_t len;
uint8_t type;
#define TCPR_BGP4_OPEN 1
#define TCPR_BGP4_UPDATE 2
#define TCPR_BGP4_NOTIFICATION 3
#define TCPR_BGP4_KEEPALIVE 4
};
/*
* BGP4 open header
* Border Gateway Protocol 4
* Base header size : 10 bytes
*/
struct tcpr_bgp4_open_hdr
{
uint8_t version;
uint16_t src_as;
uint16_t hold_time;
uint32_t bgp_id;
uint8_t opt_len;
};
/*
* BGP4 notification message
*
* Border Gateway Protocol 4
* Base header size : 2 bytes
*
* Use payload if you need data
*/
struct tcpr_bgp4_notification_hdr
{
#define TCPR_BGP4_MESSAGE_HEADER_ERROR 1
#define TCPR_BGP4_OPEN_MESSAGE_ERROR 2
#define TCPR_BGP4_UPDATE_MESSAGE_ERROR 3
#define TCPR_BGP4_HOLD_TIMER_EXPIRED 4
#define TCPR_BGP4_FINITE_STATE__ERROR 5
#define TCPR_BGP4_CEASE 6
uint8_t err_code;
/* Message Header Error subcodes */
#define TCPR_BGP4_CONNECTION_NOT_SYNCHRONIZED 1
#define TCPR_BGP4_BAD_MESSAGE_LENGTH 2
#define TCPR_BGP4_BAD_MESSAGE_TYPE 3
/* OPEN Message Error subcodes */
#define TCPR_BGP4_UNSUPPORTED_VERSION_NUMBER 1
#define TCPR_BGP4_BAD_PEER_AS 2
#define TCPR_BGP4_BAD_BGP_IDENTIFIER 3
#define TCPR_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
#define TCPR_BGP4_AUTHENTICATION_FAILURE 5
#define TCPR_BGP4_UNACCEPTABLE_HOLD_TIME 6
/* UPDATE Message Error subcodes */
#define TCPR_BGP4_MALFORMED_ATTRIBUTE_LIST
#define TCPR_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
#define TCPR_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
#define TCPR_BGP4_ATTRIBUTE_FLAGS_ERROR
#define TCPR_BGP4_ATTRIBUTE_LENGTH_ERROR
#define TCPR_BGP4_INVALID_ORIGIN_ATTRIBUTE
#define TCPR_BGP4_AS_ROUTING_LOOP
#define TCPR_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
#define TCPR_BGP4_OPTIONAL_ATTRIBUTE_ERROR
#define TCPR_BGP4_INVALID_NETWORK_FIELD
#define TCPR_BGP4_MALFORMED_AS_PATH
uint8_t err_subcode;
};
/*
* CDP header
* Cisco Discovery Protocol
* Base header size: 8 bytes
*/
/*
* For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
* Let's hope this one stays that way for a while!
*/
#define TCPR_PROTO_CDP 200
struct tcpr_cdp_hdr
{
uint8_t cdp_version; /* version (should always be 0x01) */
uint8_t cdp_ttl; /* time reciever should hold info in this packet */
uint16_t cdp_sum; /* checksum */
uint16_t cdp_type; /* type */
#define TCPR_CDP_DEVID 0x1 /* device id */
#define TCPR_CDP_ADDRESS 0x2 /* address */
#define TCPR_CDP_PORTID 0x3 /* port id */
#define TCPR_CDP_CAPABIL 0x4 /* capabilities */
#define TCPR_CDP_VERSION 0x5 /* version */
#define TCPR_CDP_PLATFORM 0x6 /* platform */
#define TCPR_CDP_IPPREFIX 0x7 /* ip prefix */
uint16_t cdp_len; /* type + length + value */
/* value information done dynamically */
/* CDP capabilities */
#define TCPR_CDP_CAP_L3R 0x01/* performs level 3 routing */
#define TCPR_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */
#define TCPR_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */
#define TCPR_CDP_CAP_L2S 0x08/* performs level 2 switching */
#define TCPR_CDP_CAP_SR 0x10/* sends and recieves packets on a network */
#define TCPR_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router ports */
#define TCPR_CDP_CAP_L1F 0x40/* provides level 1 functionality */
};
/*
* Used as an overlay for type/len/values
*/
struct tcpr_cdp_value_hdr
{
uint16_t cdp_type;
uint16_t cdp_len;
};
/*
* DHCP header
* Dynamic Host Configuration Protocol
* Static header size: f0 bytes
*/
struct tcpr_dhcpv4_hdr
{
uint8_t dhcp_opcode; /* opcode */
#define TCPR_DHCP_REQUEST 0x1
#define TCPR_DHCP_REPLY 0x2
uint8_t dhcp_htype; /* hardware address type */
uint8_t dhcp_hlen; /* hardware address length */
uint8_t dhcp_hopcount; /* used by proxy servers */
uint32_t dhcp_xid; /* transaction ID */
uint16_t dhcp_secs; /* number of seconds since trying to bootstrap */
uint16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */
uint32_t dhcp_cip; /* client's IP */
uint32_t dhcp_yip; /* your IP */
uint32_t dhcp_sip; /* server's IP */
uint32_t dhcp_gip; /* gateway IP */
uint8_t dhcp_chaddr[16]; /* client hardware address */
uint8_t dhcp_sname[64]; /* server host name */
uint8_t dhcp_file[128]; /* boot file name */
uint32_t dhcp_magic; /* BOOTP magic header */
#define DHCP_MAGIC 0x63825363
#define TCPR_BOOTP_MIN_LEN 0x12c
#define TCPR_DHCP_PAD 0x00
#define TCPR_DHCP_SUBNETMASK 0x01
#define TCPR_DHCP_TIMEOFFSET 0x02
#define TCPR_DHCP_ROUTER 0x03
#define TCPR_DHCP_TIMESERVER 0x04
#define TCPR_DHCP_NAMESERVER 0x05
#define TCPR_DHCP_DNS 0x06
#define TCPR_DHCP_LOGSERV 0x07
#define TCPR_DHCP_COOKIESERV 0x08
#define TCPR_DHCP_LPRSERV 0x09
#define TCPR_DHCP_IMPSERV 0x0a
#define TCPR_DHCP_RESSERV 0x0b
#define TCPR_DHCP_HOSTNAME 0x0c
#define TCPR_DHCP_BOOTFILESIZE 0x0d
#define TCPR_DHCP_DUMPFILE 0x0e
#define TCPR_DHCP_DOMAINNAME 0x0f
#define TCPR_DHCP_SWAPSERV 0x10
#define TCPR_DHCP_ROOTPATH 0x11
#define TCPR_DHCP_EXTENPATH 0x12
#define TCPR_DHCP_IPFORWARD 0x13
#define TCPR_DHCP_SRCROUTE 0x14
#define TCPR_DHCP_POLICYFILTER 0x15
#define TCPR_DHCP_MAXASMSIZE 0x16
#define TCPR_DHCP_IPTTL 0x17
#define TCPR_DHCP_MTUTIMEOUT 0x18
#define TCPR_DHCP_MTUTABLE 0x19
#define TCPR_DHCP_MTUSIZE 0x1a
#define TCPR_DHCP_LOCALSUBNETS 0x1b
#define TCPR_DHCP_BROADCASTADDR 0x1c
#define TCPR_DHCP_DOMASKDISCOV 0x1d
#define TCPR_DHCP_MASKSUPPLY 0x1e
#define TCPR_DHCP_DOROUTEDISC 0x1f
#define TCPR_DHCP_ROUTERSOLICIT 0x20
#define TCPR_DHCP_STATICROUTE 0x21
#define TCPR_DHCP_TRAILERENCAP 0x22
#define TCPR_DHCP_ARPTIMEOUT 0x23
#define TCPR_DHCP_ETHERENCAP 0x24
#define TCPR_DHCP_TCPTTL 0x25
#define TCPR_DHCP_TCPKEEPALIVE 0x26
#define TCPR_DHCP_TCPALIVEGARBAGE 0x27
#define TCPR_DHCP_NISDOMAIN 0x28
#define TCPR_DHCP_NISSERVERS 0x29
#define TCPR_DHCP_NISTIMESERV 0x2a
#define TCPR_DHCP_VENDSPECIFIC 0x2b
#define TCPR_DHCP_NBNS 0x2c
#define TCPR_DHCP_NBDD 0x2d
#define TCPR_DHCP_NBTCPIP 0x2e
#define TCPR_DHCP_NBTCPSCOPE 0x2f
#define TCPR_DHCP_XFONT 0x30
#define TCPR_DHCP_XDISPLAYMGR 0x31
#define TCPR_DHCP_DISCOVERADDR 0x32
#define TCPR_DHCP_LEASETIME 0x33
#define TCPR_DHCP_OPTIONOVERLOAD 0x34
#define TCPR_DHCP_MESSAGETYPE 0x35
#define TCPR_DHCP_SERVIDENT 0x36
#define TCPR_DHCP_PARAMREQUEST 0x37
#define TCPR_DHCP_MESSAGE 0x38
#define TCPR_DHCP_MAXMSGSIZE 0x39
#define TCPR_DHCP_RENEWTIME 0x3a
#define TCPR_DHCP_REBINDTIME 0x3b
#define TCPR_DHCP_CLASSSID 0x3c
#define TCPR_DHCP_CLIENTID 0x3d
#define TCPR_DHCP_NISPLUSDOMAIN 0x40
#define TCPR_DHCP_NISPLUSSERVERS 0x41
#define TCPR_DHCP_MOBILEIPAGENT 0x44
#define TCPR_DHCP_SMTPSERVER 0x45
#define TCPR_DHCP_POP3SERVER 0x46
#define TCPR_DHCP_NNTPSERVER 0x47
#define TCPR_DHCP_WWWSERVER 0x48
#define TCPR_DHCP_FINGERSERVER 0x49
#define TCPR_DHCP_IRCSERVER 0x4a
#define TCPR_DHCP_STSERVER 0x4b
#define TCPR_DHCP_STDASERVER 0x4c
#define TCPR_DHCP_END 0xff
#define TCPR_DHCP_MSGDISCOVER 0x01
#define TCPR_DHCP_MSGOFFER 0x02
#define TCPR_DHCP_MSGREQUEST 0x03
#define TCPR_DHCP_MSGDECLINE 0x04
#define TCPR_DHCP_MSGACK 0x05
#define TCPR_DHCP_MSGNACK 0x06
#define TCPR_DHCP_MSGRELEASE 0x07
#define TCPR_DHCP_MSGINFORM 0x08
};
/*
* Base DNSv4 header
* Domain Name System
* Base header size: 12/14 bytes
*/
struct tcpr_dnsv4_hdr
{
uint16_t h_len; /* length of the packet - only used with TCP */
uint16_t id; /* DNS packet ID */
uint16_t flags; /* DNS flags */
uint16_t num_q; /* Number of questions */
uint16_t num_answ_rr; /* Number of answer resource records */
uint16_t num_auth_rr; /* Number of authority resource records */
uint16_t num_addi_rr; /* Number of additional resource records */
};
#define TCPR_DNS_H TCPR_UDP_DNSV4_H
struct tcpr_dnsv4udp_hdr
{
uint16_t id; /* DNS packet ID */
uint16_t flags; /* DNS flags */
uint16_t num_q; /* Number of questions */
uint16_t num_answ_rr; /* Number of answer resource records */
uint16_t num_auth_rr; /* Number of authority resource records */
uint16_t num_addi_rr; /* Number of additional resource records */
};
/*
* PPP over Serial with HDLC encapsulation for NetBSD
*/
struct tcpr_pppserial_hdr
{
uint8_t address;
uint8_t control;
uint16_t protocol;
};
/*
* Ethernet II header
* Static header size: 14 bytes
*/
struct tcpr_ethernet_hdr
{
uint8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
uint8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
uint16_t ether_type; /* protocol */
};
#ifndef ETHERTYPE_PUP
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#endif
#ifndef ETHERTYPE_IP
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#endif
#ifndef ETHERTYPE_ARP
#define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */
#endif
#ifndef ETHERTYPE_REVARP
#define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
#endif
#ifndef ETHERTYPE_VLAN
#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
#endif
#ifndef ETHERTYPE_EAP
#define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */
#endif
#ifndef ETHERTYPE_MPLS
#define ETHERTYPE_MPLS 0x8847 /* MPLS */
#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
#endif
#ifndef ETHERTYPE_IP6
#define ETHERTYPE_IP6 0x86DD /* IPv6 */
#endif
struct tcpr_ether_addr
{
uint8_t ether_addr_octet[6]; /* Ethernet address */
};
/*
* Fiber Distributed Data Interface header
*
* Static header size: 21 bytes (LLC and 48-bit address addr only)
*
* Note: Organization field is 3 bytes which throws off the
* alignment of type. Therefore fddi_type (19 bytes in)
* is specified as two uint8_ts.
*/
struct tcpr_fddi_hdr
{
uint8_t fddi_frame_control; /* Class/Format/Priority */
#define TCPR_FDDI_LLC_FRAME 0x10
#define TCPR_FDDI_48BIT_ADDR 0x40
#define TCPR_FDDI_FC_REQD TCPR_FDDI_LLC_FRAME | TCPR_FDDI_48BIT_ADDR
uint8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */
uint8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */
uint8_t fddi_llc_dsap; /* DSAP */
uint8_t fddi_llc_ssap; /* SSAP */
uint8_t fddi_llc_control_field; /* Class/Format/Priority */
uint8_t fddi_llc_org_code[TCPR_ORG_CODE_SIZE]; /* Organization Code 3-bytes */
uint8_t fddi_type; /* Protocol Type */
uint8_t fddi_type1; /* see note above. */
#define FDDI_TYPE_IP 0x0800 /* IP protocol */
#define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */
#define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
};
struct tcpr_fddi_addr
{
uint8_t fddi_addr_octet[6]; /* FDDI address */
};
/*
* GRE header - RFC 1701 & 2637
* Generic Routing Encapsulation (GRE)
* Base header size: 4 bytes
*/
struct tcpr_gre_hdr
{
uint16_t flags_ver;
#define GRE_CSUM 0x8000
#define GRE_ROUTING 0x4000
#define GRE_KEY 0x2000
#define GRE_SEQ 0x1000
#define GRE_STRICT 0x0800
#define GRE_REC 0x0700
#define GRE_ACK 0x0080
#define GRE_FLAGS_MASK 0x00F8
#define GRE_VERSION_MASK 0x0007
#define GRE_VERSION_0 0x0000
#define GRE_VERSION_1 0x0001
uint16_t type;
#define GRE_SNA 0x0004
#define GRE_OSI_NETWORK_LAYER 0x00FE
#define GRE_PUP 0x0200
#define GRE_XNS 0x0600
#define GRE_IP 0x0800
#define GRE_CHAOS 0x0804
#define GRE_RFC_826_ARP 0x0806
#define GRE_FRAME_RELAY_ARP 0x0808
#define GRE_VINES 0x0BAD
#define GRE_VINES_ECHO 0x0BAE
#define GRE_VINES_LOOPBACK 0x0BAF
#define GRE_DECNET 0x6003
#define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558
#define GRE_RAW_FRAME_RELAY 0x6559
#define GRE_APOLLO_DOMAIN 0x8019
#define GRE_ETHERTALK 0x809B
#define GRE_NOVELL_IPX 0x8137
#define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B
#define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C
#define GRE_SECURE_DATA 0x876D
#define GRE_PPP 0x880b /* taken from RFC 2637 */
union {
struct {
uint16_t sum; /* optional */
uint16_t offset; /* optional */
uint32_t key; /* optional */
uint32_t seq; /* optional */
} _gre;
struct {
uint16_t payload_s; /* optional */
uint16_t callID; /* optional */
uint32_t seq; /* optional */
uint32_t ack; /* optional */
} _egre;
}_data;
#define gre_sum _data._gre.sum
#define gre_offset _data._gre.offset
#define gre_key _data._gre.key
#define gre_seq _data._gre.seq
#define egre_payload_s _data._egre.payload_s
#define egre_callID _data._egre.callID
#define egre_seq _data._egre.seq
#define egre_ack _data._egre.ack
};
#ifndef IPPROTO_GRE
#define IPPROTO_GRE 47
#endif
/*
* Source Route Entries (SRE)
* This is used for GRE as the Routing field is a list of SREs - RFC 1701
* Base header size: 4 bytes
*/
struct tcpr_gre_sre_hdr
{
uint16_t af; /* address familly */
uint8_t sre_offset;
uint8_t sre_length;
uint8_t *routing;
};
/*
* IPv4 header
* Internet Protocol, version 4
* Static header size: 20 bytes
*/
struct tcpr_ipv4_hdr
{
#ifdef WORDS_BIGENDIAN
uint8_t ip_v:4, /* version */
ip_hl:4; /* header length */
#else
uint8_t ip_hl:4, /* header length */
ip_v:4; /* version */
#endif
uint8_t ip_tos; /* type of service */
#ifndef IPTOS_LOWDELAY
#define IPTOS_LOWDELAY 0x10
#endif
#ifndef IPTOS_THROUGHPUT
#define IPTOS_THROUGHPUT 0x08
#endif
#ifndef IPTOS_RELIABILITY
#define IPTOS_RELIABILITY 0x04
#endif
#ifndef IPTOS_LOWCOST
#define IPTOS_LOWCOST 0x02
#endif
uint16_t ip_len; /* total length */
uint16_t ip_id; /* identification */
uint16_t ip_off;
#ifndef IP_RF
#define IP_RF 0x8000 /* reserved fragment flag */
#endif
#ifndef IP_DF
#define IP_DF 0x4000 /* dont fragment flag */
#endif
#ifndef IP_MF
#define IP_MF 0x2000 /* more fragments flag */
#endif
#ifndef IP_OFFMASK
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
#endif
uint8_t ip_ttl; /* time to live */
uint8_t ip_p; /* protocol */
uint16_t ip_sum; /* checksum */
struct in_addr ip_src, ip_dst; /* source and dest address */
};
/*
* IP options
*/
#ifndef IPOPT_EOL
#define IPOPT_EOL 0 /* end of option list */
#endif
#ifndef IPOPT_NOP
#define IPOPT_NOP 1 /* no operation */
#endif
#ifndef IPOPT_RR
#define IPOPT_RR 7 /* record packet route */
#endif
#ifndef IPOPT_TS
#define IPOPT_TS 68 /* timestamp */
#endif
#ifndef IPOPT_SECURITY
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
#endif
#ifndef IPOPT_LSRR
#define IPOPT_LSRR 131 /* loose source route */
#endif
#ifndef IPOPT_SATID
#define IPOPT_SATID 136 /* satnet id */
#endif
#ifndef IPOPT_SSRR
#define IPOPT_SSRR 137 /* strict source route */
#endif
struct tcpr_in6_addr
{
union
{
u_int8_t __u6_addr8[16];
u_int16_t __u6_addr16[8];
u_int32_t __u6_addr32[4];
} __u6_addr; /* 128-bit IP6 address */
};
#define tcpr_s6_addr __u6_addr.__u6_addr8
#define tcpr_s6_addr8 __u6_addr.__u6_addr8
#define tcpr_s6_addr16 __u6_addr.__u6_addr16
#define tcpr_s6_addr32 __u6_addr.__u6_addr32
/*
* IPv6 header
* Internet Protocol, version 6
* Static header size: 40 bytes
*/
struct tcpr_ipv6_hdr
{
uint8_t ip_flags[4]; /* version, traffic class, flow label */
uint16_t ip_len; /* total length */
uint8_t ip_nh; /* next header */
uint8_t ip_hl; /* hop limit */
struct tcpr_in6_addr ip_src, ip_dst; /* source and dest address */
};
struct tcpr_ipv6_ext_hdr_base
{
uint8_t ip_nh; /* next header */
uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
/* some more bytes are always here, but we don't know what kind */
};
#define TCPR_IPV6_NH_NO_NEXT 59
#define TCPR_IPV6_NH_IPV6 41
#define TCPR_IPV6_NH_ESP 50
#define TCPR_IPV6_NH_AH 51
/*
* IPv6 frag header
* Internet Protocol, version 6
* Static header size: 8 bytes
*/
#define TCPR_IPV6_NH_FRAGMENT 44
struct tcpr_ipv6_frag_hdr
{
uint8_t ip_nh; /* next header */
uint8_t ip_reserved; /* reserved */
uint16_t ip_frag; /* fragmentation stuff */
uint32_t ip_id; /* id */
};
/*
* IPv6 routing header
* Internet Protocol, version 6
* Base header size: 4 bytes
*/
#define TCPR_IPV6_NH_ROUTING 43
struct tcpr_ipv6_routing_hdr
{
uint8_t ip_nh; /* next header */
uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
uint8_t ip_rtype; /* routing type */
uint8_t ip_segments; /* segments left */
/* routing information allocated dynamically */
};
/*
* IPv6 destination options header
* Internet Protocol, version 6
* Base header size: 2 bytes
*/
#define TCPR_IPV6_NH_DESTOPTS 60
struct tcpr_ipv6_destopts_hdr
{
uint8_t ip_nh; /* next header */
uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
/* destination options information allocated dynamically */
};
/*
* IPv6 hop by hop options header
* Internet Protocol, version 6
* Base header size: 2 bytes
*/
#define TCPR_IPV6_NH_HBH 0
struct tcpr_ipv6_hbhopts_hdr
{
uint8_t ip_nh; /* next header */
uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
/* destination options information allocated dynamically */
};
/*
* ICMP6 header
* Internet Control Message Protocol v6
* Base header size: 8 bytes
*/
#ifndef IPPROTO_ICMP6
#define IPPROTO_ICMP6 0x3a
#endif
struct tcpr_icmpv6_hdr
{
uint8_t icmp_type; /* ICMP type */
#ifndef ICMP6_ECHO
#define ICMP6_ECHO 128
#endif
#ifndef ICMP6_ECHOREPLY
#define ICMP6_ECHOREPLY 129
#endif
#ifndef ICMP6_UNREACH
#define ICMP6_UNREACH 1
#endif
#ifndef ICMP6_PKTTOOBIG
#define ICMP6_PKTTOOBIG 2
#endif
#ifndef ICMP6_TIMXCEED
#define ICMP6_TIMXCEED 3
#endif
#ifndef ICMP6_PARAMPROB
#define ICMP6_PARAMPROB 4
#endif
uint8_t icmp_code; /* ICMP code */
uint16_t icmp_sum; /* ICMP Checksum */
uint16_t id; /* ICMP id */
uint16_t seq; /* ICMP sequence number */
};
/*
* ICMP header
* Internet Control Message Protocol
* Base header size: 4 bytes
*/
struct tcpr_icmpv4_hdr
{
uint8_t icmp_type; /* ICMP type */
#ifndef ICMP_ECHOREPLY
#define ICMP_ECHOREPLY 0
#endif
#ifndef ICMP_UNREACH
#define ICMP_UNREACH 3
#endif
#ifndef ICMP_SOURCEQUENCH
#define ICMP_SOURCEQUENCH 4
#endif
#ifndef ICMP_REDIRECT
#define ICMP_REDIRECT 5
#endif
#ifndef ICMP_ECHO
#define ICMP_ECHO 8
#endif
#ifndef ICMP_ROUTERADVERT
#define ICMP_ROUTERADVERT 9
#endif
#ifndef ICMP_ROUTERSOLICIT
#define ICMP_ROUTERSOLICIT 10
#endif
#ifndef ICMP_TIMXCEED
#define ICMP_TIMXCEED 11
#endif
#ifndef ICMP_PARAMPROB
#define ICMP_PARAMPROB 12
#endif
#ifndef ICMP_TSTAMP
#define ICMP_TSTAMP 13
#endif
#ifndef ICMP_TSTAMPREPLY
#define ICMP_TSTAMPREPLY 14
#endif
#ifndef ICMP_IREQ
#define ICMP_IREQ 15
#endif
#ifndef ICMP_IREQREPLY
#define ICMP_IREQREPLY 16
#endif
#ifndef ICMP_MASKREQ
#define ICMP_MASKREQ 17
#endif
#ifndef ICMP_MASKREPLY
#define ICMP_MASKREPLY 18
#endif
uint8_t icmp_code; /* ICMP code */
#ifndef ICMP_UNREACH_NET
#define ICMP_UNREACH_NET 0
#endif
#ifndef ICMP_UNREACH_HOST
#define ICMP_UNREACH_HOST 1
#endif
#ifndef ICMP_UNREACH_PROTOCOL
#define ICMP_UNREACH_PROTOCOL 2
#endif
#ifndef ICMP_UNREACH_PORT
#define ICMP_UNREACH_PORT 3
#endif
#ifndef ICMP_UNREACH_NEEDFRAG
#define ICMP_UNREACH_NEEDFRAG 4
#endif
#ifndef ICMP_UNREACH_SRCFAIL
#define ICMP_UNREACH_SRCFAIL 5
#endif
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6
#endif
#ifndef ICMP_UNREACH_HOST_UNKNOWN
#define ICMP_UNREACH_HOST_UNKNOWN 7
#endif
#ifndef ICMP_UNREACH_ISOLATED
#define ICMP_UNREACH_ISOLATED 8
#endif
#ifndef ICMP_UNREACH_NET_PROHIB
#define ICMP_UNREACH_NET_PROHIB 9
#endif
#ifndef ICMP_UNREACH_HOST_PROHIB
#define ICMP_UNREACH_HOST_PROHIB 10
#endif
#ifndef ICMP_UNREACH_TOSNET
#define ICMP_UNREACH_TOSNET 11
#endif
#ifndef ICMP_UNREACH_TOSHOST
#define ICMP_UNREACH_TOSHOST 12
#endif
#ifndef ICMP_UNREACH_FILTER_PROHIB
#define ICMP_UNREACH_FILTER_PROHIB 13
#endif
#ifndef ICMP_UNREACH_HOST_PRECEDENCE