Deleted Added
full compact
sap_tables.c (108533) sap_tables.c (122760)
1/*
2 * Copyright (c) 1995 John Hay. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
1/*
2 * Copyright (c) 1995 John Hay. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $FreeBSD: head/usr.sbin/IPXrouted/sap_tables.c 108533 2003-01-01 18:49:04Z schweikh $
31 * $FreeBSD: head/usr.sbin/IPXrouted/sap_tables.c 122760 2003-11-15 17:10:56Z trhodes $
32 */
33
34#include "defs.h"
32 */
33
34#include "defs.h"
35#include <search.h>
35#include <string.h>
36#include <stdlib.h>
37
38#define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));}
39
40sap_hash sap_head[SAPHASHSIZ];
41
42void

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

118 *
119 * XXX TODO:
120 * Maybe we can use RIP tables to get the fastest service (ticks).
121 */
122struct sap_entry *
123sap_nearestserver(ushort ServType, struct interface *ifp)
124{
125 register struct sap_entry *sap;
36#include <string.h>
37#include <stdlib.h>
38
39#define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));}
40
41sap_hash sap_head[SAPHASHSIZ];
42
43void

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

119 *
120 * XXX TODO:
121 * Maybe we can use RIP tables to get the fastest service (ticks).
122 */
123struct sap_entry *
124sap_nearestserver(ushort ServType, struct interface *ifp)
125{
126 register struct sap_entry *sap;
126 register struct sap_entry *csap;
127 struct sap_hash *sh;
128 register struct sap_entry *best = NULL;
129 register int besthops = HOPCNT_INFINITY;
130
131 sh = sap_head;
132
133 for (; sh < &sap_head[SAPHASHSIZ]; sh++)
134 for(sap = sh->forw; sap != (sap_entry *)sh; sap = sap->forw) {
135 if (ServType != sap->sap.ServType)
136 continue;
137
138 if (ntohs(sap->sap.hops) < besthops) {
139 best = sap;
140 besthops = ntohs(best->sap.hops);
141 }
127 struct sap_hash *sh;
128 register struct sap_entry *best = NULL;
129 register int besthops = HOPCNT_INFINITY;
130
131 sh = sap_head;
132
133 for (; sh < &sap_head[SAPHASHSIZ]; sh++)
134 for(sap = sh->forw; sap != (sap_entry *)sh; sap = sap->forw) {
135 if (ServType != sap->sap.ServType)
136 continue;
137
138 if (ntohs(sap->sap.hops) < besthops) {
139 best = sap;
140 besthops = ntohs(best->sap.hops);
141 }
142next:;
143 }
144 return best;
145}
146
147/*
148 * Add an entry to the SAP table.
149 *
150 * If the malloc fail, the entry will silently be thrown away.

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

278 return;
279
280 FIXLEN(from);
281 nsap = malloc(sizeof(struct sap_entry));
282 if (nsap == NULL)
283 return;
284
285 if (ftrace)
142 }
143 return best;
144}
145
146/*
147 * Add an entry to the SAP table.
148 *
149 * If the malloc fail, the entry will silently be thrown away.

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

277 return;
278
279 FIXLEN(from);
280 nsap = malloc(sizeof(struct sap_entry));
281 if (nsap == NULL)
282 return;
283
284 if (ftrace)
286 fprintf(ftrace, "CLONE ADD %04.4X %s.\n",
285 fprintf(ftrace, "CLONE ADD %4.4X %s.\n",
287 ntohs(clone->ServType),
288 clone->ServName);
289
290 nsap->sap = *clone;
291 nsap->source = *from;
292 nsap->clone = NULL;
293 nsap->ifp = if_ifwithnet(from);
294 nsap->state = RTS_CHANGED;

--- 28 unchanged lines hidden ---
286 ntohs(clone->ServType),
287 clone->ServName);
288
289 nsap->sap = *clone;
290 nsap->source = *from;
291 nsap->clone = NULL;
292 nsap->ifp = if_ifwithnet(from);
293 nsap->state = RTS_CHANGED;

--- 28 unchanged lines hidden ---