• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: IP6IN4 api
15  * Author: NA
16  * Create: 2020
17  */
18 
19 /**
20  * @defgroup Threadsafe_Ip6in4_Interfaces ip6in4
21  * @ingroup wifimesh
22  */
23 
24 #ifndef LWIP_HDR_IP6IN4_API_H
25 #define LWIP_HDR_IP6IN4_API_H
26 #include "lwip/opt.h"
27 
28 #if LWIP_IP6IN4
29 
30 #include <stdint.h>
31 #define LWIP_IP6IN4_IP6_LEN 16
32 #define LWIP_IP6IN4_MAC_LEN 6
33 #define LWIP_IP6IN4_LIFETIME_INFINITE  0xFFFFFFFF
34 #define LWIP_IP6IN4_LIFETIME_DEFAULT  (30 * 60)
35 
36 typedef struct {
37   uint8_t ip6[LWIP_IP6IN4_IP6_LEN];
38   uint32_t ip4;
39   uint32_t lifetime;
40 } lwip_ip6in4_entry_t;
41 
42 /*
43  * Func Name: lwip_ip6in4_entry_add_update
44  */
45 /**
46  * @ingroup Threadsafe_Ip6in4_Interfaces
47  *
48  * @brief
49  *
50  *  This is a thread safe API, used to add or update entries of ip6in4 table.
51  *
52  * @param[in]    entry        Indicates the buffer of entries.
53  * @param[in]    cnt          Indicates the number of the entries.
54  *
55  * @returns
56  *  0 : On success \n
57  *  Negative value : On failure \n
58  *
59  * @note
60  *   - this api takes time to merge the entry.
61  */
62 int lwip_ip6in4_entry_add_update(const lwip_ip6in4_entry_t *entry, uint8_t cnt);
63 
64 /*
65  * Func Name: lwip_ip6in4_entry_delete
66  */
67 /**
68  * @ingroup Threadsafe_Ip6in4_Interfaces
69  *
70  * @brief
71  *
72  *  This is a thread safe API, used to delete entries in the ip6in4 table.
73  *
74  * @param[in]    entry        Indicates the buffer of entries.
75  * @param[in]    cnt          Indicates the number of the entries.
76  *
77  * @returns
78  *  0 : On success \n
79  *  Negative value : On failure \n
80  *
81  * @note
82  *   - this api takes time to handle the entry, when the entry is too big.
83  */
84 int lwip_ip6in4_entry_delete(const lwip_ip6in4_entry_t *entry, uint8_t cnt);
85 
86 /*
87  * Func Name: lwip_ip6in4_entry_sync
88  */
89 /**
90  * @ingroup Threadsafe_Ip6in4_Interfaces
91  *
92  * @brief
93  *
94  *  This is a thread safe API, used to sync entries of ip6in4 table.
95  *
96  * @param[in]    entry        Indicates the buffer of entries.
97  * @param[in]    cnt          Indicates the number of the entries.
98  *
99  * @returns
100  *  0 : On success \n
101  *  Negative value : On failure \n
102  *
103  * @note
104  *   - this api is to sync the entries with the leader.
105  */
106 int lwip_ip6in4_entry_sync(const lwip_ip6in4_entry_t *entry, uint8_t cnt);
107 
108 /*
109  * Func Name: lwip_ip6in4_entry_all_get
110  */
111 /**
112  * @ingroup Threadsafe_Ip6in4_Interfaces
113  *
114  * @brief
115  *
116  *  This is a thread safe API, used to get all entries of ip6in4 table.
117  *
118  * @param[out]    entry        Indicates the buffer of entries.
119  * @param[out]    cnt          Indicates the number of the entries.
120  *
121  * @returns
122  *  >0 : On success, the real copied entry count. \n
123  *  Negative value : On failure \n
124  *
125  * @note
126  *   - this api is to get the whole entries, not only the entry that the node holds.
127  */
128 int lwip_ip6in4_entry_all_get(lwip_ip6in4_entry_t *entry, uint8_t cnt);
129 
130 /*
131  * Func Name: lwip_ip6in4_entry_get
132  */
133 /**
134  * @ingroup Threadsafe_Ip6in4_Interfaces
135  *
136  * @brief
137  *
138  *  This is a thread safe API, used to get the entry the node holds.
139  *
140  * @param[out]    entry        Indicates the buffer of entry.
141  *
142  * @returns
143  *  0 : On success \n
144  *  Negative value : On failure \n
145  *
146  * @note
147  *   - the node just holds one entry.
148  */
149 int lwip_ip6in4_entry_get(lwip_ip6in4_entry_t *entry);
150 
151 /*
152  * Func Name: lwip_ip6in4_entry_get_by_mac
153  */
154 /**
155  * @ingroup Threadsafe_Ip6in4_Interfaces
156  *
157  * @brief
158  *
159  *  This is a thread safe API, used to get the entry that is referred to the mac.
160  *
161  * @param[in]     mac          Indicates the buffer of mac.
162  * @param[in]     len          Indicates the length of mac buffer.
163  * @param[out]    entry        Indicates the buffer of entry.
164  *
165  * @returns
166  *  0 : On success \n
167  *  Negative value : On failure \n
168  *
169  * @note
170  *   - the in parameter mac is the mbr mac of wlan0.
171  */
172 int lwip_ip6in4_entry_get_by_mac(const char *mac, uint8_t len, lwip_ip6in4_entry_t *entry);
173 
174 /*
175  * Func Name: lwip_ip6in4_init
176  */
177 /**
178  * @ingroup Threadsafe_Ip6in4_Interfaces
179  *
180  * @brief
181  *
182  *  This is a thread safe API, used to init the ip6in4.
183  *
184  * @param[in]    name        Indicates the netif name.
185  * @param[in]    len         Indicates the len of netif name.
186  * @param[in]    mbr_cnt     Indicates the number of the ip6in4 entry.
187  *
188  * @returns
189  *  0 : On success \n
190  *  Negative value : On failure \n
191  *
192  * @note
193  *   - this api alloc the table buffer.
194  */
195 int lwip_ip6in4_init(const char *name, uint8_t len, uint8_t mbr_cnt);
196 
197 /*
198  * Func Name: lwip_ip6in4_deinit
199  */
200 /**
201  * @ingroup Threadsafe_Ip6in4_Interfaces
202  *
203  * @brief
204  *
205  *  This is a thread safe API, used to deinit the ip6in4.
206  *
207  * @returns
208  *  0 : On success \n
209  *  Negative value : On failure \n
210  *
211  * @note
212  *   - this api free the resource(like the table buffer).
213  */
214 int lwip_ip6in4_deinit(void);
215 
216 #endif /* LWIP_IP6IN4 */
217 #endif /* LWIP_HDR_IP6IN4_API_H */
218