2
* lib/route/link/bridge.c AF_BRIDGE link oeprations
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation version 2.1
9
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
12
#include <netlink-local.h>
13
#include <netlink/netlink.h>
14
#include <netlink/attr.h>
15
#include <netlink/route/rtnl.h>
16
#include <netlink/route/link/api.h>
23
static void *bridge_alloc(struct rtnl_link *link)
25
return calloc(1, sizeof(struct bridge_data));
28
static void *bridge_clone(struct rtnl_link *link, void *data)
30
struct bridge_data *bd;
32
if ((bd = bridge_alloc(link)))
33
memcpy(bd, data, sizeof(*bd));
38
static void bridge_free(struct rtnl_link *link, void *data)
43
static int bridge_parse_protinfo(struct rtnl_link *link, struct nlattr *attr,
46
struct bridge_data *bd = data;
48
bd->b_port_state = nla_get_u8(attr);
53
static void bridge_dump_details(struct rtnl_link *link,
54
struct nl_dump_params *p, void *data)
56
struct bridge_data *bd = data;
58
nl_dump(p, "port-state %u ", bd->b_port_state);
61
static const struct nla_policy protinfo_policy = {
65
static struct rtnl_link_af_ops bridge_ops = {
66
.ao_family = AF_BRIDGE,
67
.ao_alloc = &bridge_alloc,
68
.ao_clone = &bridge_clone,
69
.ao_free = &bridge_free,
70
.ao_parse_protinfo = &bridge_parse_protinfo,
71
.ao_dump[NL_DUMP_DETAILS] = &bridge_dump_details,
72
.ao_protinfo_policy = &protinfo_policy,
75
static void __init bridge_init(void)
77
rtnl_link_af_register(&bridge_ops);
80
static void __exit bridge_exit(void)
82
rtnl_link_af_unregister(&bridge_ops);