Warning, cross-references for /kernel/lwip/api/netifapi.c need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "lwip/opt.h"
0035
0036 #if LWIP_NETIF_API
0037
0038 #include "lwip/netifapi.h"
0039 #include "lwip/tcpip.h"
0040
0041
0042
0043
0044 void
0045 do_netifapi_netif_add( struct netifapi_msg_msg *msg)
0046 {
0047 if (!netif_add( msg->netif,
0048 msg->msg.add.ipaddr,
0049 msg->msg.add.netmask,
0050 msg->msg.add.gw,
0051 msg->msg.add.state,
0052 msg->msg.add.init,
0053 msg->msg.add.input)) {
0054 msg->err = ERR_IF;
0055 } else {
0056 msg->err = ERR_OK;
0057 }
0058 TCPIP_NETIFAPI_ACK(msg);
0059 }
0060
0061
0062
0063
0064 void
0065 do_netifapi_netif_set_addr( struct netifapi_msg_msg *msg)
0066 {
0067 netif_set_addr( msg->netif,
0068 msg->msg.add.ipaddr,
0069 msg->msg.add.netmask,
0070 msg->msg.add.gw);
0071 msg->err = ERR_OK;
0072 TCPIP_NETIFAPI_ACK(msg);
0073 }
0074
0075
0076
0077
0078
0079 void
0080 do_netifapi_netif_common( struct netifapi_msg_msg *msg)
0081 {
0082 if (msg->msg.common.errtfunc!=NULL) {
0083 msg->err =
0084 msg->msg.common.errtfunc(msg->netif);
0085 } else {
0086 msg->err = ERR_OK;
0087 msg->msg.common.voidfunc(msg->netif);
0088 }
0089 TCPIP_NETIFAPI_ACK(msg);
0090 }
0091
0092
0093
0094
0095
0096
0097
0098 err_t
0099 netifapi_netif_add(struct netif *netif,
0100 struct ip_addr *ipaddr,
0101 struct ip_addr *netmask,
0102 struct ip_addr *gw,
0103 void *state,
0104 err_t (* init)(struct netif *netif),
0105 err_t (* input)(struct pbuf *p, struct netif *netif))
0106 {
0107 struct netifapi_msg msg;
0108 msg.function = do_netifapi_netif_add;
0109 msg.msg.netif = netif;
0110 msg.msg.msg.add.ipaddr = ipaddr;
0111 msg.msg.msg.add.netmask = netmask;
0112 msg.msg.msg.add.gw = gw;
0113 msg.msg.msg.add.state = state;
0114 msg.msg.msg.add.init = init;
0115 msg.msg.msg.add.input = input;
0116 TCPIP_NETIFAPI(&msg);
0117 return msg.msg.err;
0118 }
0119
0120
0121
0122
0123
0124
0125
0126 err_t
0127 netifapi_netif_set_addr(struct netif *netif,
0128 struct ip_addr *ipaddr,
0129 struct ip_addr *netmask,
0130 struct ip_addr *gw)
0131 {
0132 struct netifapi_msg msg;
0133 msg.function = do_netifapi_netif_set_addr;
0134 msg.msg.netif = netif;
0135 msg.msg.msg.add.ipaddr = ipaddr;
0136 msg.msg.msg.add.netmask = netmask;
0137 msg.msg.msg.add.gw = gw;
0138 TCPIP_NETIFAPI(&msg);
0139 return msg.msg.err;
0140 }
0141
0142
0143
0144
0145
0146
0147
0148 err_t
0149 netifapi_netif_common( struct netif *netif,
0150 void (* voidfunc)(struct netif *netif),
0151 err_t (* errtfunc)(struct netif *netif) )
0152 {
0153 struct netifapi_msg msg;
0154 msg.function = do_netifapi_netif_common;
0155 msg.msg.netif = netif;
0156 msg.msg.msg.common.voidfunc = voidfunc;
0157 msg.msg.msg.common.errtfunc = errtfunc;
0158 TCPIP_NETIFAPI(&msg);
0159 return msg.msg.err;
0160 }
0161
0162 #endif