#include "lwip/opt.h"#include "lwip/def.h"#include "lwip/mem.h"#include "lwip/netif.h"#include "lwip/ip_addr.h"Include dependency graph for netif.c:
Go to the source code of this file.
Functions | |
| netif * | netif_add (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)) |
| void | netif_set_addr (struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw) |
| void | netif_remove (struct netif *netif) |
| netif * | netif_find (char *name) |
| void | netif_set_ipaddr (struct netif *netif, struct ip_addr *ipaddr) |
| void | netif_set_gw (struct netif *netif, struct ip_addr *gw) |
| void | netif_set_netmask (struct netif *netif, struct ip_addr *netmask) |
| void | netif_set_default (struct netif *netif) |
| void | netif_init (void) |
Variables | |
| netif * | netif_list = NULL |
| netif * | netif_default = NULL |
Definition in file netif.c.
|
||||||||||||||||||||||||||||
|
Add a network interface to the list of lwIP netifs.
Definition at line 69 of file netif.c. References DEBUGF, ERR_OK, err_t, netif::input, ip_addr_debug_print, ipaddr, mem_free(), mem_malloc(), NETIF_DEBUG, netif_list, netif_set_addr(), netif::next, NULL, netif::num, and netif::state.
00074 {
00075 struct netif *netif;
00076 static int netifnum = 0;
00077
00078 /* allocate netif structure */
00079 netif = mem_malloc(sizeof(struct netif));
00080
00081 if(netif == NULL) {
00082 DEBUGF(NETIF_DEBUG, ("netif_add(): out of memory for netif\n"));
00083 return NULL;
00084 }
00085 #if LWIP_DHCP
00086 /* netif not under DHCP control by default */
00087 netif->dhcp = NULL;
00088 #endif
00089 /* remember netif specific state information data */
00090 netif->state = state;
00091 netif->num = netifnum++;
00092 netif->input = input;
00093
00094 netif_set_addr(netif, ipaddr, netmask, gw);
00095
00096 /* call user specified initialization function for netif */
00097 if (init(netif) != ERR_OK) {
00098 mem_free(netif);
00099 return NULL;
00100 }
00101
00102 /* add this netif to the list */
00103 netif->next = netif_list;
00104 netif_list = netif;
00105 #if NETIF_DEBUG
00106 DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
00107 netif->name[0], netif->name[1]));
00108 ip_addr_debug_print(ipaddr);
00109 DEBUGF(NETIF_DEBUG, (" netmask "));
00110 ip_addr_debug_print(netmask);
00111 DEBUGF(NETIF_DEBUG, (" gw "));
00112 ip_addr_debug_print(gw);
00113 DEBUGF(NETIF_DEBUG, ("\n"));
00114 #endif /* NETIF_DEBUG */
00115 return netif;
00116 }
|
Here is the call graph for this function:
|
|
Definition at line 160 of file netif.c. References DEBUGF, name, NETIF_DEBUG, netif_list, NULL, and u8_t.
00161 {
00162 struct netif *netif;
00163 u8_t num;
00164
00165 if(name == NULL) {
00166 return NULL;
00167 }
00168
00169 num = name[2] - '0';
00170
00171 for(netif = netif_list; netif != NULL; netif = netif->next) {
00172 if(num == netif->num &&
00173 name[0] == netif->name[0] &&
00174 name[1] == netif->name[1]) {
00175 DEBUGF(NETIF_DEBUG, ("netif_find: found %s\n", name));
00176 return netif;
00177 }
00178 }
00179 DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %s\n", name));
00180 return NULL;
00181 }
|
|
|
Definition at line 228 of file netif.c. References netif_default, netif_list, and NULL.
00229 {
00230 netif_list = netif_default = NULL;
00231 }
|
|
|
Definition at line 128 of file netif.c. References DEBUGF, mem_free(), NETIF_DEBUG, netif_default, netif_list, netif::next, and NULL.
00129 {
00130 if ( netif == NULL ) return;
00131
00132 /* is it the first netif? */
00133 if(netif_list == netif) {
00134 netif_list = netif->next;
00135 }
00136 else
00137 {
00138 /* look for netif further down the list */
00139 struct netif * tmpNetif;
00140 for(tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
00141 if(tmpNetif->next == netif) {
00142 tmpNetif->next = netif->next;
00143 break;
00144 }
00145 }
00146 if(tmpNetif == NULL)
00147 return; /* we didn't find any netif today */
00148 }
00149 /* this netif is default? */
00150 if (netif_default == netif)
00151 /* reset default netif */
00152 netif_default = NULL;
00153
00154 DEBUGF(NETIF_DEBUG, ("netif_remove: removed netif\n"));
00155 mem_free( netif );
00156 }
|
Here is the call graph for this function:
|
||||||||||||||||||||
|
Definition at line 119 of file netif.c. References ipaddr, netif_set_gw(), netif_set_ipaddr(), and netif_set_netmask(). Referenced by netif_add().
00121 {
00122 netif_set_ipaddr(netif, ipaddr);
00123 netif_set_netmask(netif, netmask);
00124 netif_set_gw(netif, gw);
00125 }
|
Here is the call graph for this function:
|
|
Definition at line 220 of file netif.c. References DEBUGF, NETIF_DEBUG, and netif_default.
00221 {
00222 netif_default = netif;
00223 DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
00224 netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
00225 }
|
|
||||||||||||
|
Definition at line 196 of file netif.c. References ip_addr::addr, DBG_STATE, DBG_TRACE, DEBUGF, netif::gw, ip_addr_set, netif::name, NETIF_DEBUG, ntohl, netif::num, and u8_t. Referenced by dhcp_bind(), dhcp_release(), and netif_set_addr().
00197 {
00198 DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting GW address of interface %c%c%u to %u.%u.%u.%u\n",
00199 netif->name[0], netif->name[1], netif->num,
00200 (u8_t)(ntohl(gw->addr) >> 24 & 0xff),
00201 (u8_t)(ntohl(gw->addr) >> 16 & 0xff),
00202 (u8_t)(ntohl(gw->addr) >> 8 & 0xff),
00203 (u8_t)(ntohl(gw->addr) & 0xff)));
00204 ip_addr_set(&(netif->gw), gw);
00205 }
|
|
||||||||||||
|
Definition at line 184 of file netif.c. References ip_addr::addr, DBG_STATE, DBG_TRACE, DEBUGF, netif::ip_addr, ip_addr_set, ipaddr, netif::name, NETIF_DEBUG, ntohl, netif::num, and u8_t. Referenced by dhcp_bind(), dhcp_release(), and netif_set_addr().
00185 {
00186 DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting IP address of interface %c%c%u to %u.%u.%u.%u\n",
00187 netif->name[0], netif->name[1], netif->num,
00188 (u8_t)(ntohl(ipaddr->addr) >> 24 & 0xff),
00189 (u8_t)(ntohl(ipaddr->addr) >> 16 & 0xff),
00190 (u8_t)(ntohl(ipaddr->addr) >> 8 & 0xff),
00191 (u8_t)(ntohl(ipaddr->addr) & 0xff)));
00192 ip_addr_set(&(netif->ip_addr), ipaddr);
00193 }
|
|
||||||||||||
|
Definition at line 208 of file netif.c. References ip_addr::addr, DBG_STATE, DBG_TRACE, DEBUGF, ip_addr_set, netif::name, NETIF_DEBUG, netif::netmask, ntohl, netif::num, and u8_t. Referenced by dhcp_bind(), dhcp_release(), and netif_set_addr().
00209 {
00210 DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting netmask of interface %c%c%u to %u.%u.%u.%u\n",
00211 netif->name[0], netif->name[1], netif->num,
00212 (u8_t)(ntohl(netmask->addr) >> 24 & 0xff),
00213 (u8_t)(ntohl(netmask->addr) >> 16 & 0xff),
00214 (u8_t)(ntohl(netmask->addr) >> 8 & 0xff),
00215 (u8_t)(ntohl(netmask->addr) & 0xff)));
00216 ip_addr_set(&(netif->netmask), netmask);
00217 }
|
|
|
The default network interface. Definition at line 54 of file netif.c. Referenced by ip_route(), netif_init(), netif_remove(), and netif_set_default(). |
|
|
The list of network interfaces. Definition at line 53 of file netif.c. Referenced by dhcp_coarse_tmr(), dhcp_fine_tmr(), ip_input(), ip_route(), netif_add(), netif_find(), netif_init(), and netif_remove(). |
1.3.4