2 * iplink_bridge.c Bridge device support
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Jiri Pirko <jiri@resnulli.us>
15 #include <linux/if_link.h>
18 #include "ip_common.h"
20 static void explain(void)
23 "Usage: ... bridge [ forward_delay FORWARD_DELAY ]\n"
24 " [ hello_time HELLO_TIME ]\n"
25 " [ max_age MAX_AGE ]\n"
26 " [ ageing_time AGEING_TIME ]\n"
27 " [ stp_state STP_STATE ]\n"
28 " [ priority PRIORITY ]\n"
32 static int bridge_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
38 if (matches(*argv
, "forward_delay") == 0) {
40 if (get_u32(&val
, *argv
, 0)) {
41 invarg("invalid forward_delay", *argv
);
44 addattr32(n
, 1024, IFLA_BR_FORWARD_DELAY
, val
);
45 } else if (matches(*argv
, "hello_time") == 0) {
47 if (get_u32(&val
, *argv
, 0)) {
48 invarg("invalid hello_time", *argv
);
51 addattr32(n
, 1024, IFLA_BR_HELLO_TIME
, val
);
52 } else if (matches(*argv
, "max_age") == 0) {
54 if (get_u32(&val
, *argv
, 0)) {
55 invarg("invalid max_age", *argv
);
58 addattr32(n
, 1024, IFLA_BR_MAX_AGE
, val
);
59 } else if (matches(*argv
, "ageing_time") == 0) {
61 if (get_u32(&val
, *argv
, 0)) {
62 invarg("invalid ageing_time", *argv
);
65 addattr32(n
, 1024, IFLA_BR_AGEING_TIME
, val
);
66 } else if (matches(*argv
, "stp_state") == 0) {
68 if (get_u32(&val
, *argv
, 0)) {
69 invarg("invalid stp_state", *argv
);
72 addattr32(n
, 1024, IFLA_BR_STP_STATE
, val
);
73 } else if (matches(*argv
, "priority") == 0) {
77 if (get_u16(&prio
, *argv
, 0)) {
78 invarg("invalid priority", *argv
);
81 addattr16(n
, 1024, IFLA_BR_PRIORITY
, prio
);
82 } else if (matches(*argv
, "help") == 0) {
86 fprintf(stderr
, "bridge: unknown command \"%s\"?\n", *argv
);
96 static void bridge_print_opt(struct link_util
*lu
, FILE *f
, struct rtattr
*tb
[])
101 if (tb
[IFLA_BR_FORWARD_DELAY
])
102 fprintf(f
, "forward_delay %u ",
103 rta_getattr_u32(tb
[IFLA_BR_FORWARD_DELAY
]));
105 if (tb
[IFLA_BR_HELLO_TIME
])
106 fprintf(f
, "hello_time %u ",
107 rta_getattr_u32(tb
[IFLA_BR_HELLO_TIME
]));
109 if (tb
[IFLA_BR_MAX_AGE
])
110 fprintf(f
, "max_age %u ",
111 rta_getattr_u32(tb
[IFLA_BR_MAX_AGE
]));
114 struct link_util bridge_link_util
= {
116 .maxattr
= IFLA_BR_MAX
,
117 .parse_opt
= bridge_parse_opt
,
118 .print_opt
= bridge_print_opt
,