]> git.pld-linux.org Git - packages/samba.git/blob - samba-2.2.3a+IPv6-20020419.diff
- pl description for cups-backend-smb
[packages/samba.git] / samba-2.2.3a+IPv6-20020419.diff
1 Index: samba-2.2.3a+IPv6/source/acconfig.h
2 ===================================================================
3 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/acconfig.h,v
4 retrieving revision 1.1.1.1
5 retrieving revision 1.2
6 diff -u -r1.1.1.1 -r1.2
7 --- samba-2.2.3a+IPv6/source/acconfig.h 16 Apr 2002 03:34:34 -0000      1.1.1.1
8 +++ samba-2.2.3a+IPv6/source/acconfig.h 18 Apr 2002 04:53:04 -0000      1.2
9 @@ -59,6 +59,7 @@
10  #undef WITH_SYSLOG
11  #undef WITH_PROFILE
12  #undef WITH_SSL
13 +#undef HAVE_INET6
14  #undef WITH_LDAP
15  #undef WITH_NISPLUS
16  #undef WITH_TDBPWD
17 Index: samba-2.2.3a+IPv6/source/configure.in
18 ===================================================================
19 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/configure.in,v
20 retrieving revision 1.1.1.1
21 retrieving revision 1.2
22 diff -u -r1.1.1.1 -r1.2
23 --- samba-2.2.3a+IPv6/source/configure.in       16 Apr 2002 03:34:34 -0000      1.1.1.1
24 +++ samba-2.2.3a+IPv6/source/configure.in       18 Apr 2002 04:53:04 -0000      1.2
25 @@ -2100,6 +2100,53 @@
26  )
27  
28  #################################################
29 +# check for IPv6 support
30 +AC_MSG_CHECKING(whether to use IPv6)
31 +AC_ARG_WITH(ipv6,
32 +[  --with-ipv6             Include IPv6 support (default=no)],
33 +[ case "$withval" in
34 +  yes)
35 +    AC_MSG_RESULT(yes)
36 +    AC_DEFINE(HAVE_INET6)
37 +
38 +    AC_CACHE_CHECK(for struct sockaddr_in6,samba_cv_struct_sockaddr_in6,
39 +       AC_TRY_COMPILE(
40 +               [#include <sys/types.h>
41 +               #include <sys/socket.h>
42 +               #include <netinet/in.h>],
43 +               [struct sockaddr_in6 sin6;
44 +               sin6.sin6_port = 0;],
45 +               [samba_cv_struct_sockaddr_in6=yes],
46 +               [samba_cv_struct_sockaddr_in6=no]))
47 +    if test "$samba_cv_struct_sockaddr_in6" != yes ; then
48 +       AC_MSG_ERROR([This system does not have IPv6 support.  Reconfigure without the --with-ipv6 flag.])
49 +    fi
50 +
51 +    AC_CHECK_FUNC(getaddrinfo,,
52 +       AC_MSG_ERROR([IPv6 functionality requires getaddrinfo.  Reconfigure without the --with-ipv6 flag.]))
53 +
54 +    dnl This can't check for member names because we're not sure what they
55 +    dnl might be.  Doesn't matter - we only need it defined for sizeof.
56 +    AC_CACHE_CHECK(for struct sockaddr_storage,samba_cv_struct_sockaddr_storage,
57 +       AC_TRY_COMPILE(
58 +               [#include <sys/types.h>
59 +               #include <sys/socket.h>
60 +               #include <netinet/in.h>],
61 +               [struct sockaddr_storage ss;],
62 +               [samba_cv_struct_sockaddr_storage=yes],
63 +               [samba_cv_struct_sockaddr_storage=no]))
64 +    if test "$samba_cv_struct_sockaddr_storage" != yes ; then
65 +       AC_MSG_ERROR([IPv6 functionality requires the sockaddr_storage structure.  Reconfigure without the --with-ipv6 flag.])
66 +    fi
67 +    ;;
68 +  *)
69 +    AC_MSG_RESULT(no)
70 +    ;;
71 +  esac],
72 +  AC_MSG_RESULT(no)
73 +)
74 +
75 +#################################################
76  # check for syslog logging
77  AC_MSG_CHECKING(whether to use syslog logging)
78  AC_ARG_WITH(syslog,
79 Index: samba-2.2.3a+IPv6/source/client/client.c
80 ===================================================================
81 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/client/client.c,v
82 retrieving revision 1.1.1.1
83 retrieving revision 1.2
84 diff -u -r1.1.1.1 -r1.2
85 --- samba-2.2.3a+IPv6/source/client/client.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
86 +++ samba-2.2.3a+IPv6/source/client/client.c    18 Apr 2002 04:53:04 -0000      1.2
87 @@ -30,7 +30,7 @@
88  struct cli_state *cli;
89  extern BOOL in_client;
90  extern BOOL AllowDebugChange;
91 -static int port = SMB_PORT;
92 +static int port = 0;
93  pstring cur_dir = "\\";
94  pstring cd_path = "";
95  static pstring service;
96 @@ -81,7 +81,7 @@
97  static BOOL recurse = False;
98  BOOL lowercase = False;
99  
100 -struct in_addr dest_ip;
101 +char dest_ip[512];
102  
103  #define SEPARATORS " \t\n\r"
104  
105 @@ -2146,8 +2146,7 @@
106         struct cli_state *c;
107         struct nmb_name called, calling;
108         char *server_n;
109 -       struct in_addr ip;
110 -       extern struct in_addr ipzero;
111 +       struct sockaddr_list *salist;
112         fstring servicename;
113         char *sharename;
114         
115 @@ -2164,19 +2163,16 @@
116  
117         server_n = server;
118         
119 -       ip = ipzero;
120 -
121         make_nmb_name(&calling, global_myname, 0x0);
122         make_nmb_name(&called , server, name_type);
123  
124   again:
125 -       ip = ipzero;
126 -       if (have_ip) ip = dest_ip;
127 +       salist = resolve_name_smb(have_ip ? dest_ip : server_n, port);
128  
129         /* have to open a new connection */
130 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) == 0) ||
131 -           !cli_connect(c, server_n, &ip)) {
132 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, salist)) {
133                 DEBUG(0,("Connection to %s failed\n", server_n));
134 +               free_sockaddr_list(salist);
135                 return NULL;
136         }
137  
138 @@ -2416,19 +2412,17 @@
139  ****************************************************************************/
140  static int do_message_op(void)
141  {
142 -       struct in_addr ip;
143         struct nmb_name called, calling;
144 -
145 -       ip = ipzero;
146 +       struct sockaddr_list *salist;
147  
148         make_nmb_name(&calling, global_myname, 0x0);
149         make_nmb_name(&called , desthost, name_type);
150  
151 -       ip = ipzero;
152 -       if (have_ip) ip = dest_ip;
153 +       salist = resolve_name_smb(have_ip ? dest_ip : desthost, port);
154  
155 -       if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, port) == 0) || !cli_connect(cli, desthost, &ip)) {
156 +       if (!(cli=cli_initialise(NULL)) || !cli_connect(cli, desthost, salist)) {
157                 DEBUG(0,("Connection to %s failed\n", desthost));
158 +               free_sockaddr_list(salist);
159                 return 1;
160         }
161  
162 @@ -2660,9 +2654,7 @@
163                         break;
164                 case 'I':
165                         {
166 -                               dest_ip = *interpret_addr2(optarg);
167 -                               if (zero_ip(dest_ip))
168 -                                       exit(1);
169 +                               strncpy(dest_ip, optarg, sizeof(dest_ip));
170                                 have_ip = True;
171                         }
172                         break;
173 Index: samba-2.2.3a+IPv6/source/client/smbmount.c
174 ===================================================================
175 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/client/smbmount.c,v
176 retrieving revision 1.1.1.1
177 retrieving revision 1.3
178 diff -u -r1.1.1.1 -r1.3
179 --- samba-2.2.3a+IPv6/source/client/smbmount.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
180 +++ samba-2.2.3a+IPv6/source/client/smbmount.c  19 Apr 2002 14:50:33 -0000      1.3
181 @@ -43,9 +43,9 @@
182  static pstring service;
183  static pstring options;
184  
185 -static struct in_addr dest_ip;
186 +static char dest_ip[512];
187  static BOOL have_ip;
188 -static int smb_port = 139;
189 +static int smb_port = 0;
190  static BOOL got_pass;
191  static uid_t mount_uid;
192  static gid_t mount_gid;
193 @@ -118,9 +118,8 @@
194  {
195         struct cli_state *c;
196         struct nmb_name called, calling;
197 +       struct sockaddr_list *salist;
198         char *server_n;
199 -       struct in_addr ip;
200 -       extern struct in_addr ipzero;
201         pstring server;
202         char *share;
203  
204 @@ -144,13 +143,12 @@
205         make_nmb_name(&called , server, 0x20);
206  
207   again:
208 -       ip = ipzero;
209 -       if (have_ip) ip = dest_ip;
210 +       salist = resolve_name_smb(have_ip ? dest_ip : server_n, smb_port);
211  
212         /* have to open a new connection */
213 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) == 0) ||
214 -           !cli_connect(c, server_n, &ip)) {
215 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, salist)) {
216                 DEBUG(0,("%d: Connection to %s failed\n", getpid(), server_n));
217 +               free_sockaddr_list(salist);
218                 if (c) {
219                         cli_shutdown(c);
220                 }
221 @@ -747,11 +745,7 @@
222                         } else if(!strcmp(opts, "debug")) {
223                                 DEBUGLEVEL = val;
224                         } else if(!strcmp(opts, "ip")) {
225 -                               dest_ip = *interpret_addr2(opteq+1);
226 -                               if (zero_ip(dest_ip)) {
227 -                                       fprintf(stderr,"Can't resolve address %s\n", opteq+1);
228 -                                       exit(1);
229 -                               }
230 +                               strncpy(dest_ip, optarg, sizeof(dest_ip));
231                                 have_ip = True;
232                         } else if(!strcmp(opts, "workgroup")) {
233                                 pstrcpy(workgroup,opteq+1);
234 Index: samba-2.2.3a+IPv6/source/client/smbspool.c
235 ===================================================================
236 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/client/smbspool.c,v
237 retrieving revision 1.1.1.1
238 retrieving revision 1.2
239 diff -u -r1.1.1.1 -r1.2
240 --- samba-2.2.3a+IPv6/source/client/smbspool.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
241 +++ samba-2.2.3a+IPv6/source/client/smbspool.c  18 Apr 2002 04:53:04 -0000      1.2
242 @@ -29,7 +29,6 @@
243   */
244  
245  extern BOOL            in_client;      /* Boolean for client library */
246 -extern struct in_addr  ipzero;         /* Any address */
247  
248  
249  /*
250 @@ -280,7 +279,6 @@
251    struct cli_state     *c;             /* New connection */
252    struct nmb_name      called,         /* NMB name of server */
253                         calling;        /* NMB name of client */
254 -  struct in_addr       ip;             /* IP address of server */
255    pstring              myname;         /* Client name */
256  
257  
258 @@ -290,8 +288,6 @@
259  
260    get_myname(myname);  
261  
262 -  ip = ipzero;
263 -
264    make_nmb_name(&calling, myname, 0x0);
265    make_nmb_name(&called, server, 0x20);
266  
267 @@ -305,13 +301,7 @@
268      return (NULL);
269    }
270  
271 -  if (!cli_set_port(c, SMB_PORT))
272 -  {
273 -    fputs("ERROR: cli_set_port() failed...\n", stderr);
274 -    return (NULL);
275 -  }
276 -
277 -  if (!cli_connect(c, server, &ip))
278 +  if (!cli_connect(c, server, NULL))
279    {
280      fputs("ERROR: cli_connect() failed...\n", stderr);
281      return (NULL);
282 Index: samba-2.2.3a+IPv6/source/include/client.h
283 ===================================================================
284 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/include/client.h,v
285 retrieving revision 1.1.1.1
286 retrieving revision 1.2
287 diff -u -r1.1.1.1 -r1.2
288 --- samba-2.2.3a+IPv6/source/include/client.h   16 Apr 2002 03:34:39 -0000      1.1.1.1
289 +++ samba-2.2.3a+IPv6/source/include/client.h   18 Apr 2002 04:53:04 -0000      1.2
290 @@ -58,7 +58,7 @@
291  };
292  
293  struct cli_state {
294 -       int port;
295 +       int default_port;
296         int fd;
297         uint16 cnum;
298         uint16 pid;
299 @@ -88,7 +88,8 @@
300         struct nmb_name called;
301         struct nmb_name calling;
302         fstring full_dest_host_name;
303 -       struct in_addr dest_ip;
304 +       struct sockaddr_list *dest_addrs;
305 +       struct sockaddr_list *connected_addr;
306  
307         struct pwd_info pwd;
308         unsigned char cryptkey[8];
309 Index: samba-2.2.3a+IPv6/source/include/config.h.in
310 ===================================================================
311 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/include/config.h.in,v
312 retrieving revision 1.1.1.1
313 retrieving revision 1.2
314 diff -u -r1.1.1.1 -r1.2
315 --- samba-2.2.3a+IPv6/source/include/config.h.in        16 Apr 2002 03:34:39 -0000      1.1.1.1
316 +++ samba-2.2.3a+IPv6/source/include/config.h.in        18 Apr 2002 04:53:04 -0000      1.2
317 @@ -122,6 +122,7 @@
318  #undef WITH_SYSLOG
319  #undef WITH_PROFILE
320  #undef WITH_SSL
321 +#undef HAVE_INET6
322  #undef WITH_LDAP
323  #undef WITH_NISPLUS
324  #undef WITH_TDBPWD
325 Index: samba-2.2.3a+IPv6/source/include/nameserv.h
326 ===================================================================
327 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/include/nameserv.h,v
328 retrieving revision 1.1.1.1
329 retrieving revision 1.2
330 diff -u -r1.1.1.1 -r1.2
331 --- samba-2.2.3a+IPv6/source/include/nameserv.h 16 Apr 2002 03:34:39 -0000      1.1.1.1
332 +++ samba-2.2.3a+IPv6/source/include/nameserv.h 18 Apr 2002 04:53:04 -0000      1.2
333 @@ -129,6 +129,17 @@
334  #define FIND_SELF_NAME  1
335  
336  /*
337 + * Linked-list structure for storing resolved IP addresses.
338 + */
339 +
340 +struct sockaddr_list {
341 +       struct sockaddr_list *next;
342 +       int pfamily;
343 +       int len;
344 +       struct sockaddr *addr;
345 +};
346 +
347 +/*
348   * The different name types that can be in namelists.
349   *
350   * SELF_NAME should only be on the broadcast and unicast subnets.
351 Index: samba-2.2.3a+IPv6/source/include/proto.h
352 ===================================================================
353 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/include/proto.h,v
354 retrieving revision 1.1.1.1
355 retrieving revision 1.2
356 diff -u -r1.1.1.1 -r1.2
357 --- samba-2.2.3a+IPv6/source/include/proto.h    16 Apr 2002 03:34:39 -0000      1.1.1.1
358 +++ samba-2.2.3a+IPv6/source/include/proto.h    18 Apr 2002 04:53:04 -0000      1.2
359 @@ -181,14 +181,15 @@
360  BOOL cli_negprot(struct cli_state *cli);
361  BOOL cli_session_request(struct cli_state *cli,
362                          struct nmb_name *calling, struct nmb_name *called);
363 -BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
364 +BOOL cli_connect(struct cli_state *cli, const char *host,
365 +               struct sockaddr_list *salist);
366  BOOL cli_establish_connection(struct cli_state *cli, 
367 -                               char *dest_host, struct in_addr *dest_ip,
368 +                               char *dest_host, struct sockaddr_list *salist,
369                                 struct nmb_name *calling, struct nmb_name *called,
370                                 char *service, char *service_type,
371                                 BOOL do_shutdown, BOOL do_tcon);
372 -BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
373 -                                     struct in_addr *pdest_ip);
374 +BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost,
375 +               char *desthost);
376  
377  /*The following definitions come from  libsmb/cli_dfs.c  */
378  
379 @@ -660,11 +661,14 @@
380  BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
381  void endlmhosts(FILE *fp);
382  BOOL name_register_wins(const char *name, int name_type);
383 -BOOL name_resolve_bcast(const char *name, int name_type,
384 -                       struct in_addr **return_ip_list, int *return_count);
385 -BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
386 -BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
387 -                                struct in_addr *ip);
388 +struct sockaddr_list *name_resolve_bcast(const char *name, int name_type);
389 +BOOL resolve_name_netbios(const char *name, struct in_addr *return_ip,
390 +               int name_type);
391 +struct sockaddr_list *resolve_name_smb(const char *name, int port);
392 +struct sockaddr_list *resolve_srv_name(const char* srv_name,
393 +               fstring dest_host, int port);
394 +//BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
395 +//                                struct in_addr *ip);
396  BOOL find_master_ip(char *group, struct in_addr *master_ip);
397  BOOL lookup_dc_name(const char *srcname, const char *domain, 
398                     struct in_addr *dc_ip, char *ret_name);
399 @@ -1076,9 +1080,23 @@
400  void safe_free(void *p);
401  BOOL get_myname(char *my_name);
402  int interpret_protocol(char *str,int def);
403 +BOOL is_ipv4address(const char *str);
404  BOOL is_ipaddress(const char *str);
405  uint32 interpret_addr(const char *str);
406  struct in_addr *interpret_addr2(const char *str);
407 +struct sockaddr *get_numeric_addr(const char *str);
408 +int get_sockaddr_port(struct sockaddr *sa);
409 +void set_sockaddr_port(struct sockaddr *sa, int port);
410 +struct sockaddr_list *set_default_ports(struct sockaddr_list *salist);
411 +BOOL is_directsmb(struct sockaddr *sa);
412 +char *print_sockaddr(struct sockaddr *sa);
413 +void make_sockaddr_in(struct sockaddr *sa, struct in_addr *addr);
414 +void free_sockaddr_list(struct sockaddr_list *salist);
415 +struct sockaddr_list *make_sin_list(struct in_addr *addr, int count);
416 +struct sockaddr_list *make_singlet_list(struct in_addr *addr, int port);
417 +#ifdef HAVE_INET6
418 +struct sockaddr_list *make_sa_list(struct addrinfo *ai);
419 +#endif
420  BOOL zero_ip(struct in_addr ip);
421  char *automount_lookup(char *user_name);
422  char *automount_lookup(char *user_name);
423 @@ -1212,7 +1230,8 @@
424  BOOL send_smb(int fd,char *buffer);
425  BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type);
426  int open_socket_in( int type, int port, int dlevel, uint32 socket_addr, BOOL rebind );
427 -int open_socket_out(int type, struct in_addr *addr, int port ,int timeout);
428 +int open_socket_out(struct sockaddr_list *addrs,
429 +               struct sockaddr_list **connected_addr, int timeout);
430  void client_setfd(int fd);
431  char *client_name(void);
432  char *client_addr(void);
433 Index: samba-2.2.3a+IPv6/source/include/smb.h
434 ===================================================================
435 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/include/smb.h,v
436 retrieving revision 1.1.1.1
437 retrieving revision 1.2
438 diff -u -r1.1.1.1 -r1.2
439 --- samba-2.2.3a+IPv6/source/include/smb.h      16 Apr 2002 03:34:38 -0000      1.1.1.1
440 +++ samba-2.2.3a+IPv6/source/include/smb.h      18 Apr 2002 04:53:04 -0000      1.2
441 @@ -463,7 +463,8 @@
442         char *user; /* name of user who *opened* this connection */
443         uid_t uid; /* uid of user who *opened* this connection */
444         gid_t gid; /* gid of user who *opened* this connection */
445 -       char client_address[18]; /* String version of client IP address. */
446 +       char client_address[50]; /* String version of client IP address.
447 +                                 * Nice and long for IPv6 addresses... */
448  
449         uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
450  
451 Index: samba-2.2.3a+IPv6/source/lib/access.c
452 ===================================================================
453 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/lib/access.c,v
454 retrieving revision 1.1.1.1
455 retrieving revision 1.2
456 diff -u -r1.1.1.1 -r1.2
457 --- samba-2.2.3a+IPv6/source/lib/access.c       16 Apr 2002 03:34:35 -0000      1.1.1.1
458 +++ samba-2.2.3a+IPv6/source/lib/access.c       18 Apr 2002 04:53:05 -0000      1.2
459 @@ -16,7 +16,7 @@
460  #define        FAIL            (-1)
461  
462  /* masked_match - match address against netnumber/netmask */
463 -static int masked_match(char *tok, char *slash, char *s)
464 +static BOOL masked_match_ipv4(char *tok, char *slash, char *s)
465  {
466         uint32 net;
467         uint32 mask;
468 @@ -35,6 +35,54 @@
469         return ((addr & mask) == net);
470  }
471  
472 +#ifdef HAVE_INET6
473 +static BOOL masked_match_ipv6(char *tok, char *slash, char *s)
474 +{
475 +       struct in6_addr net, addr;
476 +       unsigned char *n = (unsigned char *)&net;
477 +       unsigned char *a = (unsigned char *)&addr;
478 +       int ret, len, i, mask;
479 +
480 +       if(inet_pton(AF_INET6, s, &addr) <= 0)
481 +       {
482 +               DEBUG(0,("access: unable to parse remote address: %s\n", s));
483 +               return False;
484 +       }
485 +       *slash = '\0';
486 +       ret = inet_pton(AF_INET6, tok, &net);
487 +       *slash = '/';
488 +       len = atoi(slash + 1);
489 +       if(ret <= 0 || len < 0 || len > 128
490 +                       || (len == 0 && strcmp(slash + 1, "0")))
491 +       {
492 +               DEBUG(0,("access: bad net/mask access control: %s\n", tok));
493 +               return False;
494 +       }
495 +       for(i = 0; i < len; i += 8)
496 +       {
497 +
498 +               if( len - i < 8 )
499 +                       mask = ~((1 << (8 - (len - i))) - 1);
500 +               else
501 +                       mask = ~0;
502 +               DEBUG(3,("len=%d i=%d mask=%02x *n=%02x *a=%02x *a&mask=%02x\n",
503 +                                       len, i, mask, *n, *a, *a & mask));
504 +               if(*(n++) != (*(a++) & mask)) return False;
505 +       }
506 +       return True;
507 +}
508 +#endif
509 +
510 +static BOOL masked_match(char *tok, char *slash, char *s)
511 +{
512 +       if(is_ipv4address(s)) return masked_match_ipv4(tok, slash, s);
513 +#ifdef HAVE_INET6
514 +       return masked_match_ipv6(tok, slash, s);
515 +#else
516 +       return False;
517 +#endif
518 +}
519 +
520  /* string_match - match string against token */
521  static int string_match(char *tok,char *s, char *invalid_char)
522  {
523 @@ -105,8 +153,13 @@
524         } else if (tok[(tok_len = strlen(tok)) - 1] == '.') {   /* network */
525                 if (strncmp(tok, s, tok_len) == 0)
526                         return (True);
527 +#ifdef HAVE_INET6
528 +       } else if (tok[(tok_len = strlen(tok)) - 1] == ':') { /* IPv6 network */
529 +               if (strncasecmp(tok, s, tok_len) == 0)
530 +                       return (True);
531 +#endif
532         } else if ((cut = strchr(tok, '/')) != 0) {     /* netnumber/netmask */
533 -               if (isdigit((int)s[0]) && masked_match(tok, cut, s))
534 +               if (isxdigit((int)s[0]) && masked_match(tok, cut, s))
535                         return (True);
536         } else if (strchr(tok, '*') != 0) {
537                 *invalid_char = '*';
538 @@ -200,9 +253,13 @@
539         client[1] = caddr;  
540  
541         /* if it is loopback then always allow unless specifically denied */
542 +#ifdef HAVE_INET6
543 +       if (strcmp(caddr, "127.0.0.1") == 0 || strcmp(caddr, "::1") == 0) {
544 +#else
545         if (strcmp(caddr, "127.0.0.1") == 0) {
546 +#endif
547                 /*
548 -                * If 127.0.0.1 matches both allow and deny then allow.
549 +                * If 127.0.0.1 or ::1 matches both allow and deny then allow.
550                  * Patch from Steve Langasek vorlon@netexpress.net.
551                  */
552                 if (deny_list && 
553 Index: samba-2.2.3a+IPv6/source/lib/util.c
554 ===================================================================
555 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/lib/util.c,v
556 retrieving revision 1.1.1.1
557 retrieving revision 1.2
558 diff -u -r1.1.1.1 -r1.2
559 --- samba-2.2.3a+IPv6/source/lib/util.c 16 Apr 2002 03:34:35 -0000      1.1.1.1
560 +++ samba-2.2.3a+IPv6/source/lib/util.c 18 Apr 2002 04:53:05 -0000      1.2
561 @@ -732,11 +732,11 @@
562   Return true if a string could be a pure IP address.
563  ****************************************************************************/
564  
565 -BOOL is_ipaddress(const char *str)
566 +BOOL is_ipv4address(const char *str)
567  {
568    BOOL pure_address = True;
569    int i;
570 -  
571 +
572    for (i=0; pure_address && str[i]; i++)
573      if (!(isdigit((int)str[i]) || str[i] == '.'))
574        pure_address = False;
575 @@ -747,6 +747,26 @@
576    return pure_address;
577  }
578  
579 +BOOL is_ipaddress(const char *str)
580 +{
581 +#ifdef HAVE_INET6
582 +  /* First we see if the address is an IPv6 address */
583 +  if (strchr(str, ':'))
584 +  {
585 +       int i;
586 +
587 +       /* It contains a colon; it probably is */
588 +       for (i=0; str[i]; i++)
589 +               if (!(isxdigit((int)str[i]) || str[i] == '.' || str[i] == ':'))
590 +                       return False;
591 +
592 +       return True;
593 +  }
594 +#endif
595 +
596 +  return is_ipv4address(str);
597 +}
598 +
599  /****************************************************************************
600  interpret an internet address or name into an IP address in 4 byte form
601  ****************************************************************************/
602 @@ -792,6 +812,186 @@
603    return(&ret);
604  }
605  
606 +struct sockaddr *get_numeric_addr(const char *str)
607 +{
608 +#ifdef HAVE_INET6
609 +       struct sockaddr *sa;
610 +       struct addrinfo *ai, hints;
611 +
612 +       memset(&hints, 0, sizeof(hints));
613 +       hints.ai_socktype = SOCK_STREAM;
614 +       hints.ai_flags = AI_NUMERICHOST;
615 +       if(getaddrinfo(str, NULL, &hints, &ai) || ! ai) return NULL;
616 +       sa = (struct sockaddr *)malloc(ai->ai_addrlen);
617 +       memcpy(sa, ai->ai_addr, ai->ai_addrlen);
618 +       freeaddrinfo(ai);
619 +       return sa;
620 +#else
621 +       struct sockaddr *sa;
622 +       struct in_addr addr;
623 +
624 +       if(inet_aton(str, &addr))
625 +       {
626 +               sa = (struct sockaddr *)malloc(sizeof(struct sockaddr_in));
627 +               make_sockaddr_in(sa, &addr);
628 +               return sa;
629 +       }
630 +       return NULL;
631 +#endif
632 +}
633 +
634 +int get_sockaddr_port(struct sockaddr *sa)
635 +{
636 +#ifdef HAVE_INET6
637 +       if(sa->sa_family==AF_INET6)
638 +               return ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
639 +       else
640 +#endif
641 +       if(sa->sa_family==AF_INET)
642 +               return ntohs(((struct sockaddr_in *)sa)->sin_port);
643 +       else
644 +               return 0;
645 +}
646 +
647 +void set_sockaddr_port(struct sockaddr *sa, int port)
648 +{
649 +#ifdef HAVE_INET6
650 +       if(sa->sa_family==AF_INET6)
651 +               ((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
652 +       else
653 +#endif
654 +       if(sa->sa_family==AF_INET)
655 +               ((struct sockaddr_in *)sa)->sin_port = htons(port);
656 +}
657 +
658 +struct sockaddr_list *set_default_ports(struct sockaddr_list *salist)
659 +{
660 +       struct sockaddr_list *cur;
661 +
662 +       for(cur = salist; cur; cur = cur->next)
663 +       {
664 +               set_sockaddr_port(cur->addr, 445);
665 +               if(cur->addr->sa_family == AF_INET)
666 +               {
667 +                       struct sockaddr_list *sc;
668 +
669 +                       sc = (struct sockaddr_list *)
670 +                               malloc(sizeof(struct sockaddr_list));
671 +                       sc->next = cur->next;
672 +                       cur->next = sc;
673 +                       sc->pfamily = cur->pfamily;
674 +                       sc->len = cur->len;
675 +                       sc->addr = (struct sockaddr *)malloc(sc->len);
676 +                       memcpy(sc->addr, cur->addr, cur->len);
677 +                       set_sockaddr_port(sc->addr, 139);
678 +                       cur = sc;
679 +               }
680 +       }
681 +       return salist;
682 +}
683 +
684 +
685 +BOOL is_directsmb(struct sockaddr *sa)
686 +{
687 +       BOOL ret = sa->sa_family != AF_INET
688 +               || ((struct sockaddr_in *)sa)->sin_port == htons(445);
689 +       DEBUG(4,("connection is%s direct SMB\n", ret ? "" : " not"));
690 +       return ret;
691 +}
692 +
693 +char *print_sockaddr(struct sockaddr *sa)
694 +{
695 +#ifdef HAVE_INET6
696 +       static char addr[64];
697 +
698 +       if(sa->sa_family == AF_INET6)
699 +       {
700 +               inet_ntop(AF_INET6, &((struct sockaddr_in6 *)sa)->sin6_addr,
701 +                               addr, sizeof(addr));
702 +               return addr;
703 +       } else
704 +#endif
705 +       if(sa->sa_family == AF_INET)
706 +               return inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
707 +       else return NULL;
708 +}
709 +
710 +void make_sockaddr_in(struct sockaddr *sa, struct in_addr *addr)
711 +{
712 +       memset(sa, 0, sizeof(struct sockaddr_in));
713 +       ((struct sockaddr_in *)sa)->sin_family = AF_INET;
714 +       ((struct sockaddr_in *)sa)->sin_port = 0;
715 +       memcpy(&((struct sockaddr_in *)sa)->sin_addr, addr,
716 +                       sizeof(struct in_addr));
717 +}
718 +
719 +void free_sockaddr_list(struct sockaddr_list *salist)
720 +{
721 +       struct sockaddr_list *next;
722 +
723 +       while(salist)
724 +       {
725 +               next = salist->next;
726 +               SAFE_FREE(salist->addr);
727 +               SAFE_FREE(salist);
728 +               salist = next;
729 +       }
730 +}
731 +
732 +struct sockaddr_list *make_sin_list(struct in_addr *addr, int count)
733 +{
734 +       int i;
735 +       struct sockaddr_list *top = NULL, *last = NULL, *sc;
736 +
737 +       for(i = 0; i<count; ++i)
738 +       {
739 +               sc = (struct sockaddr_list *)
740 +                       malloc(sizeof(struct sockaddr_list));
741 +               if(i==0) top = sc;
742 +               else last->next = sc;
743 +               last = sc;
744 +               sc->next = NULL;
745 +               sc->pfamily = PF_INET;
746 +               sc->len = sizeof(struct sockaddr_in);
747 +               sc->addr = (struct sockaddr *)
748 +                       malloc(sizeof(struct sockaddr_in));
749 +               make_sockaddr_in(sc->addr, &addr[i]);
750 +       }
751 +       return top;
752 +}
753 +
754 +struct sockaddr_list *make_singlet_list(struct in_addr *addr, int port)
755 +{
756 +       struct sockaddr_list *salist;
757 +
758 +       salist = make_sin_list(addr, 1);
759 +       if(port) set_sockaddr_port(salist->addr, port);
760 +       else salist = set_default_ports(salist);
761 +       return salist;
762 +}
763 +
764 +#ifdef HAVE_INET6
765 +struct sockaddr_list *make_sa_list(struct addrinfo *ai)
766 +{
767 +       struct sockaddr_list *top = NULL, *last = NULL, *sc;
768 +
769 +       for(; ai; ai = ai->ai_next)
770 +       {
771 +               sc = (struct sockaddr_list *)
772 +                       malloc(sizeof(struct sockaddr_list));
773 +               if(top==NULL) top = sc;
774 +               else last->next = sc;
775 +               last = sc;
776 +               sc->next = NULL;
777 +               sc->pfamily = ai->ai_family;
778 +               sc->len = ai->ai_addrlen;
779 +               sc->addr = (struct sockaddr *)malloc(ai->ai_addrlen);
780 +               memcpy(sc->addr, ai->ai_addr, ai->ai_addrlen);
781 +       }
782 +       return top;
783 +}
784 +#endif
785 +
786  /*******************************************************************
787    check if an IP is the 0.0.0.0
788    ******************************************************************/
789 @@ -1343,7 +1543,7 @@
790                 return True;
791  
792         /* maybe its an IP address? */
793 -       if (is_ipaddress(s))
794 +       if (is_ipv4address(s))
795         {
796                 struct iface_struct nics[MAX_INTERFACES];
797                 int i, n;
798 Index: samba-2.2.3a+IPv6/source/lib/util_sock.c
799 ===================================================================
800 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/lib/util_sock.c,v
801 retrieving revision 1.1.1.1
802 retrieving revision 1.2
803 diff -u -r1.1.1.1 -r1.2
804 --- samba-2.2.3a+IPv6/source/lib/util_sock.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
805 +++ samba-2.2.3a+IPv6/source/lib/util_sock.c    18 Apr 2002 04:53:05 -0000      1.2
806 @@ -804,67 +804,94 @@
807    create an outgoing socket. timeout is in milliseconds.
808    **************************************************************************/
809  
810 -int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
811 +int open_socket_out(struct sockaddr_list *addrs,
812 +               struct sockaddr_list **connected_addr, int timeout)
813  {
814 -  struct sockaddr_in sock_out;
815 -  int res,ret;
816 -  int connect_loop = 250; /* 250 milliseconds */
817 -  int loops = (timeout) / connect_loop;
818 -
819 -  /* create a socket to write to */
820 -  res = socket(PF_INET, type, 0);
821 -  if (res == -1) 
822 -    { DEBUG(0,("socket error\n")); return -1; }
823 -
824 -  if (type != SOCK_STREAM) return(res);
825 -  
826 -  memset((char *)&sock_out,'\0',sizeof(sock_out));
827 -  putip((char *)&sock_out.sin_addr,(char *)addr);
828 -  
829 -  sock_out.sin_port = htons( port );
830 -  sock_out.sin_family = PF_INET;
831 -
832 -  /* set it non-blocking */
833 -  set_blocking(res,False);
834 -
835 -  DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port));
836 -  
837 -  /* and connect it to the destination */
838 -connect_again:
839 -  ret = connect(res,(struct sockaddr *)&sock_out,sizeof(sock_out));
840 -
841 -  /* Some systems return EAGAIN when they mean EINPROGRESS */
842 -  if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
843 -        errno == EAGAIN) && loops--) {
844 -    msleep(connect_loop);
845 -    goto connect_again;
846 -  }
847 -
848 -  if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
849 -         errno == EAGAIN)) {
850 -      DEBUG(1,("timeout connecting to %s:%d\n",inet_ntoa(*addr),port));
851 -      close(res);
852 -      return -1;
853 -  }
854 +       struct sockaddr_list *sl;
855 +       int res,ret;
856 +       int connect_loop = 250; /* 250 milliseconds */
857 +       int loops = (timeout) / connect_loop;
858 +
859 +       if(connected_addr) *connected_addr = NULL;
860 +
861 +       for(sl = addrs; sl; sl = sl->next)
862 +       {
863 +               /* create a socket to write to */
864 +               res = socket(sl->pfamily, SOCK_STREAM, 0);
865 +               if (res == -1) 
866 +               {
867 +                       /* If there are more addresses available, then we
868 +                        * are probably running on a platform without IPv6
869 +                        * support in the kernel, and we just tried
870 +                        * connecting to an IPv6 address.  Don't complain
871 +                        * until we're out of addresses. */
872 +
873 +                       if(!sl->next) DEBUG(0,("socket error\n"));
874 +                       continue;
875 +               }
876 +
877 +               /* set it non-blocking */
878 +               set_blocking(res,False);
879 +
880 +               DEBUG(3,("Connecting to %s at port %d\n",
881 +                       print_sockaddr(sl->addr), get_sockaddr_port(sl->addr)));
882 +               
883 +               /* and connect it to the destination */
884 +       connect_again:
885 +               ret = connect(res,sl->addr,sl->len);
886 +
887 +               /* Some systems return EAGAIN when they mean EINPROGRESS */
888 +               if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
889 +                                       errno == EAGAIN) && loops--) {
890 +                       msleep(connect_loop);
891 +                       goto connect_again;
892 +               }
893 +
894 +               if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
895 +                                        errno == EAGAIN)) {
896 +                       DEBUG(1,("timeout connecting to [%s]:%d\n",
897 +                               print_sockaddr(sl->addr),
898 +                               get_sockaddr_port(sl->addr)));
899 +                       close(res);
900 +                       if(sl->next) {
901 +                               DEBUG(1,("attempting next address...\n"));
902 +                               continue;
903 +                       } else return -1;
904 +               }
905  
906  #ifdef EISCONN
907 -  if (ret < 0 && errno == EISCONN) {
908 -    errno = 0;
909 -    ret = 0;
910 -  }
911 -#endif
912 -
913 -  if (ret < 0) {
914 -    DEBUG(2,("error connecting to %s:%d (%s)\n",
915 -            inet_ntoa(*addr),port,strerror(errno)));
916 -    close(res);
917 -    return -1;
918 -  }
919 +               if (ret < 0 && errno == EISCONN) {
920 +                       errno = 0;
921 +                       ret = 0;
922 +               }
923 +#endif
924  
925 -  /* set it blocking again */
926 -  set_blocking(res,True);
927 +               if (ret < 0) {
928 +                       /* If we got connection refused or host unreachable,
929 +                        * we may be trying to connect to an IPv6 host but
930 +                        * this system isn't configured for IPv6.  If we have
931 +                        * more addresses, don't complain about this one --
932 +                        * just try the next ones. */
933 +
934 +                       BOOL can_ignore = sl->next &&
935 +                               (errno == ECONNREFUSED || errno == ENETUNREACH);
936 +                       DEBUG(can_ignore ? 3 : 2,
937 +                               ("error connecting to [%s]:%d (%s)\n",
938 +                               print_sockaddr(sl->addr),
939 +                               get_sockaddr_port(sl->addr),
940 +                               strerror(errno)));
941 +                       close(res);
942 +                       continue;
943 +               }
944  
945 -  return res;
946 +               /* set it blocking again */
947 +               set_blocking(res,True);
948 +
949 +               if(connected_addr) *connected_addr = sl;
950 +
951 +               return res;
952 +       }
953 +       return -1;
954  }
955  
956  /* the following 3 client_*() functions are nasty ways of allowing
957 @@ -891,9 +918,63 @@
958   matchname - determine if host name matches IP address. Used to
959   confirm a hostname lookup to prevent spoof attacks
960   ******************************************************************/
961 -static BOOL matchname(char *remotehost,struct in_addr  addr)
962 +#ifdef HAVE_INET6
963 +static BOOL addr_equal(struct sockaddr *a, struct sockaddr *b)
964 +{
965 +       if(a->sa_family == AF_INET6 && b->sa_family == AF_INET6)
966 +       {
967 +               struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)a;
968 +               struct sockaddr_in6 *b6 = (struct sockaddr_in6 *)b;
969 +
970 +               return !memcmp(&a6->sin6_addr, &b6->sin6_addr, 16);
971 +       }
972 +       if(a->sa_family == AF_INET && b->sa_family == AF_INET)
973 +       {
974 +               struct sockaddr_in *a4 = (struct sockaddr_in *)a;
975 +               struct sockaddr_in *b4 = (struct sockaddr_in *)b;
976 +
977 +               return a4->sin_addr.s_addr == b4->sin_addr.s_addr;
978 +       }
979 +       return False;
980 +}
981 +#endif
982 +
983 +/*******************************************************************
984 + matchname - determine if host name matches IP address. Used to
985 + confirm a hostname lookup to prevent spoof attacks
986 + ******************************************************************/
987 +static BOOL matchname(char *remotehost, struct sockaddr *can)
988  {
989 +#ifdef HAVE_INET6
990 +       struct addrinfo *ai, hints, *cur;
991 +
992 +       memset(&hints, 0, sizeof(hints));
993 +       hints.ai_socktype = SOCK_STREAM;
994 +       if(getaddrinfo(remotehost, NULL, &hints, &ai)){
995 +               DEBUG(0,("getaddrinfo(%s): lookup failure.\n", remotehost));
996 +               return False;
997 +       }
998 +       for( cur = ai; cur; cur = cur->ai_next )
999 +               if(addr_equal(cur->ai_addr, can))
1000 +               {
1001 +                       freeaddrinfo(ai);
1002 +                       return True;
1003 +               }
1004 +
1005 +       /*
1006 +        * The host name does not map to the original host address. Perhaps
1007 +        * someone has compromised a name server. More likely someone botched
1008 +        * it, but that could be dangerous, too.
1009 +        */
1010 +       
1011 +       DEBUG(0,("host name/address mismatch: %s != %s\n",
1012 +                print_sockaddr(can), remotehost));
1013 +
1014 +       freeaddrinfo(ai);
1015 +       return False;
1016 +#else
1017         struct hostent *hp;
1018 +       struct in_addr addr = ((struct sockaddr_in *)can)->sin_addr;
1019         int     i;
1020         
1021         if ((hp = sys_gethostbyname(remotehost)) == 0) {
1022 @@ -931,6 +1012,56 @@
1023         DEBUG(0,("host name/address mismatch: %s != %s\n",
1024                  inet_ntoa(addr), hp->h_name));
1025         return False;
1026 +#endif
1027 +}
1028 +
1029 +/*******************************************************************
1030 + return a sockaddr describing the remote endpoint
1031 + ******************************************************************/
1032 +static BOOL get_socket_sa(int fd, struct sockaddr **sa, int *len)
1033 +{
1034 +       if (fd == -1) {
1035 +               return False;
1036 +       }
1037 +
1038 +#ifdef HAVE_INET6
1039 +       *len = sizeof(struct sockaddr_storage);
1040 +#else
1041 +       *len = sizeof(struct sockaddr);
1042 +#endif
1043 +
1044 +       *sa = (struct sockaddr *)malloc(*len);
1045 +
1046 +       if (getpeername(fd, *sa, len) < 0) {
1047 +               DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
1048 +               SAFE_FREE(*sa);
1049 +               *sa = NULL;
1050 +               return False;
1051 +       }
1052 +
1053 +#ifdef HAVE_INET6
1054 +       if((*sa)->sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(
1055 +                               &((struct sockaddr_in6 *)(*sa))->sin6_addr))
1056 +       {
1057 +               struct sockaddr_in *newsin;
1058 +               struct in_addr addr;
1059 +               int port = ((struct sockaddr_in6 *)(*sa))->sin6_port;
1060 +
1061 +               DEBUG(5,("converting IPv6-mapped address %s\n",
1062 +                                       print_sockaddr(*sa)));
1063 +               memcpy(&addr, &((struct sockaddr_in6 *)
1064 +                                       (*sa))->sin6_addr + 12, 4);
1065 +               SAFE_FREE(*sa);
1066 +               *len = sizeof(struct sockaddr_in);
1067 +               *sa = (struct sockaddr *)malloc(*len);
1068 +               newsin = (struct sockaddr_in *)(*sa);
1069 +               newsin->sin_family = AF_INET;
1070 +               newsin->sin_port = port;
1071 +               newsin->sin_addr = addr;
1072 +       }
1073 +#endif
1074 +
1075 +       return True;
1076  }
1077  
1078   
1079 @@ -940,34 +1071,60 @@
1080  char *get_socket_name(int fd)
1081  {
1082         static pstring name_buf;
1083 -       static fstring addr_buf;
1084 -       struct hostent *hp;
1085 -       struct in_addr addr;
1086 +       struct sockaddr *sa;
1087         char *p;
1088 +       int len;
1089         
1090 -       p = get_socket_addr(fd);
1091 -
1092 -       /* it might be the same as the last one - save some DNS work */
1093 -       if (strcmp(p, addr_buf) == 0) return name_buf;
1094 -
1095         pstrcpy(name_buf,"UNKNOWN");
1096         if (fd == -1) return name_buf;
1097  
1098 -       fstrcpy(addr_buf, p);
1099 +       if(!get_socket_sa(fd, &sa, &len)) return name_buf;
1100 +       p = print_sockaddr(sa);
1101  
1102 -       addr = *interpret_addr2(p);
1103 -       
1104 -       /* Look up the remote host name. */
1105 -       if ((hp = gethostbyaddr((char *)&addr.s_addr, sizeof(addr.s_addr), AF_INET)) == 0) {
1106 -               DEBUG(1,("Gethostbyaddr failed for %s\n",p));
1107 -               pstrcpy(name_buf, p);
1108 -       } else {
1109 -               pstrcpy(name_buf,(char *)hp->h_name);
1110 -               if (!matchname(name_buf, addr)) {
1111 -                       DEBUG(0,("Matchname failed on %s %s\n",name_buf,p));
1112 -                       pstrcpy(name_buf,"UNKNOWN");
1113 +#ifdef HAVE_INET6
1114 +       {
1115 +               char hostbuf[NI_MAXHOST];
1116 +
1117 +               if(getnameinfo(sa, len, hostbuf, NI_MAXHOST, NULL, 0, 0)) {
1118 +                       DEBUG(1,("Getnameinfo failed for %s\n",p));
1119 +                       pstrcpy(name_buf, p);
1120 +               } else {
1121 +                       if (matchname(hostbuf, sa))
1122 +                               pstrcpy(name_buf, hostbuf);
1123 +                       else {
1124 +                               DEBUG(0,("Matchname failed on %s %s\n",
1125 +                                                       name_buf, p));
1126 +                               pstrcpy(name_buf,p);
1127 +                       }
1128                 }
1129         }
1130 +#else
1131 +       {
1132 +               struct hostent *hp;
1133 +               struct sockaddr_in *nsin = (struct sockaddr_in *)sa;
1134 +
1135 +               if(sa->sa_family != AF_INET)
1136 +               {
1137 +                       SAFE_FREE(sa);
1138 +                       return name_buf;
1139 +               }
1140 +
1141 +               /* Look up the remote host name. */
1142 +               if ((hp = gethostbyaddr((char *)&nsin->sin_addr.s_addr,
1143 +                               sizeof(nsin->sin_addr.s_addr), AF_INET)) == 0) {
1144 +                       DEBUG(1,("Gethostbyaddr failed for %s\n",p));
1145 +                       pstrcpy(name_buf, p);
1146 +               } else {
1147 +                       pstrcpy(name_buf,(char *)hp->h_name);
1148 +                       if (!matchname(name_buf, sa)) {
1149 +                               DEBUG(0,("Matchname failed on %s %s\n",
1150 +                                                       name_buf, p));
1151 +                               pstrcpy(name_buf,p);
1152 +                       }
1153 +               }
1154 +       }
1155 +#endif
1156 +       SAFE_FREE(sa);
1157  
1158         alpha_strcpy(name_buf, name_buf, "_-.", sizeof(name_buf));
1159         if (strstr(name_buf,"..")) {
1160 @@ -982,23 +1139,17 @@
1161   ******************************************************************/
1162  char *get_socket_addr(int fd)
1163  {
1164 -       struct sockaddr sa;
1165 -       struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
1166 -       int     length = sizeof(sa);
1167         static fstring addr_buf;
1168 +       struct sockaddr *sa;
1169 +       int len;
1170  
1171         fstrcpy(addr_buf,"0.0.0.0");
1172  
1173 -       if (fd == -1) {
1174 -               return addr_buf;
1175 +       if(get_socket_sa(fd, &sa, &len))
1176 +       {
1177 +               fstrcpy(addr_buf,print_sockaddr(sa));
1178 +               SAFE_FREE(sa);
1179         }
1180 -       
1181 -       if (getpeername(fd, &sa, &length) < 0) {
1182 -               DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
1183 -               return addr_buf;
1184 -       }
1185 -       
1186 -       fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
1187         
1188         return addr_buf;
1189  }
1190 Index: samba-2.2.3a+IPv6/source/lib/wins_srv.c
1191 ===================================================================
1192 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/lib/wins_srv.c,v
1193 retrieving revision 1.1.1.1
1194 retrieving revision 1.2
1195 diff -u -r1.1.1.1 -r1.2
1196 --- samba-2.2.3a+IPv6/source/lib/wins_srv.c     16 Apr 2002 03:34:35 -0000      1.1.1.1
1197 +++ samba-2.2.3a+IPv6/source/lib/wins_srv.c     18 Apr 2002 04:53:05 -0000      1.2
1198 @@ -155,7 +155,7 @@
1199        else
1200          {
1201          /* Add server to list. */
1202 -        if( is_ipaddress( wins_id_bufr ) )
1203 +        if( is_ipv4address( wins_id_bufr ) )
1204            entry->ip_addr = *interpret_addr2( wins_id_bufr );
1205          else
1206            entry->ip_addr = *interpret_addr2( "0.0.0.0" );
1207 Index: samba-2.2.3a+IPv6/source/libsmb/cli_lsarpc.c
1208 ===================================================================
1209 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/cli_lsarpc.c,v
1210 retrieving revision 1.1.1.1
1211 retrieving revision 1.3
1212 diff -u -r1.1.1.1 -r1.3
1213 --- samba-2.2.3a+IPv6/source/libsmb/cli_lsarpc.c        16 Apr 2002 03:34:35 -0000      1.1.1.1
1214 +++ samba-2.2.3a+IPv6/source/libsmb/cli_lsarpc.c        19 Apr 2002 14:50:33 -0000      1.3
1215 @@ -817,6 +817,7 @@
1216  {
1217         extern pstring global_myname;
1218         struct cli_state cli;
1219 +       struct sockaddr_list *dest_addrs;
1220         NTSTATUS result;
1221         POLICY_HND lsa_pol;
1222         BOOL ret = False;
1223 @@ -827,20 +828,22 @@
1224                 return False;
1225         }
1226   
1227 -       if(!resolve_name( remote_machine, &cli.dest_ip, 0x20)) {
1228 +       if(!(dest_addrs = resolve_name_smb(remote_machine, 0))) {
1229                 DEBUG(0,("fetch_domain_sid: Can't resolve address for %s\n", remote_machine));
1230                 goto done;
1231         }
1232   
1233 -       if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) {
1234 +       if (!cli_connect(&cli, remote_machine, dest_addrs)) {
1235                 DEBUG(0,("fetch_domain_sid: unable to connect to SMB server on \
1236  machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
1237                 goto done;
1238         }
1239  
1240 -       if (!attempt_netbios_session_request(&cli, global_myname, remote_machine, &cli.dest_ip)) {
1241 +       if (!attempt_netbios_session_request(&cli, global_myname,
1242 +                               remote_machine)) {
1243                 DEBUG(0,("fetch_domain_sid: machine %s rejected the NetBIOS \
1244  session request. Error was %s\n", remote_machine, cli_errstr(&cli) ));
1245 +               free_sockaddr_list(dest_addrs);
1246                 goto done;
1247         }
1248   
1249 Index: samba-2.2.3a+IPv6/source/libsmb/cli_pipe_util.c
1250 ===================================================================
1251 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/cli_pipe_util.c,v
1252 retrieving revision 1.1.1.1
1253 retrieving revision 1.3
1254 diff -u -r1.1.1.1 -r1.3
1255 --- samba-2.2.3a+IPv6/source/libsmb/cli_pipe_util.c     16 Apr 2002 03:34:36 -0000      1.1.1.1
1256 +++ samba-2.2.3a+IPv6/source/libsmb/cli_pipe_util.c     19 Apr 2002 14:50:33 -0000      1.3
1257 @@ -27,7 +27,7 @@
1258                                       char *pipe_name, 
1259                                        struct ntuser_creds *creds)
1260  {
1261 -       struct in_addr dest_ip;
1262 +       struct sockaddr_list *dest_addrs;
1263         struct nmb_name calling, called;
1264         fstring dest_host;
1265         extern pstring global_myname;
1266 @@ -49,15 +49,18 @@
1267  
1268         /* Establish a SMB connection */
1269  
1270 -       if (!resolve_srv_name(system_name, dest_host, &dest_ip)) {
1271 +       if (!(dest_addrs = resolve_srv_name(system_name, dest_host,
1272 +                                       cli->default_port))) {
1273                 return NULL;
1274         }
1275  
1276         make_nmb_name(&called, dns_to_netbios_name(dest_host), 0x20);
1277         make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0);
1278  
1279 -       if (!cli_establish_connection(cli, dest_host, &dest_ip, &calling, 
1280 +       if (!cli_establish_connection(cli, dest_host, dest_addrs, &calling, 
1281                                       &called, "IPC$", "IPC", False, True)) {
1282 +               cli_shutdown(cli);
1283 +               free_sockaddr_list(dest_addrs);
1284                 return NULL;
1285         }
1286  
1287 Index: samba-2.2.3a+IPv6/source/libsmb/cliconnect.c
1288 ===================================================================
1289 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/cliconnect.c,v
1290 retrieving revision 1.1.1.1
1291 retrieving revision 1.2
1292 diff -u -r1.1.1.1 -r1.2
1293 --- samba-2.2.3a+IPv6/source/libsmb/cliconnect.c        16 Apr 2002 03:34:35 -0000      1.1.1.1
1294 +++ samba-2.2.3a+IPv6/source/libsmb/cliconnect.c        18 Apr 2002 04:53:05 -0000      1.2
1295 @@ -430,7 +430,7 @@
1296                 }
1297         }
1298  
1299 -       if (cli->port == 445) {
1300 +       if (is_directsmb(cli->connected_addr->addr)) {
1301                 slprintf(fullshare, sizeof(fullshare)-1,
1302                          "%s", share);
1303         } else {
1304 @@ -638,8 +638,8 @@
1305         int len = 4;
1306         extern pstring user_socket_options;
1307  
1308 -       /* 445 doesn't have session request */
1309 -       if (cli->port == 445) return True;
1310 +       /* Direct SMB doesn't have session request */
1311 +       if (is_directsmb(cli->connected_addr->addr)) return True;
1312  
1313         /* send a session request (RFC 1002) */
1314         memcpy(&(cli->calling), calling, sizeof(*calling));
1315 @@ -683,9 +683,12 @@
1316                 */
1317                 int port = (CVAL(cli->inbuf,8)<<8)+CVAL(cli->inbuf,9);
1318                 /* SESSION RETARGET */
1319 -               putip((char *)&cli->dest_ip,cli->inbuf+4);
1320 -
1321 -               cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, port, LONG_CONNECT_TIMEOUT);
1322 +               struct in_addr addr;
1323 +               putip((char *)&addr,cli->inbuf+4);
1324 +               if(cli->dest_addrs) free_sockaddr_list(cli->dest_addrs);
1325 +               cli->dest_addrs = make_singlet_list(&addr, port);
1326 +               cli->fd = open_socket_out(cli->dest_addrs,
1327 +                               &cli->connected_addr, LONG_CONNECT_TIMEOUT);
1328                 if (cli->fd == -1)
1329                         return False;
1330  
1331 @@ -728,11 +731,11 @@
1332  /****************************************************************************
1333  open the client sockets
1334  ****************************************************************************/
1335 -BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
1336 +BOOL cli_connect(struct cli_state *cli, const char *host,
1337 +               struct sockaddr_list *salist)
1338  {
1339 -       extern struct in_addr ipzero;
1340         extern pstring user_socket_options;
1341 -       int name_type = 0x20;
1342 +       BOOL free_on_error = False;
1343         char *p;
1344  
1345         /* reasonable default hostname */
1346 @@ -740,45 +743,44 @@
1347                 host = "*SMBSERVER";
1348  
1349         fstrcpy(cli->desthost, host);
1350 -       
1351 -       /* allow hostnames of the form NAME#xx and do a netbios lookup */
1352 -       if ((p = strchr(cli->desthost, '#'))) {
1353 -               name_type = strtol(p+1, NULL, 16);              
1354 -               *p = 0;
1355 -       }
1356 -       
1357 -       if (!ip || ip_equal(*ip, ipzero)) {
1358 -               if (!resolve_name(cli->desthost, &cli->dest_ip, name_type)) {
1359 -                       return False;
1360 +
1361 +       /* At this point, cli->dest_addrs should be empty */
1362 +       if(cli->dest_addrs) free_sockaddr_list(cli->dest_addrs);
1363 +
1364 +       if (!salist) {
1365 +               free_on_error = True;
1366 +               if ((p = strchr(cli->desthost, '#'))) {
1367 +                       struct in_addr ip;
1368 +                       int name_type = strtol(p+1, NULL, 16);          
1369 +
1370 +                       *p = 0;
1371 +                       if(!resolve_name_netbios(cli->desthost, &ip, name_type))
1372 +                               return False;
1373 +                       salist = make_singlet_list(&ip, 139);
1374 +               } else {
1375 +                       if(!(salist = resolve_name_smb(cli->desthost,
1376 +                                                       cli->default_port)))
1377 +                               return False;
1378                 }
1379 -               if (ip)
1380 -                       *ip = cli->dest_ip;
1381 -       } else {
1382 -               cli->dest_ip = *ip;
1383         }
1384  
1385         if (getenv("LIBSMB_PROG")) {
1386                 cli->fd = sock_exec(getenv("LIBSMB_PROG"));
1387         } else {
1388 -               /* try 445 first, then 139 */
1389 -               int port = cli->port?cli->port:445;
1390 -               cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, 
1391 -                                         port, cli->timeout);
1392 -               if (cli->fd == -1 && cli->port == 0) {
1393 -                       port = 139;
1394 -                       cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, 
1395 -                                                 port, cli->timeout);
1396 -               }
1397 -               if (cli->fd != -1) cli->port = port;
1398 +               cli->fd = open_socket_out(salist, &cli->connected_addr,
1399 +                               cli->timeout);
1400         }
1401         if (cli->fd == -1) {
1402                 DEBUG(1,("Error connecting to %s (%s)\n",
1403 -                        inet_ntoa(*ip),strerror(errno)));
1404 +                       print_sockaddr(salist->addr),strerror(errno)));
1405 +               if(free_on_error) free_sockaddr_list(salist);
1406                 return False;
1407         }
1408  
1409         set_socket_options(cli->fd,user_socket_options);
1410  
1411 +       cli->dest_addrs = salist;
1412 +
1413         return True;
1414  }
1415  
1416 @@ -786,13 +788,14 @@
1417  establishes a connection right up to doing tconX, reading in a password.
1418  ****************************************************************************/
1419  BOOL cli_establish_connection(struct cli_state *cli, 
1420 -                               char *dest_host, struct in_addr *dest_ip,
1421 +                               char *dest_host, struct sockaddr_list *salist,
1422                                 struct nmb_name *calling, struct nmb_name *called,
1423                                 char *service, char *service_type,
1424                                 BOOL do_shutdown, BOOL do_tcon)
1425  {
1426         DEBUG(5,("cli_establish_connection: %s connecting to %s (%s) - %s [%s]\n",
1427 -                         nmb_namestr(calling), nmb_namestr(called), inet_ntoa(*dest_ip),
1428 +                         nmb_namestr(calling), nmb_namestr(called),
1429 +                         salist ? print_sockaddr(salist->addr) : "unspecified",
1430                       cli->user_name, cli->domain));
1431  
1432         /* establish connection */
1433 @@ -804,10 +807,12 @@
1434  
1435         if (cli->fd == -1)
1436         {
1437 -               if (!cli_connect(cli, dest_host, dest_ip))
1438 +               if (!cli_connect(cli, dest_host, salist))
1439                 {
1440                         DEBUG(1,("cli_establish_connection: failed to connect to %s (%s)\n",
1441 -                                         nmb_namestr(called), inet_ntoa(*dest_ip)));
1442 +                                 nmb_namestr(called),
1443 +                                 salist ? print_sockaddr(salist->addr)
1444 +                                       : "unknown"));
1445                         return False;
1446                 }
1447         }
1448 @@ -929,9 +934,10 @@
1449   Attempt a NetBIOS session request, falling back to *SMBSERVER if needed.
1450  ****************************************************************************/
1451  
1452 -BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
1453 -                                     struct in_addr *pdest_ip)
1454 +BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost,
1455 +               char *desthost)
1456  {
1457 +  struct sockaddr_list *dest_addrs_cache = cli->dest_addrs;
1458    struct nmb_name calling, called;
1459  
1460    make_nmb_name(&calling, srchost, 0x0);
1461 @@ -968,10 +974,11 @@
1462                 return False;
1463         }
1464  
1465 +    cli->dest_addrs = NULL; /* we cached it, so it shouldn't get freed */
1466      cli_shutdown(cli);
1467  
1468      if (!cli_initialise(cli) ||
1469 -        !cli_connect(cli, desthost, pdest_ip) ||
1470 +        !cli_connect(cli, desthost, dest_addrs_cache) ||
1471          !cli_session_request(cli, &calling, &smbservername)) {
1472            DEBUG(0,("attempt_netbios_session_request: %s rejected the session for \
1473  name *SMBSERVER with error %s\n", desthost, cli_errstr(cli) ));
1474 Index: samba-2.2.3a+IPv6/source/libsmb/clidgram.c
1475 ===================================================================
1476 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/clidgram.c,v
1477 retrieving revision 1.1.1.1
1478 retrieving revision 1.2
1479 diff -u -r1.1.1.1 -r1.2
1480 --- samba-2.2.3a+IPv6/source/libsmb/clidgram.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
1481 +++ samba-2.2.3a+IPv6/source/libsmb/clidgram.c  18 Apr 2002 04:53:05 -0000      1.2
1482 @@ -147,7 +147,7 @@
1483    struct sockaddr_in sock_out;
1484    socklen_t name_size;
1485  
1486 -  if (!resolve_name(send_to_name, &sendto_ip, 0x1d)) {
1487 +  if (!resolve_name_netbios(send_to_name, &sendto_ip, 0x1d)) {
1488  
1489      DEBUG(0, ("Could not resolve name: %s<1D>\n", send_to_name));
1490      return False;
1491 @@ -156,17 +156,15 @@
1492  
1493    my_ip.s_addr = inet_addr("0.0.0.0");
1494   
1495 -  if (!resolve_name(myname, &my_ip, 0x00)) { /* FIXME: Call others here */
1496 +  if (!resolve_name_netbios(myname, &my_ip, 0x00)) { /* FIXME: Call others here */
1497  
1498      DEBUG(0, ("Could not resolve name: %s<00>\n", myname));
1499  
1500    }
1501  
1502 -  if ((dgram_sock = open_socket_out(SOCK_DGRAM, &sendto_ip, 138, LONG_CONNECT_TIMEOUT)) < 0) {
1503 -
1504 -    DEBUG(4, ("open_sock_out failed ..."));
1505 +  if ((dgram_sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
1506 +    DEBUG(0, ("socket failed (%s)", strerror(errno)));
1507      return False;
1508 -
1509    }
1510  
1511    /* Make it a broadcast socket ... */
1512 Index: samba-2.2.3a+IPv6/source/libsmb/clientgen.c
1513 ===================================================================
1514 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/clientgen.c,v
1515 retrieving revision 1.1.1.1
1516 retrieving revision 1.2
1517 diff -u -r1.1.1.1 -r1.2
1518 --- samba-2.2.3a+IPv6/source/libsmb/clientgen.c 16 Apr 2002 03:34:35 -0000      1.1.1.1
1519 +++ samba-2.2.3a+IPv6/source/libsmb/clientgen.c 18 Apr 2002 04:53:05 -0000      1.2
1520 @@ -24,11 +24,14 @@
1521  #include "includes.h"
1522  
1523  /*
1524 - * Change the port number used to call on 
1525 + * Change the default port number used to call on.
1526 + *
1527 + * This should only truly be used if we're operating on a non-standard
1528 + * port.  The default behavior is to first try port 445, then 139.
1529   */
1530  int cli_set_port(struct cli_state *cli, int port)
1531  {
1532 -       cli->port = port;
1533 +       cli->default_port = port;
1534         return port;
1535  }
1536  
1537 @@ -180,7 +183,9 @@
1538  
1539         ZERO_STRUCTP(cli);
1540  
1541 -       cli->port = 0;
1542 +       cli->default_port = 0;
1543 +       cli->dest_addrs = NULL;
1544 +       cli->connected_addr = NULL;
1545         cli->fd = -1;
1546         cli->cnum = -1;
1547         cli->pid = (uint16)sys_getpid();
1548 @@ -237,6 +242,9 @@
1549         BOOL allocated;
1550         SAFE_FREE(cli->outbuf);
1551         SAFE_FREE(cli->inbuf);
1552 +
1553 +       if (cli->dest_addrs)
1554 +              free_sockaddr_list(cli->dest_addrs);
1555  
1556         if (cli->mem_ctx)
1557                 talloc_destroy(cli->mem_ctx);
1558 Index: samba-2.2.3a+IPv6/source/libsmb/domain_client_validate.c
1559 ===================================================================
1560 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/domain_client_validate.c,v
1561 retrieving revision 1.1.1.1
1562 retrieving revision 1.3
1563 diff -u -r1.1.1.1 -r1.3
1564 --- samba-2.2.3a+IPv6/source/libsmb/domain_client_validate.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
1565 +++ samba-2.2.3a+IPv6/source/libsmb/domain_client_validate.c    19 Apr 2002 14:50:33 -0000      1.3
1566 @@ -34,7 +34,7 @@
1567  static BOOL connect_to_domain_password_server(struct cli_state *pcli, 
1568                                               char *server, unsigned char *trust_passwd)
1569  {
1570 -       struct in_addr dest_ip;
1571 +       struct sockaddr_list *dest_addrs;
1572         fstring remote_machine;
1573          NTSTATUS result;
1574  
1575 @@ -43,7 +43,7 @@
1576                 return False;
1577         }
1578  
1579 -       if (is_ipaddress(server)) {
1580 +       if (is_ipv4address(server)) {
1581                 struct in_addr to_ip;
1582           
1583                 /* we shouldn't have 255.255.255.255 forthe IP address of 
1584 @@ -65,27 +65,31 @@
1585         standard_sub_basic(remote_machine);
1586         strupper(remote_machine);
1587  
1588 -       if(!resolve_name( remote_machine, &dest_ip, 0x20)) {
1589 +       if(!(dest_addrs = resolve_name_smb(remote_machine, pcli->default_port))) {
1590                 DEBUG(1,("connect_to_domain_password_server: Can't resolve address for %s\n", remote_machine));
1591                 cli_shutdown(pcli);
1592                 return False;
1593         }
1594    
1595 +#if 0
1596         if (ismyip(dest_ip)) {
1597                 DEBUG(1,("connect_to_domain_password_server: Password server loop - not using password server %s\n",
1598                          remote_machine));
1599                 cli_shutdown(pcli);
1600                 return False;
1601         }
1602 +#endif
1603    
1604 -       if (!cli_connect(pcli, remote_machine, &dest_ip)) {
1605 +       if (!cli_connect(pcli, remote_machine, dest_addrs)) {
1606                 DEBUG(0,("connect_to_domain_password_server: unable to connect to SMB server on \
1607  machine %s. Error was : %s.\n", remote_machine, cli_errstr(pcli) ));
1608 +               free_sockaddr_list(dest_addrs);
1609                 cli_shutdown(pcli);
1610                 return False;
1611         }
1612    
1613 -       if (!attempt_netbios_session_request(pcli, global_myname, remote_machine, &dest_ip)) {
1614 +       if (!attempt_netbios_session_request(pcli, global_myname,
1615 +                               remote_machine)) {
1616                 DEBUG(0,("connect_to_password_server: machine %s rejected the NetBIOS \
1617  session request. Error was : %s.\n", remote_machine, cli_errstr(pcli) ));
1618                 return False;
1619 Index: samba-2.2.3a+IPv6/source/libsmb/libsmbclient.c
1620 ===================================================================
1621 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/libsmbclient.c,v
1622 retrieving revision 1.1.1.1
1623 retrieving revision 1.2
1624 diff -u -r1.1.1.1 -r1.2
1625 --- samba-2.2.3a+IPv6/source/libsmb/libsmbclient.c      16 Apr 2002 03:34:36 -0000      1.1.1.1
1626 +++ samba-2.2.3a+IPv6/source/libsmb/libsmbclient.c      18 Apr 2002 04:53:05 -0000      1.2
1627 @@ -244,10 +244,7 @@
1628         char *p, *server_n = server;
1629         fstring group;
1630         pstring ipenv;
1631 -       struct in_addr ip;
1632 -       extern struct in_addr ipzero;
1633    
1634 -       ip = ipzero;
1635         ZERO_STRUCT(c);
1636  
1637         /* try to use an existing connection */
1638 @@ -305,10 +302,8 @@
1639   again:
1640         slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
1641  
1642 -       ip = ipzero;
1643 -
1644         /* have to open a new connection */
1645 -       if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) {
1646 +       if (!cli_initialise(&c) || !cli_connect(&c, server_n, NULL)) {
1647                 if (c.initialised) cli_shutdown(&c);
1648                 errno = ENOENT;
1649                 return NULL;
1650 @@ -1591,7 +1586,7 @@
1651  
1652                 /* We have server and share and path empty ... so list the workgroups */
1653  
1654 -               if (!resolve_name(lp_workgroup(), &rem_ip, 0x1d)) {
1655 +               if (!resolve_name_netbios(lp_workgroup(), &rem_ip, 0x1d)) {
1656        
1657                         errno = EINVAL;  /* Something wrong with smb.conf? */
1658                         return -1;
1659 @@ -1662,8 +1657,8 @@
1660                         /* Check to see if <server><1D> translates, or <server><20> translates */
1661                         /* However, we check to see if <server> is an IP address first */
1662  
1663 -                       if (!is_ipaddress(server) &&  /* Not an IP addr so check next */
1664 -                           resolve_name(server, &rem_ip, 0x1d)) { /* Found LMB */
1665 +                       if (!is_ipv4address(server) &&  /* Not an IP addr so check next */
1666 +                           resolve_name_netbios(server, &rem_ip, 0x1d)) { /* Found LMB */
1667                                 pstring buserver;
1668  
1669                                 smbc_file_table[slot]->dir_type = SMBC_SERVER;
1670 @@ -1715,8 +1710,7 @@
1671  
1672                         }
1673                         else {
1674 -
1675 -                               if (resolve_name(server, &rem_ip, 0x20)) {
1676 +                               if (resolve_name_netbios(server, &rem_ip, 0x20)) {
1677  
1678                                         /* Now, list the shares ... */
1679  
1680 Index: samba-2.2.3a+IPv6/source/libsmb/namequery.c
1681 ===================================================================
1682 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/namequery.c,v
1683 retrieving revision 1.1.1.1
1684 retrieving revision 1.2
1685 diff -u -r1.1.1.1 -r1.2
1686 --- samba-2.2.3a+IPv6/source/libsmb/namequery.c 16 Apr 2002 03:34:35 -0000      1.1.1.1
1687 +++ samba-2.2.3a+IPv6/source/libsmb/namequery.c 18 Apr 2002 04:53:05 -0000      1.2
1688 @@ -628,15 +628,11 @@
1689   Resolve via "bcast" method.
1690  *********************************************************/
1691  
1692 -BOOL name_resolve_bcast(const char *name, int name_type,
1693 -                       struct in_addr **return_ip_list, int *return_count)
1694 +struct sockaddr_list *name_resolve_bcast(const char *name, int name_type)
1695  {
1696         int sock, i;
1697         int num_interfaces = iface_count();
1698  
1699 -       *return_ip_list = NULL;
1700 -       *return_count = 0;
1701 -       
1702         /*
1703          * "bcast" means do a broadcast lookup on all the local interfaces.
1704          */
1705 @@ -646,7 +642,7 @@
1706         sock = open_socket_in( SOCK_DGRAM, 0, 3,
1707                                interpret_addr(lp_socket_address()), True );
1708  
1709 -       if (sock == -1) return False;
1710 +       if (sock == -1) return NULL;
1711  
1712         set_socket_options(sock,"SO_BROADCAST");
1713         /*
1714 @@ -655,33 +651,36 @@
1715          */
1716         for( i = num_interfaces-1; i >= 0; i--) {
1717                 struct in_addr sendto_ip;
1718 +               struct in_addr *addr;
1719 +               int return_count;
1720 +
1721                 /* Done this way to fix compiler error on IRIX 5.x */
1722                 sendto_ip = *iface_bcast(*iface_n_ip(i));
1723 -               *return_ip_list = name_query(sock, name, name_type, True, 
1724 -                                   True, sendto_ip, return_count);
1725 -               if(*return_ip_list != NULL) {
1726 +               addr = name_query(sock, name, name_type, True, 
1727 +                                 True, sendto_ip, &return_count);
1728 +               if(addr != NULL) {
1729 +                       struct sockaddr_list *salist;
1730 +
1731                         close(sock);
1732 -                       return True;
1733 +                       salist = make_sin_list(addr, return_count);
1734 +                       SAFE_FREE(addr);
1735 +                       return salist;
1736                 }
1737         }
1738  
1739         close(sock);
1740 -       return False;
1741 +       return NULL;
1742  }
1743  
1744  /********************************************************
1745   Resolve via "wins" method.
1746  *********************************************************/
1747  
1748 -static BOOL resolve_wins(const char *name, int name_type,
1749 -                         struct in_addr **return_iplist, int *return_count)
1750 +static struct sockaddr_list *resolve_wins(const char *name, int name_type)
1751  {
1752         int sock;
1753         struct in_addr wins_ip;
1754         BOOL wins_ismyip;
1755 -
1756 -       *return_iplist = NULL;
1757 -       *return_count = 0;
1758         
1759         /*
1760          * "wins" means do a unicast lookup to the WINS server.
1761 @@ -703,7 +702,7 @@
1762                 wins_ismyip = True;
1763         } else if( wins_srv_count() < 1 ) {
1764                 DEBUG(3,("resolve_wins: WINS server resolution selected and no WINS servers listed.\n"));
1765 -               return False;
1766 +               return NULL;
1767         } else {
1768                 wins_ip     = wins_srv_ip();
1769                 wins_ismyip = ismyip(wins_ip);
1770 @@ -715,27 +714,32 @@
1771                                         interpret_addr(lp_socket_address()),
1772                                         True );
1773                 if (sock != -1) {
1774 -                       *return_iplist = name_query( sock,      name,
1775 -                                                    name_type, False, 
1776 -                                                    True,      wins_ip,
1777 -                                                    return_count);
1778 -                       if(*return_iplist != NULL) {
1779 -                               close(sock);
1780 -                               return True;
1781 -                       }
1782 +                       struct in_addr *addr;
1783 +                       int return_count;
1784 +
1785 +                       addr = name_query(sock,      name,
1786 +                                         name_type, False, 
1787 +                                         True,      wins_ip,
1788 +                                         &return_count);
1789                         close(sock);
1790 +                       if(addr != NULL) {
1791 +                               struct sockaddr_list *salist;
1792 +
1793 +                               salist = make_sin_list(addr, return_count);
1794 +                               SAFE_FREE(addr);
1795 +                               return salist;
1796 +                       }
1797                 }
1798         }
1799  
1800 -       return False;
1801 +       return NULL;
1802  }
1803  
1804  /********************************************************
1805   Resolve via "lmhosts" method.
1806  *********************************************************/
1807  
1808 -static BOOL resolve_lmhosts(const char *name, int name_type,
1809 -                         struct in_addr **return_iplist, int *return_count)
1810 +static struct sockaddr_list *resolve_lmhosts(const char *name, int name_type)
1811  {
1812         /*
1813          * "lmhosts" means parse the local lmhosts file.
1814 @@ -746,9 +750,6 @@
1815         int name_type2;
1816         struct in_addr return_ip;
1817  
1818 -       *return_iplist = NULL;
1819 -       *return_count = 0;
1820 -
1821         DEBUG(3,("resolve_lmhosts: Attempting lmhosts lookup for name %s<0x%x>\n", name, name_type));
1822  
1823         fp = startlmhosts( LMHOSTSFILE );
1824 @@ -758,19 +759,12 @@
1825                  ((name_type2 == -1) || (name_type == name_type2))
1826                 ) {
1827                                 endlmhosts(fp);
1828 -                               *return_iplist = (struct in_addr *)malloc(sizeof(struct in_addr));
1829 -                               if(*return_iplist == NULL) {
1830 -                                       DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
1831 -                                       return False;
1832 -                               }
1833 -                               **return_iplist = return_ip;
1834 -                               *return_count = 1;
1835 -                               return True; 
1836 +                               return make_sin_list(&return_ip, 1);
1837                         }
1838                 }
1839                 endlmhosts(fp);
1840         }
1841 -       return False;
1842 +       return NULL;
1843  }
1844  
1845  
1846 @@ -778,32 +772,35 @@
1847   Resolve via "hosts" method.
1848  *********************************************************/
1849  
1850 -static BOOL resolve_hosts(const char *name,
1851 -                         struct in_addr **return_iplist, int *return_count)
1852 +static struct sockaddr_list *resolve_hosts(const char *name)
1853  {
1854         /*
1855          * "host" means do a localhost, or dns lookup.
1856          */
1857 +#ifdef HAVE_INET6
1858 +       struct addrinfo *ai, hints;
1859 +       struct sockaddr_list *ret;
1860 +
1861 +       DEBUG(3,("resolve_hosts: Attempting getaddrinfo for name %s<0x20>\n", name));
1862 +       memset(&hints, 0, sizeof(hints));
1863 +       hints.ai_socktype = SOCK_STREAM;
1864 +       if(getaddrinfo(name, NULL, &hints, &ai)) return NULL;
1865 +       ret = make_sa_list(ai);
1866 +       freeaddrinfo(ai);
1867 +       return ret;
1868 +#else
1869         struct hostent *hp;
1870  
1871 -       *return_iplist = NULL;
1872 -       *return_count = 0;
1873 -
1874         DEBUG(3,("resolve_hosts: Attempting host lookup for name %s<0x20>\n", name));
1875         
1876         if (((hp = sys_gethostbyname(name)) != NULL) && (hp->h_addr != NULL)) {
1877 -               struct in_addr return_ip;
1878 -               putip((char *)&return_ip,(char *)hp->h_addr);
1879 -               *return_iplist = (struct in_addr *)malloc(sizeof(struct in_addr));
1880 -               if(*return_iplist == NULL) {
1881 -                       DEBUG(3,("resolve_hosts: malloc fail !\n"));
1882 -                       return False;
1883 -               }
1884 -               **return_iplist = return_ip;
1885 -               *return_count = 1;
1886 -               return True;
1887 +               struct in_addr addr;
1888 +
1889 +               memcpy(&addr.s_addr, hp->h_addr, sizeof(addr.s_addr));
1890 +               return make_sin_list(&addr, 1);
1891         }
1892 -       return False;
1893 +       return NULL;
1894 +#endif
1895  }
1896  
1897  /********************************************************
1898 @@ -811,34 +808,44 @@
1899   Use this function if the string is either an IP address, DNS
1900   or host name or NetBIOS name. This uses the name switch in the
1901   smb.conf to determine the order of name resolution.
1902 +
1903 + WARNING: This function returns sockaddrs without the port set!
1904 +          Don't try to connect to these without first setting
1905 +         the port!
1906  *********************************************************/
1907  
1908 -static BOOL internal_resolve_name(const char *name, int name_type,
1909 -                                       struct in_addr **return_iplist, int *return_count)
1910 +static struct sockaddr_list *internal_resolve_name(const char *name, int name_type)
1911  {
1912    pstring name_resolve_list;
1913    fstring tok;
1914    char *ptr;
1915 -  BOOL allones = (strcmp(name,"255.255.255.255") == 0);
1916 -  BOOL allzeros = (strcmp(name,"0.0.0.0") == 0);
1917 -  BOOL is_address = is_ipaddress(name);
1918 -  *return_iplist = NULL;
1919 -  *return_count = 0;
1920 -
1921 -  if (allzeros || allones || is_address) {
1922 -       *return_iplist = (struct in_addr *)malloc(sizeof(struct in_addr));
1923 -       if(*return_iplist == NULL) {
1924 -               DEBUG(3,("internal_resolve_name: malloc fail !\n"));
1925 -               return False;
1926 -       }
1927 -       if(is_address) { 
1928 -               /* if it's in the form of an IP address then get the lib to interpret it */
1929 -               (*return_iplist)->s_addr = inet_addr(name);
1930 -    } else {
1931 -               (*return_iplist)->s_addr = allones ? 0xFFFFFFFF : 0;
1932 -               *return_count = 1;
1933 +  struct sockaddr_list *salist = NULL;
1934 +
1935 +  if (is_ipaddress(name)) {
1936 +       /* if it's in the form of an IP address then get
1937 +        * the lib to interpret it */
1938 +       struct sockaddr *sa;
1939 +
1940 +       if(!(sa = get_numeric_addr(name))) return NULL;
1941 +       salist = (struct sockaddr_list *)malloc(sizeof(struct sockaddr_list));
1942 +       salist->next = NULL;
1943 +       salist->addr = sa;
1944 +
1945 +       /* This isn't kosher, but it would take a lot to make Samba
1946 +        * be truly AF-independent. */
1947 +#ifdef HAVE_INET6
1948 +       if( sa->sa_family == AF_INET6 )
1949 +       {
1950 +               salist->pfamily = PF_INET6;
1951 +               salist->len = sizeof(struct sockaddr_in6);
1952 +       } else
1953 +#endif
1954 +       {
1955 +               salist->pfamily = PF_INET;
1956 +               salist->len = sizeof(struct sockaddr_in);
1957         }
1958 -    return True;
1959 +
1960 +       return salist;
1961    }
1962    
1963    pstrcpy(name_resolve_list, lp_name_resolve_order());
1964 @@ -848,78 +855,151 @@
1965  
1966    while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) {
1967           if((strequal(tok, "host") || strequal(tok, "hosts"))) {
1968 -                 if (name_type == 0x20 && resolve_hosts(name, return_iplist, return_count)) {
1969 -                         return True;
1970 +                 if (name_type == 0x20 && (salist = resolve_hosts(name)))
1971 +                 {
1972 +                         return salist;
1973                   }
1974           } else if(strequal( tok, "lmhosts")) {
1975 -                 if (resolve_lmhosts(name, name_type, return_iplist, return_count)) {
1976 -                         return True;
1977 +                 if ((salist=resolve_lmhosts(name, name_type))) {
1978 +                         return salist;
1979                   }
1980           } else if(strequal( tok, "wins")) {
1981                   /* don't resolve 1D via WINS */
1982                   if (name_type != 0x1D &&
1983 -                     resolve_wins(name, name_type, return_iplist, return_count)) {
1984 -                         return True;
1985 +                     (salist=resolve_wins(name, name_type))) {
1986 +                         return salist;
1987                   }
1988           } else if(strequal( tok, "bcast")) {
1989 -                 if (name_resolve_bcast(name, name_type, return_iplist, return_count)) {
1990 -                         return True;
1991 +                 if ((salist=name_resolve_bcast(name, name_type))) {
1992 +                         return salist;
1993                   }
1994           } else {
1995                   DEBUG(0,("resolve_name: unknown name switch type %s\n", tok));
1996           }
1997    }
1998  
1999 -  SAFE_FREE(*return_iplist);
2000 -  return False;
2001 +  return NULL;
2002 +}
2003 +
2004 +static BOOL internal_resolve_name_netbios(const char *name, int name_type,
2005 +               struct in_addr **return_iplist, int *return_count)
2006 +{
2007 +       struct sockaddr_list *salist, *sl;
2008 +       int i;
2009 +
2010 +       *return_iplist = NULL;
2011 +       *return_count = 0;
2012 +
2013 +       salist = internal_resolve_name(name, name_type);
2014 +       if(!salist) return False;
2015 +
2016 +       for(sl = salist; sl; sl = sl->next)
2017 +               if(sl->addr->sa_family == AF_INET) ++*return_count;
2018 +
2019 +       *return_iplist = (struct in_addr *)
2020 +               malloc(*return_count * sizeof(struct in_addr));
2021 +
2022 +       for(i = 0, sl = salist; i < *return_count; ++i)
2023 +               if(sl->addr->sa_family == AF_INET)
2024 +                       *return_iplist[i] =
2025 +                               ((struct sockaddr_in *)(sl->addr))->sin_addr;
2026 +
2027 +       free_sockaddr_list(salist);
2028 +
2029 +       return True;
2030  }
2031  
2032  /********************************************************
2033 - Internal interface to resolve a name into one IP address.
2034 + Internal interface to resolve a name into one IP address for NetBIOS.
2035   Use this function if the string is either an IP address, DNS
2036   or host name or NetBIOS name. This uses the name switch in the
2037   smb.conf to determine the order of name resolution.
2038  *********************************************************/
2039  
2040 -BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
2041 +BOOL resolve_name_netbios(const char *name, struct in_addr *return_ip,
2042 +               int name_type)
2043  {
2044 -       struct in_addr *ip_list = NULL;
2045 -       int count = 0;
2046 +       struct sockaddr_list *salist;
2047  
2048         if (is_ipaddress(name)) {
2049                 *return_ip = *interpret_addr2(name);
2050                 return True;
2051         }
2052  
2053 -       if(internal_resolve_name(name, name_type, &ip_list, &count)) {
2054 -               int i;
2055 +       if((salist=internal_resolve_name(name, name_type))) {
2056 +               struct sockaddr_list *sl;
2057 +               char *ip_str;
2058 +
2059                 /* only return valid addresses for TCP connections */
2060 -               for (i=0; i<count; i++) {
2061 -                       char *ip_str = inet_ntoa(ip_list[i]);
2062 -                       if (ip_str &&
2063 +               for(sl = salist; sl; sl = sl->next)
2064 +               {
2065 +                       if ( sl->addr->sa_family == AF_INET &&
2066 +                              (ip_str = inet_ntoa(((struct sockaddr_in *)
2067 +                                                  (sl->addr))->sin_addr)) &&
2068                                 strcmp(ip_str, "255.255.255.255") != 0 &&
2069                                 strcmp(ip_str, "0.0.0.0") != 0) {
2070 -                               *return_ip = ip_list[i];
2071 -                               SAFE_FREE(ip_list);
2072 +                               *return_ip = ((struct sockaddr_in *)
2073 +                                               (sl->addr))->sin_addr;
2074 +                               free_sockaddr_list(salist);
2075                                 return True;
2076                         }
2077                 }
2078 +               free_sockaddr_list(salist);
2079         }
2080 -       SAFE_FREE(ip_list);
2081         return False;
2082  }
2083  
2084 +/********************************************************
2085 + Function to resolve a name into a list of addresses for
2086 + use with SMB. This uses the name switch in the smb.conf
2087 + to determine the order of name resolution.
2088 +*********************************************************/
2089 +
2090 +struct sockaddr_list *resolve_name_smb(const char *name, int port)
2091 +{
2092 +       struct sockaddr_list *salist;
2093 +
2094 +       if((salist=internal_resolve_name(name, 0x20))) {
2095 +               struct sockaddr_list *sl = salist, *old = NULL;
2096 +               char *ip_str;
2097 +
2098 +               /* only return valid addresses for TCP connections */
2099 +               while(sl)
2100 +               {
2101 +                       if ( sl->addr->sa_family == AF_INET &&
2102 +                              (ip_str = inet_ntoa(((struct sockaddr_in *)
2103 +                                                  (sl->addr))->sin_addr)) &&
2104 +                               ( strcmp(ip_str, "255.255.255.255") == 0 ||
2105 +                                 strcmp(ip_str, "0.0.0.0") == 0 ) )
2106 +                       {
2107 +                               struct sockaddr_list *next = sl->next;
2108 +
2109 +                               SAFE_FREE(sl->addr);
2110 +                               SAFE_FREE(sl);
2111 +                               if(old == NULL) salist = next;
2112 +                               else old->next = next;
2113 +                               sl = next;
2114 +                       } else {
2115 +                               if(port) set_sockaddr_port(sl->addr, port);
2116 +                               old = sl;
2117 +                               sl = sl->next;
2118 +                       }
2119 +               }
2120 +       }
2121 +       return port ? salist : set_default_ports(salist);
2122 +}
2123  
2124  /********************************************************
2125   resolve a name of format \\server_name or \\ipaddress
2126   into a name.  also, cut the \\ from the front for us.
2127  *********************************************************/
2128  
2129 -BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
2130 -                                struct in_addr *ip)
2131 +struct sockaddr_list *resolve_srv_name(const char* srv_name,
2132 +               fstring dest_host, int port)
2133  {
2134 -        BOOL ret;
2135          const char *sv_name = srv_name;
2136 +       struct in_addr ip;
2137 +       struct sockaddr_list *salist;
2138  
2139          DEBUG(10,("resolve_srv_name: %s\n", srv_name));
2140  
2141 @@ -927,8 +1007,11 @@
2142          {
2143                  extern pstring global_myname;
2144                  fstrcpy(dest_host, global_myname);
2145 -                ip = interpret_addr2("127.0.0.1");
2146 -                return True;
2147 +               inet_aton("127.0.0.1", &ip);
2148 +               salist = make_sin_list(&ip, 1);
2149 +               if(port) set_sockaddr_port(salist->addr, port);
2150 +               else salist = set_default_ports(salist);
2151 +               return salist;
2152          }
2153  
2154          if (strnequal("\\\\", srv_name, 2))
2155 @@ -940,18 +1023,27 @@
2156          /* treat the '*' name specially - it is a magic name for the PDC */
2157          if (strcmp(dest_host,"*") == 0) {
2158                  extern pstring global_myname;
2159 -                ret = resolve_name(lp_workgroup(), ip, 0x1B);
2160 -                lookup_dc_name(global_myname, lp_workgroup(), ip, dest_host);
2161 -        } else {
2162 -                ret = resolve_name(dest_host, ip, 0x20);
2163 +
2164 +               if(resolve_name_netbios(lp_workgroup(), &ip, 0x1B))
2165 +               {
2166 +                       lookup_dc_name(global_myname, lp_workgroup(),
2167 +                                       &ip, dest_host);
2168 +                       salist = make_sin_list(&ip, 1);
2169 +                       if(port) set_sockaddr_port(salist->addr, port);
2170 +                       else salist = set_default_ports(salist);
2171 +                       return salist;
2172 +               }
2173 +               return NULL;
2174          }
2175 +
2176 +       salist = resolve_name_smb(dest_host, port);
2177          
2178          if (is_ipaddress(dest_host))
2179          {
2180                  fstrcpy(dest_host, "*SMBSERVER");
2181          }
2182          
2183 -        return ret;
2184 +        return salist;
2185  }
2186  
2187  
2188 @@ -964,12 +1056,12 @@
2189         struct in_addr *ip_list = NULL;
2190         int count = 0;
2191  
2192 -       if (internal_resolve_name(group, 0x1D, &ip_list, &count)) {
2193 +       if (internal_resolve_name_netbios(group, 0x1D, &ip_list, &count)) {
2194                 *master_ip = ip_list[0];
2195                 SAFE_FREE(ip_list);
2196                 return True;
2197         }
2198 -       if(internal_resolve_name(group, 0x1B, &ip_list, &count)) {
2199 +       if(internal_resolve_name_netbios(group, 0x1B, &ip_list, &count)) {
2200                 *master_ip = ip_list[0];
2201                 SAFE_FREE(ip_list);
2202                 return True;
2203 @@ -1207,16 +1299,16 @@
2204                 struct in_addr *return_iplist = NULL;
2205  
2206                 if (! *pserver)
2207 -                       return internal_resolve_name(group, name_type, ip_list, count);
2208 +                       return internal_resolve_name_netbios(group, name_type, ip_list, count);
2209  
2210                 p = pserver;
2211                 while (next_token(&p,name,LIST_SEP,sizeof(name))) {
2212                         if (strequal(name, "*"))
2213 -                               return internal_resolve_name(group, name_type, ip_list, count);
2214 +                               return internal_resolve_name_netbios(group, name_type, ip_list, count);
2215                         num_adresses++;
2216                 }
2217                 if (num_adresses == 0)
2218 -                       return internal_resolve_name(group, name_type, ip_list, count);
2219 +                       return internal_resolve_name_netbios(group, name_type, ip_list, count);
2220  
2221                 return_iplist = (struct in_addr *)malloc(num_adresses * sizeof(struct in_addr));
2222                 if(return_iplist == NULL) {
2223 @@ -1227,14 +1319,14 @@
2224                 *count = 0;
2225                 while (next_token(&p,name,LIST_SEP,sizeof(name))) {
2226                         struct in_addr name_ip;
2227 -                       if (resolve_name( name, &name_ip, 0x20) == False)
2228 +                       if (resolve_name_netbios(name, &name_ip, 0x20) == False)
2229                                 continue;
2230                         return_iplist[(*count)++] = name_ip;
2231                 }
2232                 *ip_list = return_iplist;
2233                 return (*count != 0);
2234         } else
2235 -               return internal_resolve_name(group, name_type, ip_list, count);
2236 +               return internal_resolve_name_netbios(group, name_type, ip_list, count);
2237  }
2238  
2239  /********************************************************
2240 @@ -1242,5 +1334,5 @@
2241  ********************************************************/
2242  BOOL get_lmb_list(struct in_addr **ip_list, int *count)
2243  {
2244 -       return internal_resolve_name( MSBROWSE, 0x1, ip_list, count);
2245 +       return internal_resolve_name_netbios( MSBROWSE, 0x1, ip_list, count);
2246  }
2247 Index: samba-2.2.3a+IPv6/source/libsmb/passchange.c
2248 ===================================================================
2249 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/libsmb/passchange.c,v
2250 retrieving revision 1.1.1.1
2251 retrieving revision 1.2
2252 diff -u -r1.1.1.1 -r1.2
2253 --- samba-2.2.3a+IPv6/source/libsmb/passchange.c        16 Apr 2002 03:34:35 -0000      1.1.1.1
2254 +++ samba-2.2.3a+IPv6/source/libsmb/passchange.c        18 Apr 2002 04:53:05 -0000      1.2
2255 @@ -33,11 +33,11 @@
2256  {
2257         struct nmb_name calling, called;
2258         struct cli_state cli;
2259 -       struct in_addr ip;
2260 +       struct sockaddr_list *dest_addrs;
2261  
2262         *err_str = '\0';
2263  
2264 -       if(!resolve_name( remote_machine, &ip, 0x20)) {
2265 +       if(!(dest_addrs = resolve_name_smb(remote_machine, 0))) {
2266                 slprintf(err_str, err_str_len-1, "unable to find an IP address for machine %s.\n",
2267                         remote_machine );
2268                 return False;
2269 @@ -45,9 +45,11 @@
2270   
2271         ZERO_STRUCT(cli);
2272   
2273 -       if (!cli_initialise(&cli) || !cli_connect(&cli, remote_machine, &ip)) {
2274 +       if (!cli_initialise(&cli) ||
2275 +                       !cli_connect(&cli, remote_machine, dest_addrs)) {
2276                 slprintf(err_str, err_str_len-1, "unable to connect to SMB server on machine %s. Error was : %s.\n",
2277                         remote_machine, cli_errstr(&cli) );
2278 +               free_sockaddr_list(dest_addrs);
2279                 return False;
2280         }
2281    
2282 Index: samba-2.2.3a+IPv6/source/nmbd/nmbd_synclists.c
2283 ===================================================================
2284 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/nmbd/nmbd_synclists.c,v
2285 retrieving revision 1.1.1.1
2286 retrieving revision 1.2
2287 diff -u -r1.1.1.1 -r1.2
2288 --- samba-2.2.3a+IPv6/source/nmbd/nmbd_synclists.c      16 Apr 2002 03:34:35 -0000      1.1.1.1
2289 +++ samba-2.2.3a+IPv6/source/nmbd/nmbd_synclists.c      18 Apr 2002 04:53:05 -0000      1.2
2290 @@ -68,10 +68,13 @@
2291         extern fstring local_machine;
2292         fstring unix_workgroup;
2293         static struct cli_state cli;
2294 +       struct sockaddr_list *dest_addrs;
2295         uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
2296         struct nmb_name called, calling;
2297  
2298 -       if (!cli_initialise(&cli) || !cli_connect(&cli, name, &ip)) {
2299 +       dest_addrs = make_singlet_list(&ip, 0);
2300 +       if (!cli_initialise(&cli) || !cli_connect(&cli, name, dest_addrs)) {
2301 +               free_sockaddr_list(dest_addrs);
2302                 return;
2303         }
2304  
2305 Index: samba-2.2.3a+IPv6/source/nsswitch/winbindd_cm.c
2306 ===================================================================
2307 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/nsswitch/winbindd_cm.c,v
2308 retrieving revision 1.1.1.1
2309 retrieving revision 1.3
2310 diff -u -r1.1.1.1 -r1.3
2311 --- samba-2.2.3a+IPv6/source/nsswitch/winbindd_cm.c     16 Apr 2002 03:34:36 -0000      1.1.1.1
2312 +++ samba-2.2.3a+IPv6/source/nsswitch/winbindd_cm.c     19 Apr 2002 14:50:33 -0000      1.3
2313 @@ -232,7 +232,7 @@
2314         struct nmb_name calling, called;
2315         extern pstring global_myname;
2316         fstring dest_host;
2317 -       struct in_addr dest_ip;
2318 +       struct sockaddr_list *dest_addrs;
2319         BOOL result = False;
2320         struct ntuser_creds creds;
2321  
2322 @@ -280,7 +280,8 @@
2323         if (!(new_conn->cli = cli_initialise(NULL)))
2324                 goto done;
2325  
2326 -       if (!resolve_srv_name(new_conn->controller, dest_host, &dest_ip))
2327 +       if (!(dest_addrs = resolve_srv_name(new_conn->controller, dest_host,
2328 +                                       new_conn->cli->default_port)))
2329                 goto done;
2330  
2331         make_nmb_name(&called, dns_to_netbios_name(new_conn->controller), 0x20);
2332 @@ -291,9 +292,12 @@
2333         cli_init_creds(new_conn->cli, &creds);
2334  
2335         if (!cli_establish_connection(new_conn->cli, new_conn->controller, 
2336 -                                     &dest_ip, &calling, &called, "IPC$", 
2337 +                                     dest_addrs, &calling, &called, "IPC$", 
2338                                       "IPC", False, True))
2339 +       {
2340 +               free_sockaddr_list(dest_addrs);
2341                 goto done;
2342 +       }
2343  
2344         if (!cli_nt_session_open (new_conn->cli, pipe_name))
2345                 goto done;
2346 Index: samba-2.2.3a+IPv6/source/rpc_client/cli_spoolss_notify.c
2347 ===================================================================
2348 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/rpc_client/cli_spoolss_notify.c,v
2349 retrieving revision 1.1.1.1
2350 retrieving revision 1.3
2351 diff -u -r1.1.1.1 -r1.3
2352 --- samba-2.2.3a+IPv6/source/rpc_client/cli_spoolss_notify.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
2353 +++ samba-2.2.3a+IPv6/source/rpc_client/cli_spoolss_notify.c    19 Apr 2002 14:50:33 -0000      1.3
2354 @@ -45,31 +45,37 @@
2355  
2356  BOOL spoolss_connect_to_client( struct cli_state *cli, char *remote_machine)
2357  {
2358 +       struct sockaddr_list *dest_addrs;
2359 +
2360         ZERO_STRUCTP(cli);
2361         if(cli_initialise(cli) == NULL) {
2362                 DEBUG(0,("connect_to_client: unable to initialize client connection.\n"));
2363                 return False;
2364         }
2365  
2366 -       if(!resolve_name( remote_machine, &cli->dest_ip, 0x20)) {
2367 +       if(!(dest_addrs = resolve_name_smb(remote_machine, cli->default_port))) {
2368                 DEBUG(0,("connect_to_client: Can't resolve address for %s\n", remote_machine));
2369                 cli_shutdown(cli);
2370         return False;
2371         }
2372  
2373 +#if 0
2374         if (ismyip(cli->dest_ip)) {
2375                 DEBUG(0,("connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine));
2376                 cli_shutdown(cli);
2377                 return False;
2378         }
2379 +#endif
2380  
2381 -       if (!cli_connect(cli, remote_machine, &cli->dest_ip)) {
2382 +       if (!cli_connect(cli, remote_machine, dest_addrs)) {
2383                 DEBUG(0,("connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(cli) ));
2384 +               free_sockaddr_list(dest_addrs);
2385                 cli_shutdown(cli);
2386                 return False;
2387         }
2388    
2389 -       if (!attempt_netbios_session_request(cli, global_myname, remote_machine, &cli->dest_ip)) {
2390 +       if (!attempt_netbios_session_request(cli, global_myname,
2391 +                               remote_machine)) {
2392                 DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request. Error was %s\n", remote_machine, cli_errstr(cli) ));
2393                 cli_shutdown(cli);
2394                 return False;
2395 Index: samba-2.2.3a+IPv6/source/rpc_client/cli_trust.c
2396 ===================================================================
2397 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/rpc_client/cli_trust.c,v
2398 retrieving revision 1.1.1.1
2399 retrieving revision 1.3
2400 diff -u -r1.1.1.1 -r1.3
2401 --- samba-2.2.3a+IPv6/source/rpc_client/cli_trust.c     16 Apr 2002 03:34:35 -0000      1.1.1.1
2402 +++ samba-2.2.3a+IPv6/source/rpc_client/cli_trust.c     19 Apr 2002 14:50:33 -0000      1.3
2403 @@ -35,6 +35,7 @@
2404                            unsigned char new_trust_passwd_hash[16])
2405  {
2406    struct cli_state cli;
2407 +  struct sockaddr_list *dest_addrs;
2408    NTSTATUS result;
2409    DOM_SID domain_sid;
2410  
2411 @@ -53,27 +54,30 @@
2412      return False;
2413    }
2414  
2415 -  if(!resolve_name( remote_machine, &cli.dest_ip, 0x20)) {
2416 +  if(!(dest_addrs = resolve_name_smb(remote_machine, 0))) {
2417      DEBUG(0,("modify_trust_password: Can't resolve address for %s\n", remote_machine));
2418      cli_shutdown(&cli);
2419      return False;
2420    }
2421  
2422 +#if 0
2423    if (ismyip(cli.dest_ip)) {
2424      DEBUG(0,("modify_trust_password: Machine %s is one of our addresses. Cannot add \
2425  to ourselves.\n", remote_machine));
2426      cli_shutdown(&cli);
2427      return False;
2428    }
2429 +#endif
2430  
2431 -  if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) {
2432 +  if (!cli_connect(&cli, remote_machine, dest_addrs)) {
2433      DEBUG(0,("modify_trust_password: unable to connect to SMB server on \
2434  machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
2435 +    free_sockaddr_list(dest_addrs);
2436      cli_shutdown(&cli);
2437      return False;
2438    }
2439    
2440 -  if (!attempt_netbios_session_request(&cli, global_myname, remote_machine, &cli.dest_ip)) {
2441 +  if (!attempt_netbios_session_request(&cli, global_myname, remote_machine)) {
2442      DEBUG(0,("modify_trust_password: machine %s rejected the NetBIOS \
2443  session request. Error was %s\n", remote_machine, cli_errstr(&cli) ));
2444      cli_shutdown(&cli);
2445 Index: samba-2.2.3a+IPv6/source/rpcclient/rpcclient.c
2446 ===================================================================
2447 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/rpcclient/rpcclient.c,v
2448 retrieving revision 1.1.1.1
2449 retrieving revision 1.3
2450 diff -u -r1.1.1.1 -r1.3
2451 --- samba-2.2.3a+IPv6/source/rpcclient/rpcclient.c      16 Apr 2002 03:34:39 -0000      1.1.1.1
2452 +++ samba-2.2.3a+IPv6/source/rpcclient/rpcclient.c      19 Apr 2002 14:50:33 -0000      1.3
2453 @@ -560,7 +560,7 @@
2454  struct cli_state *setup_connection(struct cli_state *cli, char *system_name,
2455                                    struct ntuser_creds *creds)
2456  {
2457 -       struct in_addr dest_ip;
2458 +       struct sockaddr_list *dest_addrs;
2459         struct nmb_name calling, called;
2460         fstring dest_host;
2461         extern pstring global_myname;
2462 @@ -580,7 +580,8 @@
2463         cli_init_creds(cli, creds);
2464  
2465         /* Establish a SMB connection */
2466 -       if (!resolve_srv_name(system_name, dest_host, &dest_ip)) {
2467 +       if (!(dest_addrs = resolve_srv_name(system_name, dest_host,
2468 +                                       cli->default_port))) {
2469                  fprintf(stderr, "Could not resolve %s\n", dest_host);
2470                 return NULL;
2471         }
2472 @@ -588,9 +589,11 @@
2473         make_nmb_name(&called, dns_to_netbios_name(dest_host), 0x20);
2474         make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0);
2475  
2476 -       if (!cli_establish_connection(cli, dest_host, &dest_ip, &calling, 
2477 +       if (!cli_establish_connection(cli, dest_host, dest_addrs, &calling, 
2478                                       &called, "IPC$", "IPC", False, True)) {
2479                  fprintf(stderr, "Error establishing IPC$ connection\n");
2480 +               cli_shutdown(cli);
2481 +               free_sockaddr_list(dest_addrs);
2482                 return NULL;
2483         }
2484         
2485 Index: samba-2.2.3a+IPv6/source/smbd/password.c
2486 ===================================================================
2487 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/smbd/password.c,v
2488 retrieving revision 1.1.1.1
2489 retrieving revision 1.3
2490 diff -u -r1.1.1.1 -r1.3
2491 --- samba-2.2.3a+IPv6/source/smbd/password.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
2492 +++ samba-2.2.3a+IPv6/source/smbd/password.c    19 Apr 2002 14:50:33 -0000      1.3
2493 @@ -1033,7 +1033,7 @@
2494  {
2495         struct cli_state *cli;
2496         fstring desthost;
2497 -       struct in_addr dest_ip;
2498 +       struct sockaddr_list *dest_addrs;
2499         char *p, *pserver;
2500         BOOL connected_ok = False;
2501  
2502 @@ -1049,21 +1049,23 @@
2503                 standard_sub_basic(desthost);
2504                 strupper(desthost);
2505  
2506 -               if(!resolve_name( desthost, &dest_ip, 0x20)) {
2507 +               if(!(dest_addrs = resolve_name_smb(desthost, 0))) {
2508                         DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",desthost));
2509                         continue;
2510                 }
2511  
2512 +#if 0
2513                 if (ismyip(dest_ip)) {
2514                         DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
2515                         continue;
2516                 }
2517 +#endif
2518  
2519 -               if (cli_connect(cli, desthost, &dest_ip)) {
2520 +               if (cli_connect(cli, desthost, dest_addrs)) {
2521                         DEBUG(3,("connected to password server %s\n",desthost));
2522                         connected_ok = True;
2523                         break;
2524 -               }
2525 +               } else free_sockaddr_list(dest_addrs);
2526         }
2527  
2528         SAFE_FREE(pserver);
2529 @@ -1074,7 +1076,7 @@
2530                 return NULL;
2531         }
2532  
2533 -       if (!attempt_netbios_session_request(cli, global_myname, desthost, &dest_ip))
2534 +       if (!attempt_netbios_session_request(cli, global_myname, desthost))
2535                 return NULL;
2536  
2537         DEBUG(3,("got session\n"));
2538 @@ -1212,7 +1214,7 @@
2539  static BOOL connect_to_domain_password_server(struct cli_state *pcli, 
2540                                                                 char *server, unsigned char *trust_passwd)
2541  {
2542 -  struct in_addr dest_ip;
2543 +  struct sockaddr_list *dest_addrs;
2544    fstring remote_machine;
2545  
2546    if(!cli_initialise(pcli)) {
2547 @@ -1220,7 +1222,7 @@
2548      return False;
2549    }
2550  
2551 -  if (is_ipaddress(server)) {
2552 +  if (is_ipv4address(server)) {
2553           struct in_addr to_ip;
2554  
2555           /* we shouldn't have 255.255.255.255 forthe IP address of
2556 @@ -1242,27 +1244,30 @@
2557    standard_sub_basic(remote_machine);
2558    strupper(remote_machine);
2559  
2560 -  if(!resolve_name( remote_machine, &dest_ip, 0x20)) {
2561 +  if(!(dest_addrs = resolve_name_smb(remote_machine, 0))) {
2562      DEBUG(1,("connect_to_domain_password_server: Can't resolve address for %s\n", remote_machine));
2563      cli_shutdown(pcli);
2564      return False;
2565    }
2566    
2567 +#if 0
2568    if (ismyip(dest_ip)) {
2569      DEBUG(1,("connect_to_domain_password_server: Password server loop - not using password server %s\n",
2570           remote_machine));
2571      cli_shutdown(pcli);
2572      return False;
2573    }
2574 +#endif
2575    
2576 -  if (!cli_connect(pcli, remote_machine, &dest_ip)) {
2577 +  if (!cli_connect(pcli, remote_machine, dest_addrs)) {
2578      DEBUG(0,("connect_to_domain_password_server: unable to connect to SMB server on \
2579  machine %s. Error was : %s.\n", remote_machine, cli_errstr(pcli) ));
2580 +    free_sockaddr_list(dest_addrs);
2581      cli_shutdown(pcli);
2582      return False;
2583    }
2584    
2585 -  if (!attempt_netbios_session_request(pcli, global_myname, remote_machine, &dest_ip)) {
2586 +  if (!attempt_netbios_session_request(pcli, global_myname, remote_machine)) {
2587      DEBUG(0,("connect_to_password_server: machine %s rejected the NetBIOS \
2588  session request. Error was : %s.\n", remote_machine, cli_errstr(pcli) ));
2589      return False;
2590 Index: samba-2.2.3a+IPv6/source/smbwrapper/smbw.c
2591 ===================================================================
2592 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/smbwrapper/smbw.c,v
2593 retrieving revision 1.1.1.1
2594 retrieving revision 1.2
2595 diff -u -r1.1.1.1 -r1.2
2596 --- samba-2.2.3a+IPv6/source/smbwrapper/smbw.c  16 Apr 2002 03:34:37 -0000      1.1.1.1
2597 +++ samba-2.2.3a+IPv6/source/smbwrapper/smbw.c  18 Apr 2002 04:53:05 -0000      1.2
2598 @@ -261,9 +261,7 @@
2599  {
2600         fstring server;
2601         char *p;
2602 -       struct in_addr *ip_list = NULL;
2603 -       int count = 0;
2604 -       int i;
2605 +       struct sockaddr_list *wglist, *wg;
2606  
2607         /* first off see if an existing workgroup name exists */
2608         p = smbw_getshared("WORKGROUP");
2609 @@ -273,24 +271,29 @@
2610         if (smbw_server(server, "IPC$")) return p;
2611  
2612         /* go looking for workgroups */
2613 -       if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) {
2614 +       if (!(wglist = name_resolve_bcast(MSBROWSE, 1))) {
2615                 DEBUG(1,("No workgroups found!"));
2616                 return p;
2617         }
2618  
2619 -       for (i=0;i<count;i++) {
2620 +       for(wg = wglist; wg; wg = wg->next)
2621 +       {
2622                 static fstring name;
2623 -               if (name_status_find("*", 0, 0x1d, ip_list[i], name)) {
2624 +
2625 +               if(wg->addr->sa_family != AF_INET) continue;
2626 +               if (name_status_find("*", 0, 0x1d, ((struct sockaddr_in *)
2627 +                                               (wg->addr))->sin_addr, name))
2628 +               {
2629                         slprintf(server, sizeof(server), "%s#1D", name);
2630                         if (smbw_server(server, "IPC$")) {
2631                                 smbw_setshared("WORKGROUP", name);
2632 -                               SAFE_FREE(ip_list);
2633 +                               free_sockaddr_list(wglist);
2634                                 return name;
2635                         }
2636                 }
2637         }
2638  
2639 -       SAFE_FREE(ip_list);
2640 +       free_sockaddr_list(wglist);
2641  
2642         return p;
2643  }
2644 @@ -448,10 +451,8 @@
2645         char *p, *server_n = server;
2646         fstring group;
2647         pstring ipenv;
2648 -       struct in_addr ip;
2649 -       extern struct in_addr ipzero;
2650 +       struct sockaddr_list *salist;
2651  
2652 -       ip = ipzero;
2653         ZERO_STRUCT(c);
2654  
2655         get_auth_data_fn(server, share, &workgroup, &username, &password);
2656 @@ -502,13 +503,11 @@
2657   again:
2658         slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
2659  
2660 -       ip = ipzero;
2661 -       if ((p=smbw_getshared(ipenv))) {
2662 -               ip = *(interpret_addr2(p));
2663 -       }
2664 +       salist = resolve_name_smb((p=smbw_getshared(ipenv)) ? p : server_n, 0);
2665  
2666         /* have to open a new connection */
2667 -       if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) {
2668 +       if (!cli_initialise(&c) || !cli_connect(&c, server_n, salist)) {
2669 +               free_sockaddr_list(salist);
2670                 errno = ENOENT;
2671                 return NULL;
2672         }
2673 @@ -551,7 +550,7 @@
2674                 return NULL;
2675         }
2676  
2677 -       smbw_setshared(ipenv,inet_ntoa(ip));
2678 +       smbw_setshared(ipenv,print_sockaddr(c.connected_addr->addr));
2679         
2680         DEBUG(4,(" tconx ok\n"));
2681  
2682 Index: samba-2.2.3a+IPv6/source/utils/locktest.c
2683 ===================================================================
2684 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/locktest.c,v
2685 retrieving revision 1.1.1.1
2686 retrieving revision 1.2
2687 diff -u -r1.1.1.1 -r1.2
2688 --- samba-2.2.3a+IPv6/source/utils/locktest.c   16 Apr 2002 03:34:35 -0000      1.1.1.1
2689 +++ samba-2.2.3a+IPv6/source/utils/locktest.c   18 Apr 2002 04:53:05 -0000      1.2
2690 @@ -112,8 +112,6 @@
2691         struct nmb_name called, calling;
2692         char *server_n;
2693         fstring server;
2694 -       struct in_addr ip;
2695 -       extern struct in_addr ipzero;
2696         fstring myname;
2697         static int count;
2698  
2699 @@ -125,19 +123,14 @@
2700  
2701         server_n = server;
2702         
2703 -       ip = ipzero;
2704 -
2705         slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
2706  
2707         make_nmb_name(&calling, myname, 0x0);
2708         make_nmb_name(&called , server, 0x20);
2709  
2710   again:
2711 -       ip = ipzero;
2712 -
2713         /* have to open a new connection */
2714 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) ||
2715 -           !cli_connect(c, server_n, &ip)) {
2716 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, NULL)) {
2717                 DEBUG(0,("Connection to %s failed\n", server_n));
2718                 return NULL;
2719         }
2720 Index: samba-2.2.3a+IPv6/source/utils/locktest2.c
2721 ===================================================================
2722 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/locktest2.c,v
2723 retrieving revision 1.1.1.1
2724 retrieving revision 1.2
2725 diff -u -r1.1.1.1 -r1.2
2726 --- samba-2.2.3a+IPv6/source/utils/locktest2.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
2727 +++ samba-2.2.3a+IPv6/source/utils/locktest2.c  18 Apr 2002 04:53:05 -0000      1.2
2728 @@ -156,8 +156,6 @@
2729         struct nmb_name called, calling;
2730         char *server_n;
2731         fstring server;
2732 -       struct in_addr ip;
2733 -       extern struct in_addr ipzero;
2734         fstring myname;
2735         static int count;
2736  
2737 @@ -169,19 +167,14 @@
2738  
2739         server_n = server;
2740         
2741 -       ip = ipzero;
2742 -
2743         slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
2744  
2745         make_nmb_name(&calling, myname, 0x0);
2746         make_nmb_name(&called , server, 0x20);
2747  
2748   again:
2749 -       ip = ipzero;
2750 -
2751         /* have to open a new connection */
2752 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) ||
2753 -           !cli_connect(c, server_n, &ip)) {
2754 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, NULL)) {
2755                 DEBUG(0,("Connection to %s failed\n", server_n));
2756                 return NULL;
2757         }
2758 Index: samba-2.2.3a+IPv6/source/utils/masktest.c
2759 ===================================================================
2760 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/masktest.c,v
2761 retrieving revision 1.1.1.1
2762 retrieving revision 1.2
2763 diff -u -r1.1.1.1 -r1.2
2764 --- samba-2.2.3a+IPv6/source/utils/masktest.c   16 Apr 2002 03:34:35 -0000      1.1.1.1
2765 +++ samba-2.2.3a+IPv6/source/utils/masktest.c   18 Apr 2002 04:53:05 -0000      1.2
2766 @@ -164,8 +164,6 @@
2767         struct nmb_name called, calling;
2768         char *server_n;
2769         char *server;
2770 -       struct in_addr ip;
2771 -       extern struct in_addr ipzero;
2772  
2773         server = share+2;
2774         share = strchr(server,'\\');
2775 @@ -175,17 +173,12 @@
2776  
2777         server_n = server;
2778         
2779 -       ip = ipzero;
2780 -
2781         make_nmb_name(&calling, "masktest", 0x0);
2782         make_nmb_name(&called , server, 0x20);
2783  
2784   again:
2785 -       ip = ipzero;
2786 -
2787         /* have to open a new connection */
2788 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) ||
2789 -           !cli_connect(c, server_n, &ip)) {
2790 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, NULL)) {
2791                 DEBUG(0,("Connection to %s failed\n", server_n));
2792                 return NULL;
2793         }
2794 Index: samba-2.2.3a+IPv6/source/utils/smbcacls.c
2795 ===================================================================
2796 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/smbcacls.c,v
2797 retrieving revision 1.1.1.1
2798 retrieving revision 1.2
2799 diff -u -r1.1.1.1 -r1.2
2800 --- samba-2.2.3a+IPv6/source/utils/smbcacls.c   16 Apr 2002 03:34:35 -0000      1.1.1.1
2801 +++ samba-2.2.3a+IPv6/source/utils/smbcacls.c   18 Apr 2002 04:53:05 -0000      1.2
2802 @@ -690,8 +690,6 @@
2803         struct cli_state *c;
2804         struct nmb_name called, calling;
2805         char *server_n;
2806 -       struct in_addr ip;
2807 -       extern struct in_addr ipzero;
2808         extern pstring global_myname;
2809  
2810         fstrcpy(server,share+2);
2811 @@ -702,19 +700,13 @@
2812  
2813         server_n = server;
2814         
2815 -       ip = ipzero;
2816 -
2817         make_nmb_name(&calling, global_myname, 0x0);
2818         make_nmb_name(&called , server, 0x20);
2819  
2820   again:
2821 -       ip = ipzero;
2822 -
2823         /* have to open a new connection */
2824 -       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) ||
2825 -           !cli_connect(c, server_n, &ip)) {
2826 +       if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, NULL)) {
2827                 DEBUG(0,("Connection to %s failed\n", server_n));
2828 -               cli_shutdown(c);
2829                 return NULL;
2830         }
2831  
2832 Index: samba-2.2.3a+IPv6/source/utils/smbfilter.c
2833 ===================================================================
2834 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/smbfilter.c,v
2835 retrieving revision 1.1.1.1
2836 retrieving revision 1.3
2837 diff -u -r1.1.1.1 -r1.3
2838 --- samba-2.2.3a+IPv6/source/utils/smbfilter.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
2839 +++ samba-2.2.3a+IPv6/source/utils/smbfilter.c  19 Apr 2002 14:50:33 -0000      1.3
2840 @@ -98,15 +98,17 @@
2841  }
2842  
2843  
2844 -static void filter_child(int c, struct in_addr dest_ip)
2845 +static void filter_child(int c, struct sockaddr_list *dest_addrs)
2846  {
2847         int s;
2848  
2849         /* we have a connection from a new client, now connect to the server */
2850 -       s = open_socket_out(SOCK_STREAM, &dest_ip, 139, LONG_CONNECT_TIMEOUT);
2851 +       s = open_socket_out(dest_addrs, NULL, LONG_CONNECT_TIMEOUT);
2852 +       free_sockaddr_list(dest_addrs);
2853  
2854         if (s == -1) {
2855 -               DEBUG(0,("Unable to connect to %s\n", inet_ntoa(dest_ip)));
2856 +               DEBUG(0,("Unable to connect to %s\n",
2857 +                                       print_sockaddr(dest_addrs->addr)));
2858                 exit(1);
2859         }
2860  
2861 @@ -152,7 +154,7 @@
2862  static void start_filter(char *desthost)
2863  {
2864         int s, c;
2865 -       struct in_addr dest_ip;
2866 +       struct sockaddr_list *dest_addrs;
2867  
2868         CatchChild();
2869  
2870 @@ -168,7 +170,7 @@
2871                 DEBUG(0,("listen failed\n"));
2872         }
2873  
2874 -       if (!resolve_name(desthost, &dest_ip, 0x20)) {
2875 +       if (!(dest_addrs = resolve_name_smb(desthost, 0))) {
2876                 DEBUG(0,("Unable to resolve host %s\n", desthost));
2877                 exit(1);
2878         }
2879 @@ -188,7 +190,7 @@
2880                         if (c != -1) {
2881                                 if (fork() == 0) {
2882                                         close(s);
2883 -                                       filter_child(c, dest_ip);
2884 +                                       filter_child(c, dest_addrs);
2885                                         exit(0);
2886                                 } else {
2887                                         close(c);
2888 Index: samba-2.2.3a+IPv6/source/utils/smbpasswd.c
2889 ===================================================================
2890 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/smbpasswd.c,v
2891 retrieving revision 1.1.1.1
2892 retrieving revision 1.3
2893 diff -u -r1.1.1.1 -r1.3
2894 --- samba-2.2.3a+IPv6/source/utils/smbpasswd.c  16 Apr 2002 03:34:35 -0000      1.1.1.1
2895 +++ samba-2.2.3a+IPv6/source/utils/smbpasswd.c  19 Apr 2002 14:50:34 -0000      1.3
2896 @@ -126,7 +126,7 @@
2897         struct ntuser_creds creds;
2898         struct cli_state cli;
2899         fstring dest_host, acct_name;
2900 -       struct in_addr dest_ip;
2901 +       struct sockaddr_list *dest_addrs;
2902         TALLOC_CTX *mem_ctx;
2903  
2904         /* rpc variables */
2905 @@ -167,7 +167,7 @@
2906         init_rpcclient_creds(&creds, username, domain, password);
2907         cli_init_creds(&cli, &creds);
2908  
2909 -       if (!resolve_srv_name(remote_machine, dest_host, &dest_ip)) {
2910 +       if (!(dest_addrs = resolve_srv_name(remote_machine, dest_host, 0))) {
2911                 DEBUG(0, ("Could not resolve name %s\n", remote_machine));
2912                 goto done;
2913         }
2914 @@ -175,9 +175,10 @@
2915         make_nmb_name(&called, dns_to_netbios_name(dest_host), 0x20);
2916         make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0);
2917  
2918 -       if (!cli_establish_connection(&cli, dest_host, &dest_ip, &calling, 
2919 +       if (!cli_establish_connection(&cli, dest_host, dest_addrs, &calling, 
2920                                       &called, "IPC$", "IPC", False, True)) {
2921                 DEBUG(0, ("Error connecting to %s\n", dest_host));
2922 +               free_sockaddr_list(dest_addrs);
2923                 goto done;
2924         }
2925  
2926 @@ -362,6 +363,9 @@
2927  
2928         if (cli.nt_pipe_fnum)
2929                 cli_nt_session_close(&cli);
2930 +
2931 +       if (cli.dest_addrs)
2932 +               free_sockaddr_list(cli.dest_addrs);
2933  
2934         /* Display success or failure */
2935  
2936 Index: samba-2.2.3a+IPv6/source/utils/torture.c
2937 ===================================================================
2938 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/utils/torture.c,v
2939 retrieving revision 1.1.1.1
2940 retrieving revision 1.2
2941 diff -u -r1.1.1.1 -r1.2
2942 --- samba-2.2.3a+IPv6/source/utils/torture.c    16 Apr 2002 03:34:35 -0000      1.1.1.1
2943 +++ samba-2.2.3a+IPv6/source/utils/torture.c    18 Apr 2002 04:53:05 -0000      1.2
2944 @@ -134,17 +134,13 @@
2945  static BOOL open_nbt_connection(struct cli_state *c)
2946  {
2947         struct nmb_name called, calling;
2948 -       struct in_addr ip;
2949 -       extern struct in_addr ipzero;
2950  
2951         ZERO_STRUCTP(c);
2952  
2953         make_nmb_name(&calling, myname, 0x0);
2954         make_nmb_name(&called , host, 0x20);
2955  
2956 -       ip = ipzero;
2957 -
2958 -       if (!cli_initialise(c) || !cli_connect(c, host, &ip)) {
2959 +       if (!cli_initialise(c) || !cli_connect(c, host, NULL)) {
2960                 printf("Failed to connect with %s\n", host);
2961                 return False;
2962         }
2963 Index: samba-2.2.3a+IPv6/source/web/diagnose.c
2964 ===================================================================
2965 RCS file: /home/lutchann/cvsroot/samba-2.2.3a+IPv6/source/web/diagnose.c,v
2966 retrieving revision 1.1.1.1
2967 retrieving revision 1.2
2968 diff -u -r1.1.1.1 -r1.2
2969 --- samba-2.2.3a+IPv6/source/web/diagnose.c     16 Apr 2002 03:34:35 -0000      1.1.1.1
2970 +++ samba-2.2.3a+IPv6/source/web/diagnose.c     18 Apr 2002 04:53:06 -0000      1.2
2971 @@ -52,12 +52,16 @@
2972  BOOL smbd_running(void)
2973  {
2974         static struct cli_state cli;
2975 +       struct sockaddr_list *localaddrs;
2976         extern struct in_addr loopback_ip;
2977  
2978         if (!cli_initialise(&cli))
2979                 return False;
2980  
2981 -       if (!cli_connect(&cli, "localhost", &loopback_ip)) {
2982 +       localaddrs = make_singlet_list(&loopback_ip, 0);
2983 +       if (!cli_connect(&cli, "localhost", localaddrs))
2984 +       {
2985 +               free_sockaddr_list(localaddrs);
2986                 cli_shutdown(&cli);
2987                 return False;
2988         }
This page took 0.27407 seconds and 3 git commands to generate.