]>
Commit | Line | Data |
---|---|---|
c6610e1d VM |
1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
2 | /* | |
3 | * Copyright (C) 2013 Allied Telesis Labs NZ | |
4 | * Chris Packham, <[email protected]> | |
5 | * | |
6 | * Copyright (C) 2022 YADRO | |
7 | * Viacheslav Mitrofanov <[email protected]> | |
8 | */ | |
9 | ||
10 | #ifndef __NDISC_H__ | |
11 | #define __NDISC_H__ | |
12 | ||
13 | #include <ndisc.h> | |
14 | ||
15 | /* struct nd_msg - ICMPv6 Neighbour Discovery message format */ | |
16 | struct nd_msg { | |
17 | struct icmp6hdr icmph; | |
18 | struct in6_addr target; | |
19 | __u8 opt[0]; | |
20 | }; | |
21 | ||
22 | /* struct echo_msg - ICMPv6 echo request/reply message format */ | |
23 | struct echo_msg { | |
24 | struct icmp6hdr icmph; | |
25 | __u16 id; | |
26 | __u16 sequence; | |
27 | }; | |
28 | ||
29 | /* Neigbour Discovery option types */ | |
30 | enum { | |
31 | __ND_OPT_PREFIX_INFO_END = 0, | |
32 | ND_OPT_SOURCE_LL_ADDR = 1, | |
33 | ND_OPT_TARGET_LL_ADDR = 2, | |
34 | ND_OPT_PREFIX_INFO = 3, | |
35 | ND_OPT_REDIRECT_HDR = 4, | |
36 | ND_OPT_MTU = 5, | |
37 | __ND_OPT_MAX | |
38 | }; | |
39 | ||
40 | /* IPv6 destination address of packet waiting for ND */ | |
41 | extern struct in6_addr net_nd_sol_packet_ip6; | |
42 | /* MAC destination address of packet waiting for ND */ | |
43 | extern uchar *net_nd_packet_mac; | |
44 | /* pointer to packet waiting to be transmitted after ND is resolved */ | |
45 | extern uchar *net_nd_tx_packet; | |
46 | /* size of packet waiting to be transmitted */ | |
47 | extern int net_nd_tx_packet_size; | |
48 | /* the timer for ND resolution */ | |
49 | extern ulong net_nd_timer_start; | |
50 | /* the number of requests we have sent so far */ | |
51 | extern int net_nd_try; | |
52 | ||
53 | #ifdef CONFIG_IPV6 | |
54 | /** | |
55 | * ndisc_init() - Make initial steps for ND state machine. | |
56 | * Usually move variables into initial state. | |
57 | */ | |
58 | void ndisc_init(void); | |
59 | ||
60 | /** | |
61 | * ndisc_receive() - Handle ND packet | |
62 | * | |
63 | * @et: pointer to incoming packet | |
64 | * @ip6: pointer to IPv6 header | |
65 | * @len: incoming packet length | |
66 | * Return: 0 if handle successfully, -1 if unsupported/unknown ND packet type | |
67 | */ | |
68 | int ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len); | |
69 | ||
70 | /** | |
71 | * ndisc_request() - Send ND request | |
72 | */ | |
73 | void ndisc_request(void); | |
74 | ||
75 | /** | |
76 | * ndisc_init() - Check ND response timeout | |
77 | * | |
78 | * Return: 0 if no timeout, -1 otherwise | |
79 | */ | |
80 | int ndisc_timeout_check(void); | |
81 | #else | |
82 | static inline void ndisc_init(void) | |
83 | { | |
84 | } | |
85 | ||
86 | static inline int | |
87 | ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) | |
88 | { | |
89 | return -1; | |
90 | } | |
91 | ||
92 | static inline void ndisc_request(void) | |
93 | { | |
94 | } | |
95 | ||
96 | static inline int ndisc_timeout_check(void) | |
97 | { | |
98 | return 0; | |
99 | } | |
100 | #endif | |
101 | ||
102 | #endif /* __NDISC_H__ */ |