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

Function vlan_parse_ethervid

tools/ifconfig/ifvlan.c:125–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125static void
126vlan_parse_ethervid(const char *name)
127{
128 char ifname[IFNAMSIZ];
129 char *cp;
130 int vid;
131
132 strlcpy(ifname, name, IFNAMSIZ);
133 if ((cp = strrchr(ifname, '.')) == NULL)
134 return;
135 /*
136 * Don't mix vlan/vlandev parameters with dot notation.
137 */
138 if (params.vlr_tag != NOTAG || params.vlr_parent[0] != '\0')
139 errx(1, "ambiguous vlan specification");
140 /*
141 * Derive params from interface name: "parent.vid".
142 */
143 *cp++ = '\0';
144 if ((*cp < '1') || (*cp > '9'))
145 errx(1, "invalid vlan tag");
146
147 vid = *cp++ - '0';
148 while ((*cp >= '0') && (*cp <= '9'))
149 vid = (vid * 10) + (*cp++ - '0');
150 if ((*cp != '\0') || (vid & ~0xFFF))
151 errx(1, "invalid vlan tag");
152
153 strlcpy(params.vlr_parent, ifname, IFNAMSIZ);
154 params.vlr_tag = (vid & 0xFFF);
155}
156
157static void
158vlan_create(int s, struct ifreq *ifr)

Callers 1

vlan_createFunction · 0.85

Calls 2

strrchrFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected