MCPcopy Create free account
hub / github.com/F-Stack/f-stack / link_ntoa

Function link_ntoa

tools/compat/linkaddr.c:123–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121static const char hexlist[] = "0123456789abcdef";
122
123char *
124link_ntoa(const struct sockaddr_dl *sdl)
125{
126 static char obuf[64];
127 char *out = obuf;
128 int i;
129 u_char *in = (u_char *)LLADDR(sdl);
130 u_char *inlim = in + sdl->sdl_alen;
131 int firsttime = 1;
132
133 if (sdl->sdl_nlen) {
134 bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen);
135 out += sdl->sdl_nlen;
136 if (sdl->sdl_alen)
137 *out++ = ':';
138 }
139 while (in < inlim) {
140 if (firsttime)
141 firsttime = 0;
142 else
143 *out++ = '.';
144 i = *in++;
145 if (i > 0xf) {
146 out[1] = hexlist[i & 0xf];
147 i >>= 4;
148 out[0] = hexlist[i];
149 out += 2;
150 } else
151 *out++ = hexlist[i];
152 }
153 *out = 0;
154 return (obuf);
155}

Callers 6

ether_strFunction · 0.85
link_statusFunction · 0.85
routenameFunction · 0.85
netnameFunction · 0.85
route.cFile · 0.85
print_entryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected