ifconfig.c (18032) | ifconfig.c (19914) |
---|---|
1/* 2 * Copyright (c) 1983, 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 | 1/* 2 * Copyright (c) 1983, 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 |
34/* 35 * 951109 - Andrew@pubnix.net - Changed to iterative buffer growing mechanism 36 * for ifconfig -a so all interfaces are queried. 37 * 38 * 960101 - peter@freebsd.org - Blow away the SIOCGIFCONF code and use 39 * sysctl() to get the structured interface conf 40 * and parse the messages in there. REALLY UGLY! 41 */ | |
42#ifndef lint | 34#ifndef lint |
43static char copyright[] = | 35static const char copyright[] = |
44"@(#) Copyright (c) 1983, 1993\n\ 45 The Regents of the University of California. All rights reserved.\n"; 46#endif /* not lint */ 47 48#ifndef lint | 36"@(#) Copyright (c) 1983, 1993\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint |
41/* |
|
49static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; | 42static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; |
43*/ 44static const char rcsid[] = 45 "$Id$"; |
|
50#endif /* not lint */ 51 52#include <sys/param.h> | 46#endif /* not lint */ 47 48#include <sys/param.h> |
53#include <sys/socket.h> | |
54#include <sys/ioctl.h> | 49#include <sys/ioctl.h> |
50#include <sys/socket.h> |
|
55#include <sys/sysctl.h> 56 57#include <net/if.h> 58#include <net/if_dl.h> 59#include <net/if_types.h> 60#include <net/route.h> | 51#include <sys/sysctl.h> 52 53#include <net/if.h> 54#include <net/if_dl.h> 55#include <net/if_types.h> 56#include <net/route.h> |
57 58/* IP */ |
|
61#include <netinet/in.h> 62#include <netinet/in_var.h> 63#include <arpa/inet.h> 64#include <netdb.h> 65 | 59#include <netinet/in.h> 60#include <netinet/in_var.h> 61#include <arpa/inet.h> 62#include <netdb.h> 63 |
64/* IPX */ |
|
66#define IPXIP 67#define IPTUNNEL 68#include <netipx/ipx.h> 69#include <netipx/ipx_if.h> 70 | 65#define IPXIP 66#define IPTUNNEL 67#include <netipx/ipx.h> 68#include <netipx/ipx_if.h> 69 |
70/* Appletalk */ |
|
71#include <netatalk/at.h> 72 | 71#include <netatalk/at.h> 72 |
73/* XNS */ |
|
73#ifdef NS 74#define NSIP 75#include <netns/ns.h> 76#include <netns/ns_if.h> 77#endif 78 | 74#ifdef NS 75#define NSIP 76#include <netns/ns.h> 77#include <netns/ns_if.h> 78#endif 79 |
80/* OSI */ |
|
79#ifdef ISO 80#define EON 81#include <netiso/iso.h> 82#include <netiso/iso_var.h> 83#endif | 81#ifdef ISO 82#define EON 83#include <netiso/iso.h> 84#include <netiso/iso_var.h> 85#endif |
84#include <sys/protosw.h> | |
85 86#include <ctype.h> 87#include <err.h> 88#include <errno.h> | 86 87#include <ctype.h> 88#include <err.h> 89#include <errno.h> |
90#include <fcntl.h> |
|
89#include <stdio.h> 90#include <stdlib.h> 91#include <string.h> 92#include <unistd.h> | 91#include <stdio.h> 92#include <stdlib.h> 93#include <string.h> 94#include <unistd.h> |
93#include <nlist.h> 94#include <kvm.h> 95#include <fcntl.h> | |
96 97struct ifreq ifr, ridreq; 98struct ifaliasreq addreq; 99#ifdef ISO 100struct iso_ifreq iso_ridreq; 101struct iso_aliasreq iso_addreq; 102#endif 103struct sockaddr_in netmask; --- 7 unchanged lines hidden (view full) --- 111int nsellength = 1; 112#endif 113int setaddr; 114int setipdst; 115int doalias; 116int clearaddr; 117int newaddr = 1; 118int s; | 95 96struct ifreq ifr, ridreq; 97struct ifaliasreq addreq; 98#ifdef ISO 99struct iso_ifreq iso_ridreq; 100struct iso_aliasreq iso_addreq; 101#endif 102struct sockaddr_in netmask; --- 7 unchanged lines hidden (view full) --- 110int nsellength = 1; 111#endif 112int setaddr; 113int setipdst; 114int doalias; 115int clearaddr; 116int newaddr = 1; 117int s; |
119kvm_t *kvmd; 120extern int errno; | |
121 | 118 |
122int setifflags(), setifaddr(), setifdstaddr(), setifnetmask(); 123int setifmetric(), setifmtu(), setifbroadaddr(), setifipdst(); 124int setatrange(), setatphase(), checkatrange(); 125int notealias(); | 119struct afswtch; 120 121void Perror __P((const char *cmd)); 122void checkatrange __P((struct sockaddr_at *)); 123int ifconfig __P((int argc, char *const *argv, int af, 124 const struct afswtch *rafp)); 125void notealias __P((const char *, int)); 126void printb __P((const char *s, unsigned value, const char *bits)); 127void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *)); 128void status __P((void)); 129 130typedef void c_func __P((const char *cmd, int arg)); 131c_func setatphase, setatrange; 132c_func setifaddr, setifbroadaddr, setifdstaddr, setifnetmask; 133c_func setifipdst; 134c_func setifflags, setifmetric, setifmtu; 135 |
126#ifdef ISO | 136#ifdef ISO |
127int setsnpaoffset(), setnsellength(); | 137c_func setsnpaoffset, setnsellength; |
128#endif | 138#endif |
129int notrailers(); | |
130 131#define NEXTARG 0xffffff 132 | 139 140#define NEXTARG 0xffffff 141 |
142const |
|
133struct cmd { | 143struct cmd { |
134 char *c_name; | 144 const char *c_name; |
135 int c_parameter; /* NEXTARG means next argv */ | 145 int c_parameter; /* NEXTARG means next argv */ |
136 int (*c_func)(); | 146 void (*c_func) __P((const char *, int)); |
137} cmds[] = { 138 { "up", IFF_UP, setifflags } , 139 { "down", -IFF_UP, setifflags }, | 147} cmds[] = { 148 { "up", IFF_UP, setifflags } , 149 { "down", -IFF_UP, setifflags }, |
140 { "trailers", -1, notrailers }, 141 { "-trailers", 1, notrailers }, | |
142 { "arp", -IFF_NOARP, setifflags }, 143 { "-arp", IFF_NOARP, setifflags }, 144 { "debug", IFF_DEBUG, setifflags }, 145 { "-debug", -IFF_DEBUG, setifflags }, 146 { "alias", IFF_UP, notealias }, 147 { "-alias", -IFF_UP, notealias }, 148 { "delete", -IFF_UP, notealias }, 149#ifdef notdef --- 24 unchanged lines hidden (view full) --- 174 { 0, 0, setifaddr }, 175 { 0, 0, setifdstaddr }, 176}; 177 178/* 179 * XNS support liberally adapted from code written at the University of 180 * Maryland principally by James O'Toole and Chris Torek. 181 */ | 150 { "arp", -IFF_NOARP, setifflags }, 151 { "-arp", IFF_NOARP, setifflags }, 152 { "debug", IFF_DEBUG, setifflags }, 153 { "-debug", -IFF_DEBUG, setifflags }, 154 { "alias", IFF_UP, notealias }, 155 { "-alias", -IFF_UP, notealias }, 156 { "delete", -IFF_UP, notealias }, 157#ifdef notdef --- 24 unchanged lines hidden (view full) --- 182 { 0, 0, setifaddr }, 183 { 0, 0, setifdstaddr }, 184}; 185 186/* 187 * XNS support liberally adapted from code written at the University of 188 * Maryland principally by James O'Toole and Chris Torek. 189 */ |
182int in_status(), in_getaddr(); 183int ipx_status(), ipx_getaddr(); 184int at_status(), at_getaddr(); | 190typedef void af_status __P((int)); 191typedef void af_getaddr __P((const char *, int)); 192 193af_status in_status, ipx_status, at_status, ether_status; 194af_getaddr in_getaddr, ipx_getaddr, at_getaddr; 195 |
185#ifdef NS | 196#ifdef NS |
186int xns_status(), xns_getaddr(); | 197af_status xns_status; 198af_getaddr xns_getaddr; |
187#endif 188#ifdef ISO | 199#endif 200#ifdef ISO |
189int iso_status(), iso_getaddr(); | 201af_status iso_status; 202af_getaddr iso_getaddr; |
190#endif | 203#endif |
191int ether_status(); | |
192 193/* Known address families */ | 204 205/* Known address families */ |
194struct afswtch { 195 char *af_name; | 206const 207struct afswtch { 208 const char *af_name; |
196 short af_af; | 209 short af_af; |
197 int (*af_status)(); 198 int (*af_getaddr)(); | 210 af_status *af_status; 211 af_getaddr *af_getaddr; |
199 int af_difaddr; 200 int af_aifaddr; 201 caddr_t af_ridreq; 202 caddr_t af_addreq; 203} afs[] = { 204#define C(x) ((caddr_t) &x) 205 { "inet", AF_INET, in_status, in_getaddr, 206 SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, --- 8 unchanged lines hidden (view full) --- 215#ifdef ISO 216 { "iso", AF_ISO, iso_status, iso_getaddr, 217 SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) }, 218#endif 219 { "ether", AF_INET, ether_status, NULL }, /* XXX not real!! */ 220 { 0, 0, 0, 0 } 221}; 222 | 212 int af_difaddr; 213 int af_aifaddr; 214 caddr_t af_ridreq; 215 caddr_t af_addreq; 216} afs[] = { 217#define C(x) ((caddr_t) &x) 218 { "inet", AF_INET, in_status, in_getaddr, 219 SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) }, --- 8 unchanged lines hidden (view full) --- 228#ifdef ISO 229 { "iso", AF_ISO, iso_status, iso_getaddr, 230 SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) }, 231#endif 232 { "ether", AF_INET, ether_status, NULL }, /* XXX not real!! */ 233 { 0, 0, 0, 0 } 234}; 235 |
223struct afswtch *afp; /*the address family being set or asked about*/ | 236const struct afswtch *afp; /*the address family being set or asked about*/ |
224 | 237 |
225void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *)); 226int ifconfig __P((int argc, char *argv[], int af, struct afswtch *rafp)); 227 228 | |
229/* 230 * Expand the compacted form of addresses as returned via the 231 * configuration read via sysctl(). 232 */ 233 234#define ROUNDUP(a) \ 235 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) 236#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) --- 21 unchanged lines hidden (view full) --- 258 * Apologies to the world for committing gross things like this in 1996.. 259 */ 260struct if_msghdr *ifm; 261struct ifa_msghdr *ifam; 262struct sockaddr_dl *sdl; 263struct rt_addrinfo info; 264char *buf, *lim, *next; 265 | 238/* 239 * Expand the compacted form of addresses as returned via the 240 * configuration read via sysctl(). 241 */ 242 243#define ROUNDUP(a) \ 244 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) 245#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) --- 21 unchanged lines hidden (view full) --- 267 * Apologies to the world for committing gross things like this in 1996.. 268 */ 269struct if_msghdr *ifm; 270struct ifa_msghdr *ifam; 271struct sockaddr_dl *sdl; 272struct rt_addrinfo info; 273char *buf, *lim, *next; 274 |
266 267 | 275int |
268main(argc, argv) 269 int argc; | 276main(argc, argv) 277 int argc; |
270 char *argv[]; | 278 char *const *argv; |
271{ 272 int af = AF_INET; | 279{ 280 int af = AF_INET; |
273 struct afswtch *rafp; | 281 const struct afswtch *rafp; |
274 275 size_t needed; | 282 283 size_t needed; |
276 int mib[6], len; | 284 int mib[6]; |
277 int all; 278 | 285 int all; 286 |
287 rafp = 0; 288 |
|
279 if (argc < 2) { 280 fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s%s%s", 281 "\t[ af [ address [ dest_addr ] ] [ up ] [ down ]", 282 "[ netmask mask ] ]\n", 283 "\t[ metric n ]\n", 284 "\t[ mtu n ]\n", 285 "\t[ arp | -arp ]\n", 286 "\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ] \n", --- 82 unchanged lines hidden (view full) --- 369 name[sdl->sdl_nlen] = '\0'; 370 } 371 372 if ((s = socket(af, SOCK_DGRAM, 0)) < 0) { 373 perror("ifconfig: socket"); 374 exit(1); 375 } 376 | 289 if (argc < 2) { 290 fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s%s%s", 291 "\t[ af [ address [ dest_addr ] ] [ up ] [ down ]", 292 "[ netmask mask ] ]\n", 293 "\t[ metric n ]\n", 294 "\t[ mtu n ]\n", 295 "\t[ arp | -arp ]\n", 296 "\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ] \n", --- 82 unchanged lines hidden (view full) --- 379 name[sdl->sdl_nlen] = '\0'; 380 } 381 382 if ((s = socket(af, SOCK_DGRAM, 0)) < 0) { 383 perror("ifconfig: socket"); 384 exit(1); 385 } 386 |
377 ifconfig(argc,argv,af,rafp); | 387 ifconfig(argc, argv, af, rafp); |
378 379 close(s); 380 381 if (all == 0) { 382 all = -1; /* flag it as 'done' */ 383 break; 384 } 385 } --- 6 unchanged lines hidden (view full) --- 392 exit (0); 393} 394 395 396 397int 398ifconfig(argc,argv,af,rafp) 399 int argc; | 388 389 close(s); 390 391 if (all == 0) { 392 all = -1; /* flag it as 'done' */ 393 break; 394 } 395 } --- 6 unchanged lines hidden (view full) --- 402 exit (0); 403} 404 405 406 407int 408ifconfig(argc,argv,af,rafp) 409 int argc; |
400 char *argv[]; | 410 char *const *argv; |
401 int af; | 411 int af; |
402 struct afswtch *rafp; | 412 const struct afswtch *rafp; |
403{ 404 405 strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); 406 407 if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0) 408 perror("ioctl (SIOCGIFMETRIC)"); 409 else 410 metric = ifr.ifr_metric; --- 4 unchanged lines hidden (view full) --- 415 mtu = ifr.ifr_mtu; 416 417 if (argc == 0) { 418 status(); 419 return(0); 420 } 421 422 while (argc > 0) { | 413{ 414 415 strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); 416 417 if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0) 418 perror("ioctl (SIOCGIFMETRIC)"); 419 else 420 metric = ifr.ifr_metric; --- 4 unchanged lines hidden (view full) --- 425 mtu = ifr.ifr_mtu; 426 427 if (argc == 0) { 428 status(); 429 return(0); 430 } 431 432 while (argc > 0) { |
423 register struct cmd *p; | 433 register const struct cmd *p; |
424 425 for (p = cmds; p->c_name; p++) 426 if (strcmp(*argv, p->c_name) == 0) 427 break; 428 if (p->c_name == 0 && setaddr) 429 p++; /* got src, do dst */ 430 if (p->c_func) { 431 if (p->c_parameter == NEXTARG) { 432 if (argv[1] == NULL) 433 errx(1, "'%s' requires argument", 434 p->c_name); | 434 435 for (p = cmds; p->c_name; p++) 436 if (strcmp(*argv, p->c_name) == 0) 437 break; 438 if (p->c_name == 0 && setaddr) 439 p++; /* got src, do dst */ 440 if (p->c_func) { 441 if (p->c_parameter == NEXTARG) { 442 if (argv[1] == NULL) 443 errx(1, "'%s' requires argument", 444 p->c_name); |
435 (*p->c_func)(argv[1]); | 445 (*p->c_func)(argv[1], 0); |
436 argc--, argv++; 437 } else 438 (*p->c_func)(*argv, p->c_parameter); 439 } 440 argc--, argv++; 441 } 442#ifdef ISO 443 if (af == AF_ISO) --- 55 unchanged lines hidden (view full) --- 499 return(0); 500} 501#define RIDADDR 0 502#define ADDR 1 503#define MASK 2 504#define DSTADDR 3 505 506/*ARGSUSED*/ | 446 argc--, argv++; 447 } else 448 (*p->c_func)(*argv, p->c_parameter); 449 } 450 argc--, argv++; 451 } 452#ifdef ISO 453 if (af == AF_ISO) --- 55 unchanged lines hidden (view full) --- 509 return(0); 510} 511#define RIDADDR 0 512#define ADDR 1 513#define MASK 2 514#define DSTADDR 3 515 516/*ARGSUSED*/ |
517void |
|
507setifaddr(addr, param) | 518setifaddr(addr, param) |
508 char *addr; 509 short param; | 519 const char *addr; 520 int param; |
510{ 511 /* 512 * Delay the ioctl to set the interface addr until flags are all set. 513 * The address interpretation may depend on the flags, 514 * and the flags may change when the address is set. 515 */ 516 setaddr++; 517 if (doalias == 0) 518 clearaddr = 1; 519 (*afp->af_getaddr)(addr, (doalias >= 0 ? ADDR : RIDADDR)); 520} 521 | 521{ 522 /* 523 * Delay the ioctl to set the interface addr until flags are all set. 524 * The address interpretation may depend on the flags, 525 * and the flags may change when the address is set. 526 */ 527 setaddr++; 528 if (doalias == 0) 529 clearaddr = 1; 530 (*afp->af_getaddr)(addr, (doalias >= 0 ? ADDR : RIDADDR)); 531} 532 |
522setifnetmask(addr) 523 char *addr; | 533void 534setifnetmask(addr, dummy) 535 const char *addr; 536 int dummy __unused; |
524{ 525 (*afp->af_getaddr)(addr, MASK); 526} 527 | 537{ 538 (*afp->af_getaddr)(addr, MASK); 539} 540 |
528setifbroadaddr(addr) 529 char *addr; | 541void 542setifbroadaddr(addr, dummy) 543 const char *addr; 544 int dummy __unused; |
530{ 531 (*afp->af_getaddr)(addr, DSTADDR); 532} 533 | 545{ 546 (*afp->af_getaddr)(addr, DSTADDR); 547} 548 |
534setifipdst(addr) 535 char *addr; | 549void 550setifipdst(addr, dummy) 551 const char *addr; 552 int dummy __unused; |
536{ 537 in_getaddr(addr, DSTADDR); 538 setipdst++; 539 clearaddr = 0; 540 newaddr = 0; 541} 542#define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr)) | 553{ 554 in_getaddr(addr, DSTADDR); 555 setipdst++; 556 clearaddr = 0; 557 newaddr = 0; 558} 559#define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr)) |
543/*ARGSUSED*/ | 560 561void |
544notealias(addr, param) | 562notealias(addr, param) |
545 char *addr; | 563 const char *addr; 564 int param; |
546{ 547 if (setaddr && doalias == 0 && param < 0) 548 bcopy((caddr_t)rqtosa(af_addreq), 549 (caddr_t)rqtosa(af_ridreq), 550 rqtosa(af_addreq)->sa_len); 551 doalias = param; 552 if (param < 0) { 553 clearaddr = 1; 554 newaddr = 0; 555 } else 556 clearaddr = 0; 557} 558 559/*ARGSUSED*/ | 565{ 566 if (setaddr && doalias == 0 && param < 0) 567 bcopy((caddr_t)rqtosa(af_addreq), 568 (caddr_t)rqtosa(af_ridreq), 569 rqtosa(af_addreq)->sa_len); 570 doalias = param; 571 if (param < 0) { 572 clearaddr = 1; 573 newaddr = 0; 574 } else 575 clearaddr = 0; 576} 577 578/*ARGSUSED*/ |
560notrailers(vname, value) 561 char *vname; 562 int value; 563{ 564 printf("Note: trailers are no longer sent, but always received\n"); 565} 566 567/*ARGSUSED*/ | 579void |
568setifdstaddr(addr, param) | 580setifdstaddr(addr, param) |
569 char *addr; 570 int param; | 581 const char *addr; 582 int param __unused; |
571{ 572 (*afp->af_getaddr)(addr, DSTADDR); 573} 574 | 583{ 584 (*afp->af_getaddr)(addr, DSTADDR); 585} 586 |
587void |
|
575setifflags(vname, value) | 588setifflags(vname, value) |
576 char *vname; 577 short value; | 589 const char *vname; 590 int value; |
578{ 579 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { 580 Perror("ioctl (SIOCGIFFLAGS)"); 581 exit(1); 582 } 583 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 584 flags = ifr.ifr_flags; 585 586 if (value < 0) { 587 value = -value; 588 flags &= ~value; 589 } else 590 flags |= value; 591 ifr.ifr_flags = flags; 592 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) 593 Perror(vname); 594} 595 | 591{ 592 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { 593 Perror("ioctl (SIOCGIFFLAGS)"); 594 exit(1); 595 } 596 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 597 flags = ifr.ifr_flags; 598 599 if (value < 0) { 600 value = -value; 601 flags &= ~value; 602 } else 603 flags |= value; 604 ifr.ifr_flags = flags; 605 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) 606 Perror(vname); 607} 608 |
596setifmetric(val) 597 char *val; | 609void 610setifmetric(val, dummy) 611 const char *val; 612 int dummy __unused; |
598{ 599 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 600 ifr.ifr_metric = atoi(val); 601 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) 602 perror("ioctl (set metric)"); 603} 604 | 613{ 614 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 615 ifr.ifr_metric = atoi(val); 616 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) 617 perror("ioctl (set metric)"); 618} 619 |
605setifmtu(val) 606 char *val; | 620void 621setifmtu(val, dummy) 622 const char *val; 623 int dummy __unused; |
607{ 608 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 609 ifr.ifr_mtu = atoi(val); 610 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) 611 perror("ioctl (set mtu)"); 612} 613 614#ifdef ISO | 624{ 625 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); 626 ifr.ifr_mtu = atoi(val); 627 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) 628 perror("ioctl (set mtu)"); 629} 630 631#ifdef ISO |
615setsnpaoffset(val) | 632void 633setsnpaoffset(val, dummy) |
616 char *val; | 634 char *val; |
635 int dummy __unused; |
|
617{ 618 iso_addreq.ifra_snpaoffset = atoi(val); 619} 620#endif 621 622#define IFFBITS \ | 636{ 637 iso_addreq.ifra_snpaoffset = atoi(val); 638} 639#endif 640 641#define IFFBITS \ |
623"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\ 624\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST" | 642"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6b6\7RUNNING" \ 643"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \ 644"\20MULTICAST" |
625 626/* 627 * Print the status of the interface. If an address family was 628 * specified, show it and it only; otherwise, show them all. 629 */ | 645 646/* 647 * Print the status of the interface. If an address family was 648 * specified, show it and it only; otherwise, show them all. 649 */ |
650void |
|
630status() 631{ | 651status() 652{ |
632 struct afswtch *p = NULL; 633 short af = ifr.ifr_addr.sa_family; | 653 const struct afswtch *p = NULL; |
634 char *mynext; 635 struct if_msghdr *myifm; 636 637 printf("%s: ", name); 638 printb("flags", flags, IFFBITS); 639 if (metric) 640 printf(" metric %d", metric); 641 if (mtu) --- 41 unchanged lines hidden (view full) --- 683 } 684 } else for (p = afs; p->af_name; p++) { 685 if (p->af_af == info.rti_info[RTAX_IFA]->sa_family && 686 p->af_status != ether_status) 687 (*p->af_status)(0); 688 } 689 } 690 if (afp == NULL || afp->af_status == ether_status) | 654 char *mynext; 655 struct if_msghdr *myifm; 656 657 printf("%s: ", name); 658 printb("flags", flags, IFFBITS); 659 if (metric) 660 printf(" metric %d", metric); 661 if (mtu) --- 41 unchanged lines hidden (view full) --- 703 } 704 } else for (p = afs; p->af_name; p++) { 705 if (p->af_af == info.rti_info[RTAX_IFA]->sa_family && 706 p->af_status != ether_status) 707 (*p->af_status)(0); 708 } 709 } 710 if (afp == NULL || afp->af_status == ether_status) |
691 ether_status(); | 711 ether_status(0); |
692 else if (afp && !p) { 693 warnx("%s has no %s IFA address!", name, afp->af_name); 694 } 695} 696 | 712 else if (afp && !p) { 713 warnx("%s has no %s IFA address!", name, afp->af_name); 714 } 715} 716 |
717void |
|
697in_status(force) 698 int force; 699{ 700 struct sockaddr_in *sin, null_sin; | 718in_status(force) 719 int force; 720{ 721 struct sockaddr_in *sin, null_sin; |
701 char *inet_ntoa(); | |
702 | 722 |
703 | |
704 memset(&null_sin, 0, sizeof(null_sin)); 705 706 sin = (struct sockaddr_in *)info.rti_info[RTAX_IFA]; 707 if (!sin || sin->sin_family != AF_INET) { 708 if (!force) 709 return; 710 /* warnx("%s has no AF_INET IFA address!", name); */ 711 sin = &null_sin; --- 6 unchanged lines hidden (view full) --- 718 if (!sin) 719 sin = &null_sin; 720 printf("--> %s ", inet_ntoa(sin->sin_addr)); 721 } 722 723 sin = (struct sockaddr_in *)info.rti_info[RTAX_NETMASK]; 724 if (!sin) 725 sin = &null_sin; | 723 memset(&null_sin, 0, sizeof(null_sin)); 724 725 sin = (struct sockaddr_in *)info.rti_info[RTAX_IFA]; 726 if (!sin || sin->sin_family != AF_INET) { 727 if (!force) 728 return; 729 /* warnx("%s has no AF_INET IFA address!", name); */ 730 sin = &null_sin; --- 6 unchanged lines hidden (view full) --- 737 if (!sin) 738 sin = &null_sin; 739 printf("--> %s ", inet_ntoa(sin->sin_addr)); 740 } 741 742 sin = (struct sockaddr_in *)info.rti_info[RTAX_NETMASK]; 743 if (!sin) 744 sin = &null_sin; |
726 printf("netmask 0x%x ", ntohl(sin->sin_addr.s_addr)); | 745 printf("netmask 0x%lx ", (unsigned long)ntohl(sin->sin_addr.s_addr)); |
727 728 if (flags & IFF_BROADCAST) { 729 /* note RTAX_BRD overlap with IFF_POINTOPOINT */ 730 sin = (struct sockaddr_in *)info.rti_info[RTAX_BRD]; 731 if (sin && sin->sin_addr.s_addr != 0) 732 printf("broadcast %s", inet_ntoa(sin->sin_addr)); 733 } 734 putchar('\n'); 735} 736 | 746 747 if (flags & IFF_BROADCAST) { 748 /* note RTAX_BRD overlap with IFF_POINTOPOINT */ 749 sin = (struct sockaddr_in *)info.rti_info[RTAX_BRD]; 750 if (sin && sin->sin_addr.s_addr != 0) 751 printf("broadcast %s", inet_ntoa(sin->sin_addr)); 752 } 753 putchar('\n'); 754} 755 |
756void |
|
737ipx_status(force) 738 int force; 739{ 740 struct sockaddr_ipx *sipx, null_sipx; 741 742 close(s); 743 s = socket(AF_IPX, SOCK_DGRAM, 0); 744 if (s < 0) { --- 19 unchanged lines hidden (view full) --- 764 if (!sipx) 765 sipx = &null_sipx; 766 printf("--> %s ", ipx_ntoa(sipx->sipx_addr)); 767 } 768 putchar('\n'); 769 770} 771 | 757ipx_status(force) 758 int force; 759{ 760 struct sockaddr_ipx *sipx, null_sipx; 761 762 close(s); 763 s = socket(AF_IPX, SOCK_DGRAM, 0); 764 if (s < 0) { --- 19 unchanged lines hidden (view full) --- 784 if (!sipx) 785 sipx = &null_sipx; 786 printf("--> %s ", ipx_ntoa(sipx->sipx_addr)); 787 } 788 putchar('\n'); 789 790} 791 |
792void |
|
772at_status(force) 773 int force; 774{ 775 struct sockaddr_at *sat, null_sat; 776 struct netrange *nr; 777 778 memset(&null_sat, 0, sizeof(null_sat)); 779 --- 23 unchanged lines hidden (view full) --- 803 ntohs(sat->sat_addr.s_net), 804 sat->sat_addr.s_node); 805 } 806 807 putchar('\n'); 808} 809 810#ifdef NS | 793at_status(force) 794 int force; 795{ 796 struct sockaddr_at *sat, null_sat; 797 struct netrange *nr; 798 799 memset(&null_sat, 0, sizeof(null_sat)); 800 --- 23 unchanged lines hidden (view full) --- 824 ntohs(sat->sat_addr.s_net), 825 sat->sat_addr.s_node); 826 } 827 828 putchar('\n'); 829} 830 831#ifdef NS |
832void |
|
811xns_status(force) 812 int force; 813{ 814 struct sockaddr_ns *sns, null_sns; 815 816 close(s); 817 s = socket(AF_NS, SOCK_DGRAM, 0); 818 if (s < 0) { --- 20 unchanged lines hidden (view full) --- 839 printf("--> %s ", ns_ntoa(sns->sns_addr)); 840 } 841 842 putchar('\n'); 843} 844#endif 845 846#ifdef ISO | 833xns_status(force) 834 int force; 835{ 836 struct sockaddr_ns *sns, null_sns; 837 838 close(s); 839 s = socket(AF_NS, SOCK_DGRAM, 0); 840 if (s < 0) { --- 20 unchanged lines hidden (view full) --- 861 printf("--> %s ", ns_ntoa(sns->sns_addr)); 862 } 863 864 putchar('\n'); 865} 866#endif 867 868#ifdef ISO |
869void |
|
847iso_status(force) 848 int force; 849{ 850 struct sockaddr_iso *siso, null_siso; 851 852 close(s); 853 s = socket(AF_ISO, SOCK_DGRAM, 0); 854 if (s < 0) { --- 25 unchanged lines hidden (view full) --- 880 siso = &null_siso; 881 printf("--> %s ", iso_ntoa(&siso->siso_addr)); 882 } 883 884 putchar('\n'); 885} 886#endif 887 | 870iso_status(force) 871 int force; 872{ 873 struct sockaddr_iso *siso, null_siso; 874 875 close(s); 876 s = socket(AF_ISO, SOCK_DGRAM, 0); 877 if (s < 0) { --- 25 unchanged lines hidden (view full) --- 903 siso = &null_siso; 904 printf("--> %s ", iso_ntoa(&siso->siso_addr)); 905 } 906 907 putchar('\n'); 908} 909#endif 910 |
888ether_status() | 911void 912ether_status(force) 913 int force __unused; |
889{ 890 char *cp; 891 int n; 892 893 cp = (char *)LLADDR(sdl); 894 if ((n = sdl->sdl_alen) > 0) { 895 if (sdl->sdl_type == IFT_ETHER) 896 printf ("\tether "); 897 else 898 printf ("\tlladdr "); 899 while (--n >= 0) 900 printf("%02x%c",*cp++ & 0xff, n>0? ':' : ' '); 901 putchar('\n'); 902 } 903} 904 | 914{ 915 char *cp; 916 int n; 917 918 cp = (char *)LLADDR(sdl); 919 if ((n = sdl->sdl_alen) > 0) { 920 if (sdl->sdl_type == IFT_ETHER) 921 printf ("\tether "); 922 else 923 printf ("\tlladdr "); 924 while (--n >= 0) 925 printf("%02x%c",*cp++ & 0xff, n>0? ':' : ' '); 926 putchar('\n'); 927 } 928} 929 |
930void |
|
905Perror(cmd) | 931Perror(cmd) |
906 char *cmd; | 932 const char *cmd; |
907{ | 933{ |
908 extern int errno; 909 | |
910 switch (errno) { 911 912 case ENXIO: 913 errx(1, "%s: no such interface", cmd); 914 break; 915 916 case EPERM: 917 errx(1, "%s: permission denied", cmd); 918 break; 919 920 default: 921 err(1, "%s", cmd); 922 } 923} 924 | 934 switch (errno) { 935 936 case ENXIO: 937 errx(1, "%s: no such interface", cmd); 938 break; 939 940 case EPERM: 941 errx(1, "%s: permission denied", cmd); 942 break; 943 944 default: 945 err(1, "%s", cmd); 946 } 947} 948 |
925struct in_addr inet_makeaddr(); 926 | |
927#define SIN(x) ((struct sockaddr_in *) &(x)) 928struct sockaddr_in *sintab[] = { 929SIN(ridreq.ifr_addr), SIN(addreq.ifra_addr), 930SIN(addreq.ifra_mask), SIN(addreq.ifra_broadaddr)}; 931 | 949#define SIN(x) ((struct sockaddr_in *) &(x)) 950struct sockaddr_in *sintab[] = { 951SIN(ridreq.ifr_addr), SIN(addreq.ifra_addr), 952SIN(addreq.ifra_mask), SIN(addreq.ifra_broadaddr)}; 953 |
954void |
|
932in_getaddr(s, which) | 955in_getaddr(s, which) |
933 char *s; | 956 const char *s; 957 int which; |
934{ 935 register struct sockaddr_in *sin = sintab[which]; 936 struct hostent *hp; 937 struct netent *np; | 958{ 959 register struct sockaddr_in *sin = sintab[which]; 960 struct hostent *hp; 961 struct netent *np; |
938 int val; | |
939 940 sin->sin_len = sizeof(*sin); 941 if (which != MASK) 942 sin->sin_family = AF_INET; 943 944 if (inet_aton(s, &sin->sin_addr)) | 962 963 sin->sin_len = sizeof(*sin); 964 if (which != MASK) 965 sin->sin_family = AF_INET; 966 967 if (inet_aton(s, &sin->sin_addr)) |
945 ; 946 else if (hp = gethostbyname(s)) | 968 return; 969 if ((hp = gethostbyname(s)) != 0) |
947 bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length); | 970 bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length); |
948 else if (np = getnetbyname(s)) | 971 else if ((np = getnetbyname(s)) != 0) |
949 sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY); 950 else 951 errx(1, "%s: bad value", s); 952} 953 954/* 955 * Print a value a la the %b format of the kernel's printf 956 */ | 972 sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY); 973 else 974 errx(1, "%s: bad value", s); 975} 976 977/* 978 * Print a value a la the %b format of the kernel's printf 979 */ |
980void |
|
957printb(s, v, bits) | 981printb(s, v, bits) |
958 char *s; 959 register char *bits; 960 register unsigned short v; | 982 const char *s; 983 register unsigned v; 984 register const char *bits; |
961{ 962 register int i, any = 0; 963 register char c; 964 965 if (bits && *bits == 8) 966 printf("%s=%o", s, v); 967 else 968 printf("%s=%x", s, v); 969 bits++; 970 if (bits) { 971 putchar('<'); | 985{ 986 register int i, any = 0; 987 register char c; 988 989 if (bits && *bits == 8) 990 printf("%s=%o", s, v); 991 else 992 printf("%s=%x", s, v); 993 bits++; 994 if (bits) { 995 putchar('<'); |
972 while (i = *bits++) { | 996 while ((i = *bits++) != '\0') { |
973 if (v & (1 << (i-1))) { 974 if (any) 975 putchar(','); 976 any = 1; 977 for (; (c = *bits) > 32; bits++) 978 putchar(c); 979 } else 980 for (; *bits > 32; bits++) 981 ; 982 } 983 putchar('>'); 984 } 985} 986 987#define SIPX(x) ((struct sockaddr_ipx *) &(x)) 988struct sockaddr_ipx *sipxtab[] = { 989SIPX(ridreq.ifr_addr), SIPX(addreq.ifra_addr), 990SIPX(addreq.ifra_mask), SIPX(addreq.ifra_broadaddr)}; 991 | 997 if (v & (1 << (i-1))) { 998 if (any) 999 putchar(','); 1000 any = 1; 1001 for (; (c = *bits) > 32; bits++) 1002 putchar(c); 1003 } else 1004 for (; *bits > 32; bits++) 1005 ; 1006 } 1007 putchar('>'); 1008 } 1009} 1010 1011#define SIPX(x) ((struct sockaddr_ipx *) &(x)) 1012struct sockaddr_ipx *sipxtab[] = { 1013SIPX(ridreq.ifr_addr), SIPX(addreq.ifra_addr), 1014SIPX(addreq.ifra_mask), SIPX(addreq.ifra_broadaddr)}; 1015 |
1016void |
|
992ipx_getaddr(addr, which) | 1017ipx_getaddr(addr, which) |
993char *addr; | 1018 const char *addr; 1019 int which; |
994{ 995 struct sockaddr_ipx *sipx = sipxtab[which]; | 1020{ 1021 struct sockaddr_ipx *sipx = sipxtab[which]; |
996 struct ipx_addr ipx_addr(); | |
997 998 sipx->sipx_family = AF_IPX; 999 sipx->sipx_len = sizeof(*sipx); 1000 sipx->sipx_addr = ipx_addr(addr); 1001 if (which == MASK) 1002 printf("Attempt to set IPX netmask will be ineffectual\n"); 1003} 1004 | 1022 1023 sipx->sipx_family = AF_IPX; 1024 sipx->sipx_len = sizeof(*sipx); 1025 sipx->sipx_addr = ipx_addr(addr); 1026 if (which == MASK) 1027 printf("Attempt to set IPX netmask will be ineffectual\n"); 1028} 1029 |
1005at_getaddr(char *addr, int which) | 1030void 1031at_getaddr(addr, which) 1032 const char *addr; 1033 int which; |
1006{ 1007 struct sockaddr_at *sat = (struct sockaddr_at *) &addreq.ifra_addr; 1008 u_int net, node; 1009 1010 sat->sat_family = AF_APPLETALK; 1011 sat->sat_len = sizeof(*sat); 1012 if (which == MASK) 1013 errx(1, "AppleTalk does not use netmasks\n"); 1014 if (sscanf(addr, "%u.%u", &net, &node) != 2 1015 || net > 0xffff || node > 0xfe) 1016 errx(1, "%s: illegal address", addr); 1017 sat->sat_addr.s_net = htons(net); 1018 sat->sat_addr.s_node = node; 1019} 1020 | 1034{ 1035 struct sockaddr_at *sat = (struct sockaddr_at *) &addreq.ifra_addr; 1036 u_int net, node; 1037 1038 sat->sat_family = AF_APPLETALK; 1039 sat->sat_len = sizeof(*sat); 1040 if (which == MASK) 1041 errx(1, "AppleTalk does not use netmasks\n"); 1042 if (sscanf(addr, "%u.%u", &net, &node) != 2 1043 || net > 0xffff || node > 0xfe) 1044 errx(1, "%s: illegal address", addr); 1045 sat->sat_addr.s_net = htons(net); 1046 sat->sat_addr.s_node = node; 1047} 1048 |
1021setatrange(char *range) | 1049/* XXX FIXME -- should use strtoul for better parsing. */ 1050void 1051setatrange(range, dummy) 1052 const char *range; 1053 int dummy __unused; |
1022{ 1023 u_short first = 123, last = 123; 1024 1025 if (sscanf(range, "%hu-%hu", &first, &last) != 2 1026 || first == 0 || first > 0xffff 1027 || last == 0 || last > 0xffff || first > last) 1028 errx(1, "%s: illegal net range: %u-%u", range, first, last); 1029 at_nr.nr_firstnet = htons(first); 1030 at_nr.nr_lastnet = htons(last); 1031} 1032 | 1054{ 1055 u_short first = 123, last = 123; 1056 1057 if (sscanf(range, "%hu-%hu", &first, &last) != 2 1058 || first == 0 || first > 0xffff 1059 || last == 0 || last > 0xffff || first > last) 1060 errx(1, "%s: illegal net range: %u-%u", range, first, last); 1061 at_nr.nr_firstnet = htons(first); 1062 at_nr.nr_lastnet = htons(last); 1063} 1064 |
1033setatphase(char *phase) | 1065void 1066setatphase(phase, dummy) 1067 const char *phase; 1068 int dummy __unused; |
1034{ 1035 if (!strcmp(phase, "1")) 1036 at_nr.nr_phase = 1; 1037 else if (!strcmp(phase, "2")) 1038 at_nr.nr_phase = 2; 1039 else 1040 errx(1, "%s: illegal phase", phase); 1041} 1042 | 1069{ 1070 if (!strcmp(phase, "1")) 1071 at_nr.nr_phase = 1; 1072 else if (!strcmp(phase, "2")) 1073 at_nr.nr_phase = 2; 1074 else 1075 errx(1, "%s: illegal phase", phase); 1076} 1077 |
1078void |
|
1043checkatrange(struct sockaddr_at *sat) 1044{ 1045 if (at_nr.nr_phase == 0) 1046 at_nr.nr_phase = 2; /* Default phase 2 */ 1047 if (at_nr.nr_firstnet == 0) 1048 at_nr.nr_firstnet = /* Default range of one */ 1049 at_nr.nr_lastnet = sat->sat_addr.s_net; 1050printf("\tatalk %d.%d range %d-%d phase %d\n", --- 8 unchanged lines hidden (view full) --- 1059} 1060 1061#ifdef NS 1062#define SNS(x) ((struct sockaddr_ns *) &(x)) 1063struct sockaddr_ns *snstab[] = { 1064SNS(ridreq.ifr_addr), SNS(addreq.ifra_addr), 1065SNS(addreq.ifra_mask), SNS(addreq.ifra_broadaddr)}; 1066 | 1079checkatrange(struct sockaddr_at *sat) 1080{ 1081 if (at_nr.nr_phase == 0) 1082 at_nr.nr_phase = 2; /* Default phase 2 */ 1083 if (at_nr.nr_firstnet == 0) 1084 at_nr.nr_firstnet = /* Default range of one */ 1085 at_nr.nr_lastnet = sat->sat_addr.s_net; 1086printf("\tatalk %d.%d range %d-%d phase %d\n", --- 8 unchanged lines hidden (view full) --- 1095} 1096 1097#ifdef NS 1098#define SNS(x) ((struct sockaddr_ns *) &(x)) 1099struct sockaddr_ns *snstab[] = { 1100SNS(ridreq.ifr_addr), SNS(addreq.ifra_addr), 1101SNS(addreq.ifra_mask), SNS(addreq.ifra_broadaddr)}; 1102 |
1103void |
|
1067xns_getaddr(addr, which) | 1104xns_getaddr(addr, which) |
1068char *addr; | 1105 const char *addr; 1106 int which; |
1069{ 1070 struct sockaddr_ns *sns = snstab[which]; | 1107{ 1108 struct sockaddr_ns *sns = snstab[which]; |
1071 struct ns_addr ns_addr(); | |
1072 1073 sns->sns_family = AF_NS; 1074 sns->sns_len = sizeof(*sns); 1075 sns->sns_addr = ns_addr(addr); 1076 if (which == MASK) 1077 printf("Attempt to set XNS netmask will be ineffectual\n"); 1078} 1079#endif 1080 1081#ifdef ISO 1082#define SISO(x) ((struct sockaddr_iso *) &(x)) 1083struct sockaddr_iso *sisotab[] = { 1084SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr), 1085SISO(iso_addreq.ifra_mask), SISO(iso_addreq.ifra_dstaddr)}; 1086 | 1109 1110 sns->sns_family = AF_NS; 1111 sns->sns_len = sizeof(*sns); 1112 sns->sns_addr = ns_addr(addr); 1113 if (which == MASK) 1114 printf("Attempt to set XNS netmask will be ineffectual\n"); 1115} 1116#endif 1117 1118#ifdef ISO 1119#define SISO(x) ((struct sockaddr_iso *) &(x)) 1120struct sockaddr_iso *sisotab[] = { 1121SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr), 1122SISO(iso_addreq.ifra_mask), SISO(iso_addreq.ifra_dstaddr)}; 1123 |
1124void |
|
1087iso_getaddr(addr, which) 1088char *addr; 1089{ 1090 register struct sockaddr_iso *siso = sisotab[which]; 1091 struct iso_addr *iso_addr(); 1092 siso->siso_addr = *iso_addr(addr); 1093 1094 if (which == MASK) { 1095 siso->siso_len = TSEL(siso) - (caddr_t)(siso); 1096 siso->siso_nlen = 0; 1097 } else { 1098 siso->siso_len = sizeof(*siso); 1099 siso->siso_family = AF_ISO; 1100 } 1101} 1102 | 1125iso_getaddr(addr, which) 1126char *addr; 1127{ 1128 register struct sockaddr_iso *siso = sisotab[which]; 1129 struct iso_addr *iso_addr(); 1130 siso->siso_addr = *iso_addr(addr); 1131 1132 if (which == MASK) { 1133 siso->siso_len = TSEL(siso) - (caddr_t)(siso); 1134 siso->siso_nlen = 0; 1135 } else { 1136 siso->siso_len = sizeof(*siso); 1137 siso->siso_family = AF_ISO; 1138 } 1139} 1140 |
1141void |
|
1103setnsellength(val) 1104 char *val; 1105{ 1106 nsellength = atoi(val); 1107 if (nsellength < 0) 1108 errx(1, "Negative NSEL length is absurd"); 1109 if (afp == 0 || afp->af_af != AF_ISO) 1110 errx(1, "Setting NSEL length valid only for iso"); 1111} 1112 | 1142setnsellength(val) 1143 char *val; 1144{ 1145 nsellength = atoi(val); 1146 if (nsellength < 0) 1147 errx(1, "Negative NSEL length is absurd"); 1148 if (afp == 0 || afp->af_af != AF_ISO) 1149 errx(1, "Setting NSEL length valid only for iso"); 1150} 1151 |
1152void |
|
1113fixnsel(s) 1114register struct sockaddr_iso *s; 1115{ 1116 if (s->siso_family == 0) 1117 return; 1118 s->siso_tlen = nsellength; 1119} 1120 | 1153fixnsel(s) 1154register struct sockaddr_iso *s; 1155{ 1156 if (s->siso_family == 0) 1157 return; 1158 s->siso_tlen = nsellength; 1159} 1160 |
1161void |
|
1121adjust_nsellength() 1122{ 1123 fixnsel(sisotab[RIDADDR]); 1124 fixnsel(sisotab[ADDR]); 1125 fixnsel(sisotab[DSTADDR]); 1126} 1127#endif | 1162adjust_nsellength() 1163{ 1164 fixnsel(sisotab[RIDADDR]); 1165 fixnsel(sisotab[ADDR]); 1166 fixnsel(sisotab[DSTADDR]); 1167} 1168#endif |