diff options
Diffstat (limited to 'usr.sbin/IPXrouted/sap_tables.c')
| -rw-r--r-- | usr.sbin/IPXrouted/sap_tables.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/usr.sbin/IPXrouted/sap_tables.c b/usr.sbin/IPXrouted/sap_tables.c index 4f64a4cdee99..ea9032495772 100644 --- a/usr.sbin/IPXrouted/sap_tables.c +++ b/usr.sbin/IPXrouted/sap_tables.c @@ -28,14 +28,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sap_tables.c,v 1.9 1995/10/11 18:57:29 jhay Exp $ + * $Id: sap_tables.c,v 1.1 1995/10/26 21:28:25 julian Exp $ */ #include "defs.h" #include <string.h> #include <stdlib.h> -/* XXX I thought that this should work! #include <sys/systm.h> */ -#include <machine/cpufunc.h> #define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));} @@ -52,16 +50,9 @@ sapinit(void) } /* - * XXX Make sure that this hash is good enough. - * - * This hash use the first 8 letters of the ServName and the ServType + * This hash use the first 14 letters of the ServName and the ServType * to create a 32 bit hash value. - * - * NOTE: The first two letters of ServName will be used to generate - * the lower bits of the hash. This is used to index into the hash table. */ -#define rol(x) (((x * 2) & 0xFFFF) + ((x & 0x8000) != 0)) - int saphash(u_short ServType, char *ServName) { @@ -74,14 +65,18 @@ saphash(u_short ServType, char *ServName) hsh = 0; - for (i=0;i<8;i++) { - hsh = rol(hsh) + *ServName; +#define SMVAL 33 + + hsh = hsh * SMVAL + (ServType & 0xff); + hsh = hsh * SMVAL + (ServType >> 8); + + for (i=0;i<14;i++) { + hsh = hsh * SMVAL + *ServName++; ServName++; } - hsh = rol(hsh) + (ServType >> 8); - hsh = rol(hsh) + (ServType & 0xff); - hsh = (hsh >> 7) ^ hsh; +#undef SMVAL + return hsh; } @@ -173,6 +168,9 @@ sap_add(struct sap_info *si, struct sockaddr *from) register struct sap_entry *nsap; register struct sap_hash *sh; + if (ntohs(si->hops) == HOPCNT_INFINITY) + return; + FIXLEN(from); nsap = malloc(sizeof(struct sap_entry)); if (nsap == NULL) @@ -189,6 +187,7 @@ sap_add(struct sap_info *si, struct sockaddr *from) sh = &sap_head[nsap->hash & SAPHASHMASK]; insque(nsap, sh); + TRACE_SAP_ACTION("ADD", nsap); } /* @@ -204,6 +203,7 @@ sap_change(struct sap_entry *sap, struct sap_entry *osap = NULL; FIXLEN(from); + TRACE_SAP_ACTION("CHANGE FROM", sap); /* * If the hopcount (metric) is HOPCNT_INFINITY (16) it means that * a service has gone down. We should keep it like that for 30 @@ -230,6 +230,7 @@ sap_change(struct sap_entry *sap, while (osap) { nsap = osap->clone; + TRACE_SAP_ACTION("DELETE", osap); free(osap); osap = nsap; } @@ -241,6 +242,7 @@ sap_change(struct sap_entry *sap, while (osap) { if (equal(&osap->source, from)) { psap->clone = osap->clone; + TRACE_SAP_ACTION("DELETE", osap); free(osap); osap = psap->clone; } else { @@ -263,8 +265,11 @@ sap_change(struct sap_entry *sap, else sap->timer = 0; - if (osap) + if (osap) { + TRACE_SAP_ACTION("DELETE", osap); free(osap); + } + TRACE_SAP_ACTION("CHANGE TO", sap); } /* @@ -282,6 +287,9 @@ sap_add_clone(struct sap_entry *sap, register struct sap_entry *nsap; register struct sap_entry *csap; + if (ntohs(clone->hops) == HOPCNT_INFINITY) + return; + FIXLEN(from); nsap = malloc(sizeof(struct sap_entry)); if (nsap == NULL) @@ -304,6 +312,7 @@ sap_add_clone(struct sap_entry *sap, while (csap->clone) csap = csap->clone; csap->clone = nsap; + TRACE_SAP_ACTION("ADD CLONE", nsap); } /* @@ -321,6 +330,6 @@ sap_delete(struct sap_entry *sap) return; } remque(sap); + TRACE_SAP_ACTION("DELETE", sap); free(sap); } - |
