Added LGPL standard comment, and copyright notices where necessary.
[wine] / dlls / icmp / icmp_main.c
1 /*
2  * ICMP
3  *
4  * Francois Gouget, 1999, based on the work of
5  *   RW Hall, 1999, based on public domain code PING.C by Mike Muus (1983) 
6  *   and later works (c) 1989 Regents of Univ. of California - see copyright 
7  *   notice at end of source-code.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 /* Future work:
25  * - Systems like FreeBSD don't seem to support the IP_TTL option and maybe others.
26  *   But using IP_HDRINCL and building the IP header by hand might work.
27  * - Not all IP options are supported.
28  * - Are ICMP handles real handles, i.e. inheritable and all? There might be some 
29  *   more work to do here, including server side stuff with synchronization.
30  * - Is it correct to use malloc for the internal buffer, for allocating the 
31  *   handle's structure?
32  * - This API should probably be thread safe. Is it really?
33  * - Using the winsock functions has not been tested.
34  */
35
36 #include "config.h"
37
38 #include <sys/types.h>
39 #ifdef HAVE_SYS_SOCKET_H
40 # include <sys/socket.h>
41 #endif
42 #ifdef HAVE_NETDB_H
43 # include <netdb.h>
44 #endif
45 #ifdef HAVE_NETINET_IN_SYSTM_H
46 # include <netinet/in_systm.h>
47 #endif
48 #ifdef HAVE_NETINET_IN_H
49 # include <netinet/in.h>
50 #endif
51
52 #include <sys/time.h>
53 #include <string.h>
54 #include <errno.h>
55 #include <unistd.h>
56 #ifdef HAVE_ARPA_INET_H
57 # include <arpa/inet.h>
58 #endif
59
60 #include "windef.h"
61 #include "winbase.h"
62 #ifdef ICMP_WIN
63 #include "winsock2.h"
64 #endif
65
66 #include "winerror.h"
67 #include "wine/ipexport.h"
68 #include "wine/icmpapi.h"
69 #include "wine/debug.h"
70
71 /* Set up endiannes macros for the ip and ip_icmp BSD headers */
72 #ifndef BIG_ENDIAN
73 #define BIG_ENDIAN       4321
74 #endif
75 #ifndef LITTLE_ENDIAN
76 #define LITTLE_ENDIAN    1234
77 #endif
78 #ifndef BYTE_ORDER
79 #ifdef WORDS_BIGENDIAN
80 #define BYTE_ORDER       BIG_ENDIAN
81 #else
82 #define BYTE_ORDER       LITTLE_ENDIAN
83 #endif
84 #endif /* BYTE_ORDER */
85
86 #define u_int16_t  WORD
87 #define u_int32_t  DWORD
88
89 /* These are BSD headers. We use these here because they are needed on 
90  * libc5 Linux systems. On other platforms they are usually simply more 
91  * complete than the native stuff, and cause less portability problems 
92  * so we use them anyway.
93  */
94 #include "ip.h"
95 #include "ip_icmp.h"
96
97
98 WINE_DEFAULT_DEBUG_CHANNEL(icmp);
99
100 /* Define the following macro to use the winsock functions */
101 /*#define ICMP_WIN*/
102
103 #ifdef ICMP_WIN
104 /* FIXME: should we include winsock.h ???*/
105 SOCKET WINAPI WINSOCK_socket(INT af, INT type, INT protocol);
106 INT WINAPI WINSOCK_sendto(SOCKET s, char *buf, INT len, INT flags, struct sockaddr *to, INT tolen);
107 INT WINAPI WINSOCK_recvfrom(SOCKET s, char *buf,INT len, INT flags, struct sockaddr *from, INT *fromlen32);
108 INT WINAPI WINSOCK_shutdown(SOCKET s, INT how);
109 #endif
110
111
112 #ifdef ICMP_WIN
113 #define ISOCK_SOCKET                SOCKET
114 #define ISOCK_ISVALID(a)            ((a)!=INVALID_SOCKET)
115 #define ISOCK_getsockopt(a,b,c,d,e) WINSOCK_getsockopt(a,b,c,d,e)
116 #define ISOCK_recvfrom(a,b,c,d,e,f) WINSOCK_recvfrom(a,b,c,d,e,f)
117 #define ISOCK_select(a,b,c,d,e)     WINSOCK_select(a,b,c,d,e)
118 #define ISOCK_sendto(a,b,c,d,e,f)   WINSOCK_sendto(a,b,c,d,e,f)
119 #define ISOCK_setsockopt(a,b,c,d,e) WINSOCK_setsockopt(a,b,c,d,e)
120 #define ISOCK_shutdown(a,b)         WINSOCK_shutdown(a,b)
121 #define ISOCK_socket(a,b,c)         WINSOCK_socket(a,b,c)
122 #else
123 #define ISOCK_SOCKET                int
124 #define ISOCK_ISVALID(a)            ((a)>=0)
125 #define ISOCK_getsockopt(a,b,c,d,e) getsockopt(a,b,c,d,e)
126 #define ISOCK_recvfrom(a,b,c,d,e,f) recvfrom(a,b,c,d,e,f)
127 #define ISOCK_select(a,b,c,d,e)     select(a,b,c,d,e)
128 #define ISOCK_setsockopt(a,b,c,d,e) setsockopt(a,b,c,d,e)
129 #define ISOCK_sendto(a,b,c,d,e,f)   sendto(a,b,c,d,e,f)
130 #define ISOCK_shutdown(a,b)         shutdown(a,b)
131 #define ISOCK_socket(a,b,c)         socket(a,b,c)
132 #endif
133
134 typedef struct {
135     ISOCK_SOCKET sid;
136     IP_OPTION_INFORMATION default_opts;
137 } icmp_t;
138
139 #define IP_OPTS_UNKNOWN     0
140 #define IP_OPTS_DEFAULT     1
141 #define IP_OPTS_CUSTOM      2
142
143 /* The sequence number is unique process wide, so that all threads 
144  * have a distinct sequence number.
145  */
146 static LONG icmp_sequence=0;
147
148 static int in_cksum(u_short *addr, int len)
149 {
150     int nleft=len;
151     u_short *w = addr;
152     int sum = 0;
153     u_short answer = 0;
154
155     while (nleft > 1) {
156         sum += *w++;
157         nleft -= 2;
158     }
159
160     if (nleft == 1) {
161         *(u_char *)(&answer) = *(u_char *)w;
162         sum += answer;
163     }
164
165     sum = (sum >> 16) + (sum & 0xffff);
166     sum  += (sum >> 16);
167     answer = ~sum;
168     return(answer);
169 }
170
171
172
173 /*
174  * Exported Routines.
175  */
176
177 /***********************************************************************
178  *              IcmpCreateFile (ICMP.@)
179  */
180 HANDLE WINAPI IcmpCreateFile(VOID)
181 {
182     icmp_t* icp;
183
184     ISOCK_SOCKET sid=ISOCK_socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
185     if (!ISOCK_ISVALID(sid)) {
186         MESSAGE("WARNING: Trying to use ICMP will fail unless running as root\n");
187         SetLastError(ERROR_ACCESS_DENIED);
188         return INVALID_HANDLE_VALUE;
189     }
190
191     icp=HeapAlloc(GetProcessHeap(), 0, sizeof(*icp));
192     if (icp==NULL) {
193         SetLastError(IP_NO_RESOURCES);
194         return INVALID_HANDLE_VALUE;
195     }
196     icp->sid=sid;
197     icp->default_opts.OptionsSize=IP_OPTS_UNKNOWN;
198     return (HANDLE)icp;
199 }
200
201
202 /***********************************************************************
203  *              IcmpCloseHandle (ICMP.@)
204  */
205 BOOL WINAPI IcmpCloseHandle(HANDLE  IcmpHandle)
206 {
207     icmp_t* icp=(icmp_t*)IcmpHandle;
208     if (IcmpHandle==INVALID_HANDLE_VALUE) {
209         /* FIXME: in fact win98 seems to ignore the handle value !!! */
210         SetLastError(ERROR_INVALID_HANDLE);
211         return FALSE;
212     }
213
214     ISOCK_shutdown(icp->sid,2);
215     HeapFree(GetProcessHeap (), 0, icp);
216     return TRUE;
217 }
218
219
220 /***********************************************************************
221  *              IcmpSendEcho (ICMP.@)
222  */
223 DWORD WINAPI IcmpSendEcho(
224     HANDLE                   IcmpHandle,
225     IPAddr                   DestinationAddress,
226     LPVOID                   RequestData,
227     WORD                     RequestSize,
228     PIP_OPTION_INFORMATION   RequestOptions,
229     LPVOID                   ReplyBuffer,
230     DWORD                    ReplySize,
231     DWORD                    Timeout
232     )
233 {
234     icmp_t* icp=(icmp_t*)IcmpHandle;
235     unsigned char* reqbuf;
236     int reqsize;
237
238     struct icmp_echo_reply* ier;
239     struct ip* ip_header;
240     struct icmp* icmp_header;
241     char* endbuf;
242     int ip_header_len;
243     int maxlen;
244     fd_set fdr;
245     struct timeval timeout,send_time,recv_time;
246     struct sockaddr_in addr;
247     int addrlen;
248     unsigned short id,seq,cksum;
249     int res;
250
251     if (IcmpHandle==INVALID_HANDLE_VALUE) {
252         /* FIXME: in fact win98 seems to ignore the handle value !!! */
253         SetLastError(ERROR_INVALID_HANDLE);
254         return 0;
255     }
256
257     if (ReplySize<sizeof(ICMP_ECHO_REPLY)+ICMP_MINLEN) {
258         SetLastError(IP_BUF_TOO_SMALL);
259         return 0;
260     }
261     /* check the request size against SO_MAX_MSG_SIZE using getsockopt */
262
263     /* Prepare the request */
264     id=getpid() & 0xFFFF;
265     seq=InterlockedIncrement(&icmp_sequence) & 0xFFFF;
266
267     reqsize=ICMP_MINLEN+RequestSize;
268     reqbuf=HeapAlloc(GetProcessHeap(), 0, reqsize);
269     if (reqbuf==NULL) {
270         SetLastError(ERROR_OUTOFMEMORY);
271         return 0;
272     }
273
274     icmp_header=(struct icmp*)reqbuf;
275     icmp_header->icmp_type=ICMP_ECHO;
276     icmp_header->icmp_code=0;
277     icmp_header->icmp_cksum=0;
278     icmp_header->icmp_id=id;
279     icmp_header->icmp_seq=seq;
280     memcpy(reqbuf+ICMP_MINLEN, RequestData, RequestSize);
281     icmp_header->icmp_cksum=cksum=in_cksum((u_short*)reqbuf,reqsize);
282
283     addr.sin_family=AF_INET;
284     addr.sin_addr.s_addr=DestinationAddress;
285     addr.sin_port=0;
286
287     if (RequestOptions!=NULL) {
288         int val;
289         if (icp->default_opts.OptionsSize==IP_OPTS_UNKNOWN) {
290             int len;
291             /* Before we mess with the options, get the default values */
292             len=sizeof(val);
293             ISOCK_getsockopt(icp->sid,IPPROTO_IP,IP_TTL,(char *)&val,&len);
294             icp->default_opts.Ttl=val;
295
296             len=sizeof(val);
297             ISOCK_getsockopt(icp->sid,IPPROTO_IP,IP_TOS,(char *)&val,&len);
298             icp->default_opts.Tos=val;
299             /* FIXME: missing: handling of IP 'flags', and all the other options */
300         }
301
302         val=RequestOptions->Ttl;
303         ISOCK_setsockopt(icp->sid,IPPROTO_IP,IP_TTL,(char *)&val,sizeof(val));
304         val=RequestOptions->Tos;
305         ISOCK_setsockopt(icp->sid,IPPROTO_IP,IP_TOS,(char *)&val,sizeof(val));
306         /* FIXME:  missing: handling of IP 'flags', and all the other options */
307
308         icp->default_opts.OptionsSize=IP_OPTS_CUSTOM;
309     } else if (icp->default_opts.OptionsSize==IP_OPTS_CUSTOM) {
310         int val;
311
312         /* Restore the default options */
313         val=icp->default_opts.Ttl;
314         ISOCK_setsockopt(icp->sid,IPPROTO_IP,IP_TTL,(char *)&val,sizeof(val));
315         val=icp->default_opts.Tos;
316         ISOCK_setsockopt(icp->sid,IPPROTO_IP,IP_TOS,(char *)&val,sizeof(val));
317         /* FIXME: missing: handling of IP 'flags', and all the other options */
318
319         icp->default_opts.OptionsSize=IP_OPTS_DEFAULT;
320     }
321
322     /* Get ready for receiving the reply
323      * Do it before we send the request to minimize the risk of introducing delays
324      */
325     FD_ZERO(&fdr);
326     FD_SET(icp->sid,&fdr);
327     timeout.tv_sec=Timeout/1000;
328     timeout.tv_usec=(Timeout % 1000)*1000;
329     addrlen=sizeof(addr);
330     ier=ReplyBuffer;
331     ip_header=(struct ip *) ((char *) ReplyBuffer+sizeof(ICMP_ECHO_REPLY));
332     endbuf=(char *) ReplyBuffer+ReplySize;
333     maxlen=ReplySize-sizeof(ICMP_ECHO_REPLY);
334
335     /* Send the packet */
336     TRACE("Sending %d bytes (RequestSize=%d) to %s\n", reqsize, RequestSize, inet_ntoa(addr.sin_addr));
337 #if 0
338     if (TRACE_ON(icmp)){
339         unsigned char* buf=(unsigned char*)reqbuf;
340         int i;
341         printf("Output buffer:\n");
342         for (i=0;i<reqsize;i++)
343             printf("%2x,", buf[i]);
344         printf("\n");
345     }
346 #endif
347
348     gettimeofday(&send_time,NULL);
349     res=ISOCK_sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr));
350     HeapFree(GetProcessHeap (), 0, reqbuf);
351     if (res<0) {
352         if (errno==EMSGSIZE)
353             SetLastError(IP_PACKET_TOO_BIG);
354         else {
355             switch (errno) {
356             case ENETUNREACH:
357                 SetLastError(IP_DEST_NET_UNREACHABLE);
358                 break;
359             case EHOSTUNREACH:
360                 SetLastError(IP_DEST_NET_UNREACHABLE);
361                 break;
362             default:
363                 TRACE("unknown error: errno=%d\n",errno);
364                 SetLastError(ERROR_UNKNOWN);
365             }
366         }
367         return 0;
368     }
369
370     /* Get the reply */
371     ip_header_len=0; /* because gcc was complaining */
372     while ((res=ISOCK_select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
373         gettimeofday(&recv_time,NULL);
374         res=ISOCK_recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
375         TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
376         ier->Status=IP_REQ_TIMED_OUT;
377
378         /* Check whether we should ignore this packet */
379         if ((ip_header->ip_p==IPPROTO_ICMP) && (res>=sizeof(struct ip)+ICMP_MINLEN)) {
380             ip_header_len=ip_header->ip_hl << 2;
381             icmp_header=(struct icmp*)(((char*)ip_header)+ip_header_len);
382             TRACE("received an ICMP packet of type,code=%d,%d\n",icmp_header->icmp_type,icmp_header->icmp_code);
383             if (icmp_header->icmp_type==ICMP_ECHOREPLY) {
384                 if ((icmp_header->icmp_id==id) && (icmp_header->icmp_seq==seq))
385                     ier->Status=IP_SUCCESS;
386             } else {
387                 switch (icmp_header->icmp_type) {
388                 case ICMP_UNREACH:
389                     switch (icmp_header->icmp_code) {
390                     case ICMP_UNREACH_HOST:
391 #ifdef ICMP_UNREACH_HOST_UNKNOWN
392                     case ICMP_UNREACH_HOST_UNKNOWN:
393 #endif
394 #ifdef ICMP_UNREACH_ISOLATED
395                     case ICMP_UNREACH_ISOLATED:
396 #endif
397 #ifdef ICMP_UNREACH_HOST_PROHIB
398                     case ICMP_UNREACH_HOST_PROHIB:
399 #endif
400 #ifdef ICMP_UNREACH_TOSHOST
401                     case ICMP_UNREACH_TOSHOST:
402 #endif
403                         ier->Status=IP_DEST_HOST_UNREACHABLE;
404                         break;
405                     case ICMP_UNREACH_PORT:
406                         ier->Status=IP_DEST_PORT_UNREACHABLE;
407                         break;
408                     case ICMP_UNREACH_PROTOCOL:
409                         ier->Status=IP_DEST_PROT_UNREACHABLE;
410                         break;
411                     case ICMP_UNREACH_SRCFAIL:
412                         ier->Status=IP_BAD_ROUTE;
413                         break;
414                     default:
415                         ier->Status=IP_DEST_NET_UNREACHABLE;
416                     }
417                     break;
418                 case ICMP_TIMXCEED:
419                     if (icmp_header->icmp_code==ICMP_TIMXCEED_REASS)
420                         ier->Status=IP_TTL_EXPIRED_REASSEM;
421                     else
422                         ier->Status=IP_TTL_EXPIRED_TRANSIT;
423                     break;
424                 case ICMP_PARAMPROB:
425                     ier->Status=IP_PARAM_PROBLEM;
426                     break;
427                 case ICMP_SOURCEQUENCH:
428                     ier->Status=IP_SOURCE_QUENCH;
429                     break;
430                 }
431                 if (ier->Status!=IP_REQ_TIMED_OUT) {
432                     struct ip* rep_ip_header;
433                     struct icmp* rep_icmp_header;
434                     /* The ICMP header size of all the packets we accept is the same */
435                     rep_ip_header=(struct ip*)(((char*)icmp_header)+ICMP_MINLEN);
436                     rep_icmp_header=(struct icmp*)(((char*)rep_ip_header)+(rep_ip_header->ip_hl << 2));
437
438                     /* Make sure that this is really a reply to our packet */
439                     if (ip_header_len+ICMP_MINLEN+(rep_ip_header->ip_hl << 2)+ICMP_MINLEN>ip_header->ip_len) {
440                         ier->Status=IP_REQ_TIMED_OUT;
441                     } else if ((rep_icmp_header->icmp_type!=ICMP_ECHO) ||
442                         (rep_icmp_header->icmp_code!=0) ||
443                         (rep_icmp_header->icmp_id!=id) ||
444                         /* windows doesn't check this checksum, else tracert */
445                         /* behind a Linux 2.2 masquerading firewall would fail*/
446                         /* (rep_icmp_header->icmp_cksum!=cksum) || */
447                         (rep_icmp_header->icmp_seq!=seq)) {
448                         /* This was not a reply to one of our packets after all */
449                         TRACE("skipping type,code=%d,%d id,seq=%d,%d cksum=%d\n",
450                             rep_icmp_header->icmp_type,rep_icmp_header->icmp_code,
451                             rep_icmp_header->icmp_id,rep_icmp_header->icmp_seq,
452                             rep_icmp_header->icmp_cksum);
453                         TRACE("expected type,code=8,0 id,seq=%d,%d cksum=%d\n",
454                             id,seq,
455                             cksum);
456                         ier->Status=IP_REQ_TIMED_OUT;
457                     }
458                 }
459             }                
460         }
461
462         if (ier->Status==IP_REQ_TIMED_OUT) {
463             /* This packet was not for us.
464              * Decrease the timeout so that we don't enter an endless loop even
465              * if we get flooded with ICMP packets that are not for us.
466              */
467             timeout.tv_sec=Timeout/1000-(recv_time.tv_sec-send_time.tv_sec);
468             timeout.tv_usec=(Timeout % 1000)*1000+send_time.tv_usec-(recv_time.tv_usec-send_time.tv_usec);
469             if (timeout.tv_usec<0) {
470                 timeout.tv_usec+=1000000;
471                 timeout.tv_sec--;
472             }
473             continue;
474         } else {
475             /* This is a reply to our packet */
476             memcpy(&ier->Address,&ip_header->ip_src,sizeof(IPAddr));
477             /* Status is already set */
478             ier->RoundTripTime=(recv_time.tv_sec-send_time.tv_sec)*1000+(recv_time.tv_usec-send_time.tv_usec)/1000;
479             ier->DataSize=res-ip_header_len-ICMP_MINLEN;
480             ier->Reserved=0;
481             ier->Data=endbuf-ier->DataSize;
482             memmove(ier->Data,((char*)ip_header)+ip_header_len+ICMP_MINLEN,ier->DataSize);
483             ier->Options.Ttl=ip_header->ip_ttl;
484             ier->Options.Tos=ip_header->ip_tos;
485             ier->Options.Flags=ip_header->ip_off >> 13;
486             ier->Options.OptionsSize=ip_header_len-sizeof(struct ip);
487             if (ier->Options.OptionsSize!=0) {
488                 ier->Options.OptionsData=(unsigned char *) ier->Data-ier->Options.OptionsSize;
489                 /* FIXME: We are supposed to rearrange the option's 'source route' data */
490                 memmove(ier->Options.OptionsData,((char*)ip_header)+ip_header_len,ier->Options.OptionsSize);
491                 endbuf=ier->Options.OptionsData;
492             } else {
493                 ier->Options.OptionsData=NULL;
494                 endbuf=ier->Data;
495             }
496
497             /* Prepare for the next packet */
498             ier++;
499             ip_header=(struct ip*)(((char*)ip_header)+sizeof(ICMP_ECHO_REPLY));
500             maxlen=endbuf-(char*)ip_header;
501
502             /* Check out whether there is more but don't wait this time */
503             timeout.tv_sec=0;
504             timeout.tv_usec=0;
505         }
506         FD_ZERO(&fdr);
507         FD_SET(icp->sid,&fdr);
508     }
509     res=ier-(ICMP_ECHO_REPLY*)ReplyBuffer;
510     if (res==0)
511         SetLastError(IP_REQ_TIMED_OUT);
512     TRACE("received %d replies\n",res);
513     return res;
514 }
515
516 /*
517  * Copyright (c) 1989 The Regents of the University of California.
518  * All rights reserved.
519  *
520  * This code is derived from software contributed to Berkeley by
521  * Mike Muuss.
522  *
523  * Redistribution and use in source and binary forms, with or without
524  * modification, are permitted provided that the following conditions
525  * are met:
526  * 1. Redistributions of source code must retain the above copyright
527  *    notice, this list of conditions and the following disclaimer.
528  * 2. Redistributions in binary form must reproduce the above copyright
529  *    notice, this list of conditions and the following disclaimer in the
530  *    documentation and/or other materials provided with the distribution.
531  * 3. Neither the name of the University nor the names of its contributors
532  *    may be used to endorse or promote products derived from this software
533  *    without specific prior written permission.
534  *
535  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
536  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
537  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
538  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
539  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
540  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
541  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
542  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
543  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
544  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
545  * SUCH DAMAGE.
546  *
547  */