2 * Copyright (c) 1990,1997 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
10 #include <sys/socket.h>
11 #include <sys/signal.h>
14 #include <netatalk/endian.h>
15 #include <netatalk/at.h>
17 #include <atalk/nbp.h>
18 #include <atalk/ddp.h>
19 #include <atalk/util.h>
23 char nbp_send[ 1024 ];
24 char nbp_recv[ 1024 ];
26 unsigned char nbp_id = 0;
28 int nbp_parse( data, nn, len )
35 memcpy( &nt, data, SZ_NBPTUPLE);
43 nn->nn_sat.sat_len = sizeof( struct sockaddr_at );
45 nn->nn_sat.sat_family = AF_APPLETALK;
46 nn->nn_sat.sat_addr.s_net = nt.nt_net;
47 nn->nn_sat.sat_addr.s_node = nt.nt_node;
48 nn->nn_sat.sat_port = nt.nt_port;
50 nn->nn_objlen = *data++;
51 len -= nn->nn_objlen + 1;
55 if ( nn->nn_objlen > NBPSTRLEN ) {
58 memcpy( nn->nn_obj, data, nn->nn_objlen );
59 data += nn->nn_objlen;
61 nn->nn_typelen = *data++;
62 len -= nn->nn_typelen + 1;
66 if ( nn->nn_typelen > NBPSTRLEN ) {
69 memcpy( nn->nn_type, data, nn->nn_typelen );
71 data += nn->nn_typelen;
72 nn->nn_zonelen = *data++;
73 len -= nn->nn_zonelen + 1;
77 if ( nn->nn_zonelen > NBPSTRLEN ) {
80 memcpy( nn->nn_zone, data, nn->nn_zonelen );
85 #define NBPM_OBJ (1<<1)
86 #define NBPM_TYPE (1<<2)
87 #define NBPM_ZONE (1<<3)
89 int nbp_match( n1, n2, flags )
90 struct nbpnve *n1, *n2;
95 if ( flags & NBPMATCH_NOZONE ) {
99 if ( !( flags & NBPMATCH_NOGLOB )) {
100 if ( n1->nn_objlen == 1 && n1->nn_obj[0] == '=' ) {
103 if ( n1->nn_typelen == 1 && n1->nn_type[0] == '=' ) {
108 if ( !( match & NBPM_OBJ )) {
109 if ( n1->nn_objlen != n2->nn_objlen ||
110 strndiacasecmp( n1->nn_obj, n2->nn_obj, n1->nn_objlen )) {
114 if ( !( match & NBPM_TYPE )) {
115 if ( n1->nn_typelen != n2->nn_typelen ||
116 strndiacasecmp( n1->nn_type, n2->nn_type, n1->nn_typelen )) {
120 if ( !( match & NBPM_ZONE )) {
121 if ( n1->nn_zonelen != n2->nn_zonelen ||
122 strndiacasecmp( n1->nn_zone, n2->nn_zone, n1->nn_zonelen )) {
130 int nbp_name( name, objp, typep, zonep )
132 char **objp, **typep, **zonep;
134 static char buf[ 32 + 1 + 32 + 1 + 32 + 1 ];
138 if ( strlen( name ) + 1 > sizeof( buf )) {
143 if (( p = strrchr( buf, '@' )) != NULL ) {
147 if (( p = strrchr( buf, ':' )) != NULL ) {
151 if ( *buf != '\0' ) {