clean up variable names (llif -> dev)
[project/netifd.git] / proto.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #include "netifd.h"
6 #include "interface.h"
7 #include "proto.h"
8
9 static void
10 default_proto_free(struct interface_proto_state *proto)
11 {
12         free(proto);
13 }
14
15 static int
16 default_proto_handler(struct interface_proto_state *proto,
17                       enum interface_proto_cmd cmd, bool force)
18 {
19         enum interface_event ev;
20
21         switch(cmd) {
22         case PROTO_CMD_SETUP:
23                 ev = IFEV_UP;
24                 break;
25         case PROTO_CMD_TEARDOWN:
26                 ev = IFEV_DOWN;
27                 break;
28         default:
29                 return -EINVAL;
30         }
31         proto->proto_event(proto, ev);
32         return 0;
33 }
34
35 struct interface_proto_state *get_default_proto(void)
36 {
37         struct interface_proto_state *proto;
38
39         proto = calloc(1, sizeof(*proto));
40         proto->handler = default_proto_handler;
41         proto->free = default_proto_free;
42         return proto;
43 }