sys_arch.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. * File : sys_arch.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2012-12-8 Bernard add file header
  13. * export bsd socket symbol for RT-Thread Application Module
  14. */
  15. #include <rtthread.h>
  16. #include "lwip/sys.h"
  17. #include "lwip/opt.h"
  18. #include "lwip/stats.h"
  19. #include "lwip/err.h"
  20. #include "arch/sys_arch.h"
  21. #include "lwip/debug.h"
  22. #include "lwip/netif.h"
  23. #include "lwip/netifapi.h"
  24. #include "lwip/tcpip.h"
  25. #include "netif/ethernetif.h"
  26. #include "lwip/sio.h"
  27. #include "lwip/init.h"
  28. #include "lwip/dhcp.h"
  29. #include <string.h>
  30. /*
  31. * Initialize the network interface device
  32. *
  33. * @return the operation status, ERR_OK on OK, ERR_IF on error
  34. */
  35. static err_t netif_device_init(struct netif *netif)
  36. {
  37. struct eth_device *ethif;
  38. ethif = (struct eth_device *)netif->state;
  39. if (ethif != RT_NULL)
  40. {
  41. rt_device_t device;
  42. /* get device object */
  43. device = (rt_device_t) ethif;
  44. if (rt_device_init(device) != RT_EOK)
  45. {
  46. return ERR_IF;
  47. }
  48. /* copy device flags to netif flags */
  49. netif->flags = ethif->flags;
  50. return ERR_OK;
  51. }
  52. return ERR_IF;
  53. }
  54. /*
  55. * Initialize the ethernetif layer and set network interface device up
  56. */
  57. static void tcpip_init_done_callback(void *arg)
  58. {
  59. rt_device_t device;
  60. struct eth_device *ethif;
  61. ip_addr_t ipaddr, netmask, gw;
  62. struct rt_list_node* node;
  63. struct rt_object* object;
  64. struct rt_object_information *information;
  65. extern struct rt_object_information rt_object_container[];
  66. LWIP_ASSERT("invalid arg.\n",arg);
  67. IP4_ADDR(&gw, 0,0,0,0);
  68. IP4_ADDR(&ipaddr, 0,0,0,0);
  69. IP4_ADDR(&netmask, 0,0,0,0);
  70. /* enter critical */
  71. rt_enter_critical();
  72. /* for each network interfaces */
  73. information = &rt_object_container[RT_Object_Class_Device];
  74. for (node = information->object_list.next;
  75. node != &(information->object_list);
  76. node = node->next)
  77. {
  78. object = rt_list_entry(node, struct rt_object, list);
  79. device = (rt_device_t)object;
  80. if (device->type == RT_Device_Class_NetIf)
  81. {
  82. ethif = (struct eth_device *)device;
  83. /* leave critical */
  84. rt_exit_critical();
  85. netif_add(ethif->netif, &ipaddr, &netmask, &gw,
  86. ethif, netif_device_init, tcpip_input);
  87. if (netif_default == RT_NULL)
  88. netif_set_default(ethif->netif);
  89. #if LWIP_DHCP
  90. /* set interface up */
  91. netif_set_up(ethif->netif);
  92. /* if this interface uses DHCP, start the DHCP client */
  93. dhcp_start(ethif->netif);
  94. #else
  95. /* set interface up */
  96. netif_set_up(ethif->netif);
  97. #endif
  98. if (ethif->flags & ETHIF_LINK_PHYUP)
  99. {
  100. netif_set_link_up(ethif->netif);
  101. }
  102. /* enter critical */
  103. rt_enter_critical();
  104. }
  105. }
  106. /* leave critical */
  107. rt_exit_critical();
  108. rt_sem_release((rt_sem_t)arg);
  109. }
  110. /**
  111. * LwIP system initialization
  112. */
  113. int lwip_system_init(void)
  114. {
  115. rt_err_t rc;
  116. struct rt_semaphore done_sem;
  117. /* set default netif to NULL */
  118. netif_default = RT_NULL;
  119. rc = rt_sem_init(&done_sem, "done", 0, RT_IPC_FLAG_FIFO);
  120. if (rc != RT_EOK)
  121. {
  122. LWIP_ASSERT("Failed to create semaphore", 0);
  123. return -1;
  124. }
  125. tcpip_init(tcpip_init_done_callback, (void *)&done_sem);
  126. /* waiting for initialization done */
  127. if (rt_sem_take(&done_sem, RT_WAITING_FOREVER) != RT_EOK)
  128. {
  129. rt_sem_detach(&done_sem);
  130. return -1;
  131. }
  132. rt_sem_detach(&done_sem);
  133. /* set default ip address */
  134. #if !LWIP_DHCP
  135. if (netif_default != RT_NULL)
  136. {
  137. struct ip4_addr ipaddr, netmask, gw;
  138. IP4_ADDR(&ipaddr, RT_LWIP_IPADDR0, RT_LWIP_IPADDR1, RT_LWIP_IPADDR2, RT_LWIP_IPADDR3);
  139. IP4_ADDR(&gw, RT_LWIP_GWADDR0, RT_LWIP_GWADDR1, RT_LWIP_GWADDR2, RT_LWIP_GWADDR3);
  140. IP4_ADDR(&netmask, RT_LWIP_MSKADDR0, RT_LWIP_MSKADDR1, RT_LWIP_MSKADDR2, RT_LWIP_MSKADDR3);
  141. netifapi_netif_set_addr(netif_default, &ipaddr, &netmask, &gw);
  142. }
  143. #endif
  144. rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION);
  145. return 0;
  146. }
  147. INIT_COMPONENT_EXPORT(lwip_system_init);
  148. void sys_init(void)
  149. {
  150. /* nothing on RT-Thread porting */
  151. }
  152. void lwip_sys_init(void)
  153. {
  154. lwip_system_init();
  155. }
  156. /*
  157. * Create a new semaphore
  158. *
  159. * @return the operation status, ERR_OK on OK; others on error
  160. */
  161. err_t sys_sem_new(sys_sem_t *sem, u8_t count)
  162. {
  163. static unsigned short counter = 0;
  164. char tname[RT_NAME_MAX];
  165. sys_sem_t tmpsem;
  166. RT_DEBUG_NOT_IN_INTERRUPT;
  167. rt_snprintf(tname, RT_NAME_MAX, "%s%d", SYS_LWIP_SEM_NAME, counter);
  168. counter ++;
  169. tmpsem = rt_sem_create(tname, count, RT_IPC_FLAG_FIFO);
  170. if (tmpsem == RT_NULL)
  171. return ERR_MEM;
  172. else
  173. {
  174. *sem = tmpsem;
  175. return ERR_OK;
  176. }
  177. }
  178. /*
  179. * Deallocate a semaphore
  180. */
  181. void sys_sem_free(sys_sem_t *sem)
  182. {
  183. RT_DEBUG_NOT_IN_INTERRUPT;
  184. rt_sem_delete(*sem);
  185. }
  186. /*
  187. * Signal a semaphore
  188. */
  189. void sys_sem_signal(sys_sem_t *sem)
  190. {
  191. rt_sem_release(*sem);
  192. }
  193. /*
  194. * Block the thread while waiting for the semaphore to be signaled
  195. *
  196. * @return If the timeout argument is non-zero, it will return the number of milliseconds
  197. * spent waiting for the semaphore to be signaled; If the semaphore isn't signaled
  198. * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
  199. * wait for the semaphore, it will return zero
  200. */
  201. u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
  202. {
  203. rt_err_t ret;
  204. s32_t t;
  205. u32_t tick;
  206. RT_DEBUG_NOT_IN_INTERRUPT;
  207. /* get the begin tick */
  208. tick = rt_tick_get();
  209. if (timeout == 0)
  210. t = RT_WAITING_FOREVER;
  211. else
  212. {
  213. /* convert msecond to os tick */
  214. if (timeout < (1000/RT_TICK_PER_SECOND))
  215. t = 1;
  216. else
  217. t = timeout / (1000/RT_TICK_PER_SECOND);
  218. }
  219. ret = rt_sem_take(*sem, t);
  220. if (ret == -RT_ETIMEOUT)
  221. return SYS_ARCH_TIMEOUT;
  222. else
  223. {
  224. if (ret == RT_EOK)
  225. ret = 1;
  226. }
  227. /* get elapse msecond */
  228. tick = rt_tick_get() - tick;
  229. /* convert tick to msecond */
  230. tick = tick * (1000 / RT_TICK_PER_SECOND);
  231. if (tick == 0)
  232. tick = 1;
  233. return tick;
  234. }
  235. #ifndef sys_sem_valid
  236. /** Check if a semaphore is valid/allocated:
  237. * return 1 for valid, 0 for invalid
  238. */
  239. int sys_sem_valid(sys_sem_t *sem)
  240. {
  241. return (int)(*sem);
  242. }
  243. #endif
  244. #ifndef sys_sem_set_invalid
  245. /** Set a semaphore invalid so that sys_sem_valid returns 0
  246. */
  247. void sys_sem_set_invalid(sys_sem_t *sem)
  248. {
  249. *sem = RT_NULL;
  250. }
  251. #endif
  252. /* ====================== Mutex ====================== */
  253. /** Create a new mutex
  254. * @param mutex pointer to the mutex to create
  255. * @return a new mutex
  256. */
  257. err_t sys_mutex_new(sys_mutex_t *mutex)
  258. {
  259. static unsigned short counter = 0;
  260. char tname[RT_NAME_MAX];
  261. sys_mutex_t tmpmutex;
  262. RT_DEBUG_NOT_IN_INTERRUPT;
  263. rt_snprintf(tname, RT_NAME_MAX, "%s%d", SYS_LWIP_MUTEX_NAME, counter);
  264. counter ++;
  265. tmpmutex = rt_mutex_create(tname, RT_IPC_FLAG_FIFO);
  266. if (tmpmutex == RT_NULL)
  267. return ERR_MEM;
  268. else
  269. {
  270. *mutex = tmpmutex;
  271. return ERR_OK;
  272. }
  273. }
  274. /** Lock a mutex
  275. * @param mutex the mutex to lock
  276. */
  277. void sys_mutex_lock(sys_mutex_t *mutex)
  278. {
  279. RT_DEBUG_NOT_IN_INTERRUPT;
  280. rt_mutex_take(*mutex, RT_WAITING_FOREVER);
  281. return;
  282. }
  283. /** Unlock a mutex
  284. * @param mutex the mutex to unlock
  285. */
  286. void sys_mutex_unlock(sys_mutex_t *mutex)
  287. {
  288. rt_mutex_release(*mutex);
  289. }
  290. /** Delete a semaphore
  291. * @param mutex the mutex to delete
  292. */
  293. void sys_mutex_free(sys_mutex_t *mutex)
  294. {
  295. RT_DEBUG_NOT_IN_INTERRUPT;
  296. rt_mutex_delete(*mutex);
  297. }
  298. #ifndef sys_mutex_valid
  299. /** Check if a mutex is valid/allocated:
  300. * return 1 for valid, 0 for invalid
  301. */
  302. int sys_mutex_valid(sys_mutex_t *mutex)
  303. {
  304. return (int)(*mutex);
  305. }
  306. #endif
  307. #ifndef sys_mutex_set_invalid
  308. /** Set a mutex invalid so that sys_mutex_valid returns 0
  309. */
  310. void sys_mutex_set_invalid(sys_mutex_t *mutex)
  311. {
  312. *mutex = RT_NULL;
  313. }
  314. #endif
  315. /* ====================== Mailbox ====================== */
  316. /*
  317. * Create an empty mailbox for maximum "size" elements
  318. *
  319. * @return the operation status, ERR_OK on OK; others on error
  320. */
  321. err_t sys_mbox_new(sys_mbox_t *mbox, int size)
  322. {
  323. static unsigned short counter = 0;
  324. char tname[RT_NAME_MAX];
  325. sys_mbox_t tmpmbox;
  326. RT_DEBUG_NOT_IN_INTERRUPT;
  327. rt_snprintf(tname, RT_NAME_MAX, "%s%d", SYS_LWIP_MBOX_NAME, counter);
  328. counter ++;
  329. tmpmbox = rt_mb_create(tname, size, RT_IPC_FLAG_FIFO);
  330. if (tmpmbox != RT_NULL)
  331. {
  332. *mbox = tmpmbox;
  333. return ERR_OK;
  334. }
  335. return ERR_MEM;
  336. }
  337. /*
  338. * Deallocate a mailbox
  339. */
  340. void sys_mbox_free(sys_mbox_t *mbox)
  341. {
  342. RT_DEBUG_NOT_IN_INTERRUPT;
  343. rt_mb_delete(*mbox);
  344. return;
  345. }
  346. /** Post a message to an mbox - may not fail
  347. * -> blocks if full, only used from tasks not from ISR
  348. * @param mbox mbox to posts the message
  349. * @param msg message to post (ATTENTION: can be NULL)
  350. */
  351. void sys_mbox_post(sys_mbox_t *mbox, void *msg)
  352. {
  353. RT_DEBUG_NOT_IN_INTERRUPT;
  354. rt_mb_send_wait(*mbox, (rt_uint32_t)msg, RT_WAITING_FOREVER);
  355. return;
  356. }
  357. /*
  358. * Try to post the "msg" to the mailbox
  359. *
  360. * @return return ERR_OK if the "msg" is posted, ERR_MEM if the mailbox is full
  361. */
  362. err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
  363. {
  364. if (rt_mb_send(*mbox, (rt_uint32_t)msg) == RT_EOK)
  365. return ERR_OK;
  366. return ERR_MEM;
  367. }
  368. /** Wait for a new message to arrive in the mbox
  369. * @param mbox mbox to get a message from
  370. * @param msg pointer where the message is stored
  371. * @param timeout maximum time (in milliseconds) to wait for a message
  372. * @return time (in milliseconds) waited for a message, may be 0 if not waited
  373. or SYS_ARCH_TIMEOUT on timeout
  374. * The returned time has to be accurate to prevent timer jitter!
  375. */
  376. u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
  377. {
  378. rt_err_t ret;
  379. s32_t t;
  380. u32_t tick;
  381. RT_DEBUG_NOT_IN_INTERRUPT;
  382. /* get the begin tick */
  383. tick = rt_tick_get();
  384. if(timeout == 0)
  385. t = RT_WAITING_FOREVER;
  386. else
  387. {
  388. /* convirt msecond to os tick */
  389. if (timeout < (1000/RT_TICK_PER_SECOND))
  390. t = 1;
  391. else
  392. t = timeout / (1000/RT_TICK_PER_SECOND);
  393. }
  394. ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, t);
  395. if(ret == -RT_ETIMEOUT)
  396. return SYS_ARCH_TIMEOUT;
  397. else
  398. {
  399. LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK);
  400. }
  401. /* get elapse msecond */
  402. tick = rt_tick_get() - tick;
  403. /* convert tick to msecond */
  404. tick = tick * (1000 / RT_TICK_PER_SECOND);
  405. if (tick == 0)
  406. tick = 1;
  407. return tick;
  408. }
  409. /** Wait for a new message to arrive in the mbox
  410. * @param mbox mbox to get a message from
  411. * @param msg pointer where the message is stored
  412. * @param timeout maximum time (in milliseconds) to wait for a message
  413. * @return 0 (milliseconds) if a message has been received
  414. * or SYS_MBOX_EMPTY if the mailbox is empty
  415. */
  416. u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
  417. {
  418. int ret;
  419. ret = rt_mb_recv(*mbox, (rt_uint32_t *)msg, 0);
  420. if(ret == -RT_ETIMEOUT)
  421. return SYS_ARCH_TIMEOUT;
  422. else
  423. {
  424. if (ret == RT_EOK)
  425. ret = 1;
  426. }
  427. return ret;
  428. }
  429. #ifndef sys_mbox_valid
  430. /** Check if an mbox is valid/allocated:
  431. * return 1 for valid, 0 for invalid
  432. */
  433. int sys_mbox_valid(sys_mbox_t *mbox)
  434. {
  435. return (int)(*mbox);
  436. }
  437. #endif
  438. #ifndef sys_mbox_set_invalid
  439. /** Set an mbox invalid so that sys_mbox_valid returns 0
  440. */
  441. void sys_mbox_set_invalid(sys_mbox_t *mbox)
  442. {
  443. *mbox = RT_NULL;
  444. }
  445. #endif
  446. /* ====================== System ====================== */
  447. /*
  448. * Start a new thread named "name" with priority "prio" that will begin
  449. * its execution in the function "thread()". The "arg" argument will be
  450. * passed as an argument to the thread() function
  451. */
  452. sys_thread_t sys_thread_new(const char *name,
  453. lwip_thread_fn thread,
  454. void *arg,
  455. int stacksize,
  456. int prio)
  457. {
  458. rt_thread_t t;
  459. RT_DEBUG_NOT_IN_INTERRUPT;
  460. /* create thread */
  461. t = rt_thread_create(name, thread, arg, stacksize, prio, 20);
  462. RT_ASSERT(t != RT_NULL);
  463. /* startup thread */
  464. rt_thread_startup(t);
  465. return t;
  466. }
  467. sys_prot_t sys_arch_protect(void)
  468. {
  469. rt_base_t level;
  470. /* disable interrupt */
  471. level = rt_hw_interrupt_disable();
  472. return level;
  473. }
  474. void sys_arch_unprotect(sys_prot_t pval)
  475. {
  476. /* enable interrupt */
  477. rt_hw_interrupt_enable(pval);
  478. return;
  479. }
  480. void sys_arch_assert(const char *file, int line)
  481. {
  482. rt_kprintf("\nAssertion: %d in %s, thread %s\n",
  483. line, file, rt_thread_self()->name);
  484. RT_ASSERT(0);
  485. }
  486. u32_t sys_jiffies(void)
  487. {
  488. return rt_tick_get();
  489. }
  490. u32_t sys_now(void)
  491. {
  492. return rt_tick_get() * (1000 / RT_TICK_PER_SECOND);
  493. }
  494. RT_WEAK
  495. void mem_init(void)
  496. {
  497. }
  498. void *mem_calloc(mem_size_t count, mem_size_t size)
  499. {
  500. return rt_calloc(count, size);
  501. }
  502. void *mem_trim(void *mem, mem_size_t size)
  503. {
  504. // return rt_realloc(mem, size);
  505. /* not support trim yet */
  506. return mem;
  507. }
  508. void *mem_malloc(mem_size_t size)
  509. {
  510. return rt_malloc(size);
  511. }
  512. void mem_free(void *mem)
  513. {
  514. rt_free(mem);
  515. }
  516. #ifdef RT_LWIP_PPP
  517. u32_t sio_read(sio_fd_t fd, u8_t *buf, u32_t size)
  518. {
  519. u32_t len;
  520. RT_ASSERT(fd != RT_NULL);
  521. len = rt_device_read((rt_device_t)fd, 0, buf, size);
  522. if (len <= 0)
  523. return 0;
  524. return len;
  525. }
  526. u32_t sio_write(sio_fd_t fd, u8_t *buf, u32_t size)
  527. {
  528. RT_ASSERT(fd != RT_NULL);
  529. return rt_device_write((rt_device_t)fd, 0, buf, size);
  530. }
  531. void sio_read_abort(sio_fd_t fd)
  532. {
  533. rt_kprintf("read_abort\n");
  534. }
  535. void ppp_trace(int level, const char *format, ...)
  536. {
  537. va_list args;
  538. rt_size_t length;
  539. static char rt_log_buf[RT_CONSOLEBUF_SIZE];
  540. va_start(args, format);
  541. length = rt_vsprintf(rt_log_buf, format, args);
  542. rt_device_write((rt_device_t)rt_console_get_device(), 0, rt_log_buf, length);
  543. va_end(args);
  544. }
  545. #endif
  546. /*
  547. * export bsd socket symbol for RT-Thread Application Module
  548. */
  549. #if LWIP_SOCKET
  550. #include <lwip/sockets.h>
  551. RTM_EXPORT(lwip_accept);
  552. RTM_EXPORT(lwip_bind);
  553. RTM_EXPORT(lwip_shutdown);
  554. RTM_EXPORT(lwip_getpeername);
  555. RTM_EXPORT(lwip_getsockname);
  556. RTM_EXPORT(lwip_getsockopt);
  557. RTM_EXPORT(lwip_setsockopt);
  558. RTM_EXPORT(lwip_close);
  559. RTM_EXPORT(lwip_connect);
  560. RTM_EXPORT(lwip_listen);
  561. RTM_EXPORT(lwip_recv);
  562. RTM_EXPORT(lwip_read);
  563. RTM_EXPORT(lwip_recvfrom);
  564. RTM_EXPORT(lwip_send);
  565. RTM_EXPORT(lwip_sendto);
  566. RTM_EXPORT(lwip_socket);
  567. RTM_EXPORT(lwip_write);
  568. RTM_EXPORT(lwip_select);
  569. RTM_EXPORT(lwip_ioctl);
  570. RTM_EXPORT(lwip_fcntl);
  571. RTM_EXPORT(lwip_htons);
  572. RTM_EXPORT(lwip_htonl);
  573. #if LWIP_DNS
  574. #include <lwip/netdb.h>
  575. RTM_EXPORT(lwip_gethostbyname);
  576. RTM_EXPORT(lwip_gethostbyname_r);
  577. RTM_EXPORT(lwip_freeaddrinfo);
  578. RTM_EXPORT(lwip_getaddrinfo);
  579. #endif
  580. #endif
  581. #if LWIP_DHCP
  582. #include <lwip/dhcp.h>
  583. RTM_EXPORT(dhcp_start);
  584. RTM_EXPORT(dhcp_renew);
  585. RTM_EXPORT(dhcp_stop);
  586. #endif
  587. #if LWIP_NETIF_API
  588. #include <lwip/netifapi.h>
  589. RTM_EXPORT(netifapi_netif_set_addr);
  590. #endif
  591. #if LWIP_NETIF_LINK_CALLBACK
  592. RTM_EXPORT(netif_set_link_callback);
  593. #endif
  594. #if LWIP_NETIF_STATUS_CALLBACK
  595. RTM_EXPORT(netif_set_status_callback);
  596. #endif
  597. RTM_EXPORT(netif_find);
  598. RTM_EXPORT(netif_set_addr);
  599. RTM_EXPORT(netif_set_ipaddr);
  600. RTM_EXPORT(netif_set_gw);
  601. RTM_EXPORT(netif_set_netmask);