From f62eea9492a669bcf96464e85f04ae5e80190a76 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 28 Mar 2011 21:54:19 +0200 Subject: [PATCH] restructure the proto state, add a callback for notifications by the protocol handler, move the iface pointer to the proto state --- interface.c | 4 ++-- interface.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interface.c b/interface.c index 7bf0ed4..0aa0b0d 100644 --- a/interface.c +++ b/interface.c @@ -58,7 +58,7 @@ interface_event(struct interface *iface, enum interface_event ev) if (!iface->state || !iface->state->event) return 0; - return iface->state->event(iface, iface->state, ev); + return iface->state->event(iface->state, ev); } static void @@ -148,7 +148,7 @@ free_interface(struct interface *iface) netifd_ubus_remove_interface(iface); list_del(&iface->list); if (iface->state && iface->state->free) - iface->state->free(iface, iface->state); + iface->state->free(iface->state); free(iface); } diff --git a/interface.h b/interface.h index 3a0b96f..dd72389 100644 --- a/interface.h +++ b/interface.h @@ -12,11 +12,21 @@ enum interface_event { IFEV_DOWN, }; +enum interface_proto_event { + PROTO_UP, + PROTO_DOWN, +}; + struct interface_proto_state { + struct interface *iface; const struct interface_proto *proto; - int (*event)(struct interface *, struct interface_proto_state *, enum interface_event ev); - void (*free)(struct interface *, struct interface_proto_state *); + /* filled in by the protocol user */ + int (*proto_event)(struct interface_proto_state *, enum interface_proto_event ev); + + /* filled in by the protocol handler */ + int (*event)(struct interface_proto_state *, enum interface_event ev); + void (*free)(struct interface_proto_state *); }; struct interface_error { -- 2.25.1