diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-06 12:09:17 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-06 12:09:17 +0000 |
commit | a2bdfd7ffd4a9fab034f097e5f9b9d93e7f4cbc3 (patch) | |
tree | c70339ed54ad614be571ead404fdb9711f2b2643 /usr.sbin/ppp | |
parent | 05b8a6ced5e37188cd43c3f2d1601751af2960ed (diff) |
Understand ``sockaddr_dl''s where sdl_nlen != 0
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/route.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index f86ca6114a1..4cae9029691 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.1 1997/11/23 20:27:35 brian Exp $ + * $Id: route.c,v 1.2 1997/12/06 12:09:16 brian Exp $ * */ @@ -147,7 +147,6 @@ static void p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width) { char buf[29]; - const char *cp; struct sockaddr_in *ihost = (struct sockaddr_in *)phost; struct sockaddr_in *mask = (struct sockaddr_in *)pmask; struct sockaddr_dl *dl = (struct sockaddr_dl *)phost; @@ -155,11 +154,11 @@ p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width) switch (phost->sa_family) { case AF_INET: if (!phost) - cp = ""; + buf[0] = '\0'; else if (ihost->sin_addr.s_addr == INADDR_ANY) - cp = "default"; + strcpy(buf, "default"); else if (!mask) - cp = inet_ntoa(ihost->sin_addr); + strcpy(buf, inet_ntoa(ihost->sin_addr)); else { u_int msk = ntohl(mask->sin_addr.s_addr); u_int tst; @@ -185,36 +184,38 @@ p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width) sprintf(buf+strlen(buf),"&0x%08x", msk); else sprintf(buf+strlen(buf), "/%d", bits); - cp = buf; } break; case AF_LINK: - if (!dl) - cp = ""; - else if (dl->sdl_nlen == 0 && dl->sdl_alen == 0 && dl->sdl_slen == 0) { + if (dl->sdl_nlen) + snprintf(buf, sizeof buf, "%.*s", dl->sdl_nlen, dl->sdl_data); + else if (dl->sdl_alen) + if (dl->sdl_type == IFT_ETHER) + if (dl->sdl_alen < sizeof(buf)/3) { + int f; + u_char *MAC; + + MAC = (u_char *)dl->sdl_data + dl->sdl_nlen; + for (f = 0; f < dl->sdl_alen; f++) + sprintf(buf+f*3, "%02x:", MAC[f]); + buf[f*3-1] = '\0'; + } else + sprintf(buf, "??:??:??:??:??:??"); + else + sprintf(buf, "<IFT type %d>", dl->sdl_type); + else if (dl->sdl_slen) + sprintf(buf, "<slen %d?>", dl->sdl_slen); + else sprintf(buf, "link#%d", dl->sdl_index); - cp = buf; - } else if (dl->sdl_type == IFT_ETHER && dl->sdl_alen && - dl->sdl_alen < sizeof(buf)/3) { - int f; - u_char *MAC; - - MAC = (u_char *)dl->sdl_data + dl->sdl_nlen; - for (f = 0; f < dl->sdl_alen; f++) - sprintf(buf+f*3, "%02x:", MAC[f]); - buf[f*3-1] = '\0'; - cp = buf; - } else - cp = "???"; break; default: - cp = "???"; + sprintf(buf, "<AF type %d>", phost->sa_family); break; } - fprintf(VarTerm, "%-*s ", width-1, cp); + fprintf(VarTerm, "%-*s ", width-1, buf); } struct bits { |