]> git.saurik.com Git - apple/network_cmds.git/commitdiff
network_cmds-329.2.tar.gz mac-os-x-1064 v329.2
authorApple <opensource@apple.com>
Sat, 23 Jan 2010 01:03:33 +0000 (01:03 +0000)
committerApple <opensource@apple.com>
Sat, 23 Jan 2010 01:03:33 +0000 (01:03 +0000)
ifconfig.tproj/ifconfig.8
ifconfig.tproj/ifconfig.c
ifconfig.tproj/ifvlan.c
netstat.tproj/if.c
netstat.tproj/main.c
netstat.tproj/netstat.1
netstat.tproj/netstat.h
netstat.tproj/route.c
route.tproj/route.c

index cba935e1bdc7ae1a08cf6d5ebfe83138b316a5fe..18768283ced0bf64eeed694a2dbaf73957a68a07 100644 (file)
@@ -38,6 +38,7 @@
 .Nm
 .Op Fl L
 .Op Fl m
 .Nm
 .Op Fl L
 .Op Fl m
+.Op Fl r
 .Ar interface
 .Op Cm create
 .Op Ar address_family
 .Ar interface
 .Op Cm create
 .Op Ar address_family
@@ -54,6 +55,7 @@
 .Op Fl L
 .Op Fl d
 .Op Fl m
 .Op Fl L
 .Op Fl d
 .Op Fl m
+.Op Fl r
 .Op Fl u
 .Op Fl v
 .Op Ar address_family
 .Op Fl u
 .Op Fl v
 .Op Ar address_family
@@ -66,6 +68,7 @@
 .Op Fl L
 .Op Fl d
 .Op Fl m
 .Op Fl L
 .Op Fl d
 .Op Fl m
+.Op Fl r
 .Op Fl u
 .Op Fl v
 .Op Fl C
 .Op Fl u
 .Op Fl v
 .Op Fl C
@@ -895,6 +898,10 @@ flag may be used to list all of the interface cloners available on
 the system, with no additional information.
 Use of this flag is mutually exclusive with all other flags and commands.
 .Pp
 the system, with no additional information.
 Use of this flag is mutually exclusive with all other flags and commands.
 .Pp
+The
+.Fl r
+flag may be used to show additional information related to the count of route references on the network interface.
+.Pp
 For bridge interfaces, the list of addresses learned by the bridge is not shown when displaying information about 
 all interfaces except when the 
 .Fl v
 For bridge interfaces, the list of addresses learned by the bridge is not shown when displaying information about 
 all interfaces except when the 
 .Fl v
index a0d823c461881f2c951f7626005b09ba010ca37f..1c50df3e2278c50a370cd9858ec568fb2c341658 100644 (file)
@@ -95,6 +95,7 @@ int all;
 
 int bond_details = 0;
 int    supmedia = 0;
 
 int bond_details = 0;
 int    supmedia = 0;
+int    showrtref = 0;
 int    printkeys = 0;          /* Print keying material for interfaces. */
 
 static int ifconfig(int argc, char *const *argv, int iscreate,
 int    printkeys = 0;          /* Print keying material for interfaces. */
 
 static int ifconfig(int argc, char *const *argv, int iscreate,
@@ -161,7 +162,7 @@ main(int argc, char *argv[])
 #ifndef __APPLE__
        strlcpy(options, "adklmnuv", sizeof(options));
 #else
 #ifndef __APPLE__
        strlcpy(options, "adklmnuv", sizeof(options));
 #else
-       strlcpy(options, "adlmuv", sizeof(options));
+       strlcpy(options, "adlmruv", sizeof(options));
 #endif
        for (p = opts; p != NULL; p = p->next)
                strlcat(options, p->opt, sizeof(options));
 #endif
        for (p = opts; p != NULL; p = p->next)
                strlcat(options, p->opt, sizeof(options));
@@ -181,7 +182,7 @@ main(int argc, char *argv[])
                        printkeys++;
                        break;
 #endif
                        printkeys++;
                        break;
 #endif
-                       case 'l':       /* scan interface names only */
+               case 'l':       /* scan interface names only */
                        namesonly++;
                        break;
                case 'm':       /* show media choices in status */
                        namesonly++;
                        break;
                case 'm':       /* show media choices in status */
@@ -192,7 +193,10 @@ main(int argc, char *argv[])
                        noload++;
                        break;
 #endif
                        noload++;
                        break;
 #endif
-                       case 'u':       /* restrict scan to "up" interfaces */
+               case 'r':
+                       showrtref++;
+                       break;
+               case 'u':       /* restrict scan to "up" interfaces */
                        uponly++;
                        break;
                case 'v':
                        uponly++;
                        break;
                case 'v':
@@ -212,8 +216,8 @@ main(int argc, char *argv[])
        argc -= optind;
        argv += optind;
 
        argc -= optind;
        argv += optind;
 
-       /* -l cannot be used with -a or -m or -b */
-       if (namesonly && (all || supmedia || bond_details))
+       /* -l cannot be used with -a or -r or -m or -b */
+       if (namesonly && (all || supmedia || showrtref || bond_details))
                usage();
 
        /* nonsense.. */
                usage();
 
        /* nonsense.. */
@@ -829,6 +833,10 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                        printf(" metric %d", ifr.ifr_metric);
        if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
                printf(" mtu %d", ifr.ifr_mtu);
                        printf(" metric %d", ifr.ifr_metric);
        if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
                printf(" mtu %d", ifr.ifr_mtu);
+#ifdef SIOCGIFGETRTREFCNT
+       if (showrtref && ioctl(s, SIOCGIFGETRTREFCNT, &ifr) != -1)
+               printf(" rtref %d", ifr.ifr_route_refcnt);
+#endif
        putchar('\n');
 
 #ifndef __APPLE__      
        putchar('\n');
 
 #ifndef __APPLE__      
index aeb8dad3be6b089f8d8db296d98dd819fe9a5eaa..eec3ef15c2c7566a3411e8c103761f62b858852f 100644 (file)
@@ -98,7 +98,7 @@ vlan_create(int s, struct ifreq *ifr)
                        errx(1, "must specify a parent device for vlan create");
                ifr->ifr_data = (caddr_t) &params;
        }
                        errx(1, "must specify a parent device for vlan create");
                ifr->ifr_data = (caddr_t) &params;
        }
-#if SIOCIFCREATE2
+#ifdef SIOCIFCREATE2
        if (ioctl(s, SIOCIFCREATE2, ifr) < 0)
                err(1, "SIOCIFCREATE2");
 #else
        if (ioctl(s, SIOCIFCREATE2, ifr) < 0)
                err(1, "SIOCIFCREATE2");
 #else
index e3f438e7c13fb46b781857806e600a3f4f1059d4..18986be75567356fbba54ee653e5f75f4f18c9ee 100644 (file)
@@ -459,6 +459,8 @@ struct      iftot {
        u_int64_t       ift_dr;                 /* drops */
        u_int64_t       ift_ib;                 /* input bytes */
        u_int64_t       ift_ob;                 /* output bytes */
        u_int64_t       ift_dr;                 /* drops */
        u_int64_t       ift_ib;                 /* input bytes */
        u_int64_t       ift_ob;                 /* output bytes */
+       u_int64_t       ift_obgp;               /* output bg packets */
+       u_int64_t       ift_obgb;               /* output bg bytes */
 };
 
 u_char signalled;                      /* set if alarm goes off "early" */
 };
 
 u_char signalled;                      /* set if alarm goes off "early" */
@@ -541,6 +543,8 @@ banner:
            "packets", "errs", "bytes", "packets", "errs", "bytes", "colls");
        if (dflag)
                printf(" %5.5s", "drops");
            "packets", "errs", "bytes", "packets", "errs", "bytes", "colls");
        if (dflag)
                printf(" %5.5s", "drops");
+       if (prioflag)
+               printf(" %10s %10s", "obgpkts", "obgbytes");
        putchar('\n');
        fflush(stdout);
        line = 0;
        putchar('\n');
        fflush(stdout);
        line = 0;
@@ -566,6 +570,10 @@ loop:
                                ifmd.ifmd_data.ifi_collisions - interesting->ift_co);
                        if (dflag)
                                printf(" %5llu", ifmd.ifmd_snd_drops - interesting->ift_dr);
                                ifmd.ifmd_data.ifi_collisions - interesting->ift_co);
                        if (dflag)
                                printf(" %5llu", ifmd.ifmd_snd_drops - interesting->ift_dr);
+                       if (prioflag)
+                               printf(" %10llu %10llu",
+                                   ifmd.ifmd_filler[0] - interesting->ift_obgp,
+                                   ifmd.ifmd_filler[1] - interesting->ift_obgb);
                }
                interesting->ift_ip = ifmd.ifmd_data.ifi_ipackets;
                interesting->ift_ie = ifmd.ifmd_data.ifi_ierrors;
                }
                interesting->ift_ip = ifmd.ifmd_data.ifi_ipackets;
                interesting->ift_ie = ifmd.ifmd_data.ifi_ierrors;
@@ -575,6 +583,9 @@ loop:
                interesting->ift_ob = ifmd.ifmd_data.ifi_obytes;
                interesting->ift_co = ifmd.ifmd_data.ifi_collisions;
                interesting->ift_dr = ifmd.ifmd_snd_drops;
                interesting->ift_ob = ifmd.ifmd_data.ifi_obytes;
                interesting->ift_co = ifmd.ifmd_data.ifi_collisions;
                interesting->ift_dr = ifmd.ifmd_snd_drops;
+               /* private counters */
+               interesting->ift_obgp = ifmd.ifmd_filler[0];
+               interesting->ift_obgb = ifmd.ifmd_filler[1];
        } else {
                unsigned int latest_ifcount;
                
        } else {
                unsigned int latest_ifcount;
                
@@ -609,6 +620,8 @@ loop:
                sum->ift_ob = 0;
                sum->ift_co = 0;
                sum->ift_dr = 0;
                sum->ift_ob = 0;
                sum->ift_co = 0;
                sum->ift_dr = 0;
+               sum->ift_obgp = 0;
+               sum->ift_obgb = 0;
                for (i = 0; i < ifcount; i++) {
                        struct ifmibdata *ifmd = ifmdall + i;
                        
                for (i = 0; i < ifcount; i++) {
                        struct ifmibdata *ifmd = ifmdall + i;
                        
@@ -620,6 +633,9 @@ loop:
                        sum->ift_ob += ifmd->ifmd_data.ifi_obytes;
                        sum->ift_co += ifmd->ifmd_data.ifi_collisions;
                        sum->ift_dr += ifmd->ifmd_snd_drops;
                        sum->ift_ob += ifmd->ifmd_data.ifi_obytes;
                        sum->ift_co += ifmd->ifmd_data.ifi_collisions;
                        sum->ift_dr += ifmd->ifmd_snd_drops;
+                       /* private counters */
+                       sum->ift_obgp += ifmd->ifmd_filler[0];
+                       sum->ift_obgb += ifmd->ifmd_filler[1];
                }
                if (!first) {
                        printf("%10llu %5llu %10llu %10llu %5llu %10llu %5llu",
                }
                if (!first) {
                        printf("%10llu %5llu %10llu %10llu %5llu %10llu %5llu",
@@ -632,6 +648,10 @@ loop:
                                sum->ift_co - total->ift_co);
                        if (dflag)
                                printf(" %5llu", sum->ift_dr - total->ift_dr);
                                sum->ift_co - total->ift_co);
                        if (dflag)
                                printf(" %5llu", sum->ift_dr - total->ift_dr);
+                       if (prioflag)
+                               printf(" %10llu %10llu",
+                                   sum->ift_obgp - total->ift_obgp,
+                                   sum->ift_obgb - total->ift_obgb);
                }
                *total = *sum;
        }
                }
                *total = *sum;
        }
index 9d686078ff13464b95fc0f7aafa3647ac6a9de34..102c933f4062d2b6289d782333fa8102a8ff3926 100644 (file)
@@ -275,7 +275,7 @@ int Aflag;          /* show addresses of protocol control block */
 int    aflag;          /* show all sockets (including servers) */
 int    bflag;          /* show i/f total bytes in/out */
 int    dflag;          /* show i/f dropped packets */
 int    aflag;          /* show all sockets (including servers) */
 int    bflag;          /* show i/f total bytes in/out */
 int    dflag;          /* show i/f dropped packets */
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__)
 int    gflag;          /* show group (multicast) routing or stats */
 #endif
 int    iflag;          /* show interfaces */
 int    gflag;          /* show group (multicast) routing or stats */
 #endif
 int    iflag;          /* show interfaces */
@@ -284,6 +284,7 @@ int Lflag;          /* show size of listen queues */
 int    mflag;          /* show memory stats */
 int    nflag;          /* show addresses numerically */
 static int pflag;      /* show given protocol */
 int    mflag;          /* show memory stats */
 int    nflag;          /* show addresses numerically */
 static int pflag;      /* show given protocol */
+int    prioflag;       /* show packet priority statistics */
 int    rflag;          /* show routing tables (or routing stats) */
 int    sflag;          /* show protocol statistics */
 int    tflag;          /* show i/f watchdog timers */
 int    rflag;          /* show routing tables (or routing stats) */
 int    sflag;          /* show protocol statistics */
 int    tflag;          /* show i/f watchdog timers */
@@ -306,7 +307,7 @@ main(argc, argv)
 
        af = AF_UNSPEC;
 
 
        af = AF_UNSPEC;
 
-       while ((ch = getopt(argc, argv, "Aabdf:gI:iLlmnp:rRstuWw:")) != -1)
+       while ((ch = getopt(argc, argv, "Aabdf:gI:iLlmnPp:rRstuWw:")) != -1)
                switch(ch) {
                case 'A':
                        Aflag = 1;
                switch(ch) {
                case 'A':
                        Aflag = 1;
@@ -339,7 +340,7 @@ main(argc, argv)
                                errx(1, "%s: unknown address family", optarg);
                        }
                        break;
                                errx(1, "%s: unknown address family", optarg);
                        }
                        break;
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__)
                case 'g':
                        gflag = 1;
                        break;
                case 'g':
                        gflag = 1;
                        break;
@@ -368,6 +369,9 @@ main(argc, argv)
                case 'n':
                        nflag = 1;
                        break;
                case 'n':
                        nflag = 1;
                        break;
+               case 'P':
+                       prioflag = 1;
+                       break;
                case 'p':
                        if ((tp = name2protox(optarg)) == NULL) {
                                errx(1, 
                case 'p':
                        if ((tp = name2protox(optarg)) == NULL) {
                                errx(1, 
@@ -430,8 +434,9 @@ main(argc, argv)
                        routepr(nl[N_RTREE].n_value);
                exit(0);
        }
                        routepr(nl[N_RTREE].n_value);
                exit(0);
        }
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__)
        if (gflag) {
        if (gflag) {
+#if !TARGET_OS_EMBEDDED                
                if (sflag) {
                        if (af == AF_INET || af == AF_UNSPEC)
                                mrt_stats();
                if (sflag) {
                        if (af == AF_INET || af == AF_UNSPEC)
                                mrt_stats();
@@ -447,6 +452,7 @@ main(argc, argv)
                                mroute6pr();
 #endif
                }
                                mroute6pr();
 #endif
                }
+#endif /* !TARGET_OS_EMBEDDED */
                ifmalist_dump();
                exit(0);
        }
                ifmalist_dump();
                exit(0);
        }
index 1b07b6095bb23382c611a693cc0b4df27cad023f..7fa01d2a27e359d9021845c3918435642f3fa7da 100644 (file)
@@ -306,6 +306,7 @@ D   RTF_DYNAMIC     Created dynamically (by redirect)
 G      RTF_GATEWAY     Destination requires forwarding by intermediary
 H      RTF_HOST        Host entry (net otherwise)
 I      RTF_IFSCOPE     Route is associated with an interface scope
 G      RTF_GATEWAY     Destination requires forwarding by intermediary
 H      RTF_HOST        Host entry (net otherwise)
 I      RTF_IFSCOPE     Route is associated with an interface scope
+i      RTF_IFREF       Route is holding a reference to the interface
 L      RTF_LLINFO      Valid protocol to link address translation
 M      RTF_MODIFIED    Modified dynamically (by redirect)
 m      RTF_MULTICAST   The route represents a multicast address
 L      RTF_LLINFO      Valid protocol to link address translation
 M      RTF_MODIFIED    Modified dynamically (by redirect)
 m      RTF_MULTICAST   The route represents a multicast address
index 9c25ee71b401cf0bc5afd1ca0b33d6aead3d23e0..b53e5b063a65cbbb916ef9fb46a2b062b418fac8 100644 (file)
@@ -80,6 +80,7 @@ extern int    mflag;  /* show memory stats */
 extern int     nflag;  /* show addresses numerically */
 extern int     rflag;  /* show routing tables (or routing stats) */
 extern int     sflag;  /* show protocol statistics */
 extern int     nflag;  /* show addresses numerically */
 extern int     rflag;  /* show routing tables (or routing stats) */
 extern int     sflag;  /* show protocol statistics */
+extern int     prioflag; /* show packet priority  statistics */
 extern int     tflag;  /* show i/f watchdog timers */
 extern int     Wflag;  /* wide display */
 
 extern int     tflag;  /* show i/f watchdog timers */
 extern int     Wflag;  /* wide display */
 
index 576d51e0fac5d09413c1feafba7536f60bc33238..1e7befcbf441301149eb10f2356d97e62d9bc239 100644 (file)
@@ -116,6 +116,7 @@ struct bits {
        { RTF_BLACKHOLE,'B' },
        { RTF_BROADCAST,'b' },
        { RTF_IFSCOPE,  'I' },
        { RTF_BLACKHOLE,'B' },
        { RTF_BROADCAST,'b' },
        { RTF_IFSCOPE,  'I' },
+       { RTF_IFREF,    'i' },
        { 0 }
 };
 
        { 0 }
 };
 
index f8850e67ab97e1d77f998ec03fcd66ded0455a0c..b1960d7b6e6e14439771209e7dcaeedc5bb43403 100644 (file)
@@ -1245,7 +1245,8 @@ char routeflags[] =
 "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010DELCLONE"
 "\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016"
 "\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024b024"
 "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010DELCLONE"
 "\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016"
 "\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024b024"
-"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\031IFSCOPE";
+"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST\031IFSCOPE\032CONDEMNED"
+"\033IFREF";
 char ifnetflags[] =
 "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP"
 "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1"
 char ifnetflags[] =
 "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP"
 "\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1"
@@ -1298,6 +1299,8 @@ print_rtmsg(rtm, msglen)
                        (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
                if (rtm->rtm_flags & RTF_IFSCOPE)
                        (void) printf("ifscope %d, ", rtm->rtm_index);
                        (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
                if (rtm->rtm_flags & RTF_IFSCOPE)
                        (void) printf("ifscope %d, ", rtm->rtm_index);
+               if (rtm->rtm_flags & RTF_IFREF)
+                       (void) printf("ifref, ");
                (void) printf("flags:");
                bprintf(stdout, rtm->rtm_flags, routeflags);
                pmsg_common(rtm);
                (void) printf("flags:");
                bprintf(stdout, rtm->rtm_flags, routeflags);
                pmsg_common(rtm);