File: protocols.h

package info (click to toggle)
irpas 0.10-4.1
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 412 kB
  • ctags: 973
  • sloc: ansic: 7,385; makefile: 145
file content (620 lines) | stat: -rw-r--r-- 21,452 bytes parent folder | download | duplicates (2)
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
/* Phenoelit IRPAS 
 * protocol definitions
 *
 * $Id: protocols.h,v 1.9 2001/10/18 12:02:58 fx Exp $
 */
#ifndef _PROTOCOLS_H_
#define _PROTOCOLS_H_

#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>

/* ************************************************************
 * Ethernet Frames
 * ************************************************************/
typedef struct {
    struct ether_addr   daddr;
    struct ether_addr   saddr;
    u_int16_t           type;
} etherIIhdr_t;

/* IEEE 802.3, LLC related structs */
struct eth_ieee802_3 {
    struct ether_addr   daddr;
    struct ether_addr   saddr;
    u_int16_t           length;
};

struct eth_LLC {
    u_int8_t            DSAP;
    u_int8_t            SSAP;
    u_int8_t            Control;
    u_int8_t            orgcode[3];
    u_int16_t           proto;
};

struct eth_LLC_short {
    u_int8_t            DSAP;
    u_int8_t            SSAP;
    u_int8_t            Control;
    u_int8_t            orgcode[3];
    u_int16_t           proto;
};

/* ************************************************************
 * CDP frames
 * ************************************************************/

/* CDP header */
struct cdphdr {
    u_int8_t            version;
    u_int8_t            ttl;
    u_int16_t           checksum;
};
/* CDP sections */
#define TYPE_DEVICE_ID          0x0001
#define TYPE_ADDRESS            0x0002
#define TYPE_PORT_ID            0x0003
#define TYPE_CAPABILITIES       0x0004
#define TYPE_IOS_VERSION        0x0005
#define TYPE_PLATFORM           0x0006
#define TYPE_VTP_MGMT		0x0009
#define TYPE_VLAN		0x000a
#define TYPE_DUPLEX		0x000b

struct cdp_device {
    u_int16_t           type;           /* 0x0001 */
    u_int16_t           length;
    u_char              device;         /* pointer to device name */
};

struct cdp_address {
    u_int16_t           type;           /* 0x0002 */
    u_int16_t           length;
    u_int32_t           number;         /* number of addresses */
};

struct cdp_address_entry {
    u_int8_t            proto_type;     /* 0x1 for NLPID */
    u_int8_t            length;         /* 0x1 for IP */
    u_int8_t            proto;          /* 0xCC for IP */
    u_int8_t            addrlen[2];
    u_char              addr;
};

struct cdp_port {
    u_int16_t           type;           /* 0x0003 */
    u_int16_t           length;
    u_char              port;           /* pointer to port name */
};


#define CDP_CAP_LEVEL1          0x40
#define CDP_CAP_FORWARD_IGMP    0x20
#define CDP_CAP_NETWORK_LAYER   0x10
#define CDP_CAP_LEVEL2_SWITCH   0x08
#define CDP_CAP_LEVEL2_SRB      0x04
#define CDP_CAP_LEVEL2_TRBR     0x02
#define CDP_CAP_LEVEL3_ROUTER   0x01
struct cdp_capabilities {
    u_int16_t           type;           /* 0x0004 */
    u_int16_t           length;         /* is 8 */
    u_int32_t           capab;
};

struct cdp_software {
    u_int16_t           type;           /* 0x0005 */
    u_int16_t           length;
    u_char              software;       /* pointer to software string */
};

struct cdp_platform {
    u_int16_t           type;           /* 0x0006 */
    u_int16_t           length;
    u_char              platform;       /* pointer to platform string */
};

typedef struct {
    u_int16_t           type;           
    u_int16_t           length;
    u_char              value;           /* pointer to port name */
} cdp_generic_t;

/* ************************************************************
 * PPPoE 
 * ************************************************************/
typedef struct {
    u_int8_t		version:4,type:4	__attribute__ ((packed));
    u_int8_t		code			__attribute__ ((packed));
    u_int16_t           session			__attribute__ ((packed));
    u_int16_t           payload_len		__attribute__ ((packed));
} pppoe_data_t;


/* ************************************************************
 * ARP version 4
 * ************************************************************/
#define ARPOP_REQUEST   1               /* ARP request.  */
#define ARPOP_REPLY     2               /* ARP reply.  */
#define ARPOP_RREQUEST  3               /* RARP request.  */
#define ARPOP_RREPLY    4               /* RARP reply.  */
typedef struct {
    u_int16_t	hardware;
    u_int16_t	protocol;
    u_int8_t	hw_size;
    u_int8_t	proto_size;
    u_int16_t	opcode;
    u_int8_t	sha[ETH_ALEN];   	/* Sender hardware address.  */
    u_int8_t 	sip[4];	          	/* Sender IP address.  */
    u_int8_t 	tha[ETH_ALEN];   	/* Target hardware address.  */
    u_int8_t 	tip[4];          	/* Target IP address.  */
} arphdr_t;


/* ************************************************************
 * IP version 4
 * ************************************************************/
/* #define IPPROTO_ICMP	0x01 */
#define IPPROTO_IGRP    0x09
/* #define IPPROTO_UDP	0x11 */
#define IPPROTO_EIGRP	0x58
#define IPPROTO_OSPF	0x59
/* #define IPPROTO_GRE	0x2f */

#define IP_ADDR_LEN	4
typedef struct {
        u_int8_t        ihl:4,          /* header length */
                        version:4;      /* version */
        u_int8_t        tos;            /* type of service */
        u_int16_t       tot_len;        /* total length */
        u_int16_t       id;             /* identification */
        u_int16_t       off;            /* fragment offset field */
        u_int8_t        ttl;            /* time to live */
        u_int8_t        protocol;       /* protocol */
        u_int16_t       check;          /* checksum */
        struct in_addr  saddr;
        struct in_addr  daddr;  	/* source and dest address */
} iphdr_t;

/* ************************************************************
 * TCP
 * ************************************************************/
typedef struct {
    u_int16_t th_sport;         /* source port */
    u_int16_t th_dport;         /* destination port */
    u_int32_t th_seq;             /* sequence number */
    u_int32_t th_ack;             /* acknowledgement number */
#if __BYTE_ORDER == __LITTLE_ENDIAN
    u_int8_t th_x2:4;           /* (unused) */
    u_int8_t th_off:4;          /* data offset */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
    u_int8_t th_off:4;          /* data offset */
    u_int8_t th_x2:4;           /* (unused) */
#endif
    u_int8_t th_flags;
#define TH_FIN  0x01
#define TH_SYN  0x02
#define TH_RST  0x04
#define TH_PUSH 0x08
#define TH_ACK  0x10
#define TH_URG  0x20
    u_int16_t th_win;           /* window */
    u_int16_t th_sum;           /* checksum */
    u_int16_t th_urp;           /* urgent pointer */
} tcphdr_t;

struct pseudohdr {
    struct in_addr saddr;
    struct in_addr daddr;
    u_char zero;
    u_char protocol;
    u_short length;
    tcphdr_t tcpheader;
};

/* ************************************************************
 * UDP
 * ************************************************************/
typedef struct {
    u_int16_t	sport			__attribute__ ((packed));
    u_int16_t	dport			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int16_t	checksum		__attribute__ ((packed));
} udphdr_t;


/* ************************************************************
 * IGRP 
 * ************************************************************/
#define IGRP_OPCODE_REQUEST     2
#define IGRP_OPCODE_UPDATE      1

typedef struct {
    u_int8_t            opcode:4,version:4	__attribute__ ((packed));
    u_int8_t            edition			__attribute__ ((packed));
    u_int16_t           autosys			__attribute__ ((packed));
    u_int16_t           interior		__attribute__ ((packed));
    u_int16_t           system			__attribute__ ((packed));
    u_int16_t           exterior		__attribute__ ((packed));
    u_int16_t           checksum		__attribute__ ((packed));
} igrp_t;

/* 
 * comment:
 *      the thing with delay[3] ... is very ugly, but I'm not good 
 *      in representing this perhaps 3 byte long data type correctly.
 *      Cisco's documentation has still free space for improvements  ...
 */
typedef struct {
    u_int8_t            destination[3]  __attribute__ ((packed));
    u_int8_t            delay[3]        __attribute__ ((packed));
    u_int8_t            bandwith[3]     __attribute__ ((packed));
    u_int16_t           mtu             __attribute__ ((packed));
    u_int8_t            reliability     __attribute__ ((packed));
    u_int8_t            load            __attribute__ ((packed));
    u_int8_t            hopcount        __attribute__ ((packed));
} igrp_system_entry_t;


/* ************************************************************
 * ICMP
 * ************************************************************/
#define ICMP_ECHOREPLY          0       /* Echo Reply                   */
#define ICMP_DEST_UNREACH       3       /* Destination Unreachable      */
#define ICMP_SOURCE_QUENCH      4       /* Source Quench                */
#define ICMP_REDIRECT           5       /* Redirect (change route)      */
#define ICMP_ECHO               8       /* Echo Request                 */
#define ICMP_ROUTER_ADVERT	9	/* router advertisement 	*/
#define ICMP_SOLICITATION	10	/* router solicitation		*/
#define ICMP_TIME_EXCEEDED      11      /* Time Exceeded                */
#define ICMP_PARAMETERPROB      12      /* Parameter Problem            */
#define ICMP_TIMESTAMP          13      /* Timestamp Request            */
#define ICMP_TIMESTAMPREPLY     14      /* Timestamp Reply              */
#define ICMP_INFO_REQUEST       15      /* Information Request          */
#define ICMP_INFO_REPLY         16      /* Information Reply            */
#define ICMP_ADDRESS            17      /* Address Mask Request         */
#define ICMP_ADDRESSREPLY       18      /* Address Mask Reply           */
/* Codes for REDIRECT. */
#define ICMP_REDIR_NET          0       /* Redirect Net                 */
#define ICMP_REDIR_HOST         1       /* Redirect Host                */
#define ICMP_REDIR_NETTOS       2       /* Redirect Net for TOS         */
#define ICMP_REDIR_HOSTTOS      3       /* Redirect Host for TOS        */
/* codes for unreach */
#define ICMP_UNREACH_NET	0
#define ICMP_UNREACH_HOST	1
#define ICMP_UNREACH_PROTO	2	/* protocol unreachable 	*/
#define ICMP_UNREACH_PORT	3	/* port unreachable 		*/
#define ICMP_UNREACH_FRAG	4	/* fragmentation needed and DF	*/
#define ICMP_UNREACH_SOURCE	5	/* source route failed 		*/
#define ICMP_UNREACH_ADMIN1	9	/* administratively prohibited	*/
#define ICMP_UNREACH_TOS	11	/* unreach fro TOS		*/
#define ICMP_UNREACH_FIREWALL	13	/* port filtered 		*/

typedef struct {
    u_int8_t type			__attribute__ ((packed));
    u_int8_t code			__attribute__ ((packed));
    u_int16_t checksum			__attribute__ ((packed));
} icmphdr_t;

typedef struct {
    u_int16_t	identifier		__attribute__ ((packed));
    u_int16_t	seq			__attribute__ ((packed));
    u_int8_t	data[56]		__attribute__ ((packed));
} icmp_echohdr_t;

typedef struct {
    icmphdr_t		icmp		__attribute__ ((packed));
    icmp_echohdr_t	echo		__attribute__ ((packed));
} icmp_ping_t;

typedef struct {
    u_int16_t	identifier		__attribute__ ((packed));
    u_int16_t	seq			__attribute__ ((packed));
    u_int8_t	mask[4]			__attribute__ ((packed));
} icmp_netmask_t;

typedef struct {
    u_int16_t   identifier		__attribute__ ((packed));
    u_int16_t   seq			__attribute__ ((packed));
    u_int32_t   origts			__attribute__ ((packed));
    u_int32_t   recvts			__attribute__ ((packed));
    u_int32_t   transts			__attribute__ ((packed));
} icmp_timestamp_t;

typedef struct {
    u_int8_t	num_addr		__attribute__ ((packed));
    u_int8_t	addrsize		__attribute__ ((packed));
    u_int16_t	lifetime		__attribute__ ((packed));
} irdp_t;

typedef struct {
    u_int8_t	addr[4]			__attribute__ ((packed));
    u_int32_t	pref			__attribute__ ((packed));
} irdp_rec_t;

typedef struct {
    u_int8_t	type			__attribute__ ((packed));
    u_int8_t	code			__attribute__ ((packed));
    u_int16_t	checksum		__attribute__ ((packed));
    u_int32_t	reserved		__attribute__ ((packed));
} irdp_solicitation_t;

typedef struct {
    u_int8_t	type			__attribute__ ((packed));
    u_int8_t	code			__attribute__ ((packed));
    u_int16_t	checksum		__attribute__ ((packed));
    u_int8_t	gateway[4]		__attribute__ ((packed));
    u_int8_t	headerdata[28]		__attribute__ ((packed));
} icmp_redirect_t;

/* ************************************************************
 * OSPF
 * ************************************************************/
#define OSPF_HELLO      1
#define OSPF_DB_DESC    2
#define OSPF_LS_REQ     3
#define OSPF_LS_UPD     4
#define OSPF_LS_ACK     5

#define OSPF_AUTH_NONE          0
#define OSPF_AUTH_SIMPLE        1
#define OSPF_AUTH_CRYPT         2

typedef struct {
    u_int8_t	version			__attribute__ ((packed));
    u_int8_t	type			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int8_t	source[4]		__attribute__ ((packed));
    u_int8_t	area[4]			__attribute__ ((packed));
    u_int16_t	checksum		__attribute__ ((packed));
    u_int16_t	authtype		__attribute__ ((packed));
    u_int8_t	authdata[8]		__attribute__ ((packed));
} ospf_header_t;

typedef struct {
    u_int8_t	netmask[4]		__attribute__ ((packed));
    u_int16_t	hello_interval		__attribute__ ((packed));
    u_int8_t	options			__attribute__ ((packed));
    u_int8_t	priority		__attribute__ ((packed));
    u_int8_t	dead_interval[4] 	__attribute__ ((packed));
    u_int8_t	designated[4]		__attribute__ ((packed));
    u_int8_t	backup[4]		__attribute__ ((packed));
    //u_int8_t	activeneig[4]		__attribute__ ((packed));
} ospf_hello_t;

/* ************************************************************
 * Spanning Tree (STP)
 * ************************************************************/

typedef struct {
    u_int16_t	protocolid 		__attribute__ ((packed));
    u_int8_t	version 		__attribute__ ((packed));
    u_int8_t	BPDU_type 		__attribute__ ((packed));
    u_int8_t	BPDU_flags 		__attribute__ ((packed));
    u_int16_t	root_priority 		__attribute__ ((packed));
    u_int8_t	root_id[6] 		__attribute__ ((packed));
    u_int8_t	root_path_cost[4] 	__attribute__ ((packed));
    u_int16_t	bridge_priority 	__attribute__ ((packed));
    u_int8_t	bridge_id[6] 		__attribute__ ((packed));
    u_int16_t	port_id 		__attribute__ ((packed));
    u_int16_t	message_age 		__attribute__ ((packed));
    u_int16_t	max_age 		__attribute__ ((packed));
    u_int16_t	hello_time 		__attribute__ ((packed));
    u_int16_t	forward_delay 		__attribute__ ((packed));
} stp_t;

/* ************************************************************
 * EIGRP
 * ************************************************************/

#define EIGRP_UPDATE    0x01
#define EIGRP_REQUEST   0x02
#define EIGRP_QUERY     0x03
#define EIGRP_REPLY     0x04
#define EIGRP_HELLO     0x05

#define EIGRP_TYPE_PARA		0x0001
#define EIGRP_TYPE_SOFT		0x0004
#define EIGRP_TYPE_IN_ROUTE	0x0102
#define EIGRP_TYPE_EX_ROUTE	0x0103

typedef struct {
   u_int8_t	version			__attribute__ ((packed));
   u_int8_t	opcode			__attribute__ ((packed));
   u_int16_t	checksum		__attribute__ ((packed));
   u_int32_t	flags			__attribute__ ((packed));
   u_int32_t	seq			__attribute__ ((packed));
   u_int32_t	ack			__attribute__ ((packed));
   u_int32_t	as			__attribute__ ((packed));
} eigrp_t;

typedef struct {
    u_int16_t	type			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int8_t	iosmaj			__attribute__ ((packed));
    u_int8_t	iosmin			__attribute__ ((packed));
    u_int8_t	eigrpmaj		__attribute__ ((packed));
    u_int8_t	eigrpmin		__attribute__ ((packed));
} eigrpsoft_t;

typedef struct {
    u_int16_t	type			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int8_t	k1			__attribute__ ((packed));
    u_int8_t	k2			__attribute__ ((packed));
    u_int8_t	k3			__attribute__ ((packed));
    u_int8_t	k4			__attribute__ ((packed));
    u_int8_t	k5			__attribute__ ((packed));
    u_int8_t	reseved			__attribute__ ((packed));
    u_int16_t	holdtime		__attribute__ ((packed));
} eigrppara_t;

typedef struct {
    u_int16_t	type			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int8_t	nexthop[4]		__attribute__ ((packed));
    u_int8_t	origrouter[4]		__attribute__ ((packed));
    u_int32_t	origas			__attribute__ ((packed));
    u_int32_t	tag			__attribute__ ((packed));
    u_int32_t	external_metric		__attribute__ ((packed));
    u_int16_t	reserved_1		__attribute__ ((packed));
    u_int8_t	external_link		__attribute__ ((packed));
    u_int8_t	flags			__attribute__ ((packed));
    u_int32_t	delay			__attribute__ ((packed));
    u_int32_t	bandwidth		__attribute__ ((packed));
    u_int8_t	mtu[3]			__attribute__ ((packed));
    u_int8_t	hopcount		__attribute__ ((packed));
    u_int8_t	reliability		__attribute__ ((packed));
    u_int8_t	load			__attribute__ ((packed));
    u_int16_t	reserved_2		__attribute__ ((packed));
    u_int8_t	prefix_length		__attribute__ ((packed));
    		/* Warning: 
		 * this filed is variable and depends on prefix_length 
		 * 8= 1
		 * 16=2
		 * 24=3
		 * 32=4*/
    u_int8_t	dest			__attribute__ ((packed));
} eigrpextroute_t;

typedef struct {
    u_int16_t	type			__attribute__ ((packed));
    u_int16_t	length			__attribute__ ((packed));
    u_int8_t	nexthop[4]		__attribute__ ((packed));
    u_int32_t	delay			__attribute__ ((packed));
    u_int32_t	bandwidth		__attribute__ ((packed));
    u_int8_t	mtu[3]			__attribute__ ((packed));
    u_int8_t	hopcount		__attribute__ ((packed));
    u_int8_t	reliability		__attribute__ ((packed));
    u_int8_t	load			__attribute__ ((packed));
    u_int16_t	reserved_2		__attribute__ ((packed));
    u_int8_t	prefix_length		__attribute__ ((packed));
    		/* Warning: 
		 * this filed is variable and depends on prefix_length 
		 * 8= 1
		 * 16=2
		 * 24=3
		 * 32=4*/
    u_int8_t	dest			__attribute__ ((packed));
} eigrpintroute_t;

/* ************************************************************
 * RIP v1
 * ************************************************************/
#define RIP_PORT		520
#define RIP_COMMAND_REQUEST	1
#define RIP_COMMAND_RESPONSE	2

typedef struct {
    u_int8_t	command		__attribute__ ((packed));
    u_int8_t	version		__attribute__ ((packed));
    u_int16_t	zero		__attribute__ ((packed));
} ripv1hdr_t;

typedef struct {
    u_int16_t	addrfamily	__attribute__ ((packed));
    u_int16_t	zero1		__attribute__ ((packed));
    u_int8_t	address[4]	__attribute__ ((packed));
    u_int16_t	zero2[4]	__attribute__ ((packed));
    u_int32_t	metric		__attribute__ ((packed));
} ripv1addr_t;

typedef struct {
    u_int8_t	command		__attribute__ ((packed));
    u_int8_t	version		__attribute__ ((packed));
    u_int16_t	domain		__attribute__ ((packed));
} ripv2hdr_t;

typedef struct {
    u_int16_t	addrfamily	__attribute__ ((packed));
    u_int16_t	routetag	__attribute__ ((packed));
    u_int8_t	address[4]	__attribute__ ((packed));
    u_int8_t	netmask[4]	__attribute__ ((packed));
    u_int8_t	nexthop[4]	__attribute__ ((packed));
    u_int32_t	metric		__attribute__ ((packed));
} ripv2addr_t;

typedef struct {
    u_int16_t	addrfamily	__attribute__ ((packed));
    u_int16_t	authtype	__attribute__ ((packed));
    u_int8_t	auth[16]	__attribute__ ((packed));
} ripv2auth_t;

/* ************************************************************
 * GRE
 * ************************************************************/
typedef struct {
    u_int16_t	flags;
    u_int16_t	proto;
} grehdr_t;

/* ************************************************************
 * HSRP
 * ************************************************************/
#define HSRP_OPCODE_HELLO  0
#define HSRP_OPCODE_COUP   1
#define HSRP_OPCODE_RESIGN 2

#define HSRP_STATE_INITIAL  0
#define HSRP_STATE_LEARN    1
#define HSRP_STATE_LISTEN   2
#define HSRP_STATE_SPEAK    4
#define HSRP_STATE_STANDBY  8
#define HSRP_STATE_ACTIVE  16

typedef struct {
    u_int8_t	version;
    u_int8_t	opcode;
    u_int8_t	state;
    u_int8_t	hellotime;
    u_int8_t	holdtime;
    u_int8_t	prio;
    u_int8_t	group;
    u_int8_t	reserved;
    u_int8_t	auth[8];
    u_int8_t	virtip[4];
} hsrp_t;

/* ************************************************************
 * DHCP
 * ************************************************************/
#define DHCP_CLIENT_PORT	68
#define DHCP_SERVER_PORT	67
#define DHCPDISCOVER		1
#define DHCPOFFER		2
#define DHCPREQUEST		3
#define DHCPDECLINE		4
#define DHCPACK			5
#define DHCPNAK			6
#define DHCPRELEASE		7
#define DHCPINFORM		8
typedef struct {
    u_int8_t	msgtype				__attribute__ ((packed));
    u_int8_t	hwtype				__attribute__ ((packed));
    u_int8_t	hwalen				__attribute__ ((packed));
    u_int8_t	hops				__attribute__ ((packed));
    u_int32_t	transid				__attribute__ ((packed));
    u_int16_t	seconds				__attribute__ ((packed));
    u_int16_t	bcastflags			__attribute__ ((packed));
    u_int32_t	ciaddr				__attribute__ ((packed));
    u_int32_t	yiaddr				__attribute__ ((packed));
    u_int32_t	siaddr				__attribute__ ((packed));
    u_int32_t	giaddr				__attribute__ ((packed));
    u_char	chaddr[16]			__attribute__ ((packed));
    u_char	sname[64]			__attribute__ ((packed));
    u_char	file[128]			__attribute__ ((packed));
    u_int8_t	cookie[4]			__attribute__ ((packed));
} dhcp_t;

#define DHCP_OPTION_DISCOVER	53
#define DHCP_OPTION_PARAMETERS	55
#define DHCP_OPTION_CLIENTID	61
typedef struct {
    u_int8_t	type;
    u_int8_t	length;
    u_int8_t	value;
} dhcp_option_t;

#endif /* _PROTOCOLS_H_ */