614177b7bff6cb3836d8a9833f4f4abb2cd8e2fd
[project/netifd.git] / proto-static.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #include "netifd.h"
6 #include "proto.h"
7
8 struct static_proto_state {
9     struct interface_proto_state proto;
10 };
11
12
13 static int
14 static_handler(struct interface_proto_state *proto,
15                enum interface_proto_cmd cmd, bool force)
16 {
17         return 0;
18 }
19
20 static void
21 static_free(struct interface_proto_state *proto)
22 {
23         struct static_proto_state *state;
24
25         state = container_of(proto, struct static_proto_state, proto);
26         free(state);
27 }
28
29 struct interface_proto_state *
30 static_attach(struct proto_handler *h, struct interface *iface,
31               struct uci_section *s)
32 {
33         struct static_proto_state *state;
34
35         state = calloc(1, sizeof(*state));
36         state->proto.free = static_free;
37         state->proto.handler = static_handler;
38         state->proto.flags = PROTO_FLAG_IMMEDIATE;
39
40         return &state->proto;
41 }
42
43 static struct proto_handler static_proto = {
44         .name = "static",
45         .attach = static_attach,
46 };
47
48 static void __init
49 static_proto_init(void)
50 {
51         add_proto_handler(&static_proto);
52 }