Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_clone.c
Show First 20 Lines • Show All 565 Lines • ▼ Show 20 Lines | if_clone_addgroup(struct ifnet *ifp, struct if_clone *ifc) | ||||
if ((ifc->ifc_flags & IFC_NOGROUP) == 0) { | if ((ifc->ifc_flags & IFC_NOGROUP) == 0) { | ||||
if_addgroup(ifp, ifc->ifc_name); | if_addgroup(ifp, ifc->ifc_name); | ||||
IF_CLONE_REMREF(ifc); | IF_CLONE_REMREF(ifc); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* A utility function to extract unit numbers from interface names of | * A utility function to extract unit numbers from interface names of | ||||
* the form name###. | * the form name###[.###]. | ||||
* | * | ||||
* Returns 0 on success and an error on failure. | * Returns 0 on success and an error on failure. | ||||
*/ | */ | ||||
int | int | ||||
ifc_name2unit(const char *name, int *unit) | ifc_name2unit(const char *name, int *unit) | ||||
{ | { | ||||
const char *cp; | const char *cp; | ||||
int cutoff = INT_MAX / 10; | int cutoff = INT_MAX / 10; | ||||
int cutlim = INT_MAX % 10; | int cutlim = INT_MAX % 10; | ||||
for (cp = name; *cp != '\0' && (*cp < '0' || *cp > '9'); cp++); | if ((cp = strrchr(name, '.')) == NULL) | ||||
cp = name; | |||||
for (; *cp != '\0' && (*cp < '0' || *cp > '9'); cp++); | |||||
if (*cp == '\0') { | if (*cp == '\0') { | ||||
*unit = -1; | *unit = -1; | ||||
} else if (cp[0] == '0' && cp[1] != '\0') { | } else if (cp[0] == '0' && cp[1] != '\0') { | ||||
/* Disallow leading zeroes. */ | /* Disallow leading zeroes. */ | ||||
return (EINVAL); | return (EINVAL); | ||||
} else { | } else { | ||||
for (*unit = 0; *cp != '\0'; cp++) { | for (*unit = 0; *cp != '\0'; cp++) { | ||||
if (*cp < '0' || *cp > '9') { | if (*cp < '0' || *cp > '9') { | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |