Skip to content

Commit

Permalink
[WPCAP] Import wpcap
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Sep 24, 2024
1 parent 5ca8cc2 commit ba8045b
Show file tree
Hide file tree
Showing 15 changed files with 2,393 additions and 0 deletions.
95 changes: 95 additions & 0 deletions dll/3rdparty/wpcap/PRJ/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Makefile for cygwin gcc
# Nate Lawson <[email protected]>

# Set according to your system type
SYSTYPE = "NT"
# SYSTYPE = "9x"

# OPTFLAGS = -g
OPTFLAGS = -O
# DO _NOT_ USE -O2! Causes fault upon startup.

#
# Flex and bison allow you to specify the prefixes of the global symbols
# used by the generated parser. This allows programs to use lex/yacc
# and link against libpcap. If you don't have flex or bison, get them.
#
LFLAGS = -Ppcap_
YFLAGS = -y -p pcap_

FLEX = flex
BISON = bison

PACKET_DIR = packetNtx
INSTALL_DIR = ${SYSTEMROOT}\system32

CFLAGS = -I ../libpcap -I ../libpcap/bpf -I ../libpcap/lbl \
-I ../libpcap/Win32/Include -I../libpcap/Win32/Include/ipv6kit \
-I ../../Common -I ../Win32-Extensions \
-I ../../../AirPcap_DevPack/include \
-DLIBPCAP_EXPORTS -DYY_NEVER_INTERACTIVE -Dyylval=pcap_lval \
-DHAVE_STRERROR -DNEED_ADDRINFO_H -DINET6 -DWIN32 \
-DSIZEOF_CHAR=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG_LONG=8 -DWPCAP -D'_U_=' \
-DHAVE_SNPRINTF -DHAVE_VSNPRINTF \
-DSIZEOF_LONG_LONG=8 \
-DHAVE_REMOTE -DHAVE_AIRPCAP_API \
-DHAVE_TC_API \
-DHAVE_ADDRINFO \
-DHAVE_LIMITS_H \
-DYY_NO_UNISTD_H \
-mno-cygwin -shared ${OPTFLAGS}
LDFLAGS = -Wl,--out-implib,../lib/libwpcap.a
LIBS = -L ../../${PACKET_DIR}/Dll/Project -lpacket -lws2_32
OBJS = ../libpcap/bpf/net/bpf_filter.o \
../libpcap/bpf_dump.o \
../libpcap/bpf_image.o \
../libpcap/etherent.o \
../libpcap/Win32/Src/ffs.o \
../libpcap/gencode.o\
../libpcap/Win32/Src/getnetbynm.o \
../libpcap/Win32/Src/getnetent.o \
../libpcap/Win32/Src/getservent.o \
../libpcap/grammar.o \
../libpcap/Win32/Src/getaddrinfo.o \
../libpcap/inet.o \
../libpcap/Win32/Src/inet_aton.o \
../libpcap/Win32/Src/inet_net.o \
../libpcap/Win32/Src/inet_pton.o \
../libpcap/nametoaddr.o \
../libpcap/optimize.o \
../libpcap/pcap-win32.o \
../libpcap/fad-win32.o \
../libpcap/pcap.o \
../libpcap/savefile.o \
../libpcap/scanner.o \
../libpcap/pcap-new.o \
../libpcap/pcap-remote.o \
../libpcap/sockutils.o \
../libpcap/Win32/Src/gai_strerror.o \
../libpcap/pcap-tc.o \
../Win32-Extensions/Win32-Extensions.o

main: ${OBJS}
@${RM} -rf ../lib/
mkdir ../lib/
${CC} ${CFLAGS} ${LDFLAGS} -o wpcap.dll WPCAP.DEF ${OBJS} ${LIBS}

install:
cp wpcap.dll ${INSTALL_DIR}

clean:
${RM} ${OBJS} ../libpcap/scanner.c ../libpcap/grammar.c wpcap.a wpcap.dll

# Keeps intermediate .c files from being deleted
.SECONDARY: ../libpcap/scanner.c ../libpcap/grammar.c

.y.c:
@${RM} ../libpcap/grammar.c ../libpcap/tokdefs.h
${BISON} ${YFLAGS} -d $<
mv y.tab.c ../libpcap/grammar.c
mv y.tab.h ../libpcap/tokdefs.h
.l.c:
@${RM} $@
${FLEX} ${LFLAGS} -t $< >$*.c
.c.o:
${CC} ${CFLAGS} -o $*.o -c $<
93 changes: 93 additions & 0 deletions dll/3rdparty/wpcap/PRJ/WPCAP.DEF
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
LIBRARY wpcap.dll

EXPORTS
pcap_lookupdev
pcap_lookupnet
pcap_open_live
pcap_open_offline
pcap_close
pcap_getnonblock
pcap_setnonblock
pcap_loop
pcap_dispatch
pcap_read
pcap_setuserbuffer
pcap_offline_read
pcap_next
pcap_stats
pcap_stats_ex
pcap_setfilter
pcap_perror
pcap_strerror
pcap_geterr
pcap_compile
pcap_compile_nopcap
pcap_freecode
pcap_datalink
pcap_snapshot
pcap_is_swapped
pcap_major_version
pcap_minor_version
pcap_file
pcap_fileno
pcap_dump_open
pcap_dump_close
pcap_dump_flush
pcap_dump
pcap_dump_file
pcap_setbuff
pcap_setmode
pcap_sendpacket
pcap_sendqueue_alloc
pcap_sendqueue_destroy
pcap_sendqueue_queue
pcap_sendqueue_transmit
pcap_next_etherent
pcap_getevent
pcap_setmintocopy
pcap_open_dead
pcap_findalldevs
pcap_freealldevs
pcap_live_dump
pcap_live_dump_ended
bpf_filter
bpf_validate
bpf_image
bpf_dump
wsockinit
endservent
getservent
eproto_db
pcap_stats_ex
pcap_open
pcap_createsrcstr
pcap_parsesrcstr
pcap_findalldevs_ex
pcap_remoteact_accept
pcap_remoteact_list
pcap_remoteact_close
pcap_remoteact_cleanup
install_bpf_program
pcap_next_ex
pcap_offline_filter
pcap_setsampling
pcap_breakloop
pcap_list_datalinks
pcap_list_datalinks
pcap_set_datalink
pcap_datalink_name_to_val
pcap_datalink_val_to_name
pcap_datalink_val_to_description
pcap_lib_version
pcap_dump_file
pcap_dump_ftell
pcap_get_airpcap_handle
pcap_create
pcap_activate
pcap_set_promisc
pcap_set_snaplen
pcap_set_timeout
pcap_set_buffer_size
pcap_hopen_offline
pcap_setdirection
pcap_free_datalinks
59 changes: 59 additions & 0 deletions dll/3rdparty/wpcap/PRJ/WPCAP.dsw
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

###############################################################################

Project: "libpcap"=..\libpcap\Win32\Prj\libpcap.dsp - Package Owner=<4>

Package=<5>
{{{
}}}

Package=<4>
{{{
}}}

###############################################################################

Project: "rpcapd"=..\libpcap\rpcapd\rpcapd.dsp - Package Owner=<4>

Package=<5>
{{{
}}}

Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wpcap
End Project Dependency
}}}

###############################################################################

Project: "wpcap"=.\wpcap.dsp - Package Owner=<4>

Package=<5>
{{{
}}}

Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libpcap
End Project Dependency
}}}

###############################################################################

Global:

Package=<5>
{{{
}}}

Package=<3>
{{{
}}}

###############################################################################

77 changes: 77 additions & 0 deletions dll/3rdparty/wpcap/PRJ/Wpcap_no_extensions.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
LIBRARY wpcap.dll

DESCRIPTION 'Win32 Packet Capture Library'

EXPORTS
pcap_lookupdev
pcap_lookupnet
pcap_open_live
pcap_open_offline
pcap_close
pcap_getnonblock
pcap_setnonblock
pcap_loop
pcap_dispatch
pcap_read
pcap_setuserbuffer
pcap_offline_read
pcap_next
pcap_stats
pcap_stats_ex
pcap_setfilter
pcap_perror
pcap_strerror
pcap_geterr
pcap_compile
pcap_compile_nopcap
pcap_freecode
pcap_datalink
pcap_snapshot
pcap_is_swapped
pcap_major_version
pcap_minor_version
pcap_file
pcap_fileno
pcap_dump_open
pcap_dump_close
pcap_dump_flush
pcap_dump
pcap_dump_file
pcap_setbuff
pcap_setmode
pcap_sendpacket
pcap_sendqueue_alloc
pcap_sendqueue_destroy
pcap_sendqueue_queue
pcap_sendqueue_transmit
pcap_next_etherent
pcap_getevent
pcap_setmintocopy
pcap_open_dead
pcap_findalldevs
pcap_freealldevs
pcap_live_dump
pcap_live_dump_ended
bpf_filter
bpf_validate
bpf_image
bpf_dump
wsockinit
endservent
getservent
eproto_db
pcap_stats_ex
install_bpf_program
pcap_next_ex
pcap_offline_filter
pcap_breakloop
pcap_list_datalinks
pcap_list_datalinks
pcap_set_datalink
pcap_datalink_name_to_val
pcap_datalink_val_to_name
pcap_datalink_val_to_description
pcap_lib_version
pcap_dump_file
pcap_dump_ftell
pcap_get_airpcap_handle
26 changes: 26 additions & 0 deletions dll/3rdparty/wpcap/PRJ/build_scanner_parser.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off

echo Building the libpcap parser and scanner...
del /Q /F ..\libpcap\grammar.c > nul 2> nul
del /Q /F ..\libpcap\tokdefs.h > nul 2> nul

bison -y -p pcap_ -d ../libpcap/GRAMMAR.Y > nul
if not %ERRORLEVEL% == 0 (
echo failure in generating the grammar.
goto end
)

move y.tab.c ..\libpcap\grammar.c
move y.tab.h ..\libpcap\tokdefs.h

del /Q /F ..\libpcap\scanner.c >/nul 2>/nul
flex -Ppcap_ -t ../libpcap/scanner.l > ../libpcap/scanner.c

if not %ERRORLEVEL% == 0 (
echo failure in generating the scanner.
goto end
)

echo --- Done!

:end
Loading

0 comments on commit ba8045b

Please sign in to comment.