You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _IPXE_NEIGHBOUR_H
  2. #define _IPXE_NEIGHBOUR_H
  3. /** @file
  4. *
  5. * Neighbour discovery
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/refcnt.h>
  11. #include <ipxe/list.h>
  12. #include <ipxe/netdevice.h>
  13. #include <ipxe/retry.h>
  14. /** A neighbour discovery protocol */
  15. struct neighbour_discovery {
  16. /** Name */
  17. const char *name;
  18. /**
  19. * Transmit neighbour discovery request
  20. *
  21. * @v netdev Network device
  22. * @v net_protocol Network-layer protocol
  23. * @v net_dest Destination network-layer address
  24. * @v net_source Source network-layer address
  25. * @ret rc Return status code
  26. */
  27. int ( * tx_request ) ( struct net_device *netdev,
  28. struct net_protocol *net_protocol,
  29. const void *net_dest, const void *net_source );
  30. };
  31. /** A neighbour cache entry */
  32. struct neighbour {
  33. /** Reference count */
  34. struct refcnt refcnt;
  35. /** List of neighbour cache entries */
  36. struct list_head list;
  37. /** Network device */
  38. struct net_device *netdev;
  39. /** Network-layer protocol */
  40. struct net_protocol *net_protocol;
  41. /** Network-layer destination address */
  42. uint8_t net_dest[MAX_NET_ADDR_LEN];
  43. /** Link-layer destination address */
  44. uint8_t ll_dest[MAX_LL_ADDR_LEN];
  45. /** Neighbour discovery protocol (if any) */
  46. struct neighbour_discovery *discovery;
  47. /** Network-layer source address (if any) */
  48. uint8_t net_source[MAX_NET_ADDR_LEN];
  49. /** Retransmission timer */
  50. struct retry_timer timer;
  51. /** Pending I/O buffers */
  52. struct list_head tx_queue;
  53. };
  54. /**
  55. * Test if neighbour cache entry has a valid link-layer address
  56. *
  57. * @v neighbour Neighbour cache entry
  58. * @ret has_ll_dest Neighbour cache entry has a valid link-layer address
  59. */
  60. static inline __attribute__ (( always_inline )) int
  61. neighbour_has_ll_dest ( struct neighbour *neighbour ) {
  62. return ( ! timer_running ( &neighbour->timer ) );
  63. }
  64. extern struct list_head neighbours;
  65. extern int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
  66. struct net_protocol *net_protocol,
  67. const void *net_dest,
  68. struct neighbour_discovery *discovery,
  69. const void *net_source, const void *ll_source );
  70. extern int neighbour_update ( struct net_device *netdev,
  71. struct net_protocol *net_protocol,
  72. const void *net_dest, const void *ll_dest );
  73. extern int neighbour_define ( struct net_device *netdev,
  74. struct net_protocol *net_protocol,
  75. const void *net_dest, const void *ll_dest );
  76. #endif /* _IPXE_NEIGHBOUR_H */