Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108433382
D35971.id108770.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D35971.id108770.diff
View Options
diff --git a/sys/net/radix.h b/sys/net/radix.h
--- a/sys/net/radix.h
+++ b/sys/net/radix.h
@@ -106,13 +106,13 @@
struct radix_head;
typedef int walktree_f_t(struct radix_node *, void *);
-typedef struct radix_node *rn_matchaddr_f_t(void *v,
+typedef struct radix_node *rn_matchaddr_f_t(const void *v,
struct radix_head *head);
-typedef struct radix_node *rn_addaddr_f_t(void *v, void *mask,
+typedef struct radix_node *rn_addaddr_f_t(void *v, const void *mask,
struct radix_head *head, struct radix_node nodes[]);
-typedef struct radix_node *rn_deladdr_f_t(void *v, void *mask,
+typedef struct radix_node *rn_deladdr_f_t(const void *v, const void *mask,
struct radix_head *head);
-typedef struct radix_node *rn_lookup_f_t(void *v, void *mask,
+typedef struct radix_node *rn_lookup_f_t(const void *v, const void *mask,
struct radix_head *head);
typedef int rn_walktree_t(struct radix_head *head, walktree_f_t *f,
void *w);
@@ -176,13 +176,13 @@
int rn_inithead(void **, int);
int rn_detachhead(void **);
-int rn_refines(void *, void *);
-struct radix_node *rn_addroute(void *, void *, struct radix_head *,
+int rn_refines(const void *, const void *);
+struct radix_node *rn_addroute(void *, const void *, struct radix_head *,
struct radix_node[2]);
-struct radix_node *rn_delete(void *, void *, struct radix_head *);
-struct radix_node *rn_lookup (void *v_arg, void *m_arg,
+struct radix_node *rn_delete(const void *, const void *, struct radix_head *);
+struct radix_node *rn_lookup (const void *v_arg, const void *m_arg,
struct radix_head *head);
-struct radix_node *rn_match(void *, struct radix_head *);
+struct radix_node *rn_match(const void *, struct radix_head *);
int rn_walktree_from(struct radix_head *h, void *a, void *m,
walktree_f_t *f, void *w);
int rn_walktree(struct radix_head *, walktree_f_t *, void *);
diff --git a/sys/net/radix.c b/sys/net/radix.c
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -58,9 +58,9 @@
*rn_insert(void *, struct radix_head *, int *,
struct radix_node [2]),
*rn_newpair(void *, int, struct radix_node[2]),
- *rn_search(void *, struct radix_node *),
- *rn_search_m(void *, struct radix_node *, void *);
-static struct radix_node *rn_addmask(void *, struct radix_mask_head *, int,int);
+ *rn_search(const void *, struct radix_node *),
+ *rn_search_m(const void *, struct radix_node *, void *);
+static struct radix_node *rn_addmask(const void *, struct radix_mask_head *, int,int);
static void rn_detachhead_internal(struct radix_head *);
@@ -74,11 +74,11 @@
-1, -1, -1, -1, -1, -1, -1, -1,
};
-static int rn_lexobetter(void *m_arg, void *n_arg);
+static int rn_lexobetter(const void *m_arg, const void *n_arg);
static struct radix_mask *
rn_new_radix_mask(struct radix_node *tt,
struct radix_mask *next);
-static int rn_satisfies_leaf(char *trial, struct radix_node *leaf,
+static int rn_satisfies_leaf(const char *trial, struct radix_node *leaf,
int skip);
/*
@@ -142,10 +142,10 @@
* Search a node in the tree matching the key.
*/
static struct radix_node *
-rn_search(void *v_arg, struct radix_node *head)
+rn_search(const void *v_arg, struct radix_node *head)
{
struct radix_node *x;
- caddr_t v;
+ c_caddr_t v;
for (x = head, v = v_arg; x->rn_bit >= 0;) {
if (x->rn_bmask & v[x->rn_offset])
@@ -161,10 +161,10 @@
* XXX note this function is used only once.
*/
static struct radix_node *
-rn_search_m(void *v_arg, struct radix_node *head, void *m_arg)
+rn_search_m(const void *v_arg, struct radix_node *head, void *m_arg)
{
struct radix_node *x;
- caddr_t v = v_arg, m = m_arg;
+ c_caddr_t v = v_arg, m = m_arg;
for (x = head; x->rn_bit >= 0;) {
if ((x->rn_bmask & m[x->rn_offset]) &&
@@ -177,10 +177,10 @@
}
int
-rn_refines(void *m_arg, void *n_arg)
+rn_refines(const void *m_arg, const void *n_arg)
{
- caddr_t m = m_arg, n = n_arg;
- caddr_t lim, lim2 = lim = n + LEN(n);
+ c_caddr_t m = m_arg, n = n_arg;
+ c_caddr_t lim, lim2 = lim = n + LEN(n);
int longer = LEN(n++) - LEN(m++);
int masks_are_equal = 1;
@@ -209,7 +209,7 @@
* from host routes.
*/
struct radix_node *
-rn_lookup(void *v_arg, void *m_arg, struct radix_head *head)
+rn_lookup(const void *v_arg, const void *m_arg, struct radix_head *head)
{
struct radix_node *x;
caddr_t netmask;
@@ -250,10 +250,10 @@
}
static int
-rn_satisfies_leaf(char *trial, struct radix_node *leaf, int skip)
+rn_satisfies_leaf(const char *trial, struct radix_node *leaf, int skip)
{
- char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;
- char *cplim;
+ const char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;
+ const char *cplim;
int length = min(LEN(cp), LEN(cp2));
if (cp3 == NULL)
@@ -271,12 +271,12 @@
* Search for longest-prefix match in given @head
*/
struct radix_node *
-rn_match(void *v_arg, struct radix_head *head)
+rn_match(const void *v_arg, struct radix_head *head)
{
- caddr_t v = v_arg;
+ c_caddr_t v = v_arg;
struct radix_node *t = head->rnh_treetop, *x;
- caddr_t cp = v, cp2;
- caddr_t cplim;
+ c_caddr_t cp = v, cp2;
+ c_caddr_t cplim;
struct radix_node *saved_t, *top = t;
int off = t->rn_offset, vlen = LEN(cp), matched_off;
int test, b, rn_bit;
@@ -498,10 +498,11 @@
}
static struct radix_node *
-rn_addmask(void *n_arg, struct radix_mask_head *maskhead, int search, int skip)
+rn_addmask(const void *n_arg, struct radix_mask_head *maskhead, int search, int skip)
{
- unsigned char *netmask = n_arg;
- unsigned char *cp, *cplim;
+ const unsigned char *netmask = n_arg;
+ const unsigned char *c, *clim;
+ unsigned char *cp;
struct radix_node *x;
int b = 0, mlen, j;
int maskduplicated, isnormal;
@@ -552,17 +553,17 @@
* a non-contiguous mask.
*/
#define CONTIG(_c) (((~(_c) + 1) & (_c)) == (unsigned char)(~(_c) + 1))
- cplim = netmask + mlen;
+ clim = netmask + mlen;
isnormal = 1;
- for (cp = netmask + skip; (cp < cplim) && *(u_char *)cp == 0xff;)
- cp++;
- if (cp != cplim) {
- for (j = 0x80; (j & *cp) != 0; j >>= 1)
+ for (c = netmask + skip; (c < clim) && *(const u_char *)c == 0xff;)
+ c++;
+ if (c != clim) {
+ for (j = 0x80; (j & *c) != 0; j >>= 1)
b++;
- if (!CONTIG(*cp) || cp != (cplim - 1))
+ if (!CONTIG(*c) || c != (clim - 1))
isnormal = 0;
}
- b += (cp - netmask) << 3;
+ b += (c - netmask) << 3;
x->rn_bit = -1 - b;
if (isnormal)
x->rn_flags |= RNF_NORMAL;
@@ -570,9 +571,9 @@
}
static int /* XXX: arbitrary ordering for non-contiguous masks */
-rn_lexobetter(void *m_arg, void *n_arg)
+rn_lexobetter(const void *m_arg, const void *n_arg)
{
- u_char *mp = m_arg, *np = n_arg, *lim;
+ const u_char *mp = m_arg, *np = n_arg, *lim;
if (LEN(mp) > LEN(np))
return (1); /* not really, but need to check longer one first */
@@ -606,10 +607,10 @@
}
struct radix_node *
-rn_addroute(void *v_arg, void *n_arg, struct radix_head *head,
+rn_addroute(void *v_arg, const void *n_arg, struct radix_head *head,
struct radix_node treenodes[2])
{
- caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg;
+ caddr_t v = (caddr_t)v_arg, netmask = NULL;
struct radix_node *t, *x = NULL, *tt;
struct radix_node *saved_tt, *top = head->rnh_treetop;
short b = 0, b_leaf = 0;
@@ -624,8 +625,8 @@
* the mask to speed avoiding duplicate references at
* nodes and possibly save time in calculating indices.
*/
- if (netmask) {
- x = rn_addmask(netmask, head->rnh_masks, 0, top->rn_offset);
+ if (n_arg) {
+ x = rn_addmask(n_arg, head->rnh_masks, 0, top->rn_offset);
if (x == NULL)
return (0);
b_leaf = x->rn_bit;
@@ -763,12 +764,13 @@
}
struct radix_node *
-rn_delete(void *v_arg, void *netmask_arg, struct radix_head *head)
+rn_delete(const void *v_arg, const void *netmask_arg, struct radix_head *head)
{
struct radix_node *t, *p, *x, *tt;
struct radix_mask *m, *saved_m, **mp;
struct radix_node *dupedkey, *saved_tt, *top;
- caddr_t v, netmask;
+ c_caddr_t v;
+ c_caddr_t netmask;
int b, head_off, vlen;
v = v_arg;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 5:48 PM (18 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16154592
Default Alt Text
D35971.id108770.diff (7 KB)
Attached To
Mode
D35971: net: constantify radix.c functions
Attached
Detach File
Event Timeline
Log In to Comment