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"
29 static int bridge_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
35 if (matches(*argv
, "forward_delay") == 0) {
37 if (get_u32(&val
, *argv
, 0)) {
38 invarg("invalid forward_delay", *argv
);
41 addattr32(n
, 1024, IFLA_BR_FORWARD_DELAY
, val
);
42 } else if (matches(*argv
, "hello_time") == 0) {
44 if (get_u32(&val
, *argv
, 0)) {
45 invarg("invalid hello_time", *argv
);
48 addattr32(n
, 1024, IFLA_BR_HELLO_TIME
, val
);
49 } else if (matches(*argv
, "max_age") == 0) {
51 if (get_u32(&val
, *argv
, 0)) {
52 invarg("invalid max_age", *argv
);
55 addattr32(n
, 1024, IFLA_BR_MAX_AGE
, val
);
56 } else if (matches(*argv
, "help") == 0) {
60 fprintf(stderr
, "bridge: unknown command \"%s\"?\n", *argv
);
70 static void bridge_print_opt(struct link_util
*lu
, FILE *f
, struct rtattr
*tb
[])
75 if (tb
[IFLA_BR_FORWARD_DELAY
])
76 fprintf(f
, "forward_delay %u ",
77 rta_getattr_u32(tb
[IFLA_BR_FORWARD_DELAY
]));
79 if (tb
[IFLA_BR_HELLO_TIME
])
80 fprintf(f
, "hello_time %u ",
81 rta_getattr_u32(tb
[IFLA_BR_HELLO_TIME
]));
83 if (tb
[IFLA_BR_MAX_AGE
])
84 fprintf(f
, "max_age %u ",
85 rta_getattr_u32(tb
[IFLA_BR_MAX_AGE
]));
88 struct link_util bridge_link_util
= {
90 .maxattr
= IFLA_BR_MAX
,
91 .parse_opt
= bridge_parse_opt
,
92 .print_opt
= bridge_print_opt
,