diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-03-29 01:16:59 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-03-29 01:16:59 +0200 |
commit | d5202486636818e3ff48ede9d3e06c886c659c0a (patch) | |
tree | 9cefcabc1a153efd38dcb295bf386e4cd5dfc37c /proto.c | |
parent | f62eea9492a669bcf96464e85f04ae5e80190a76 (diff) |
add rudimentary protocol handling
Diffstat (limited to 'proto.c')
-rw-r--r-- | proto.c | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,42 @@ +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +#include "netifd.h" +#include "proto.h" + +static void +default_proto_free(struct interface_proto_state *proto) +{ + free(proto); +} + +static int +default_proto_handler(struct interface_proto_state *proto, + enum interface_proto_cmd cmd, bool force) +{ + enum interface_event ev; + + switch(cmd) { + case PROTO_CMD_SETUP: + ev = IFEV_UP; + break; + case PROTO_CMD_TEARDOWN: + ev = IFEV_DOWN; + break; + default: + return -EINVAL; + } + proto->proto_event(proto, ev); + return 0; +} + +struct interface_proto_state *get_default_proto(void) +{ + struct interface_proto_state *proto; + + proto = calloc(1, sizeof(*proto)); + proto->handler = default_proto_handler; + proto->free = default_proto_free; + return proto; +} |