00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __LIBNET_OSPF_H
00036 #define __LIBNET_OSPF_H
00037
00038 #include <sys/types.h>
00039
00040
00041
00042
00043
00044 #ifndef IPPROTO_OSPF
00045 #define IPPROTO_OSPF 89
00046 #endif
00047 #define IPPROTO_OSPF_LSA 890
00048 #define OSPFVERSION 2
00049 #define LIBNET_MODX 4102
00050
00051
00052
00053
00054
00055 #define LIBNET_OSPF_H 0x10
00056 #define LIBNET_HELLO_H 0x18
00057 #define LIBNET_DBD_H 0x8
00058 #define LIBNET_LSR_H 0xc
00059 #define LIBNET_LSU_H 0x4
00060 #define LIBNET_LSA_H 0x14
00061 #define LIBNET_AUTH_H 0x8
00062 #define LIBNET_OSPF_CKSUM 0x10
00063
00064
00065
00066
00067
00068 #define LIBNET_LS_RTR_LEN 0x10
00069 #define LIBNET_LS_NET_LEN 0x8
00070 #define LIBNET_LS_SUM_LEN 0xc
00071 #define LIBNET_LS_AS_EXT_LEN 0x10
00072
00073
00074
00075
00076
00077 struct libnet_ospf_hdr
00078 {
00079 u_char ospf_v;
00080 u_char ospf_type;
00081 #define LIBNET_OSPF_UMD 0
00082 #define LIBNET_OSPF_HELLO 1
00083 #define LIBNET_OSPF_DBD 2
00084 #define LIBNET_OSPF_LSR 3
00085 #define LIBNET_OSPF_LSU 4
00086 #define LIBNET_OSPF_LSA 5
00087 u_short ospf_len;
00088 struct in_addr ospf_rtr_id;
00089 struct in_addr ospf_area_id;
00090 u_short ospf_cksum;
00091 u_short ospf_auth_type;
00092 #define LIBNET_OSPF_AUTH_NULL 0
00093 #define LIBNET_OSPF_AUTH_SIMPLE 1
00094 #define LIBNET_OSPF_AUTH_MD5 2
00095 };
00096
00097
00098
00099
00100
00101 struct libnet_auth_hdr
00102 {
00103 u_short ospf_auth_null;
00104 u_char ospf_auth_keyid;
00105 u_char ospf_auth_len;
00106 u_int ospf_auth_seq;
00107 };
00108
00109
00110
00111
00112
00113
00114 #define LIBNET_OPT_EBIT 0x02
00115 #define LIBNET_OPT_MCBIT 0x04
00116 #define LIBNET_OPT_NPBIT 0x08
00117 #define LIBNET_OPT_EABIT 0x10
00118 #define LIBNET_OPT_DCBIT 0x20
00119
00120
00121
00122
00123
00124 struct libnet_ospf_hello_hdr
00125 {
00126 struct in_addr hello_nmask;
00127 u_short hello_intrvl;
00128 u_char hello_opts;
00129 u_char hello_rtr_pri;
00130 u_int hello_dead_intvl;
00131 struct in_addr hello_des_rtr;
00132 struct in_addr hello_bkup_rtr;
00133 struct in_addr hello_nbr;
00134 };
00135
00136
00137
00138
00139
00140 struct libnet_dbd_hdr
00141 {
00142 u_short dbd_mtu_len;
00143 u_char dbd_opts;
00144 u_char dbd_type;
00145 #define LIBNET_DBD_IBIT 0x01
00146 #define LIBNET_DBD_MBIT 0x02
00147 #define LIBNET_DBD_MSBIT 0x04
00148 u_int dbd_seq;
00149 };
00150
00151
00152
00153
00154
00155 #define LIBNET_LS_TYPE_RTR 1
00156 #define LIBNET_LS_TYPE_NET 2
00157 #define LIBNET_LS_TYPE_IP 3
00158 #define LIBNET_LS_TYPE_ASBR 4
00159 #define LIBNET_LS_TYPE_ASEXT 5
00160
00161
00162
00163
00164
00165 struct libnet_lsr_hdr
00166 {
00167 u_int lsr_type;
00168 u_int lsr_lsid;
00169 struct in_addr lsr_adrtr;
00170 };
00171
00172
00173
00174
00175
00176 struct libnet_lsu_hdr
00177 {
00178 u_int lsu_num;
00179 };
00180
00181
00182
00183
00184
00185 struct libnet_lsa_hdr
00186 {
00187 u_short lsa_age;
00188 u_char lsa_opts;
00189 u_char lsa_type;
00190 u_int lsa_id;
00191 struct in_addr lsa_adv;
00192 u_int lsa_seq;
00193 u_char lsa_cksum[2];
00194 u_short lsa_len;
00195 };
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 struct libnet_rtr_lsa_hdr
00206 {
00207 u_short rtr_flags;
00208 #define LIBNET_RTR_FLAGS_W 0x0100
00209 #define LIBNET_RTR_FLAGS_E 0x0200
00210 #define LIBNET_RTR_FLAGS_B 0x0400
00211 u_short rtr_num;
00212 u_int rtr_link_id;
00213 #define LIBNET_LINK_ID_NBR_ID 1
00214 #define LIBNET_LINK_ID_IP_DES 2
00215 #define LIBNET_LINK_ID_SUB 3
00216 u_int rtr_link_data;
00217 u_char rtr_type;
00218 #define LIBNET_RTR_TYPE_PTP 1
00219 #define LIBNET_RTR_TYPE_TRANS 2
00220 #define LIBNET_RTR_TYPE_STUB 3
00221 #define RTR_TYPE_VRTL 4
00222 u_char rtr_tos_num;
00223 u_short rtr_metric;
00224 };
00225
00226
00227
00228
00229
00230 struct libnet_net_lsa_hdr
00231 {
00232 struct in_addr net_nmask;
00233 u_int net_rtr_id;
00234 };
00235
00236
00237
00238
00239
00240 struct libnet_sum_lsa_hdr
00241 {
00242 struct in_addr sum_nmask;
00243 u_int sum_metric;
00244 u_int sum_tos_metric;
00245 };
00246
00247
00248
00249
00250
00251
00252
00253 struct libnet_as_lsa_hdr
00254 {
00255 struct in_addr as_nmask;
00256 u_int as_metric;
00257 #define LIBNET_AS_E_BIT_ON 0x80000000
00258 struct in_addr as_fwd_addr;
00259 u_int as_rte_tag;
00260 };
00261
00262
00263 int
00264 libnet_build_ospf(
00265 u_short,
00266 u_char,
00267 u_long,
00268 u_long,
00269 u_short,
00270 const char *,
00271 int,
00272 u_char *
00273 );
00274
00275
00276 int
00277 libnet_build_ospf_hello(
00278 u_long,
00279 u_short,
00280 u_char,
00281 u_char,
00282 u_int,
00283 u_long,
00284 u_long,
00285 u_long,
00286 const char *,
00287 int,
00288 u_char *
00289 );
00290
00291
00292 int
00293 libnet_build_ospf_dbd(
00294 u_short,
00295 u_char,
00296 u_char,
00297 u_int,
00298 const char *,
00299 int,
00300 u_char *
00301 );
00302
00303
00304 int
00305 libnet_build_ospf_lsr(
00306 u_int,
00307 u_int,
00308 u_long,
00309 const char *,
00310 int,
00311 u_char *
00312 );
00313
00314
00315 int
00316 libnet_build_ospf_lsu(
00317 u_int,
00318 const char *,
00319 int,
00320 u_char *
00321 );
00322
00323
00324 int
00325 libnet_build_ospf_lsa(
00326 u_short,
00327 u_char,
00328 u_char,
00329 u_int,
00330 u_long,
00331 u_int,
00332 u_short,
00333 const char *,
00334 int,
00335 u_char *
00336 );
00337
00338
00339 int
00340 libnet_build_ospf_lsa_rtr(
00341 u_short,
00342 u_short,
00343 u_int,
00344 u_int,
00345 u_char,
00346 u_char,
00347 u_short,
00348 const char *,
00349 int,
00350 u_char *
00351 );
00352
00353
00354 int
00355 libnet_build_ospf_lsa_net(
00356 u_long,
00357 u_int,
00358 const char *,
00359 int,
00360 u_char *
00361 );
00362
00363
00364 int
00365 libnet_build_ospf_lsa_sum(
00366 u_long,
00367 u_int,
00368 u_int,
00369 const char *,
00370 int,
00371 u_char *
00372 );
00373
00374
00375 int
00376 libnet_build_ospf_lsa_as(
00377 u_long,
00378 u_int,
00379 u_long,
00380 u_int,
00381 const char *,
00382 int,
00383 u_char *
00384 );
00385
00386
00387 void
00388 libnet_ospf_lsa_checksum(
00389 u_char *,
00390 int
00391 );
00392
00393
00394 #endif