@@ -35,7 +35,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
3535#include <stdlib.h>
3636#include <string.h>
3737#include <stdio.h>
38- #include <sys/time.h>
3938#include <time.h>
4039#include <math.h>
4140#include <pcap.h>
@@ -44,6 +43,10 @@ THE POSSIBILITY OF SUCH DAMAGE.
4443#include "lauxlib.h"
4544#include "lualib.h"
4645
46+ #ifdef WIN32
47+ #include <wt-win-common.h>
48+ #endif
49+
4750static double tv2secs (struct timeval * tv )
4851{
4952 double secs = tv -> tv_sec ;
@@ -58,11 +61,11 @@ static struct timeval* secs2tv(double secs, struct timeval* tv)
5861
5962 fpart = modf (secs , & ipart );
6063
61- tv -> tv_sec = (time_t ) ipart ;
64+ tv -> tv_sec = (long ) ipart ;
6265
6366 fpart = modf (fpart * 1000000.0 , & ipart );
6467
65- tv -> tv_usec = (suseconds_t ) ipart ;
68+ tv -> tv_usec = (long ) ipart ;
6669
6770 if (fpart > 0.5 )
6871 tv -> tv_usec += 1 ;
@@ -369,6 +372,7 @@ Get a selectable file descriptor number which can be used to wait for packets.
369372Returns the descriptor number on success, or nil if no such descriptor is
370373available (see pcap_get_selectable_fd).
371374*/
375+ #ifndef WIN32
372376static int lpcap_getfd (lua_State * L )
373377{
374378 pcap_t * cap = checkpcap (L );
@@ -381,6 +385,7 @@ static int lpcap_getfd(lua_State* L)
381385 lua_pushnumber (L , fd );
382386 return 1 ;
383387}
388+ #endif
384389
385390/*-
386391-- capdata, timestamp, wirelen = cap:next()
@@ -447,6 +452,7 @@ Injects packet.
447452
448453Return is bytes sent on success, or nil,emsg on failure.
449454*/
455+ #ifndef WIN32
450456static int lpcap_inject (lua_State * L )
451457{
452458 pcap_t * cap = checkpcap (L );
@@ -464,6 +470,7 @@ static int lpcap_inject(lua_State* L)
464470 return 1 ;
465471}
466472
473+ #endif
467474
468475/* Wrap pcap_dumper_t */
469476
@@ -620,8 +627,8 @@ Combine seperate seconds and microseconds into one numeric seconds.
620627static int lpcap_tv2secs (lua_State * L )
621628{
622629 struct timeval tv ;
623- tv .tv_sec = luaL_checknumber (L , 1 );
624- tv .tv_usec = luaL_checknumber (L , 2 );
630+ tv .tv_sec = ( long ) luaL_checknumber (L , 1 );
631+ tv .tv_usec = ( long ) luaL_checknumber (L , 2 );
625632
626633 lua_pushnumber (L , tv2secs (& tv ));
627634 return 1 ;
@@ -666,10 +673,14 @@ static const luaL_reg pcap_methods[] =
666673 {"set_filter" , lpcap_set_filter },
667674 {"datalink" , lpcap_datalink },
668675 {"snapshot" , lpcap_snapshot },
676+ #ifndef WIN32
669677 {"getfd" , lpcap_getfd },
678+ #endif
670679 {"next" , lpcap_next },
671680 /* TODO - wt_pcap.c also had a next_nonblocking(), I'm not sure why a setnonblocking() wasn't sufficient */
681+ #ifndef WIN32
672682 {"inject" , lpcap_inject },
683+ #endif
673684 {NULL , NULL }
674685};
675686
@@ -683,7 +694,7 @@ static const luaL_reg dumper_methods[] =
683694};
684695
685696
686- LUALIB_API int luaopen_pcap (lua_State * L )
697+ int luaopen_pcap (lua_State * L )
687698{
688699 v_obj_metatable (L , L_PCAP_DUMPER_REGID , dumper_methods );
689700 v_obj_metatable (L , L_PCAP_REGID , pcap_methods );
0 commit comments