2 * Copyright (c) 1990,1997 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
12 #include <sys/types.h>
13 #include <sys/param.h>
14 #include <sys/socket.h>
15 #include <sys/signal.h>
18 #include <netatalk/endian.h>
19 #include <netatalk/at.h>
21 #include <atalk/nbp.h>
22 #include <atalk/ddp.h>
23 #include <atalk/util.h>
27 char nbp_send[ 1024 ];
28 char nbp_recv[ 1024 ];
30 unsigned char nbp_id = 0;
32 int nbp_parse( data, nn, len )
39 memcpy( &nt, data, SZ_NBPTUPLE);
47 nn->nn_sat.sat_len = sizeof( struct sockaddr_at );
49 nn->nn_sat.sat_family = AF_APPLETALK;
50 nn->nn_sat.sat_addr.s_net = nt.nt_net;
51 nn->nn_sat.sat_addr.s_node = nt.nt_node;
52 nn->nn_sat.sat_port = nt.nt_port;
54 nn->nn_objlen = *data++;
55 len -= nn->nn_objlen + 1;
59 if ( nn->nn_objlen > NBPSTRLEN ) {
62 memcpy( nn->nn_obj, data, nn->nn_objlen );
63 data += nn->nn_objlen;
65 nn->nn_typelen = *data++;
66 len -= nn->nn_typelen + 1;
70 if ( nn->nn_typelen > NBPSTRLEN ) {
73 memcpy( nn->nn_type, data, nn->nn_typelen );
75 data += nn->nn_typelen;
76 nn->nn_zonelen = *data++;
77 len -= nn->nn_zonelen + 1;
81 if ( nn->nn_zonelen > NBPSTRLEN ) {
84 memcpy( nn->nn_zone, data, nn->nn_zonelen );
89 #define NBPM_OBJ (1<<1)
90 #define NBPM_TYPE (1<<2)
91 #define NBPM_ZONE (1<<3)
93 int nbp_match( n1, n2, flags )
94 struct nbpnve *n1, *n2;
99 if ( flags & NBPMATCH_NOZONE ) {
103 if ( !( flags & NBPMATCH_NOGLOB )) {
104 if ( n1->nn_objlen == 1 && n1->nn_obj[0] == '=' ) {
107 if ( n1->nn_typelen == 1 && n1->nn_type[0] == '=' ) {
112 if ( !( match & NBPM_OBJ )) {
113 if ( n1->nn_objlen != n2->nn_objlen ||
114 strndiacasecmp( n1->nn_obj, n2->nn_obj, n1->nn_objlen )) {
118 if ( !( match & NBPM_TYPE )) {
119 if ( n1->nn_typelen != n2->nn_typelen ||
120 strndiacasecmp( n1->nn_type, n2->nn_type, n1->nn_typelen )) {
124 if ( !( match & NBPM_ZONE )) {
125 if ( n1->nn_zonelen != n2->nn_zonelen ||
126 strndiacasecmp( n1->nn_zone, n2->nn_zone, n1->nn_zonelen )) {
134 int nbp_name( name, objp, typep, zonep )
136 char **objp, **typep, **zonep;
138 static char buf[ 32 + 1 + 32 + 1 + 32 + 1 ];
142 if ( strlen( name ) + 1 > sizeof( buf )) {
147 if (( p = strrchr( buf, '@' )) != NULL ) {
151 if (( p = strrchr( buf, ':' )) != NULL ) {
155 if ( *buf != '\0' ) {