[comp.protocols.appletalk] NBP Lookups - case sensitive, or not?

jmsellens@watdragon.waterloo.edu (John M. Sellens) (02/25/91)

I've got a selection of UNIX machines.  I have ru-cap2, and am using
ethertalk, uab, and iptalk on different machines.  I have some
AppleTalk zones, and some of the zone names are mixed case.

On the iptalk and ethertalk machines, "atlook Zone" and "atlook zone"
both do a successful lookup in zone "Zone".  But on the uab machines,
only "atlook Zone" works, "atlook zone" returns nothing.

Now, I think this is because the hash functions and the zone_compare
function in the uab+ source don't hash and match "Zone" and "zone" to
the same thing.

The question is: should it be case sensitive, or case insensitive?
I can't find a copy of Inside AppleTalk, so I can't try looking up
the definitive answer.  Anyone?

Much obliged

John Sellens
University of Waterloo
jmsellens@dragon.waterloo.edu

winders@aux.support.apple.com (Scott Winders) (02/26/91)

In article <1991Feb24.221303.20106@watdragon.waterloo.edu> 
jmsellens@watdragon.waterloo.edu (John M. Sellens) writes:

> The question is: should it be case sensitive, or case insensitive?
> I can't find a copy of Inside AppleTalk, so I can't try looking up
> the definitive answer.  Anyone?

Page 7-5 of "Inside AppleTalk, Second Edition" states the following:

      "Entity names by definition are case-insensitive.  Thus, 
       Mona:Mailbox@Bandley3 is considered the same as 
       Mona:mailbox:bandley3 and MONA:MAILBOX:BANDLEY3."

In the above example, "Bandley3" is the zone name. Zone names are NOT case sensitive and shoul not be treated as case sensitive in any implementation of AppleTalk.

Scott Winders
internet: winders@aux.support.apple.com
AppleLink: winders.s@applelink.apple.com

jmsellen@watmath.waterloo.edu (John Sellens) (03/01/91)

In article <1991Feb24.221303.20106@watdragon.waterloo.edu> I asked:
> The question is: should it be case sensitive, or case insensitive?
> I can't find a copy of Inside AppleTalk, so I can't try looking up
> the definitive answer.  Anyone?

In article <49616@apple.Apple.COM> winders@aux.support.apple.com
(Scott Winders) wrote:
>Page 7-5 of "Inside AppleTalk, Second Edition" states the following:
>      "Entity names by definition are case-insensitive.


I have a zone "CSa-talk".  On a machine using uab, "atlook CSa-talk"
would work, "atlook csa-talk" wouldn't.
Here's a patch to uab+/rtmp.c that makes zone comparisons case insensitive.

*** /tmp/,RCSt1028230	Fri Mar  1 09:51:34 1991
--- rtmp.c	Fri Mar  1 00:02:32 1991
***************
*** 142,147 ****
--- 142,148 ----
  export int route_add_host_entry();
  export char *node_format();
  private int bstrcmp();
+ private int bstrcmpci();
  private int bridgenode_compare();
  private caddr_t bridgenode_alloc();
  private u_int bridgenode_compress();
***************
*** 432,438 ****
--- 433,461 ----
        break;			/* return c */
    return(c);			/* return value */
  }
+ /* like bstrcmp, but case insensitive */
+ private int
+ bstrcmpci(a,b,l)
+ register byte *a;
+ register byte *b;
+ register int l;
+ {
+   register int c = 0;		/* if zero length, then same */
+   register byte aa, bb;
  
+   while (l--) {			/* while data */
+     aa = *a++;
+     if ( isascii(aa) && isupper(aa) )
+       aa = tolower(aa);
+     bb = *b++;
+     if ( isascii(bb) && isupper(bb) )
+       bb = tolower(bb);
+     if ((c = (aa - bb)))	/* compare and get difference */
+       break;			/* return c */
+   }
+   return(c);			/* return value */
+ }
+ 
  /* bridge node table handler */
  
  /* compare (port,node) to bridgenode */
***************
*** 1248,1253 ****
--- 1271,1277 ----
    return((caddr_t)cnode);
  }
  
+ /* needs to be case insensitive */
  private int
  pstrc(p,s)
  byte *p, *s;
***************
*** 1255,1263 ****
    int r = (*p - *s);
    if (r)
      return(r);
!   return(bstrcmp(p+1, s+1, *p));
  }
  
  private int
  zone_compare(s,cnode)
  byte *s;
--- 1279,1288 ----
    int r = (*p - *s);
    if (r)
      return(r);
!   return(bstrcmpci(p+1, s+1, *p));
  }
  
+ /* needs to be case insensitive */
  private int
  zone_compare(s,cnode)
  byte *s;
***************
*** 1266,1271 ****
--- 1291,1297 ----
    return(pstrc(s, cnode->c_data));
  }
  
+ /* needs to be case insensitive */
  private u_int
  zone_compress(p)
  byte *p;
***************
*** 1272,1280 ****
  {
    u_int r = 0;
    int i = (int) *p++;
    /* add in p, but keep rotating r */
!   while (i--)
!     r = ((r>>1)|(r<<31)) + *p++;
    return(r);
  }
  
--- 1298,1311 ----
  {
    u_int r = 0;
    int i = (int) *p++;
+   byte pp;
    /* add in p, but keep rotating r */
!   while (i--) {
!     pp = *p++;
!     if ( isascii(pp) && isupper(pp) )
!       pp = tolower(pp);
!     r = ((r>>1)|(r<<31)) + pp;
!   }
    return(r);
  }