Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/ifbridge.c
| Show First 20 Lines • Show All 805 Lines • ▼ Show 20 Lines | |||||
| unsetbridge_private(if_ctx *ctx, const char *val, int dummy __unused) | unsetbridge_private(if_ctx *ctx, const char *val, int dummy __unused) | ||||
| { | { | ||||
| do_bridgeflag(ctx, val, IFBIF_PRIVATE, 0); | do_bridgeflag(ctx, val, IFBIF_PRIVATE, 0); | ||||
| } | } | ||||
| static int | static int | ||||
| parse_vlans(ifbvlan_set_t *set, const char *str) | parse_vlans(ifbvlan_set_t *set, const char *str) | ||||
| { | { | ||||
| char *s, *token; | char *s, *free_s, *token; | ||||
| /* "none" means the empty vlan set */ | /* "none" means the empty vlan set */ | ||||
| if (strcmp(str, "none") == 0) { | if (strcmp(str, "none") == 0) { | ||||
| __BIT_ZERO(BRVLAN_SETSIZE, set); | __BIT_ZERO(BRVLAN_SETSIZE, set); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| /* "all" means all vlans, except for 0 and 4095 which are reserved */ | /* "all" means all vlans, except for 0 and 4095 which are reserved */ | ||||
| if (strcmp(str, "all") == 0) { | if (strcmp(str, "all") == 0) { | ||||
| __BIT_FILL(BRVLAN_SETSIZE, set); | __BIT_FILL(BRVLAN_SETSIZE, set); | ||||
| BRVLAN_CLR(set, DOT1Q_VID_NULL); | BRVLAN_CLR(set, DOT1Q_VID_NULL); | ||||
| BRVLAN_CLR(set, DOT1Q_VID_RSVD_IMPL); | BRVLAN_CLR(set, DOT1Q_VID_RSVD_IMPL); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| if ((s = strdup(str)) == NULL) | if ((s = strdup(str)) == NULL) | ||||
| return (-1); | return (-1); | ||||
| /* Keep the original value of s, since strsep() will modify it */ | |||||
| free_s = s; | |||||
| while ((token = strsep(&s, ",")) != NULL) { | while ((token = strsep(&s, ",")) != NULL) { | ||||
| unsigned long first, last; | unsigned long first, last; | ||||
| char *p, *lastp; | char *p, *lastp; | ||||
| if ((lastp = strchr(token, '-')) != NULL) | if ((lastp = strchr(token, '-')) != NULL) | ||||
| *lastp++ = '\0'; | *lastp++ = '\0'; | ||||
| Show All 11 Lines | if (lastp) { | ||||
| last < first) | last < first) | ||||
| goto err; | goto err; | ||||
| } | } | ||||
| for (unsigned vlan = first; vlan <= last; ++vlan) | for (unsigned vlan = first; vlan <= last; ++vlan) | ||||
| BRVLAN_SET(set, vlan); | BRVLAN_SET(set, vlan); | ||||
| } | } | ||||
| free(s); | free(free_s); | ||||
| return (0); | return (0); | ||||
| err: | err: | ||||
| free(s); | free(free_s); | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| static void | static void | ||||
| set_bridge_vlanset(if_ctx *ctx, const char *ifn, const char *vlans, int op) | set_bridge_vlanset(if_ctx *ctx, const char *ifn, const char *vlans, int op) | ||||
| { | { | ||||
| struct ifbif_vlan_req req; | struct ifbif_vlan_req req; | ||||
| ▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines | |||||