ifconfig.c (138671) | ifconfig.c (139494) |
---|---|
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 --- 24 unchanged lines hidden (view full) --- 33 The Regents of the University of California. All rights reserved.\n"; 34#endif /* not lint */ 35 36#ifndef lint 37#if 0 38static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; 39#endif 40static const char rcsid[] = | 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 --- 24 unchanged lines hidden (view full) --- 33 The Regents of the University of California. All rights reserved.\n"; 34#endif /* not lint */ 35 36#ifndef lint 37#if 0 38static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; 39#endif 40static const char rcsid[] = |
41 "$FreeBSD: head/sbin/ifconfig/ifconfig.c 138671 2004-12-11 02:33:33Z sam $"; | 41 "$FreeBSD: head/sbin/ifconfig/ifconfig.c 139494 2004-12-31 19:46:27Z sam $"; |
42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/ioctl.h> 46#include <sys/socket.h> 47#include <sys/sysctl.h> 48#include <sys/time.h> 49#include <sys/module.h> --- 47 unchanged lines hidden (view full) --- 97static void status(const struct afswtch *afp, int addrcount, 98 struct sockaddr_dl *sdl, struct if_msghdr *ifm, 99 struct ifa_msghdr *ifam); 100static void tunnel_status(int s); 101static void usage(void); 102 103static struct afswtch *af_getbyname(const char *name); 104static struct afswtch *af_getbyfamily(int af); | 42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/ioctl.h> 46#include <sys/socket.h> 47#include <sys/sysctl.h> 48#include <sys/time.h> 49#include <sys/module.h> --- 47 unchanged lines hidden (view full) --- 97static void status(const struct afswtch *afp, int addrcount, 98 struct sockaddr_dl *sdl, struct if_msghdr *ifm, 99 struct ifa_msghdr *ifam); 100static void tunnel_status(int s); 101static void usage(void); 102 103static struct afswtch *af_getbyname(const char *name); 104static struct afswtch *af_getbyfamily(int af); |
105static void af_all_status(int, const struct rt_addrinfo *sdl); | 105static void af_other_status(int); |
106 107static struct option *opts = NULL; 108 109void 110opt_register(struct option *p) 111{ 112 p->next = opts; 113 opts = p; --- 272 unchanged lines hidden (view full) --- 386 387 for (afp = afs; afp != NULL; afp = afp->af_next) 388 if (afp->af_af == af) 389 return afp; 390 return NULL; 391} 392 393static void | 106 107static struct option *opts = NULL; 108 109void 110opt_register(struct option *p) 111{ 112 p->next = opts; 113 opts = p; --- 272 unchanged lines hidden (view full) --- 386 387 for (afp = afs; afp != NULL; afp = afp->af_next) 388 if (afp->af_af == af) 389 return afp; 390 return NULL; 391} 392 393static void |
394af_all_status(int s, const struct rt_addrinfo *sdl) | 394af_other_status(int s) |
395{ 396 struct afswtch *afp; 397 uint8_t afmask[howmany(AF_MAX, NBBY)]; 398 399 memset(afmask, 0, sizeof(afmask)); 400 for (afp = afs; afp != NULL; afp = afp->af_next) { | 395{ 396 struct afswtch *afp; 397 uint8_t afmask[howmany(AF_MAX, NBBY)]; 398 399 memset(afmask, 0, sizeof(afmask)); 400 for (afp = afs; afp != NULL; afp = afp->af_next) { |
401 if (afp->af_status == NULL) | 401 if (afp->af_other_status == NULL) |
402 continue; 403 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af)) 404 continue; | 402 continue; 403 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af)) 404 continue; |
405 afp->af_status(s, sdl); | 405 afp->af_other_status(s); |
406 setbit(afmask, afp->af_af); 407 } 408} 409 410static void 411af_all_tunnel_status(int s) 412{ 413 struct afswtch *afp; --- 457 unchanged lines hidden (view full) --- 871 p = af_getbyfamily(info.rti_info[RTAX_IFA]->sa_family); 872 if (p != NULL) 873 p->af_status(s, &info); 874 } else if (afp->af_af == info.rti_info[RTAX_IFA]->sa_family) 875 afp->af_status(s, &info); 876 addrcount--; 877 ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen); 878 } | 406 setbit(afmask, afp->af_af); 407 } 408} 409 410static void 411af_all_tunnel_status(int s) 412{ 413 struct afswtch *afp; --- 457 unchanged lines hidden (view full) --- 871 p = af_getbyfamily(info.rti_info[RTAX_IFA]->sa_family); 872 if (p != NULL) 873 p->af_status(s, &info); 874 } else if (afp->af_af == info.rti_info[RTAX_IFA]->sa_family) 875 afp->af_status(s, &info); 876 addrcount--; 877 ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen); 878 } |
879 if (allfamilies || afp->af_af == AF_LINK) { 880 const struct afswtch *lafp; 881 882 /* 883 * Hack; the link level address is received separately 884 * from the routing information so any address is not 885 * handled above. Cobble together an entry and invoke 886 * the status method specially. 887 */ 888 lafp = af_getbyname("lladdr"); 889 if (lafp != NULL) { 890 info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl; 891 lafp->af_status(s, &info); 892 } 893 } |
|
879 if (allfamilies) | 894 if (allfamilies) |
880 af_all_status(s, (const struct rt_addrinfo *) sdl); 881 else if (afp->af_status != NULL) 882 afp->af_status(s, (const struct rt_addrinfo *) sdl); | 895 af_other_status(s); 896 else if (afp->af_other_status != NULL) 897 afp->af_other_status(s); |
883 884 strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name); 885 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) 886 printf("%s", ifs.ascii); 887 888 close(s); 889 return; 890} --- 155 unchanged lines hidden --- | 898 899 strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name); 900 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) 901 printf("%s", ifs.ascii); 902 903 close(s); 904 return; 905} --- 155 unchanged lines hidden --- |