mirror of
https://github.com/opnsense/src.git
synced 2026-06-03 13:58:30 -04:00
ifconfig/ifbridge.c: add get_vlan_id()
This is like get_val() but takes an ether_vlanid_t* and ensures the value is a valid VLAN ID. This avoids redundant comparisons and casting when parsing VLAN IDs. Reviewed by: des Differential Revision: https://reviews.freebsd.org/D51548 (cherry picked from commit 287a5fdcd3c941ce73705c664b5df4932ba3bad4)
This commit is contained in:
parent
6ea749503a
commit
9b6cdc5678
1 changed files with 14 additions and 0 deletions
|
|
@ -79,6 +79,20 @@ get_val(const char *cp, u_long *valp)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
get_vlan_id(const char *cp, ether_vlanid_t *valp)
|
||||
{
|
||||
u_long val;
|
||||
|
||||
if (get_val(cp, &val) == -1)
|
||||
return (-1);
|
||||
if (val < 0x1 || val > 0xffe)
|
||||
return (-1);
|
||||
|
||||
*valp = (ether_vlanid_t)val;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
do_cmd(if_ctx *ctx, u_long op, void *arg, size_t argsize, int set)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue