Deleted Added
full compact
if_llatbl.h (286577) if_llatbl.h (286616)
1/*
2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
3 * Copyright (c) 2004-2008 Qing Li. All rights reserved.
4 * Copyright (c) 2008 Kip Macy. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
3 * Copyright (c) 2004-2008 Qing Li. All rights reserved.
4 * Copyright (c) 2008 Kip Macy. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.h 286577 2015-08-10 12:03:59Z melifaro $");
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.h 286616 2015-08-11 05:51:00Z melifaro $");
29
30#ifndef _NET_IF_LLATBL_H_
31#define _NET_IF_LLATBL_H_
32
33#include <sys/_rwlock.h>
34#include <netinet/in.h>
35
36struct ifnet;

--- 96 unchanged lines hidden (view full) ---

133#define ln_timer_ch lle_timer.ln_timer_ch
134#define la_timer lle_timer.la_timer
135
136/* XXX bad name */
137#define L3_CADDR(lle) ((const struct sockaddr *)(&lle[1]))
138#define L3_ADDR(lle) ((struct sockaddr *)(&lle[1]))
139#define L3_ADDR_LEN(lle) (((struct sockaddr *)(&lle[1]))->sa_len)
140
29
30#ifndef _NET_IF_LLATBL_H_
31#define _NET_IF_LLATBL_H_
32
33#include <sys/_rwlock.h>
34#include <netinet/in.h>
35
36struct ifnet;

--- 96 unchanged lines hidden (view full) ---

133#define ln_timer_ch lle_timer.ln_timer_ch
134#define la_timer lle_timer.la_timer
135
136/* XXX bad name */
137#define L3_CADDR(lle) ((const struct sockaddr *)(&lle[1]))
138#define L3_ADDR(lle) ((struct sockaddr *)(&lle[1]))
139#define L3_ADDR_LEN(lle) (((struct sockaddr *)(&lle[1]))->sa_len)
140
141#ifndef LLTBL_HASHTBL_SIZE
142#define LLTBL_HASHTBL_SIZE 32 /* default 32 ? */
143#endif
144
145#ifndef LLTBL_HASHMASK
146#define LLTBL_HASHMASK (LLTBL_HASHTBL_SIZE - 1)
147#endif
148
149typedef struct llentry *(llt_lookup_t)(struct lltable *, u_int flags,
150 const struct sockaddr *l3addr);
151typedef struct llentry *(llt_create_t)(struct lltable *, u_int flags,
152 const struct sockaddr *l3addr);
153typedef int (llt_delete_t)(struct lltable *, u_int flags,
154 const struct sockaddr *l3addr);
155typedef void (llt_prefix_free_t)(struct lltable *,
156 const struct sockaddr *prefix, const struct sockaddr *mask, u_int flags);
157typedef int (llt_dump_entry_t)(struct lltable *, struct llentry *,
158 struct sysctl_req *);
159typedef uint32_t (llt_hash_t)(const struct llentry *, uint32_t);
160typedef int (llt_match_prefix_t)(const struct sockaddr *,
161 const struct sockaddr *, u_int, struct llentry *);
162typedef void (llt_free_entry_t)(struct lltable *, struct llentry *);
163typedef void (llt_fill_sa_entry_t)(const struct llentry *, struct sockaddr *);
141typedef struct llentry *(llt_lookup_t)(struct lltable *, u_int flags,
142 const struct sockaddr *l3addr);
143typedef struct llentry *(llt_create_t)(struct lltable *, u_int flags,
144 const struct sockaddr *l3addr);
145typedef int (llt_delete_t)(struct lltable *, u_int flags,
146 const struct sockaddr *l3addr);
147typedef void (llt_prefix_free_t)(struct lltable *,
148 const struct sockaddr *prefix, const struct sockaddr *mask, u_int flags);
149typedef int (llt_dump_entry_t)(struct lltable *, struct llentry *,
150 struct sysctl_req *);
151typedef uint32_t (llt_hash_t)(const struct llentry *, uint32_t);
152typedef int (llt_match_prefix_t)(const struct sockaddr *,
153 const struct sockaddr *, u_int, struct llentry *);
154typedef void (llt_free_entry_t)(struct lltable *, struct llentry *);
155typedef void (llt_fill_sa_entry_t)(const struct llentry *, struct sockaddr *);
156typedef void (llt_free_tbl_t)(struct lltable *);
164typedef void (llt_link_entry_t)(struct lltable *, struct llentry *);
165typedef void (llt_unlink_entry_t)(struct llentry *);
166
167typedef int (llt_foreach_cb_t)(struct lltable *, struct llentry *, void *);
168typedef int (llt_foreach_entry_t)(struct lltable *, llt_foreach_cb_t *, void *);
169
170struct lltable {
171 SLIST_ENTRY(lltable) llt_link;
157typedef void (llt_link_entry_t)(struct lltable *, struct llentry *);
158typedef void (llt_unlink_entry_t)(struct llentry *);
159
160typedef int (llt_foreach_cb_t)(struct lltable *, struct llentry *, void *);
161typedef int (llt_foreach_entry_t)(struct lltable *, llt_foreach_cb_t *, void *);
162
163struct lltable {
164 SLIST_ENTRY(lltable) llt_link;
172 struct llentries lle_head[LLTBL_HASHTBL_SIZE];
173 int llt_af;
165 int llt_af;
166 int llt_hsize;
167 struct llentries *lle_head;
174 struct ifnet *llt_ifp;
175
176 llt_lookup_t *llt_lookup;
177 llt_create_t *llt_create;
178 llt_delete_t *llt_delete;
179 llt_prefix_free_t *llt_prefix_free;
180 llt_dump_entry_t *llt_dump_entry;
181 llt_hash_t *llt_hash;
182 llt_match_prefix_t *llt_match_prefix;
183 llt_free_entry_t *llt_free_entry;
184 llt_foreach_entry_t *llt_foreach_entry;
185 llt_link_entry_t *llt_link_entry;
186 llt_unlink_entry_t *llt_unlink_entry;
187 llt_fill_sa_entry_t *llt_fill_sa_entry;
168 struct ifnet *llt_ifp;
169
170 llt_lookup_t *llt_lookup;
171 llt_create_t *llt_create;
172 llt_delete_t *llt_delete;
173 llt_prefix_free_t *llt_prefix_free;
174 llt_dump_entry_t *llt_dump_entry;
175 llt_hash_t *llt_hash;
176 llt_match_prefix_t *llt_match_prefix;
177 llt_free_entry_t *llt_free_entry;
178 llt_foreach_entry_t *llt_foreach_entry;
179 llt_link_entry_t *llt_link_entry;
180 llt_unlink_entry_t *llt_unlink_entry;
181 llt_fill_sa_entry_t *llt_fill_sa_entry;
182 llt_free_tbl_t *llt_free_tbl;
188};
189
190MALLOC_DECLARE(M_LLTABLE);
191
192/*
193 * LLentry flags
194 */
195#define LLE_DELETED 0x0001 /* entry must be deleted */
196#define LLE_STATIC 0x0002 /* entry is static */
197#define LLE_IFADDR 0x0004 /* entry is interface addr */
198#define LLE_VALID 0x0008 /* ll_addr is valid */
199#define LLE_PUB 0x0020 /* publish entry ??? */
200#define LLE_LINKED 0x0040 /* linked to lookup structure */
201/* LLE request flags */
202#define LLE_EXCLUSIVE 0x2000 /* return lle xlocked */
203
204#define LLATBL_HASH(key, mask) \
205 (((((((key >> 8) ^ key) >> 8) ^ key) >> 8) ^ key) & mask)
206
183};
184
185MALLOC_DECLARE(M_LLTABLE);
186
187/*
188 * LLentry flags
189 */
190#define LLE_DELETED 0x0001 /* entry must be deleted */
191#define LLE_STATIC 0x0002 /* entry is static */
192#define LLE_IFADDR 0x0004 /* entry is interface addr */
193#define LLE_VALID 0x0008 /* ll_addr is valid */
194#define LLE_PUB 0x0020 /* publish entry ??? */
195#define LLE_LINKED 0x0040 /* linked to lookup structure */
196/* LLE request flags */
197#define LLE_EXCLUSIVE 0x2000 /* return lle xlocked */
198
199#define LLATBL_HASH(key, mask) \
200 (((((((key >> 8) ^ key) >> 8) ^ key) >> 8) ^ key) & mask)
201
207struct lltable *lltable_init(struct ifnet *, int);
202struct lltable *lltable_allocate_htbl(uint32_t hsize);
208void lltable_free(struct lltable *);
203void lltable_free(struct lltable *);
204void lltable_link(struct lltable *llt);
209void lltable_prefix_free(int, struct sockaddr *,
210 struct sockaddr *, u_int);
211#if 0
212void lltable_drain(int);
213#endif
214int lltable_sysctl_dumparp(int, struct sysctl_req *);
215
216size_t llentry_free(struct llentry *);

--- 53 unchanged lines hidden ---
205void lltable_prefix_free(int, struct sockaddr *,
206 struct sockaddr *, u_int);
207#if 0
208void lltable_drain(int);
209#endif
210int lltable_sysctl_dumparp(int, struct sysctl_req *);
211
212size_t llentry_free(struct llentry *);

--- 53 unchanged lines hidden ---