Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "lwip/opt.h"
00035
00036 #if LWIP_NETIF_API
00037
00038 #include "lwip/netifapi.h"
00039 #include "lwip/tcpip.h"
00040
00041
00042
00043
00044 void
00045 do_netifapi_netif_add( struct netifapi_msg_msg *msg)
00046 {
00047 if (!netif_add( msg->netif,
00048 msg->msg.add.ipaddr,
00049 msg->msg.add.netmask,
00050 msg->msg.add.gw,
00051 msg->msg.add.state,
00052 msg->msg.add.init,
00053 msg->msg.add.input)) {
00054 msg->err = ERR_IF;
00055 } else {
00056 msg->err = ERR_OK;
00057 }
00058 TCPIP_NETIFAPI_ACK(msg);
00059 }
00060
00061
00062
00063
00064 void
00065 do_netifapi_netif_set_addr( struct netifapi_msg_msg *msg)
00066 {
00067 netif_set_addr( msg->netif,
00068 msg->msg.add.ipaddr,
00069 msg->msg.add.netmask,
00070 msg->msg.add.gw);
00071 msg->err = ERR_OK;
00072 TCPIP_NETIFAPI_ACK(msg);
00073 }
00074
00075
00076
00077
00078
00079 void
00080 do_netifapi_netif_common( struct netifapi_msg_msg *msg)
00081 {
00082 if (msg->msg.common.errtfunc!=NULL) {
00083 msg->err =
00084 msg->msg.common.errtfunc(msg->netif);
00085 } else {
00086 msg->err = ERR_OK;
00087 msg->msg.common.voidfunc(msg->netif);
00088 }
00089 TCPIP_NETIFAPI_ACK(msg);
00090 }
00091
00092
00093
00094
00095
00096
00097
00098 err_t
00099 netifapi_netif_add(struct netif *netif,
00100 struct ip_addr *ipaddr,
00101 struct ip_addr *netmask,
00102 struct ip_addr *gw,
00103 void *state,
00104 err_t (* init)(struct netif *netif),
00105 err_t (* input)(struct pbuf *p, struct netif *netif))
00106 {
00107 struct netifapi_msg msg;
00108 msg.function = do_netifapi_netif_add;
00109 msg.msg.netif = netif;
00110 msg.msg.msg.add.ipaddr = ipaddr;
00111 msg.msg.msg.add.netmask = netmask;
00112 msg.msg.msg.add.gw = gw;
00113 msg.msg.msg.add.state = state;
00114 msg.msg.msg.add.init = init;
00115 msg.msg.msg.add.input = input;
00116 TCPIP_NETIFAPI(&msg);
00117 return msg.msg.err;
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 err_t
00127 netifapi_netif_set_addr(struct netif *netif,
00128 struct ip_addr *ipaddr,
00129 struct ip_addr *netmask,
00130 struct ip_addr *gw)
00131 {
00132 struct netifapi_msg msg;
00133 msg.function = do_netifapi_netif_set_addr;
00134 msg.msg.netif = netif;
00135 msg.msg.msg.add.ipaddr = ipaddr;
00136 msg.msg.msg.add.netmask = netmask;
00137 msg.msg.msg.add.gw = gw;
00138 TCPIP_NETIFAPI(&msg);
00139 return msg.msg.err;
00140 }
00141
00142
00143
00144
00145
00146
00147
00148 err_t
00149 netifapi_netif_common( struct netif *netif,
00150 void (* voidfunc)(struct netif *netif),
00151 err_t (* errtfunc)(struct netif *netif) )
00152 {
00153 struct netifapi_msg msg;
00154 msg.function = do_netifapi_netif_common;
00155 msg.msg.netif = netif;
00156 msg.msg.msg.common.voidfunc = voidfunc;
00157 msg.msg.msg.common.errtfunc = errtfunc;
00158 TCPIP_NETIFAPI(&msg);
00159 return msg.msg.err;
00160 }
00161
00162 #endif