Annotation of embedaddon/quagga/ospfd/ospf_packet.h, revision 1.1.1.2
1.1 misho 1: /*
2: * OSPF Sending and Receiving OSPF Packets.
3: * Copyright (C) 1999 Toshiaki Takada
4: *
5: * This file is part of GNU Zebra.
6: *
7: * GNU Zebra is free software; you can redistribute it and/or modify it
8: * under the terms of the GNU General Public License as published by the
9: * Free Software Foundation; either version 2, or (at your option) any
10: * later version.
11: *
12: * GNU Zebra is distributed in the hope that it will be useful, but
13: * WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with GNU Zebra; see the file COPYING. If not, write to the Free
19: * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20: * 02111-1307, USA.
21: */
22:
23: #ifndef _ZEBRA_OSPF_PACKET_H
24: #define _ZEBRA_OSPF_PACKET_H
25:
26: #define OSPF_HEADER_SIZE 24U
27: #define OSPF_AUTH_SIMPLE_SIZE 8U
28: #define OSPF_AUTH_MD5_SIZE 16U
29:
30: #define OSPF_MAX_PACKET_SIZE 65535U /* includes IP Header size. */
31: #define OSPF_HELLO_MIN_SIZE 20U /* not including neighbors */
32: #define OSPF_DB_DESC_MIN_SIZE 8U
33: #define OSPF_LS_REQ_MIN_SIZE 0U
34: #define OSPF_LS_UPD_MIN_SIZE 4U
35: #define OSPF_LS_ACK_MIN_SIZE 0U
36:
37: #define OSPF_MSG_HELLO 1 /* OSPF Hello Message. */
38: #define OSPF_MSG_DB_DESC 2 /* OSPF Database Descriptoin Message. */
39: #define OSPF_MSG_LS_REQ 3 /* OSPF Link State Request Message. */
40: #define OSPF_MSG_LS_UPD 4 /* OSPF Link State Update Message. */
41: #define OSPF_MSG_LS_ACK 5 /* OSPF Link State Acknoledgement Message. */
42:
43: #define OSPF_SEND_PACKET_DIRECT 1
44: #define OSPF_SEND_PACKET_INDIRECT 2
45: #define OSPF_SEND_PACKET_LOOP 3
46:
47: #define OSPF_HELLO_REPLY_DELAY 1
48:
1.1.1.2 ! misho 49: /* Return values of functions involved in packet verification, see ospf6d. */
! 50: #define MSG_OK 0
! 51: #define MSG_NG 1
! 52:
1.1 misho 53: struct ospf_packet
54: {
55: struct ospf_packet *next;
56:
57: /* Pointer to data stream. */
58: struct stream *s;
59:
60: /* IP destination address. */
61: struct in_addr dst;
62:
63: /* OSPF packet length. */
64: u_int16_t length;
65: };
66:
67: /* OSPF packet queue structure. */
68: struct ospf_fifo
69: {
70: unsigned long count;
71:
72: struct ospf_packet *head;
73: struct ospf_packet *tail;
74: };
75:
76: /* OSPF packet header structure. */
77: struct ospf_header
78: {
79: u_char version; /* OSPF Version. */
80: u_char type; /* Packet Type. */
81: u_int16_t length; /* Packet Length. */
82: struct in_addr router_id; /* Router ID. */
83: struct in_addr area_id; /* Area ID. */
84: u_int16_t checksum; /* Check Sum. */
85: u_int16_t auth_type; /* Authentication Type. */
86: /* Authentication Data. */
87: union
88: {
89: /* Simple Authentication. */
90: u_char auth_data [OSPF_AUTH_SIMPLE_SIZE];
91: /* Cryptographic Authentication. */
92: struct
93: {
94: u_int16_t zero; /* Should be 0. */
95: u_char key_id; /* Key ID. */
96: u_char auth_data_len; /* Auth Data Length. */
97: u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
98: } crypt;
99: } u;
100: };
101:
102: /* OSPF Hello body format. */
103: struct ospf_hello
104: {
105: struct in_addr network_mask;
106: u_int16_t hello_interval;
107: u_char options;
108: u_char priority;
109: u_int32_t dead_interval;
110: struct in_addr d_router;
111: struct in_addr bd_router;
112: struct in_addr neighbors[1];
113: };
114:
115: /* OSPF Database Description body format. */
116: struct ospf_db_desc
117: {
118: u_int16_t mtu;
119: u_char options;
120: u_char flags;
121: u_int32_t dd_seqnum;
122: };
123:
1.1.1.2 ! misho 124: struct ospf_ls_update
! 125: {
! 126: u_int32_t num_lsas;
! 127: };
1.1 misho 128:
129: /* Macros. */
130: /* XXX Perhaps obsolete; function in ospf_packet.c */
131: #define OSPF_PACKET_MAX(oi) ospf_packet_max (oi)
132:
133: #define OSPF_OUTPUT_PNT(S) ((S)->data + (S)->putp)
134: #define OSPF_OUTPUT_LENGTH(S) ((S)->endp)
135:
136: #define IS_SET_DD_MS(X) ((X) & OSPF_DD_FLAG_MS)
137: #define IS_SET_DD_M(X) ((X) & OSPF_DD_FLAG_M)
138: #define IS_SET_DD_I(X) ((X) & OSPF_DD_FLAG_I)
139: #define IS_SET_DD_ALL(X) ((X) & OSPF_DD_FLAG_ALL)
140:
141: /* Prototypes. */
142: extern void ospf_output_forward (struct stream *, int);
143: extern struct ospf_packet *ospf_packet_new (size_t);
144: extern void ospf_packet_free (struct ospf_packet *);
145: extern struct ospf_fifo *ospf_fifo_new (void);
146: extern void ospf_fifo_push (struct ospf_fifo *, struct ospf_packet *);
147: extern struct ospf_packet *ospf_fifo_pop (struct ospf_fifo *);
148: extern struct ospf_packet *ospf_fifo_head (struct ospf_fifo *);
149: extern void ospf_fifo_flush (struct ospf_fifo *);
150: extern void ospf_fifo_free (struct ospf_fifo *);
151: extern void ospf_packet_add (struct ospf_interface *, struct ospf_packet *);
152: extern void ospf_packet_delete (struct ospf_interface *);
153: extern struct stream *ospf_stream_dup (struct stream *);
154: extern struct ospf_packet *ospf_packet_dup (struct ospf_packet *);
155:
156: extern int ospf_read (struct thread *);
157: extern void ospf_hello_send (struct ospf_interface *);
158: extern void ospf_db_desc_send (struct ospf_neighbor *);
159: extern void ospf_db_desc_resend (struct ospf_neighbor *);
160: extern void ospf_ls_req_send (struct ospf_neighbor *);
161: extern void ospf_ls_upd_send_lsa (struct ospf_neighbor *, struct ospf_lsa *,
162: int);
163: extern void ospf_ls_upd_send (struct ospf_neighbor *, struct list *, int);
164: extern void ospf_ls_ack_send (struct ospf_neighbor *, struct ospf_lsa *);
165: extern void ospf_ls_ack_send_delayed (struct ospf_interface *);
166: extern void ospf_ls_retransmit (struct ospf_interface *, struct ospf_lsa *);
167: extern void ospf_ls_req_event (struct ospf_neighbor *);
168:
169: extern int ospf_ls_upd_timer (struct thread *);
170: extern int ospf_ls_ack_timer (struct thread *);
171: extern int ospf_poll_timer (struct thread *);
172: extern int ospf_hello_reply_timer (struct thread *);
173:
1.1.1.2 ! misho 174: extern const struct message ospf_packet_type_str[];
! 175: extern const size_t ospf_packet_type_str_max;
! 176:
1.1 misho 177: #endif /* _ZEBRA_OSPF_PACKET_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>