sys_arch.c 17 KB

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