1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2013 Allied Telesis Labs NZ
4 * Chris Packham, <judge.packham@gmail.com>
6 * Copyright (C) 2022 YADRO
7 * Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
15 /* struct nd_msg - ICMPv6 Neighbour Discovery message format */
17 struct icmp6hdr icmph
;
18 struct in6_addr target
;
22 /* struct rs_msg - ICMPv6 Router Solicitation message format */
24 struct icmp6hdr icmph
;
28 /* struct ra_msg - ICMPv6 Router Advertisement message format */
30 struct icmp6hdr icmph
;
32 __u32 retransmission_timer
;
36 /* struct echo_msg - ICMPv6 echo request/reply message format */
38 struct icmp6hdr icmph
;
43 /* Neigbour Discovery option types */
45 __ND_OPT_PREFIX_INFO_END
= 0,
46 ND_OPT_SOURCE_LL_ADDR
= 1,
47 ND_OPT_TARGET_LL_ADDR
= 2,
48 ND_OPT_PREFIX_INFO
= 3,
49 ND_OPT_REDIRECT_HDR
= 4,
54 /* IPv6 destination address of packet waiting for ND */
55 extern struct in6_addr net_nd_sol_packet_ip6
;
56 /* MAC destination address of packet waiting for ND */
57 extern uchar
*net_nd_packet_mac
;
58 /* pointer to packet waiting to be transmitted after ND is resolved */
59 extern uchar
*net_nd_tx_packet
;
60 /* size of packet waiting to be transmitted */
61 extern int net_nd_tx_packet_size
;
62 /* the timer for ND resolution */
63 extern ulong net_nd_timer_start
;
64 /* the number of requests we have sent so far */
65 extern int net_nd_try
;
69 * ndisc_init() - Make initial steps for ND state machine.
70 * Usually move variables into initial state.
72 void ndisc_init(void);
75 * ip6_send_rs() - Send IPv6 Router Solicitation Message
77 void ip6_send_rs(void);
80 * ndisc_receive() - Handle ND packet
82 * @et: pointer to incoming packet
83 * @ip6: pointer to IPv6 header
84 * @len: incoming packet length
85 * Return: 0 if handle successfully, -1 if unsupported/unknown ND packet type
87 int ndisc_receive(struct ethernet_hdr
*et
, struct ip6_hdr
*ip6
, int len
);
90 * ndisc_request() - Send ND request
92 void ndisc_request(void);
95 * ndisc_init() - Check ND response timeout
97 * Return: 0 if no timeout, -1 otherwise
99 int ndisc_timeout_check(void);
100 bool validate_ra(struct ip6_hdr
*ip6
);
101 int process_ra(struct ip6_hdr
*ip6
, int len
);
103 static inline void ndisc_init(void)
108 ndisc_receive(struct ethernet_hdr
*et
, struct ip6_hdr
*ip6
, int len
)
113 static inline void ndisc_request(void)
117 static inline int ndisc_timeout_check(void)
122 static inline void ip6_send_rs(void)
126 static inline bool validate_ra(struct ip6_hdr
*ip6
)
131 static inline int process_ra(struct ip6_hdr
*ip6
, int len
)
137 #endif /* __NDISC_H__ */