route.c (78139) | route.c (78140) |
---|---|
1/* 2 * Copyright (c) 1983, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; 43#endif 44static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/sbin/route/route.c 78139 2001-06-12 13:23:43Z ru $"; | 45 "$FreeBSD: head/sbin/route/route.c 78140 2001-06-12 13:31:53Z ru $"; |
46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/file.h> 50#include <sys/socket.h> 51#include <sys/ioctl.h> 52#include <sys/sysctl.h> 53#include <sys/types.h> 54 55#include <net/if.h> 56#include <net/route.h> 57#include <net/if_dl.h> 58#include <netinet/in.h> | 46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/file.h> 50#include <sys/socket.h> 51#include <sys/ioctl.h> 52#include <sys/sysctl.h> 53#include <sys/types.h> 54 55#include <net/if.h> 56#include <net/route.h> 57#include <net/if_dl.h> 58#include <netinet/in.h> |
59#include <netinet/if_ether.h> |
|
59#include <netatalk/at.h> 60#ifdef NS 61#include <netns/ns.h> 62#endif 63#include <arpa/inet.h> 64#include <netdb.h> 65 66#include <ctype.h> --- 22 unchanged lines hidden (view full) --- 89#ifdef INET6 90 struct sockaddr_in6 sin6; 91#endif 92 struct sockaddr_at sat; 93#ifdef NS 94 struct sockaddr_ns sns; 95#endif 96 struct sockaddr_dl sdl; | 60#include <netatalk/at.h> 61#ifdef NS 62#include <netns/ns.h> 63#endif 64#include <arpa/inet.h> 65#include <netdb.h> 66 67#include <ctype.h> --- 22 unchanged lines hidden (view full) --- 90#ifdef INET6 91 struct sockaddr_in6 sin6; 92#endif 93 struct sockaddr_at sat; 94#ifdef NS 95 struct sockaddr_ns sns; 96#endif 97 struct sockaddr_dl sdl; |
98 struct sockaddr_inarp sinarp; |
|
97 struct sockaddr_storage ss; /* added to avoid memory overrun */ 98} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp; 99 100typedef union sockunion *sup; 101int pid, rtm_addrs, uid; 102int s; 103int forcehost, forcenet, doflush, nflag, af, qflag, tflag, keyword(); 104int iflag, verbose, aflen = sizeof (struct sockaddr_in); --- 471 unchanged lines hidden (view full) --- 576} 577 578void 579newroute(argc, argv) 580 int argc; 581 register char **argv; 582{ 583 char *cmd, *dest = "", *gateway = "", *err; | 99 struct sockaddr_storage ss; /* added to avoid memory overrun */ 100} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp; 101 102typedef union sockunion *sup; 103int pid, rtm_addrs, uid; 104int s; 105int forcehost, forcenet, doflush, nflag, af, qflag, tflag, keyword(); 106int iflag, verbose, aflen = sizeof (struct sockaddr_in); --- 471 unchanged lines hidden (view full) --- 578} 579 580void 581newroute(argc, argv) 582 int argc; 583 register char **argv; 584{ 585 char *cmd, *dest = "", *gateway = "", *err; |
584 int ishost = 0, ret, attempts, oerrno, flags = RTF_STATIC; | 586 int ishost = 0, proxy = 0, ret, attempts, oerrno, flags = RTF_STATIC; |
585 int key; 586 struct hostent *hp = 0; 587 588 if (uid) { 589 errx(EX_NOPERM, "must be root to alter routing table"); 590 } 591 cmd = argv[0]; 592 if (*cmd != 'g') --- 55 unchanged lines hidden (view full) --- 648 flags |= RTF_BLACKHOLE; 649 break; 650 case K_PROTO1: 651 flags |= RTF_PROTO1; 652 break; 653 case K_PROTO2: 654 flags |= RTF_PROTO2; 655 break; | 587 int key; 588 struct hostent *hp = 0; 589 590 if (uid) { 591 errx(EX_NOPERM, "must be root to alter routing table"); 592 } 593 cmd = argv[0]; 594 if (*cmd != 'g') --- 55 unchanged lines hidden (view full) --- 650 flags |= RTF_BLACKHOLE; 651 break; 652 case K_PROTO1: 653 flags |= RTF_PROTO1; 654 break; 655 case K_PROTO2: 656 flags |= RTF_PROTO2; 657 break; |
658 case K_PROXY: 659 proxy = 1; 660 break; |
|
656 case K_CLONING: 657 flags |= RTF_CLONING; 658 break; 659 case K_XRESOLVE: 660 flags |= RTF_XRESOLVE; 661 break; 662 case K_STATIC: 663 flags |= RTF_STATIC; --- 81 unchanged lines hidden (view full) --- 745 } 746 if (forcenet) 747 ishost = 0; 748 flags |= RTF_UP; 749 if (ishost) 750 flags |= RTF_HOST; 751 if (iflag == 0) 752 flags |= RTF_GATEWAY; | 661 case K_CLONING: 662 flags |= RTF_CLONING; 663 break; 664 case K_XRESOLVE: 665 flags |= RTF_XRESOLVE; 666 break; 667 case K_STATIC: 668 flags |= RTF_STATIC; --- 81 unchanged lines hidden (view full) --- 750 } 751 if (forcenet) 752 ishost = 0; 753 flags |= RTF_UP; 754 if (ishost) 755 flags |= RTF_HOST; 756 if (iflag == 0) 757 flags |= RTF_GATEWAY; |
758 if (proxy) { 759 so_dst.sinarp.sin_other = SIN_PROXY; 760 flags |= RTF_ANNOUNCE; 761 } |
|
753 for (attempts = 1; ; attempts++) { 754 errno = 0; 755 if ((ret = rtmsg(*cmd, flags)) == 0) 756 break; 757 if (errno != ENETUNREACH && errno != ESRCH) 758 break; 759 if (af == AF_INET && *gateway && hp && hp->h_addr_list[1]) { 760 hp->h_addr_list++; --- 901 unchanged lines hidden --- | 762 for (attempts = 1; ; attempts++) { 763 errno = 0; 764 if ((ret = rtmsg(*cmd, flags)) == 0) 765 break; 766 if (errno != ENETUNREACH && errno != ESRCH) 767 break; 768 if (af == AF_INET && *gateway && hp && hp->h_addr_list[1]) { 769 hp->h_addr_list++; --- 901 unchanged lines hidden --- |