|
|
| version 1.2, 2004/03/23 18:00:48 | version 1.3, 2004/03/23 18:25:51 |
|---|---|
| Line 88 static const struct bits bits[] = { | Line 88 static const struct bits bits[] = { |
| }; | }; |
| static void p_rtentry(struct rt_msghdr *); | static void p_rtentry(struct rt_msghdr *); |
| static void p_sockaddr(struct sockaddr *, int, int); | static int p_sockaddr(struct sockaddr *, int, int); |
| static void p_flags(int, char *); | static void p_flags(int, char *); |
| static void pr_rthdr(void); | static void pr_rthdr(void); |
| static void pr_family(int); | static void pr_family(int); |
| Line 203 p_rtentry(struct rt_msghdr *rtm) | Line 203 p_rtentry(struct rt_msghdr *rtm) |
| #endif | #endif |
| static int old_af; | static int old_af; |
| int af = 0, interesting = RTF_UP | RTF_GATEWAY | RTF_HOST; | int af = 0, interesting = RTF_UP | RTF_GATEWAY | RTF_HOST; |
| int width; | |
| #ifdef notdef | #ifdef notdef |
| /* for the moment, netmasks are skipped over */ | /* for the moment, netmasks are skipped over */ |
| Line 223 p_rtentry(struct rt_msghdr *rtm) | Line 224 p_rtentry(struct rt_msghdr *rtm) |
| pr_family(af); | pr_family(af); |
| pr_rthdr(); | pr_rthdr(); |
| } | } |
| if (rtm->rtm_addrs == RTA_DST) | |
| /* | |
| * Print the information. If wflag is set p_sockaddr() can return | |
| * a wider width then specified and we try to fit the second | |
| * address in any remaining space so the flags still lines up. | |
| */ | |
| if (rtm->rtm_addrs == RTA_DST) { | |
| p_sockaddr(sa, 0, WID_DST + WID_GW + 2); | p_sockaddr(sa, 0, WID_DST + WID_GW + 2); |
| else { | } else { |
| p_sockaddr(sa, rtm->rtm_flags, WID_DST); | width = p_sockaddr(sa, rtm->rtm_flags, WID_DST); |
| sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa); | sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa); |
| p_sockaddr(sa, 0, WID_GW); | p_sockaddr(sa, 0, WID_GW + WID_DST - width); |
| } | } |
| p_flags(rtm->rtm_flags & interesting, "%-6.6s "); | p_flags(rtm->rtm_flags & interesting, "%-6.6s "); |
| putchar('\n'); | putchar('\n'); |
| Line 276 pr_family(int af) | Line 283 pr_family(int af) |
| printf("\nProtocol Family %d:\n", af); | printf("\nProtocol Family %d:\n", af); |
| } | } |
| static void | static int |
| p_sockaddr(struct sockaddr *sa, int flags, int width) | p_sockaddr(struct sockaddr *sa, int flags, int width) |
| { | { |
| char workbuf[128], *cplim; | char workbuf[128], *cplim; |
| char *cp = workbuf; | char *cp = workbuf; |
| int len = sizeof(workbuf); | int len = sizeof(workbuf); |
| int count; | |
| switch(sa->sa_family) { | switch(sa->sa_family) { |
| Line 381 p_sockaddr(struct sockaddr *sa, int flag | Line 389 p_sockaddr(struct sockaddr *sa, int flag |
| } | } |
| } | } |
| if (width < 0 ) { | if (width < 0 ) { |
| printf("%s ", cp); | count = printf("%s ", cp); |
| } else { | } else { |
| if (nflag) | if (nflag || wflag) |
| printf("%-*s ", width, cp); | count = printf("%-*s ", width, cp); |
| else | else |
| printf("%-*.*s ", width, width, cp); | count = printf("%-*.*s ", width, width, cp); |
| } | } |
| return(count); | |
| } | } |
| static void | static void |