/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1994-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
*
*----------------------------------------------------------------------------
*
- * Copyright (c) 1994, 1996, 1997, 1998 Apple Computer, Inc.
*/
#include <sys/errno.h>
#include <netat/sysglue.h>
#include <netat/appletalk.h>
+#include <netat/at_pcb.h>
#include <netat/at_var.h>
#include <netat/ddp.h>
#include <netat/rtmp.h>
-#include <netat/at_pcb.h>
#include <netat/zip.h>
#include <netat/routing_tables.h>
#include <netat/at_snmp.h>
extern at_ifaddr_t *ifID_table[];
extern at_ifaddr_t *ifID_home;
extern snmpStats_t snmpStats;
-extern atlock_t ddpinp_lock;
short ErrorRTMPoverflow = 0; /* flag if RTMP table is too small for this net */
short ErrorZIPoverflow = 0; /* flag if ZIP table is too small for this net */
- /* prototypes */
-void getIfUsage( int, at_ifnames_t *);
/*
* This a temporary function : just to display the router error
*/
-void RouterError(port, err_number)
-short port, err_number;
-
+void RouterError(__unused short port, short err_number)
{
switch (err_number) {
RT_entry *ptree = &RT_table_start;
at_net_al LowEnd;
- register unsigned int s;
/*
dPrintf(D_M_RTMP_LOW, D_L_ROUTING, ("%s : Lookup for Net=%d\n",
"rt_blookup", NetNumber));
*/
- ATDISABLE(s, ddpinp_lock);
while (ptree) {
if (NetNumber > ptree->NetStop) {
ptree = ptree->left;
continue;
}
- ATENABLE(s, ddpinp_lock);
/* we're in the range (either extended or not)
* return the entry found.
return (ptree);
}
}
- ATENABLE(s, ddpinp_lock);
dPrintf(D_M_RTMP_LOW, D_L_ROUTING, ("%s : %04d : NOT FOUND\n",
"rt_blookup", NetNumber));
{
RT_entry *ptree = &RT_table_start;
+#if DEBUG
register at_net_al NetStart = NewEntry->NetStart;
+#endif
register at_net_al NetStop = NewEntry->NetStop;
dPrintf(D_M_RTMP_LOW, D_L_ROUTING, ("rt_binsert: for Net %d-%d state=x%x NextIR %d:%d\n",
*
*/
-RT_entry *rt_bdelete (NetStop, NetStart)
- at_net_al NetStop, NetStart;
+RT_entry *rt_bdelete (at_net_al NetStop, __unused at_net_al NetStart)
{
- RT_entry *rt_found, *pprevious, *pnext, *pnextl, *psub;
+ RT_entry *rt_found, *pprevious = NULL, *pnext, *pnextl, *psub;
at_net_al LowEnd;
rt_found = &RT_table_start;
}
-RT_entry *rt_sortedshow(parent)
-RT_entry *parent;
+#if DEBUG
+RT_entry *rt_sortedshow(RT_entry *parent);
+RT_entry *rt_sortedshow(RT_entry *parent)
{
RT_entry *me;
* debug only: display the contents of the routing table
*/
-void rt_show ()
+void rt_show(void);
+void rt_show(void)
{
RT_entry *ptree;
int i=0;
i++;
}
}
+#endif /* DEBUG */
/*
* prepare the indexing of the free entries in the RTMP table
*/
+int
rt_table_init()
{
short i;
* zt_add_zone: add a zone name in the zone table.
*/
+int
zt_add_zone(name, length)
char *name;
short length;
at_nvestr_t *zname;
{
register short res,i;
- register unsigned int s;
- if (res = zt_find_zname(zname))
+ if ((res = zt_find_zname(zname)))
return(res);
- ATDISABLE(s, ddpinp_lock);
for (i = 0; i < ZT_maxentry ; i++) {
if (ZT_table[i].ZoneCount == 0 && ZT_table[i].Zone.len == 0) {/* free entry */
ZT_table[i].Zone = *zname;
dPrintf(D_M_RTMP, D_L_VERBOSE, ("zt_add_zonename: zone #%d %s len=%d\n",
i, ZT_table[i].Zone.str, ZT_table[i].Zone.len));
at_state.flags |= AT_ST_ZT_CHANGED;
- ATENABLE(s, ddpinp_lock);
return(i+1);
}
}
- ATENABLE(s, ddpinp_lock);
/* table full... */
return (ZT_MAXEDOUT);
}
/*
* zt_compute_hash: compute hash index from the zone name string
*/
+static short zt_compute_hash(at_nvestr_t *);
-short zt_compute_hash(zname)
+static short zt_compute_hash(zname)
at_nvestr_t *zname;
{
register u_short checksum=0, i;
* zt_upper_zname: translate the name string into uppercase
*/
+#if 0
void zt_upper_zname(zname)
at_nvestr_t *zname;
{
zname->str[i] = c1;
}
}
+#endif
/*
* zt_get_zmcast: calcularte the zone multicast address for a
* Returns the result in "buffer"
*/
+int
zt_get_zmcast(ifID, zname, buffer)
at_ifaddr_t *ifID; /* we want to know the media type */
at_nvestr_t *zname; /* source name for multicast address */
/*
* zt_ent_zcount: count the number of actives zone for a routing entry
*/
-
+int
zt_ent_zcount(ent)
RT_entry *ent;
{
register u_char *zmap;
register u_short i,j;
register int zone_count = 0 ;
- register unsigned int s;
- ATDISABLE(s, ddpinp_lock);
- if (!RT_ALL_ZONES_KNOWN(ent)) {
- ATENABLE(s, ddpinp_lock);
+ if (!RT_ALL_ZONES_KNOWN(ent))
return (0);
- }
zmap = ent->ZoneBitMap;
for (i = 0 ; i < ZT_BYTES ; i++) {
zmap++;
}
- ATENABLE(s, ddpinp_lock);
return (zone_count);
}
/*
* zt_find_zname: match a zone name in the zone table and return the entry if found
*/
+int
zt_find_zname(zname)
at_nvestr_t *zname;
{
register short i, j, found;
register char c1, c2;
- register unsigned int s;
if (!zname->len)
return(0);
- ATDISABLE(s, ddpinp_lock);
for (i = 0 ; i < ZT_maxentry ; i++) {
if (!ZT_table[i].ZoneCount || zname->len != ZT_table[i].Zone.len)
continue;
}
}
- if (found) {
- ATENABLE(s, ddpinp_lock);
+ if (found)
return (i+1);
- }
}
- ATENABLE(s, ddpinp_lock);
return(0);
}
*/
void zt_set_zmap(znum, zmap)
u_short znum;
- char *zmap;
+ unsigned char *zmap;
{
register u_short num = znum -1;
- register unsigned int s;
- ATDISABLE(s, ddpinp_lock);
if (!(zmap[num >> 3] & 0x80 >> (num % 8))) {
zmap[num >> 3] |= 0x80 >> (num % 8);
ZT_table[num].ZoneCount++;
}
- ATENABLE(s, ddpinp_lock);
}
/*
* zt_clr_zmap: clear a bit for the corresponding zone map in an entry bitmap
*/
+#if 0
void zt_clr_zmap(znum, zmap)
u_short znum;
char *zmap;
{
register u_short num = znum -1;
- register unsigned int s;
- ATDISABLE(s, ddpinp_lock);
if (zmap[num >> 3] & 0x80 >> (num % 8)) {
zmap[num >> 3] ^= 0x80 >> (num % 8);
ZT_table[num].ZoneCount--;
}
- ATENABLE(s, ddpinp_lock);
}
-
+#endif
/*
* routing_needed :
return(NULL);
}
-
+int
getRtmpTableSize()
{
register int i;
return(0);
}
-getZipTableSize()
+int
+getZipTableSize(void)
{
register int i;
register ZT_entry *zt;
return(0);
}
+void
getRtmpTable(d,s,c)
RT_entry *d; /* destination */
int s; /* starting entry */
}
}
+void
getZipTable(d,s,c)
ZT_entry *d; /* destination */
int s; /* starting entry */
at_nvestr_t *getRTRLocalZone(ifz)
zone_usage_t *ifz;
{
- char *zmap;
+ unsigned char *zmap = NULL;
RT_entry *route;
int i, j, index;
int zcnt=0; /* zone we're pointing to in the list */