4 * Copyright 2011, 2014 André Hentschel
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/unixlib.h"
31 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wpcap
);
36 static unixlib_handle_t pcap_handle
;
38 #define PCAP_CALL( func, params ) __wine_unix_call( pcap_handle, unix_ ## func, params )
40 int CDECL
pcap_activate( struct pcap
*pcap
)
42 TRACE( "%p\n", pcap
);
43 return PCAP_CALL( activate
, pcap
);
46 void CDECL
pcap_breakloop( struct pcap
*pcap
)
48 TRACE( "%p\n", pcap
);
49 PCAP_CALL( breakloop
, pcap
);
52 int CDECL
pcap_can_set_rfmon( struct pcap
*pcap
)
54 TRACE( "%p\n", pcap
);
55 return PCAP_CALL( can_set_rfmon
, pcap
);
58 void CDECL
pcap_close( struct pcap
*pcap
)
60 TRACE( "%p\n", pcap
);
61 PCAP_CALL( close
, pcap
);
64 int CDECL
pcap_compile( struct pcap
*pcap
, void *program
, const char *buf
, int optimize
, unsigned int mask
)
66 struct compile_params params
= { pcap
, program
, buf
, optimize
, mask
};
67 TRACE( "%p, %p, %s, %d, %u\n", pcap
, program
, debugstr_a(buf
), optimize
, mask
);
68 return PCAP_CALL( compile
, ¶ms
);
71 int CDECL
pcap_datalink( struct pcap
*pcap
)
73 TRACE( "%p\n", pcap
);
74 return PCAP_CALL( datalink
, pcap
);
77 int CDECL
pcap_datalink_name_to_val( const char *name
)
79 struct datalink_name_to_val_params params
= { name
};
80 TRACE( "%s\n", debugstr_a(name
) );
81 return PCAP_CALL( datalink_name_to_val
, ¶ms
);
84 const char * CDECL
pcap_datalink_val_to_description( int link
)
87 struct datalink_val_to_description_params params
= { link
, &ret
};
88 TRACE( "%d\n", link
);
89 PCAP_CALL( datalink_val_to_description
, ¶ms
);
93 const char * CDECL
pcap_datalink_val_to_name( int link
)
96 struct datalink_val_to_name_params params
= { link
, &ret
};
97 TRACE( "%d\n", link
);
98 PCAP_CALL( datalink_val_to_name
, ¶ms
);
102 void CDECL
pcap_dump( unsigned char *user
, const struct pcap_pkthdr_win32
*hdr
, const unsigned char *packet
)
104 struct dump_params params
= { user
, hdr
, packet
};
105 TRACE( "%p, %p, %p\n", user
, hdr
, packet
);
106 PCAP_CALL( dump
, ¶ms
);
109 static inline WCHAR
*strdupAW( const char *str
)
114 int len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
115 if ((ret
= malloc( len
* sizeof(WCHAR
) ))) MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
120 void * CDECL
pcap_dump_open( struct pcap
*pcap
, const char *filename
)
125 struct dump_open_params params
;
127 TRACE( "%p, %s\n", pcap
, debugstr_a(filename
) );
129 if (!(filenameW
= strdupAW( filename
))) return NULL
;
130 unix_path
= wine_get_unix_file_name( filenameW
);
132 if (!unix_path
) return NULL
;
134 TRACE( "unix_path %s\n", debugstr_a(unix_path
) );
137 params
.name
= unix_path
;
138 params
.ret
= &dumper
;
139 PCAP_CALL( dump_open
, ¶ms
);
140 RtlFreeHeap( GetProcessHeap(), 0, unix_path
);
144 static void free_addresses( struct pcap_address
*addrs
)
146 struct pcap_address
*next
, *cur
= addrs
;
151 free( cur
->netmask
);
152 free( cur
->broadaddr
);
153 free( cur
->dstaddr
);
160 static void free_devices( struct pcap_interface
*devs
)
162 struct pcap_interface
*next
, *cur
= devs
;
167 free( cur
->description
);
168 free_addresses( cur
->addresses
);
175 static IP_ADAPTER_ADDRESSES
*get_adapters( void )
178 IP_ADAPTER_ADDRESSES
*ret
;
179 ULONG flags
= GAA_FLAG_SKIP_ANYCAST
| GAA_FLAG_SKIP_MULTICAST
| GAA_FLAG_SKIP_DNS_SERVER
;
181 if (GetAdaptersAddresses( AF_UNSPEC
, flags
, NULL
, NULL
, &size
) != ERROR_BUFFER_OVERFLOW
) return NULL
;
182 if (!(ret
= malloc( size
))) return NULL
;
183 if (GetAdaptersAddresses( AF_UNSPEC
, flags
, NULL
, ret
, &size
))
191 static IP_ADAPTER_ADDRESSES
*find_adapter( IP_ADAPTER_ADDRESSES
*list
, const char *name
)
193 IP_ADAPTER_ADDRESSES
*ret
;
196 if (!(nameW
= strdupAW( name
))) return NULL
;
197 for (ret
= list
; ret
; ret
= ret
->Next
)
199 if (!wcscmp( nameW
, ret
->FriendlyName
)) break;
205 static char *build_win32_name( const char *source
, const char *adapter_name
)
207 const char prefix
[] = "\\Device\\NPF_";
208 int len
= sizeof(prefix
) + strlen(adapter_name
);
211 if (source
) len
+= strlen( source
);
212 if ((ret
= malloc( len
)))
215 if (source
) strcat( ret
, source
);
216 strcat( ret
, prefix
);
217 strcat( ret
, adapter_name
);
222 static char *build_win32_description( const struct pcap_interface
*unix_dev
)
224 int len
= strlen(unix_dev
->name
) + 1;
227 if (unix_dev
->description
&& unix_dev
->description
[0]) len
+= strlen(unix_dev
->description
) + 1;
228 if ((ret
= malloc( len
)))
230 if (unix_dev
->description
)
232 strcpy( ret
, unix_dev
->description
);
234 strcat( ret
, unix_dev
->name
);
236 else strcpy( ret
, unix_dev
->name
);
241 static struct sockaddr_hdr
*dup_sockaddr( const struct sockaddr_hdr
*addr
)
243 struct sockaddr_hdr
*ret
;
245 switch (addr
->sa_family
)
249 struct sockaddr_in
*dst
, *src
= (struct sockaddr_in
*)addr
;
250 if (!(dst
= calloc( 1, sizeof(*dst
) ))) return NULL
;
251 dst
->sin_family
= src
->sin_family
;
252 dst
->sin_port
= src
->sin_port
;
253 dst
->sin_addr
= src
->sin_addr
;
254 ret
= (struct sockaddr_hdr
*)dst
;
259 struct sockaddr_in6
*dst
, *src
= (struct sockaddr_in6
*)addr
;
260 if (!(dst
= malloc( sizeof(*dst
) ))) return NULL
;
261 dst
->sin6_family
= src
->sin6_family
;
262 dst
->sin6_port
= src
->sin6_port
;
263 dst
->sin6_flowinfo
= src
->sin6_flowinfo
;
264 dst
->sin6_addr
= src
->sin6_addr
;
265 dst
->sin6_scope_id
= src
->sin6_scope_id
;
266 ret
= (struct sockaddr_hdr
*)dst
;
270 FIXME( "address family %u not supported\n", addr
->sa_family
);
277 static struct pcap_address
*build_win32_address( struct pcap_address
*src
)
279 struct pcap_address
*dst
;
281 if (!(dst
= calloc( 1, sizeof(*dst
) ))) return NULL
;
282 if (src
->addr
&& !(dst
->addr
= dup_sockaddr( src
->addr
))) goto err
;
283 if (src
->netmask
&& !(dst
->netmask
= dup_sockaddr( src
->netmask
))) goto err
;
284 if (src
->broadaddr
&& !(dst
->broadaddr
= dup_sockaddr( src
->broadaddr
))) goto err
;
285 if (src
->dstaddr
&& !(dst
->dstaddr
= dup_sockaddr( src
->dstaddr
))) goto err
;
290 free( dst
->netmask
);
291 free( dst
->broadaddr
);
292 free( dst
->dstaddr
);
297 static void add_win32_address( struct pcap_address
**list
, struct pcap_address
*addr
)
299 struct pcap_address
*cur
= *list
;
300 if (!cur
) *list
= addr
;
303 while (cur
->next
) { cur
= cur
->next
; }
308 static struct pcap_address
*build_win32_addresses( struct pcap_address
*addrs
)
310 struct pcap_address
*src
, *dst
, *ret
= NULL
;
314 if ((dst
= build_win32_address( src
))) add_win32_address( &ret
, dst
);
320 static struct pcap_interface
*build_win32_device( const struct pcap_interface
*unix_dev
, const char *source
,
321 const char *adapter_name
)
323 struct pcap_interface
*ret
;
325 if (!(ret
= calloc( 1, sizeof(*ret
) ))) return NULL
;
326 if (!(ret
->name
= build_win32_name( source
, adapter_name
))) goto err
;
327 if (!(ret
->description
= build_win32_description( unix_dev
))) goto err
;
328 ret
->addresses
= build_win32_addresses( unix_dev
->addresses
);
329 ret
->flags
= unix_dev
->flags
;
334 free( ret
->description
);
335 free_addresses( ret
->addresses
);
340 static void add_win32_device( struct pcap_interface
**list
, struct pcap_interface
*dev
)
342 struct pcap_interface
*cur
= *list
;
343 if (!cur
) *list
= dev
;
346 while (cur
->next
) { cur
= cur
->next
; }
351 static int find_all_devices( const char *source
, struct pcap_interface
**devs
, char *errbuf
)
353 struct pcap_interface
*unix_devs
, *win32_devs
= NULL
, *cur
, *dev
;
354 IP_ADAPTER_ADDRESSES
*ptr
, *adapters
= get_adapters();
355 struct findalldevs_params params
= { &unix_devs
, errbuf
};
360 if (errbuf
) sprintf( errbuf
, "Out of memory." );
364 if (!(ret
= PCAP_CALL( findalldevs
, ¶ms
)))
369 if ((ptr
= find_adapter( adapters
, cur
->name
)) && (dev
= build_win32_device( cur
, source
, ptr
->AdapterName
)))
371 add_win32_device( &win32_devs
, dev
);
376 PCAP_CALL( freealldevs
, unix_devs
);
383 int CDECL
pcap_findalldevs( struct pcap_interface
**devs
, char *errbuf
)
385 TRACE( "%p, %p\n", devs
, errbuf
);
386 return find_all_devices( NULL
, devs
, errbuf
);
389 int CDECL
pcap_findalldevs_ex( char *source
, void *auth
, struct pcap_interface
**devs
, char *errbuf
)
391 FIXME( "%s, %p, %p, %p: partial stub\n", debugstr_a(source
), auth
, devs
, errbuf
);
392 return find_all_devices( source
, devs
, errbuf
);
395 void CDECL
pcap_free_datalinks( int *links
)
397 TRACE( "%p\n", links
);
398 PCAP_CALL( free_datalinks
, links
);
401 void CDECL
pcap_free_tstamp_types( int *types
)
403 TRACE( "%p\n", types
);
404 PCAP_CALL( free_tstamp_types
, types
);
407 void CDECL
pcap_freealldevs( struct pcap_interface
*devs
)
409 TRACE( "%p\n", devs
);
410 free_devices( devs
);
413 void CDECL
pcap_freecode( void *program
)
415 TRACE( "%p\n", program
);
416 PCAP_CALL( freecode
, program
);
419 void * CDECL
pcap_get_airpcap_handle( struct pcap
*pcap
)
421 TRACE( "%p\n", pcap
);
425 int CDECL
pcap_get_tstamp_precision( struct pcap
*pcap
)
427 TRACE( "%p\n", pcap
);
428 return PCAP_CALL( get_tstamp_precision
, pcap
);
431 char * CDECL
pcap_geterr( struct pcap
*pcap
)
434 struct geterr_params params
= { pcap
, &ret
};
435 TRACE( "%p\n", pcap
);
436 PCAP_CALL( geterr
, ¶ms
);
440 int CDECL
pcap_getnonblock( struct pcap
*pcap
, char *errbuf
)
442 struct getnonblock_params params
= { pcap
, errbuf
};
443 TRACE( "%p, %p\n", pcap
, errbuf
);
444 return PCAP_CALL( getnonblock
, ¶ms
);
447 static char lib_version
[256];
448 static BOOL WINAPI
init_lib_version( INIT_ONCE
*once
, void *param
, void **ctx
)
450 struct lib_version_params params
= { lib_version
, sizeof(lib_version
) };
451 PCAP_CALL( lib_version
, ¶ms
);
455 const char * CDECL
pcap_lib_version( void )
457 static INIT_ONCE once
= INIT_ONCE_STATIC_INIT
;
458 if (!lib_version
[0]) InitOnceExecuteOnce( &once
, init_lib_version
, NULL
, NULL
);
459 TRACE( "%s\n", debugstr_a(lib_version
) );
463 int CDECL
pcap_list_datalinks( struct pcap
*pcap
, int **buf
)
465 struct list_datalinks_params params
= { pcap
, buf
};
466 TRACE( "%p, %p\n", pcap
, buf
);
467 return PCAP_CALL( list_datalinks
, ¶ms
);
470 int CDECL
pcap_list_tstamp_types( struct pcap
*pcap
, int **types
)
472 struct list_tstamp_types_params params
= { pcap
, types
};
473 TRACE( "%p, %p\n", pcap
, types
);
474 return PCAP_CALL( list_tstamp_types
, ¶ms
);
477 char * CDECL
pcap_lookupdev( char *errbuf
)
480 struct pcap_interface
*devs
;
482 TRACE( "%p\n", errbuf
);
485 if (pcap_findalldevs( &devs
, errbuf
) == -1 || !devs
) return NULL
;
486 if ((ret
= malloc( strlen(devs
->name
) + 1 ))) strcpy( ret
, devs
->name
);
487 pcap_freealldevs( devs
);
492 int CDECL
pcap_lookupnet( const char *device
, unsigned int *net
, unsigned int *mask
, char *errbuf
)
494 struct lookupnet_params params
= { device
, net
, mask
, errbuf
};
495 TRACE( "%s, %p, %p, %p\n", debugstr_a(device
), net
, mask
, errbuf
);
496 return PCAP_CALL( lookupnet
, ¶ms
);
499 int CDECL
pcap_loop( struct pcap
*pcap
, int count
,
500 void (CALLBACK
*callback
)(unsigned char *, const struct pcap_pkthdr_win32
*, const unsigned char *),
503 /* FIXME: reimplement on top of pcap_next_ex */
504 FIXME( "%p, %d, %p, %p: not implemented\n", pcap
, count
, callback
, user
);
508 int CDECL
pcap_major_version( struct pcap
*pcap
)
510 TRACE( "%p\n", pcap
);
511 return PCAP_CALL( major_version
, pcap
);
514 int CDECL
pcap_minor_version( struct pcap
*pcap
)
516 TRACE( "%p\n", pcap
);
517 return PCAP_CALL( minor_version
, pcap
);
520 int CDECL
pcap_next_ex( struct pcap
*pcap
, struct pcap_pkthdr_win32
**hdr
, const unsigned char **data
)
522 struct next_ex_params params
= { pcap
, hdr
, data
};
523 TRACE( "%p, %p, %p\n", pcap
, hdr
, data
);
524 return PCAP_CALL( next_ex
, ¶ms
);
527 const unsigned char * CDECL
pcap_next( struct pcap
*pcap
, struct pcap_pkthdr_win32
*hdr
)
529 struct pcap_pkthdr_win32
*hdr_ptr
;
530 const unsigned char *data
;
532 pcap_next_ex( pcap
, &hdr_ptr
, &data
);
537 int CDECL
pcap_dispatch( struct pcap
*pcap
, int count
,
538 void (CALLBACK
*callback
)(unsigned char *, const struct pcap_pkthdr_win32
*, const unsigned char *),
539 unsigned char *user
)
542 TRACE( "%p, %d, %p, %p\n", pcap
, count
, callback
, user
);
544 while (processed
< count
)
546 struct pcap_pkthdr_win32
*hdr
= NULL
;
547 const unsigned char *data
= NULL
;
549 int ret
= pcap_next_ex( pcap
, &hdr
, &data
);
557 if (processed
== 0) return -2;
563 callback( user
, hdr
, data
);
569 static char *strdupWA( const WCHAR
*src
)
572 int len
= WideCharToMultiByte( CP_ACP
, 0, src
, -1, NULL
, 0, NULL
, NULL
);
573 if ((dst
= malloc( len
))) WideCharToMultiByte( CP_ACP
, 0, src
, -1, dst
, len
, NULL
, NULL
);
577 static char *map_win32_device_name( const char *dev
)
579 IP_ADAPTER_ADDRESSES
*ptr
, *adapters
= get_adapters();
580 const char *name
= strchr( dev
, '{' );
583 if (!adapters
|| !name
) return NULL
;
584 for (ptr
= adapters
; ptr
; ptr
= ptr
->Next
)
586 if (!strcmp( name
, ptr
->AdapterName
))
588 ret
= strdupWA( ptr
->FriendlyName
);
596 struct pcap
* CDECL
pcap_create( const char *source
, char *errbuf
)
600 TRACE( "%s, %p\n", source
, errbuf
);
602 if (!(unix_dev
= map_win32_device_name( source
)))
604 if (errbuf
) sprintf( errbuf
, "Unable to open the adapter." );
609 struct create_params params
= { unix_dev
, errbuf
, &ret
};
610 PCAP_CALL( create
, ¶ms
);
616 static struct pcap
*open_live( const char *source
, int snaplen
, int promisc
, int timeout
, char *errbuf
)
621 if (!(unix_dev
= map_win32_device_name( source
)))
623 if (errbuf
) sprintf( errbuf
, "Unable to open the adapter." );
628 struct open_live_params params
= { unix_dev
, snaplen
, promisc
, timeout
, errbuf
, &ret
};
629 PCAP_CALL( open_live
, ¶ms
);
635 #define PCAP_OPENFLAG_PROMISCUOUS 1
636 struct pcap
* CDECL
pcap_open( const char *source
, int snaplen
, int flags
, int timeout
, void *auth
, char *errbuf
)
638 FIXME( "%s, %d, %d, %d, %p, %p: partial stub\n", debugstr_a(source
), snaplen
, flags
, timeout
, auth
, errbuf
);
639 return open_live( source
, snaplen
, flags
& PCAP_OPENFLAG_PROMISCUOUS
, timeout
, errbuf
);
642 struct pcap
* CDECL
pcap_open_live( const char *source
, int snaplen
, int promisc
, int to_ms
, char *errbuf
)
644 TRACE( "%s, %d, %d, %d, %p\n", debugstr_a(source
), snaplen
, promisc
, to_ms
, errbuf
);
645 return open_live( source
, snaplen
, promisc
, to_ms
, errbuf
);
648 #define PCAP_SRC_FILE 2
649 #define PCAP_SRC_IFLOCAL 3
651 int CDECL
pcap_parsesrcstr( const char *source
, int *type
, char *host
, char *port
, char *name
, char *errbuf
)
653 int t
= PCAP_SRC_IFLOCAL
;
654 const char *p
= source
;
656 FIXME( "%s, %p, %p, %p, %p, %p: partial stub\n", debugstr_a(source
), type
, host
, port
, name
, errbuf
);
665 if (!strncmp(p
, "rpcap://", strlen("rpcap://")))
666 p
+= strlen("rpcap://");
667 else if (!strncmp(p
, "file://", strlen("file://")))
669 p
+= strlen("file://");
679 sprintf(errbuf
, "The name has not been specified in the source string.");
689 int CDECL
pcap_sendpacket( struct pcap
*pcap
, const unsigned char *buf
, int size
)
691 struct sendpacket_params params
= { pcap
, buf
, size
};
692 TRACE( "%p, %p, %d\n", pcap
, buf
, size
);
693 return PCAP_CALL( sendpacket
, ¶ms
);
696 int CDECL
pcap_set_buffer_size( struct pcap
*pcap
, int size
)
698 struct set_buffer_size_params params
= { pcap
, size
};
699 TRACE( "%p, %d\n", pcap
, size
);
700 return PCAP_CALL( set_buffer_size
, ¶ms
);
703 int CDECL
pcap_set_datalink( struct pcap
*pcap
, int link
)
705 struct set_datalink_params params
= { pcap
, link
};
706 TRACE( "%p, %d\n", pcap
, link
);
707 return PCAP_CALL( set_datalink
, ¶ms
);
710 int CDECL
pcap_set_promisc( struct pcap
*pcap
, int enable
)
712 struct set_promisc_params params
= { pcap
, enable
};
713 TRACE( "%p, %d\n", pcap
, enable
);
714 return PCAP_CALL( set_promisc
, ¶ms
);
717 int CDECL
pcap_set_rfmon( struct pcap
*pcap
, int enable
)
719 struct set_rfmon_params params
= { pcap
, enable
};
720 TRACE( "%p, %d\n", pcap
, enable
);
721 return PCAP_CALL( set_rfmon
, ¶ms
);
724 int CDECL
pcap_set_snaplen( struct pcap
*pcap
, int len
)
726 struct set_snaplen_params params
= { pcap
, len
};
727 TRACE( "%p, %d\n", pcap
, len
);
728 return PCAP_CALL( set_snaplen
, ¶ms
);
731 int CDECL
pcap_set_timeout( struct pcap
*pcap
, int timeout
)
733 struct set_timeout_params params
= { pcap
, timeout
};
734 TRACE( "%p, %d\n", pcap
, timeout
);
735 return PCAP_CALL( set_timeout
, ¶ms
);
738 int CDECL
pcap_set_tstamp_precision( struct pcap
*pcap
, int precision
)
740 struct set_tstamp_precision_params params
= { pcap
, precision
};
741 TRACE( "%p, %d\n", pcap
, precision
);
742 return PCAP_CALL( set_tstamp_precision
, ¶ms
);
745 int CDECL
pcap_set_tstamp_type( struct pcap
*pcap
, int type
)
747 struct set_tstamp_type_params params
= { pcap
, type
};
748 TRACE( "%p, %d\n", pcap
, type
);
749 return PCAP_CALL( set_tstamp_type
, ¶ms
);
752 int CDECL
pcap_setbuff( struct pcap
*pcap
, int size
)
754 FIXME( "%p, %d\n", pcap
, size
);
758 int CDECL
pcap_setfilter( struct pcap
*pcap
, void *program
)
760 struct setfilter_params params
= { pcap
, program
};
761 TRACE( "%p, %p\n", pcap
, program
);
762 return PCAP_CALL( setfilter
, ¶ms
);
765 int CDECL
pcap_setnonblock( struct pcap
*pcap
, int nonblock
, char *errbuf
)
767 struct setnonblock_params params
= { pcap
, nonblock
, errbuf
};
768 TRACE( "%p, %d, %p\n", pcap
, nonblock
, errbuf
);
769 return PCAP_CALL( setnonblock
, ¶ms
);
772 int CDECL
pcap_snapshot( struct pcap
*pcap
)
774 TRACE( "%p\n", pcap
);
775 return PCAP_CALL( snapshot
, pcap
);
778 int CDECL
pcap_stats( struct pcap
*pcap
, void *stats
)
780 struct stats_params params
= { pcap
, stats
};
781 TRACE( "%p, %p\n", pcap
, stats
);
782 return PCAP_CALL( stats
, ¶ms
);
785 const char * CDECL
pcap_statustostr( int status
)
788 struct statustostr_params params
= { status
, &ret
};
789 TRACE( "%d\n", status
);
790 PCAP_CALL( statustostr
, ¶ms
);
794 int CDECL
pcap_tstamp_type_name_to_val( const char *name
)
796 struct tstamp_type_name_to_val_params params
= { name
};
797 TRACE( "%s\n", debugstr_a(name
) );
798 return PCAP_CALL( tstamp_type_name_to_val
, ¶ms
);
801 const char * CDECL
pcap_tstamp_type_val_to_description( int val
)
804 struct tstamp_type_val_to_description_params params
= { val
, &ret
};
805 TRACE( "%d\n", val
);
806 PCAP_CALL( tstamp_type_val_to_description
, ¶ms
);
810 const char * CDECL
pcap_tstamp_type_val_to_name( int val
)
813 struct tstamp_type_val_to_name_params params
= { val
, &ret
};
814 TRACE( "%d\n", val
);
815 PCAP_CALL( tstamp_type_val_to_name
, ¶ms
);
819 int CDECL
wsockinit( void )
823 if (WSAStartup( MAKEWORD(1, 1), &wsadata
)) return -1;
827 BOOL WINAPI
DllMain( HINSTANCE hinst
, DWORD reason
, void *reserved
)
831 case DLL_PROCESS_ATTACH
:
832 DisableThreadLibraryCalls( hinst
);
833 if (NtQueryVirtualMemory( GetCurrentProcess(), hinst
, MemoryWineUnixFuncs
,
834 &pcap_handle
, sizeof(pcap_handle
), NULL
))
835 ERR( "No pcap support, expect problems\n" );
837 case DLL_PROCESS_DETACH
: