2 * $Id: ospf_hello.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
5 * ospf_hello.c - OSPF Hello 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"
41 main(int argc, char **argv)
44 u_char *pack, *to, *from, *neighbor;
45 u_long src, dst, addaid, addrid, nbr, auth[2];
54 len = LIBNET_OSPF_H + LIBNET_HELLO_H + LIBNET_IP_H + LIBNET_AUTH_H;
55 pack = (u_char *)malloc(len);
57 sock = libnet_open_raw_sock(IPPROTO_RAW);
65 src = libnet_name_resolve(from, 0);
66 dst = libnet_name_resolve(to, 0);
67 nbr = libnet_name_resolve(neighbor, 0);
70 addaid = 0xc0ffee00; /* GENERIC : FAKE : ETC */
72 libnet_build_ip(LIBNET_OSPF_H + LIBNET_AUTH_H + LIBNET_HELLO_H, 0x00,
73 101, IP_DF, 254, IPPROTO_OSPF, src, dst, NULL, 0, pack);
78 libnet_build_ospf(LIBNET_HELLO_H + LIBNET_AUTH_H, LIBNET_OSPF_HELLO,
79 addrid, addaid, LIBNET_OSPF_AUTH_NULL, NULL, 0, pack +
82 LIBNET_OSPF_AUTHCPY(pack + LIBNET_IP_H + LIBNET_OSPF_H, auth);
84 libnet_build_ospf_hello(0xffffffff, 2, 0x00, 0x00, 30, src, src, nbr,
85 NULL, 0, pack + LIBNET_IP_H + LIBNET_OSPF_H + LIBNET_AUTH_H);
87 libnet_do_checksum(pack, IPPROTO_OSPF, len);
89 warn = libnet_write_ip(sock, pack, len);
91 printf("Error sending: %d bytes written : %s\n", warn, strerror(errno));
95 printf("%d bytes written\n", warn);
104 printf("Usage: %s <source ip> <dest. ip> <neighbor>\n", pname);
105 printf("[Use x.x.x.x format]\n");