6 #include <netinet/in.h>
10 #include "interface-ip.h"
14 struct static_proto_state
{
15 struct interface_proto_state proto
;
17 struct blob_attr
*config
;
21 static_proto_setup(struct static_proto_state
*state
)
23 return proto_apply_ip_settings(state
->proto
.iface
, state
->config
, false) == 0;
27 static_handler(struct interface_proto_state
*proto
,
28 enum interface_proto_cmd cmd
, bool force
)
30 struct static_proto_state
*state
;
33 state
= container_of(proto
, struct static_proto_state
, proto
);
37 if (!static_proto_setup(state
))
41 case PROTO_CMD_TEARDOWN
:
48 static_free(struct interface_proto_state
*proto
)
50 struct static_proto_state
*state
;
52 state
= container_of(proto
, struct static_proto_state
, proto
);
57 static struct interface_proto_state
*
58 static_attach(const struct proto_handler
*h
, struct interface
*iface
,
59 struct blob_attr
*attr
)
61 struct static_proto_state
*state
;
63 state
= calloc(1, sizeof(*state
));
67 state
->config
= malloc(blob_pad_len(attr
));
71 memcpy(state
->config
, attr
, blob_pad_len(attr
));
72 state
->proto
.free
= static_free
;
73 state
->proto
.cb
= static_handler
;
82 static struct proto_handler static_proto
= {
84 .flags
= PROTO_FLAG_IMMEDIATE
,
85 .config_params
= &proto_ip_attr
,
86 .attach
= static_attach
,
90 static_proto_init(void)
92 add_proto_handler(&static_proto
);