sys_arch.c 16 KB

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