restructure the proto state, add a callback for notifications by the protocol handler...
authorFelix Fietkau <nbd@openwrt.org>
Mon, 28 Mar 2011 19:54:19 +0000 (21:54 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 28 Mar 2011 19:55:40 +0000 (21:55 +0200)
interface.c
interface.h

index 7bf0ed490366265b170252b6404bc42b18efd512..0aa0b0d08c1d9d866c2130858fbd01551f1cf71e 100644 (file)
@@ -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);
 }
 
index 3a0b96f93cf236d8b946ca1fe1fe97e921e8e82e..dd72389a31c1c7ebe36008c41c5d937b4c41644e 100644 (file)
@@ -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 {