icmpv6.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /****************************************************************************
  2. * net/icmpv6/icmpv6.h
  3. *
  4. * Copyright (C) 2015, 2017-2019 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. #ifndef __NET_ICMPv6_ICMPv6_H
  36. #define __NET_ICMPv6_ICMPv6_H
  37. /****************************************************************************
  38. * Included Files
  39. ****************************************************************************/
  40. #include <nuttx/config.h>
  41. #include <sys/types.h>
  42. #include <stdint.h>
  43. #include <semaphore.h>
  44. #include <queue.h>
  45. #include <assert.h>
  46. #include <nuttx/mm/iob.h>
  47. #include <nuttx/net/ip.h>
  48. #include <nuttx/net/netdev.h>
  49. #if defined(CONFIG_NET_ICMPv6) && !defined(CONFIG_NET_ICMPv6_NO_STACK)
  50. /****************************************************************************
  51. * Pre-processor Definitions
  52. ****************************************************************************/
  53. #define NET_ICMPv6_HAVE_STACK 1
  54. /* Allocate a new ICMPv6 data callback */
  55. #define icmpv6_callback_alloc(dev, conn) \
  56. devif_callback_alloc((dev), &(conn)->list)
  57. #define icmpv6_callback_free(dev, conn, cb) \
  58. devif_conn_callback_free((dev), (cb), &(conn)->list)
  59. /****************************************************************************
  60. * Public Type Definitions
  61. ****************************************************************************/
  62. #ifdef CONFIG_NET_ICMPv6_SOCKET
  63. /* Representation of a IPPROTO_ICMP socket connection */
  64. struct devif_callback_s; /* Forward reference */
  65. struct icmpv6_conn_s
  66. {
  67. /* Common prologue of all connection structures. */
  68. dq_entry_t node; /* Supports a double linked list */
  69. /* This is a list of ICMPV6 callbacks. Each callback represents a thread
  70. * that is stalled, waiting for a device-specific event.
  71. */
  72. FAR struct devif_callback_s *list;
  73. /* ICMPv6-specific content follows */
  74. uint16_t id; /* ICMPv6 ECHO request ID */
  75. uint8_t nreqs; /* Number of requests with no response received */
  76. uint8_t crefs; /* Reference counts on this instance */
  77. /* The device that the ICMPv6 request was sent on */
  78. FAR struct net_driver_s *dev; /* Needed to free the callback structure */
  79. #ifdef CONFIG_MM_IOB
  80. /* ICMPv6 response read-ahead list. A singly linked list of type struct
  81. * iob_qentry_s where the ICMPv6 read-ahead data for the current ID is
  82. * retained.
  83. */
  84. struct iob_queue_s readahead; /* Read-ahead buffering */
  85. #endif
  86. };
  87. #endif
  88. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  89. /* Used to notify a thread waiting for a particular Neighbor Advertisement */
  90. struct icmpv6_notify_s
  91. {
  92. FAR struct icmpv6_notify_s *nt_flink; /* Supports singly linked list */
  93. net_ipv6addr_t nt_ipaddr; /* Waited for IP address in the mapping */
  94. sem_t nt_sem; /* Will wake up the waiter */
  95. int nt_result; /* The result of the wait */
  96. };
  97. #endif
  98. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  99. /* Used to notify a thread waiting for a particular Router Advertisement */
  100. struct icmpv6_rnotify_s
  101. {
  102. FAR struct icmpv6_rnotify_s *rn_flink; /* Supports singly linked list */
  103. char rn_ifname[IFNAMSIZ]; /* Device name */
  104. sem_t rn_sem; /* Will wake up the waiter */
  105. int rn_result; /* The result of the wait */
  106. };
  107. #endif
  108. /****************************************************************************
  109. * Public Data
  110. ****************************************************************************/
  111. #ifdef __cplusplus
  112. # define EXTERN extern "C"
  113. extern "C"
  114. {
  115. #else
  116. # define EXTERN extern
  117. #endif
  118. #ifdef CONFIG_NET_ICMPv6_SOCKET
  119. /* PF_INET6 socket address family, IPPROTO_ICMP6 protocol interface */
  120. EXTERN const struct sock_intf_s g_icmpv6_sockif;
  121. #endif
  122. /****************************************************************************
  123. * Public Function Prototypes
  124. ****************************************************************************/
  125. struct timespec; /* Forward reference */
  126. struct net_driver_s; /* Forward reference */
  127. struct socket; /* Forward reference */
  128. struct sockaddr; /* Forward reference */
  129. struct pollfd; /* Forward reference */
  130. /****************************************************************************
  131. * Name: icmpv6_input
  132. *
  133. * Description:
  134. * Handle incoming ICMPv6 input
  135. *
  136. * Input Parameters:
  137. * dev - The device driver structure containing the received ICMPv6
  138. * packet
  139. * iplen - The size of the IPv6 header. This may be larger than
  140. * IPv6_HDRLEN the IPv6 header if IPv6 extension headers are
  141. * present.
  142. *
  143. * Returned Value:
  144. * None
  145. *
  146. * Assumptions:
  147. * The network is locked.
  148. *
  149. ****************************************************************************/
  150. void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen);
  151. /****************************************************************************
  152. * Name: icmpv6_neighbor
  153. *
  154. * Description:
  155. * The icmpv6_solicit() call may be to send an ICMPv6 Neighbor
  156. * Solicitation to resolve an IPv6 address. This function first checks if
  157. * the IPv6 address is already in the Neighbor Table. If so, then it
  158. * returns success immediately.
  159. *
  160. * If the requested IPv6 address in not in the Neighbor Table, then this
  161. * function will send the Neighbor Solicitation, delay, then check if the
  162. * IP address is now in the Neighbor able. It will repeat this sequence
  163. * until either (1) the IPv6 address mapping is now in the Neighbor table,
  164. * or (2) a configurable number of timeouts occur without receiving the
  165. * ICMPv6 Neighbor Advertisement.
  166. *
  167. * Input Parameters:
  168. * ipaddr The IPv6 address to be queried.
  169. *
  170. * Returned Value:
  171. * Zero (OK) is returned on success and the IP address mapping can now be
  172. * found in the Neighbor Table. On error a negated errno value is returned:
  173. *
  174. * -ETIMEDOUT: The number or retry counts has been exceed.
  175. * -EHOSTUNREACH: Could not find a route to the host
  176. *
  177. * Assumptions:
  178. * This function is called from the normal tasking context.
  179. *
  180. ****************************************************************************/
  181. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  182. int icmpv6_neighbor(const net_ipv6addr_t ipaddr);
  183. #else
  184. # define icmpv6_neighbor(i) (0)
  185. #endif
  186. /****************************************************************************
  187. * Name: icmpv6_poll
  188. *
  189. * Description:
  190. * Poll a UDP "connection" structure for availability of ICMPv6 TX data
  191. *
  192. * Input Parameters:
  193. * dev - The device driver structure to use in the send operation
  194. *
  195. * Returned Value:
  196. * None
  197. *
  198. * Assumptions:
  199. * The network is locked.
  200. *
  201. ****************************************************************************/
  202. #if defined(CONFIG_NET_ICMPv6_SOCKET) || defined(CONFIG_NET_ICMPv6_NEIGHBOR)
  203. void icmpv6_poll(FAR struct net_driver_s *dev,
  204. FAR struct icmpv6_conn_s *conn);
  205. #endif
  206. /****************************************************************************
  207. * Name: icmpv6_solicit
  208. *
  209. * Description:
  210. * Set up to send an ICMPv6 Neighbor Solicitation message
  211. *
  212. * Input Parameters:
  213. * dev - Reference to a device driver structure
  214. * ipaddr - IP address of Neighbor to be solicited
  215. *
  216. * Returned Value:
  217. * None
  218. *
  219. ****************************************************************************/
  220. void icmpv6_solicit(FAR struct net_driver_s *dev,
  221. FAR const net_ipv6addr_t ipaddr);
  222. /****************************************************************************
  223. * Name: icmpv6_rsolicit
  224. *
  225. * Description:
  226. * Set up to send an ICMPv6 Router Solicitation message. This version
  227. * is for a standalone solicitation. If formats:
  228. *
  229. * - The IPv6 header
  230. * - The ICMPv6 Neighbor Router Message
  231. *
  232. * The device IP address should have been set to the link local address
  233. * prior to calling this function.
  234. *
  235. * Input Parameters:
  236. * dev - Reference to a device driver structure
  237. *
  238. * Returned Value:
  239. * None
  240. *
  241. ****************************************************************************/
  242. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  243. void icmpv6_rsolicit(FAR struct net_driver_s *dev);
  244. #endif
  245. /****************************************************************************
  246. * Name: icmpv6_advertise
  247. *
  248. * Description:
  249. * Send an ICMPv6 Neighbor Advertisement
  250. *
  251. * Input Parameters:
  252. * dev - The device driver structure containing the outgoing ICMPv6 packet
  253. * buffer
  254. *
  255. * Returned Value:
  256. * None.
  257. *
  258. * Assumptions:
  259. * The network is locked
  260. *
  261. ****************************************************************************/
  262. void icmpv6_advertise(FAR struct net_driver_s *dev,
  263. const net_ipv6addr_t destipaddr);
  264. /****************************************************************************
  265. * Name: icmpv6_radvertise
  266. *
  267. * Description:
  268. * Send an ICMPv6 Router Advertisement
  269. *
  270. * Input Parameters:
  271. * dev - The device driver structure containing the outgoing ICMPv6 packet
  272. * buffer
  273. *
  274. * Returned Value:
  275. * None
  276. *
  277. * Assumptions:
  278. * The network is locked
  279. *
  280. ****************************************************************************/
  281. #ifdef CONFIG_NET_ICMPv6_ROUTER
  282. void icmpv6_radvertise(FAR struct net_driver_s *dev);
  283. #endif
  284. /****************************************************************************
  285. * Name: icmpv6_wait_setup
  286. *
  287. * Description:
  288. * Called BEFORE an Neighbor Solicitation is sent. This function sets up
  289. * the Neighbor Advertisement timeout before the Neighbor Solicitation
  290. * is sent so that there is no race condition when icmpv6_wait() is called.
  291. *
  292. * Assumptions:
  293. * This function is called from icmpv6_neighbor() and executes in the normal
  294. * tasking environment.
  295. *
  296. ****************************************************************************/
  297. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  298. void icmpv6_wait_setup(const net_ipv6addr_t ipaddr,
  299. FAR struct icmpv6_notify_s *notify);
  300. #else
  301. # define icmpv6_wait_setup(i,n)
  302. #endif
  303. /****************************************************************************
  304. * Name: icmpv6_wait_cancel
  305. *
  306. * Description:
  307. * Cancel any wait set after icmpv6_wait_setup is called but before
  308. * icmpv6_wait()is called (icmpv6_wait() will automatically cancel the
  309. * wait).
  310. *
  311. * Assumptions:
  312. * This function may execute in the interrupt context when called from
  313. * icmpv6_wait().
  314. *
  315. ****************************************************************************/
  316. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  317. int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify);
  318. #else
  319. # define icmpv6_wait_cancel(n) (0)
  320. #endif
  321. /****************************************************************************
  322. * Name: icmpv6_wait
  323. *
  324. * Description:
  325. * Called each time that a Neighbor Solicitation is sent. This function
  326. * will sleep until either: (1) the matching Neighbor Advertisement is
  327. * received, or (2) a timeout occurs.
  328. *
  329. * Assumptions:
  330. * This function is called from icmpv6_neighbor() and must execute with
  331. * the network un-locked (interrupts may be disabled to keep the things
  332. * stable).
  333. *
  334. ****************************************************************************/
  335. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  336. int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
  337. FAR struct timespec *timeout);
  338. #else
  339. # define icmpv6_wait(n,t) (0)
  340. #endif
  341. /****************************************************************************
  342. * Name: icmpv6_notify
  343. *
  344. * Description:
  345. * Called each time that a Neighbor Advertisement is received in order to
  346. * wake-up any threads that may be waiting for this particular Neighbor
  347. * Advertisement.
  348. *
  349. * Assumptions:
  350. * This function is called from the MAC device driver indirectly through
  351. * icmpv6_icmpv6in() will execute with the network locked.
  352. *
  353. ****************************************************************************/
  354. #ifdef CONFIG_NET_ICMPv6_NEIGHBOR
  355. void icmpv6_notify(net_ipv6addr_t ipaddr);
  356. #else
  357. # define icmpv6_notify(i)
  358. #endif
  359. /****************************************************************************
  360. * Name: icmpv6_autoconfig
  361. *
  362. * Description:
  363. * Perform IPv6 auto-configuration to assign an IPv6 address to this
  364. * device.
  365. *
  366. * Input Parameters:
  367. * dev - The device driver structure to assign the address to
  368. *
  369. * Returned Value:
  370. * Zero (OK) is returned on success; A negated errno value is returned on
  371. * any failure.
  372. *
  373. ****************************************************************************/
  374. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  375. int icmpv6_autoconfig(FAR struct net_driver_s *dev);
  376. #endif
  377. /****************************************************************************
  378. * Name: icmpv6_rwait_setup
  379. *
  380. * Description:
  381. * Called BEFORE an Router Solicitation is sent. This function sets up
  382. * the Router Advertisement timeout before the Router Solicitation
  383. * is sent so that there is no race condition when icmpv6_rwait() is
  384. * called.
  385. *
  386. * Assumptions:
  387. * This function is called from icmpv6_autoconfig() and executes in the
  388. * normal tasking environment.
  389. *
  390. ****************************************************************************/
  391. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  392. void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
  393. FAR struct icmpv6_rnotify_s *notify);
  394. #else
  395. # define icmpv6_rwait_setup(d,n)
  396. #endif
  397. /****************************************************************************
  398. * Name: icmpv6_rwait_cancel
  399. *
  400. * Description:
  401. * Cancel any wait set after icmpv6_rwait_setup() is called but before
  402. * icmpv6_rwait()is called (icmpv6_rwait() will automatically cancel the
  403. * wait).
  404. *
  405. * Assumptions:
  406. * This function may execute in the interrupt context when called from
  407. * icmpv6_rwait().
  408. *
  409. ****************************************************************************/
  410. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  411. int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify);
  412. #else
  413. # define icmpv6_rwait_cancel(n) (0)
  414. #endif
  415. /****************************************************************************
  416. * Name: icmpv6_rwait
  417. *
  418. * Description:
  419. * Called each time that a Router Solicitation is sent. This function
  420. * will sleep until either: (1) the matching Router Advertisement is
  421. * received, or (2) a timeout occurs.
  422. *
  423. * Assumptions:
  424. * This function is called from icmpv6_autoconfig() and must execute with
  425. * the network un-locked (interrupts may be disabled to keep the things
  426. * stable).
  427. *
  428. ****************************************************************************/
  429. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  430. int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify,
  431. FAR struct timespec *timeout);
  432. #else
  433. # define icmpv6_rwait(n,t) (0)
  434. #endif
  435. /****************************************************************************
  436. * Name: icmpv6_rnotify
  437. *
  438. * Description:
  439. * Called each time that a Router Advertisement is received in order to
  440. * wake-up any threads that may be waiting for this particular Router
  441. * Advertisement.
  442. *
  443. * Assumptions:
  444. * This function is called from the MAC device driver indirectly through
  445. * icmpv6_icmpv6in() will execute with the network locked.
  446. *
  447. ****************************************************************************/
  448. #ifdef CONFIG_NET_ICMPv6_AUTOCONF
  449. void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr,
  450. const net_ipv6addr_t prefix, unsigned int preflen);
  451. #else
  452. # define icmpv6_rnotify(d,p,l)
  453. #endif
  454. /****************************************************************************
  455. * Name: icmpv6_sock_initialize
  456. *
  457. * Description:
  458. * Initialize the IPPROTO_ICMP socket connection structures. Called once
  459. * and only from the network initialization layer.
  460. *
  461. ****************************************************************************/
  462. #ifdef CONFIG_NET_ICMPv6_SOCKET
  463. void icmpv6_sock_initialize(void);
  464. #endif
  465. /****************************************************************************
  466. * Name: icmpv6_alloc
  467. *
  468. * Description:
  469. * Allocate a new, uninitialized IPPROTO_ICMP socket connection structure.
  470. * This is normally something done by the implementation of the socket()
  471. * interface.
  472. *
  473. ****************************************************************************/
  474. #ifdef CONFIG_NET_ICMPv6_SOCKET
  475. FAR struct icmpv6_conn_s *icmpv6_alloc(void);
  476. #endif
  477. /****************************************************************************
  478. * Name: icmpv6_free
  479. *
  480. * Description:
  481. * Free a IPPROTO_ICMP socket connection structure that is no longer in
  482. * use. This should be done by the implementation of close().
  483. *
  484. ****************************************************************************/
  485. #ifdef CONFIG_NET_ICMPv6_SOCKET
  486. void icmpv6_free(FAR struct icmpv6_conn_s *conn);
  487. #endif
  488. /****************************************************************************
  489. * Name: icmpv6_active()
  490. *
  491. * Description:
  492. * Find a connection structure that is the appropriate connection to be
  493. * used with the provided ECHO request ID.
  494. *
  495. * Assumptions:
  496. * This function is called from network logic at with the network locked.
  497. *
  498. ****************************************************************************/
  499. #ifdef CONFIG_NET_ICMPv6_SOCKET
  500. FAR struct icmpv6_conn_s *icmpv6_active(uint16_t id);
  501. #endif
  502. /****************************************************************************
  503. * Name: icmpv6_nextconn
  504. *
  505. * Description:
  506. * Traverse the list of allocated packet connections
  507. *
  508. * Assumptions:
  509. * This function is called from network logic at with the network locked.
  510. *
  511. ****************************************************************************/
  512. #ifdef CONFIG_NET_ICMPv6_SOCKET
  513. FAR struct icmpv6_conn_s *icmpv6_nextconn(FAR struct icmpv6_conn_s *conn);
  514. #endif
  515. /****************************************************************************
  516. * Name: icmpv6_findconn
  517. *
  518. * Description:
  519. * Find an ICMPv6 connection structure that is expecting a ICMPv6 ECHO response
  520. * with this ID from this device
  521. *
  522. * Assumptions:
  523. * This function is called from network logic at with the network locked.
  524. *
  525. ****************************************************************************/
  526. #ifdef CONFIG_NET_ICMPv6_SOCKET
  527. FAR struct icmpv6_conn_s *icmpv6_findconn(FAR struct net_driver_s *dev,
  528. uint16_t id);
  529. #endif
  530. /****************************************************************************
  531. * Name: icmpv6_sendto
  532. *
  533. * Description:
  534. * Implements the sendto() operation for the case of the IPPROTO_ICMP6
  535. * socket. The 'buf' parameter points to a block of memory that includes
  536. * an ICMPv6 request header, followed by any payload that accompanies the
  537. * request. The 'len' parameter includes both the size of the ICMPv6
  538. * header and the following payload.
  539. *
  540. * Input Parameters:
  541. * psock A pointer to a NuttX-specific, internal socket structure
  542. * buf Data to send
  543. * len Length of data to send
  544. * flags Send flags
  545. * to Address of recipient
  546. * tolen The length of the address structure
  547. *
  548. * Returned Value:
  549. * On success, returns the number of characters sent. On error, a negated
  550. * errno value is returned (see send_to() for the list of appropriate error
  551. * values.
  552. *
  553. ****************************************************************************/
  554. #ifdef CONFIG_NET_ICMPv6_SOCKET
  555. ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
  556. int flags, FAR const struct sockaddr *to, socklen_t tolen);
  557. #endif
  558. /****************************************************************************
  559. * Name: icmpv6_recvfrom
  560. *
  561. * Description:
  562. * Implements the socket recvfrom interface for the case of the AF_INET6
  563. * data gram socket with the IPPROTO_ICMP6 protocol. icmpv6_recvfrom()
  564. * receives ICMPv6 ECHO replies for the a socket.
  565. *
  566. * If 'from' is not NULL, and the underlying protocol provides the source
  567. * address, this source address is filled in. The argument 'fromlen' is
  568. * initialized to the size of the buffer associated with from, and
  569. * modified on return to indicate the actual size of the address stored
  570. * there.
  571. *
  572. * Input Parameters:
  573. * psock A pointer to a NuttX-specific, internal socket structure
  574. * buf Buffer to receive data
  575. * len Length of buffer
  576. * flags Receive flags
  577. * from Address of source (may be NULL)
  578. * fromlen The length of the address structure
  579. *
  580. * Returned Value:
  581. * On success, returns the number of characters received. If no data is
  582. * available to be received and the peer has performed an orderly shutdown,
  583. * recv() will return 0. Otherwise, on errors, a negated errno value is
  584. * returned (see recvfrom() for the list of appropriate error values).
  585. *
  586. ****************************************************************************/
  587. #ifdef CONFIG_NET_ICMPv6_SOCKET
  588. ssize_t icmpv6_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
  589. int flags, FAR struct sockaddr *from,
  590. FAR socklen_t *fromlen);
  591. #endif
  592. /****************************************************************************
  593. * Name: icmpv6_pollsetup
  594. *
  595. * Description:
  596. * Setup to monitor events on one ICMPv6 socket
  597. *
  598. * Input Parameters:
  599. * psock - The IPPROTO_ICMP6 socket of interest
  600. * fds - The structure describing the events to be monitored, OR NULL if
  601. * this is a request to stop monitoring events.
  602. *
  603. * Returned Value:
  604. * 0: Success; Negated errno on failure
  605. *
  606. ****************************************************************************/
  607. #ifdef CONFIG_NET_ICMPv6_SOCKET
  608. int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds);
  609. #endif
  610. /****************************************************************************
  611. * Name: icmpv6_pollteardown
  612. *
  613. * Description:
  614. * Teardown monitoring of events on an ICMPv6 socket
  615. *
  616. * Input Parameters:
  617. * psock - The IPPROTO_ICMP6 socket of interest
  618. * fds - The structure describing the events to be monitored, OR NULL if
  619. * this is a request to stop monitoring events.
  620. *
  621. * Returned Value:
  622. * 0: Success; Negated errno on failure
  623. *
  624. ****************************************************************************/
  625. #ifdef CONFIG_NET_ICMPv6_SOCKET
  626. int icmpv6_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
  627. #endif
  628. /****************************************************************************
  629. * Name: icmpv6_linkipaddr
  630. *
  631. * Description:
  632. * Generate the device link scope ipv6 address as below:
  633. * 128 112 96 80 64 48 32 16
  634. * ---- ---- ---- ---- ---- ---- ---- ----
  635. * fe80 0000 0000 0000 0000 00ff fe00 xx00 1-byte short address IEEE 48-bit MAC
  636. * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
  637. * fe80 0000 0000 0000 xxxx xxff fexx xxxx 6-byte normal address IEEE 48-bit MAC
  638. * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
  639. *
  640. * Input Parameters:
  641. * dev - The device driver structure containing the link layer address
  642. * ipaddr - Receive the device link scope ipv6 address
  643. *
  644. * Returned Value:
  645. * None
  646. *
  647. ****************************************************************************/
  648. void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr);
  649. #undef EXTERN
  650. #ifdef __cplusplus
  651. }
  652. #endif
  653. #endif /* CONFIG_NET_ICMPv6 && !CONFIG_NET_ICMPv6_NO_STACK */
  654. #endif /* __NET_ICMPv6_ICMPv6_H */