2 * $Id: ospf_lsa.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
5 * ospf_lsa.c - OSPF LSA packet builder
7 * Copyright (c) 1999, 2000 Andrew Reiter <areiter@bindview.com>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "../../include/config.h"
36 #include "../libnet_test.h"
42 main(int argc, char **argv)
47 u_long src, dst, addrid, addaid, auth[2];
52 len = LIBNET_IP_H + LIBNET_OSPF_H + LIBNET_AUTH_H + LIBNET_LSA_H +
54 pack = (u_char *)malloc(len);
59 src = libnet_name_resolve(from, 0);
60 dst = libnet_name_resolve(to, 0);
65 sock = libnet_open_raw_sock(IPPROTO_RAW);
72 libnet_build_ip(LIBNET_OSPF_H + LIBNET_AUTH_H + LIBNET_LSA_H +
85 libnet_build_ospf(LIBNET_AUTH_H + LIBNET_LSA_H + LIBNET_LS_NET_LEN,
89 LIBNET_OSPF_AUTH_NULL,
94 memset(auth, 0, sizeof(auth));
95 LIBNET_OSPF_AUTHCPY(pack + LIBNET_OSPF_H + LIBNET_IP_H, auth);
97 libnet_build_ospf_lsa(40,
106 pack + LIBNET_AUTH_H + LIBNET_OSPF_H + LIBNET_IP_H);
108 libnet_build_ospf_lsa_net(0xffffff00,
112 pack + LIBNET_LSA_H + LIBNET_AUTH_H +
113 LIBNET_OSPF_H + LIBNET_IP_H);
115 libnet_do_checksum(pack, IPPROTO_OSPF, len);
116 libnet_do_checksum(pack + LIBNET_IP_H + LIBNET_OSPF_H + LIBNET_AUTH_H,
117 IPPROTO_OSPF_LSA, LIBNET_LS_NET_LEN + LIBNET_LSA_H);
120 warn = libnet_write_ip(sock, pack, len);
122 printf("Error writing packet to the wire\n");
127 printf("%d bytes written\n", warn);
135 printf("Usage: %s <source ip> <dest. ip>\n", pname);
136 printf("[Use x.x.x.x format]\n");