1/* $KAME: rip6query.c,v 1.11 2001/05/08 04:36:37 itojun Exp $ */ 2 |
3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 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 29 * SUCH DAMAGE. 30 * |
31 * $FreeBSD: head/usr.sbin/rip6query/rip6query.c 78064 2001-06-11 12:39:29Z ume $ |
32 */ 33 34#include <stdio.h> 35 36#include <unistd.h> 37#include <stdlib.h> 38#include <string.h> 39#include <ctype.h> 40#include <signal.h> 41#include <errno.h> 42#include <err.h> 43 44#include <sys/types.h> 45#include <sys/socket.h> |
46#include <sys/queue.h> 47 |
48#include <net/if.h> 49#if defined(__FreeBSD__) && __FreeBSD__ >= 3 50#include <net/if_var.h> 51#endif /* __FreeBSD__ >= 3 */ 52#include <netinet/in.h> 53#include <netinet/in_var.h> 54#include <arpa/inet.h> 55#include <netdb.h> --- 25 unchanged lines hidden (view full) --- 81 struct sockaddr_in6 fsock; 82 int i, n, len, flen; 83 int c; 84 int ifidx = -1; 85 int error; 86 char pbuf[10]; 87 struct addrinfo hints, *res; 88 |
89 while ((c = getopt(argc, argv, "I:")) != -1) { |
90 switch (c) { 91 case 'I': 92 ifidx = if_nametoindex(optarg); 93 if (ifidx == 0) { 94 errx(1, "invalid interface %s", optarg); 95 /*NOTREACHED*/ 96 } 97 break; 98 default: 99 usage(); 100 exit(1); 101 /*NOTREACHED*/ 102 } 103 } 104 argv += optind; 105 argc -= optind; 106 107 if (argc != 1) { 108 usage(); |
109 exit(1); |
110 } 111 112 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { 113 err(1, "socket"); 114 /*NOTREACHED*/ 115 } 116 117 /* getaddrinfo is preferred for addr@ifname syntax */ --- 91 unchanged lines hidden --- |