From 37bdee9b7282f08cbe6e423765bd3950d753a2c6 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 13 Apr 2011 23:40:26 +0200 Subject: [PATCH 1/1] add a dummy protocol handler for "static" --- CMakeLists.txt | 2 +- proto-static.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 proto-static.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 496e9d5..212377e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,5 +9,5 @@ IF(DEBUG) ADD_DEFINITIONS(-DDEBUG -O0) ENDIF() -ADD_EXECUTABLE(netifd main.c interface.c proto.c config.c device.c bridge.c vlan.c ubus.c system-dummy.c) +ADD_EXECUTABLE(netifd main.c interface.c proto.c proto-static.c config.c device.c bridge.c vlan.c ubus.c system-dummy.c) TARGET_LINK_LIBRARIES(netifd ubox ubus uci) diff --git a/proto-static.c b/proto-static.c new file mode 100644 index 0000000..614177b --- /dev/null +++ b/proto-static.c @@ -0,0 +1,52 @@ +#include +#include +#include + +#include "netifd.h" +#include "proto.h" + +struct static_proto_state { + struct interface_proto_state proto; +}; + + +static int +static_handler(struct interface_proto_state *proto, + enum interface_proto_cmd cmd, bool force) +{ + return 0; +} + +static void +static_free(struct interface_proto_state *proto) +{ + struct static_proto_state *state; + + state = container_of(proto, struct static_proto_state, proto); + free(state); +} + +struct interface_proto_state * +static_attach(struct proto_handler *h, struct interface *iface, + struct uci_section *s) +{ + struct static_proto_state *state; + + state = calloc(1, sizeof(*state)); + state->proto.free = static_free; + state->proto.handler = static_handler; + state->proto.flags = PROTO_FLAG_IMMEDIATE; + + return &state->proto; +} + +static struct proto_handler static_proto = { + .name = "static", + .attach = static_attach, +}; + +static void __init +static_proto_init(void) +{ + add_proto_handler(&static_proto); +} -- 2.11.0