From 8a30754e9cc5322ce86154416da4989ff1d22984 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Fri, 8 Jun 2007 11:30:14 +0000 Subject: [PATCH] Done some work on task #1549 (function documentation) and minor changes to meet coding standard --- src/api/netifapi.c | 68 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/src/api/netifapi.c b/src/api/netifapi.c index d069f59e..67b6bb33 100644 --- a/src/api/netifapi.c +++ b/src/api/netifapi.c @@ -32,15 +32,22 @@ #if LWIP_NETIF_API +/** + * Call netif_add() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see netif_add() + */ err_t -netifapi_netif_add( struct netif *netif, - struct ip_addr *ipaddr, - struct ip_addr *netmask, - struct ip_addr *gw, - void *state, - err_t (* init)(struct netif *netif), - err_t (* input)(struct pbuf *p, struct netif *netif) ) -{ struct netifapi_msg msg; +netifapi_netif_add(struct netif *netif, + struct ip_addr *ipaddr, + struct ip_addr *netmask, + struct ip_addr *gw, + void *state, + err_t (* init)(struct netif *netif), + err_t (* input)(struct pbuf *p, struct netif *netif)) +{ + struct netifapi_msg msg; msg.type = NETIFAPI_MSG_NETIF_ADD; msg.netif = netif; msg.msg.add.ipaddr = ipaddr; @@ -53,36 +60,65 @@ netifapi_netif_add( struct netif *netif, return msg.err; } +/** + * Call netif_remove() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see netif_remove() + */ err_t -netifapi_netif_remove( struct netif *netif) -{ struct netifapi_msg msg; +netifapi_netif_remove(struct netif *netif) +{ + struct netifapi_msg msg; msg.type = NETIFAPI_MSG_NETIF_REMOVE; msg.netif = netif; tcpip_apimsg(&msg); return msg.err; } +/** + * Call dhcp_start() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see dhcp_start() + */ err_t -netifapi_dhcp_start( struct netif *netif) -{ struct netifapi_msg msg; +netifapi_dhcp_start(struct netif *netif) +{ + struct netifapi_msg msg; msg.type = NETIFAPI_MSG_DHCP_START; msg.netif = netif; tcpip_apimsg(&msg); return msg.err; } +/** + * Call dhcp_stop() in a thread-safe way by running that function inside the + * tcpip_thread context. + * + * @note for params @see dhcp_stop() + */ err_t -netifapi_dhcp_stop( struct netif *netif) -{ struct netifapi_msg msg; +netifapi_dhcp_stop(struct netif *netif) +{ + struct netifapi_msg msg; msg.type = NETIFAPI_MSG_DHCP_STOP; msg.netif = netif; tcpip_apimsg(&msg); return msg.err; } +/** + * This function processes the messages posted to the tcpip_thread + * by the above functions. + * + * It is responsible for doing the actual work inside the thread context + * of tcpip_thread. + */ void -netifapi_msg_input( struct netifapi_msg *msg) -{ msg->err = ERR_OK; +netifapi_msg_input(struct netifapi_msg *msg) +{ + msg->err = ERR_OK; switch (msg->type) { case NETIFAPI_MSG_NETIF_ADD: { if (!netif_add( msg->netif,