mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Upgrade libpcap to 1.8.1 (Nmap-specific patches not yet applied)
This commit is contained in:
@@ -1,3 +1,53 @@
|
|||||||
|
Tuesday, Oct. 25, 2016 mcr@sandelman.ca
|
||||||
|
Summary for 1.8.1 libpcap release
|
||||||
|
Add a target in Makefile.in for Exuberant Ctags use: 'extags'.
|
||||||
|
Rename configure.in to configure.ac: autoconf 2.59
|
||||||
|
Clean up the name-to-DLT mapping table.
|
||||||
|
Add some newer DLT_ values: IPMI_HPM_2,ZWAVE_R1_R2,ZWAVE_R3,WATTSTOPPER_DLM,ISO_14443,RDS
|
||||||
|
Clarify what the return values are for both success and failure.
|
||||||
|
Many changes to build on windows
|
||||||
|
Check for the "break the loop" condition in the inner loop for TPACKET_V3.
|
||||||
|
Fix handling of packet count in the TPACKET_V3 inner loop: GitHub issue #493.
|
||||||
|
Filter out duplicate looped back CAN frames.
|
||||||
|
Fix the handling of loopback filters for IPv6 packets.
|
||||||
|
Add a link-layer header type for RDS (IEC 62106) groups.
|
||||||
|
Use different intermediate folders for x86 and x64 builds on Windows.
|
||||||
|
On Linux, handle all CAN captures with pcap-linux.c, in cooked mode.
|
||||||
|
Removes the need for the "host-endian" link-layer header type.
|
||||||
|
Compile with '-Wused-but-marked-unused' in devel mode if supported
|
||||||
|
Have separate DLTs for big-endian and host-endian SocketCAN headers.
|
||||||
|
Reflect version.h being renamed to pcap_version.h.
|
||||||
|
Require that version.h be generated: all build procedures we support generate version.h (autoconf, CMake, MSVC)!
|
||||||
|
Properly check for sock_recv() errors.
|
||||||
|
Re-impose some of Winsock's limitations on sock_recv().
|
||||||
|
Replace sprintf() with pcap_snprintf().
|
||||||
|
Fix signature of pcap_stats_ex_remote().
|
||||||
|
Initial cmake support for remote packet capture.
|
||||||
|
Have rpcap_remoteact_getsock() return a SOCKET and supply an "is active" flag.
|
||||||
|
Clean up {DAG, Septel, Myricom SNF}-only builds.
|
||||||
|
Do UTF-16-to-ASCII conversion into the right place.
|
||||||
|
pcap_create_interface() needs the interface name on Linux.
|
||||||
|
Clean up hardware time stamp support: the "any" device does not support any time stamp types.
|
||||||
|
Add support for capturing on FreeBSD usbusN interfaces.
|
||||||
|
Add a LINKTYPE/DLT_ value for FreeBSD USB.
|
||||||
|
Go back to using PCAP_API on Windows.
|
||||||
|
CMake support
|
||||||
|
Add TurboCap support from WinPcap.
|
||||||
|
Recognize 802.1ad nested VLAN tag in vlan filter.
|
||||||
|
|
||||||
|
Thursday Sep. 3, 2015 guy@alum.mit.edu
|
||||||
|
Summary for 1.7.5 libpcap release
|
||||||
|
Man page cleanups.
|
||||||
|
Add some allocation failure checks.
|
||||||
|
Fix a number of Linux/ucLinux configure/build issues.
|
||||||
|
Fix some memory leaks.
|
||||||
|
Recognize 802.1ad nested VLAN tag in vlan filter.
|
||||||
|
Fix building Bluetooth Linux Monitor support with BlueZ 5.1+
|
||||||
|
|
||||||
|
Saturday Jun. 27, 2015 mcr@sandelman.ca
|
||||||
|
Summary for 1.7.4 libpcap release
|
||||||
|
Include fix for GitHub issue #424 -- out of tree builds.
|
||||||
|
|
||||||
Friday Apr. 10, 2015 guy@alum.mit.edu
|
Friday Apr. 10, 2015 guy@alum.mit.edu
|
||||||
Summary for 1.7.3 libpcap release
|
Summary for 1.7.3 libpcap release
|
||||||
Work around a Linux bonding driver bug.
|
Work around a Linux bonding driver bug.
|
||||||
|
|||||||
520
libpcap/CMakeLists.txt
Normal file
520
libpcap/CMakeLists.txt
Normal file
@@ -0,0 +1,520 @@
|
|||||||
|
cmake_minimum_required( VERSION 2.8.8 )
|
||||||
|
|
||||||
|
project( pcap )
|
||||||
|
#
|
||||||
|
# Call the library "wpcap" on Windows, for backwards compatibility.
|
||||||
|
#
|
||||||
|
if( WIN32 )
|
||||||
|
set( LIBRARY_NAME wpcap )
|
||||||
|
else()
|
||||||
|
set( LIBRARY_NAME pcap )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# Parameters
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
option (INET6 "Enable IPv6" ON)
|
||||||
|
if( MSVC )
|
||||||
|
option (USE_STATIC_RT "Use static Runtime" ON)
|
||||||
|
endif( MSVC )
|
||||||
|
option (BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||||
|
if( WIN32 )
|
||||||
|
set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX - this should be an option, defaulting to "yes" for Windows and to
|
||||||
|
# "no", for now, on UN*X.
|
||||||
|
#
|
||||||
|
if( WIN32 )
|
||||||
|
set( HAVE_REMOTE 1 )
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Project settings
|
||||||
|
######################################
|
||||||
|
|
||||||
|
add_definitions( -DHAVE_CONFIG_H )
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${pcap_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
if( NOT "${PACKET_DLL_DIR}" STREQUAL "" )
|
||||||
|
include_directories("${PACKET_DLL_DIR}/Include")
|
||||||
|
if( CMAKE_CL_64 )
|
||||||
|
link_directories("${PACKET_DLL_DIR}/Lib/x64")
|
||||||
|
else( CMAKE_CL_64 )
|
||||||
|
link_directories("${PACKET_DLL_DIR}/Lib")
|
||||||
|
endif( CMAKE_CL_64 )
|
||||||
|
endif()
|
||||||
|
include_directories(
|
||||||
|
../Common/
|
||||||
|
Win32/Include
|
||||||
|
)
|
||||||
|
endif( WIN32)
|
||||||
|
|
||||||
|
add_definitions( -DBUILDING_PCAP )
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
add_definitions( -D__STDC__ )
|
||||||
|
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
|
||||||
|
add_definitions( "-D_U_=" )
|
||||||
|
elseif( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
|
add_definitions( "-D_U_=__attribute__((unused))" )
|
||||||
|
else(MSVC)
|
||||||
|
add_definitions( "-D_U_=" )
|
||||||
|
endif( MSVC )
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
if (USE_STATIC_RT)
|
||||||
|
MESSAGE( STATUS "Use STATIC runtime" )
|
||||||
|
set(NAME_RT MT)
|
||||||
|
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||||
|
else (USE_STATIC_RT)
|
||||||
|
MESSAGE( STATUS "Use DYNAMIC runtime" )
|
||||||
|
set(NAME_RT MD)
|
||||||
|
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
|
||||||
|
endif (USE_STATIC_RT)
|
||||||
|
endif( MSVC )
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# Detect available platform features
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
include(CheckStructHasMember)
|
||||||
|
include(CheckTypeSize)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Header files.
|
||||||
|
#
|
||||||
|
check_include_file( inttypes.h HAVE_INTTYPES_H )
|
||||||
|
check_include_file( stdint.h HAVE_STDINT_H )
|
||||||
|
check_include_file( unistd.h HAVE_UNISTD_H )
|
||||||
|
if( NOT HAVE_UNISTD_H )
|
||||||
|
add_definitions( -DYY_NO_UNISTD_H )
|
||||||
|
endif( NOT HAVE_UNISTD_H )
|
||||||
|
check_include_file( bitypes.h HAVE_SYS_BITYPES_H )
|
||||||
|
check_include_file( limits.h HAVE_LIMITS_H )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Functions.
|
||||||
|
#
|
||||||
|
check_function_exists( strerror HAVE_STRERROR )
|
||||||
|
check_function_exists( strlcpy HAVE_STRLCPY )
|
||||||
|
check_function_exists( snprintf HAVE_SNPRINTF )
|
||||||
|
check_function_exists( vsnprintf HAVE_VSNPRINTF )
|
||||||
|
check_function_exists( strtok_r HAVE_STRTOK_R )
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
#
|
||||||
|
# Check for Windows-only functions, such as packet.dll functions.
|
||||||
|
#
|
||||||
|
check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Data types.
|
||||||
|
#
|
||||||
|
# XXX - there's no check_struct() macro that's like check_struct_has_member()
|
||||||
|
# except that it only checks for the existence of the structure type,
|
||||||
|
# so we use check_struct_has_member() and look for ss_family.
|
||||||
|
#
|
||||||
|
check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h)
|
||||||
|
check_type_size("socklen_t" SOCKLEN_T)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Structure fields.
|
||||||
|
#
|
||||||
|
check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN )
|
||||||
|
|
||||||
|
if( INET6 )
|
||||||
|
MESSAGE( STATUS "Use IPv6" )
|
||||||
|
endif( INET6 )
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
add_definitions( -DHAVE_ADDRINFO )
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# External dependencies
|
||||||
|
######################################
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Input files
|
||||||
|
######################################
|
||||||
|
|
||||||
|
set(PROJECT_SOURCE_LIST_C
|
||||||
|
bpf_dump.c
|
||||||
|
bpf_image.c
|
||||||
|
etherent.c
|
||||||
|
fad-helpers.c
|
||||||
|
gencode.c
|
||||||
|
inet.c
|
||||||
|
nametoaddr.c
|
||||||
|
optimize.c
|
||||||
|
pcap-common.c
|
||||||
|
pcap.c
|
||||||
|
savefile.c
|
||||||
|
sf-pcap-ng.c
|
||||||
|
sf-pcap.c
|
||||||
|
bpf/net/bpf_filter.c
|
||||||
|
)
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c )
|
||||||
|
else()
|
||||||
|
if( NOT HAVE_SNPRINTF )
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c )
|
||||||
|
endif( NOT HAVE_SNPRINTF )
|
||||||
|
if( NOT HAVE_STRTOK_R )
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c )
|
||||||
|
endif( NOT HAVE_STRTOK_R )
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
if( HAVE_REMOTE )
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C}
|
||||||
|
pcap-new.c pcap-rpcap.c sockutils.c)
|
||||||
|
endif( HAVE_REMOTE )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Determine the main pcap-XXX.c file to use.
|
||||||
|
#
|
||||||
|
if( WIN32 )
|
||||||
|
#
|
||||||
|
# WinPcap.
|
||||||
|
#
|
||||||
|
set( PCAP_TYPE win32 )
|
||||||
|
else()
|
||||||
|
#
|
||||||
|
# UN*X - figure out what type of packet capture mechanism we
|
||||||
|
# have.
|
||||||
|
#
|
||||||
|
if( EXISTS /dev/bpf )
|
||||||
|
#
|
||||||
|
# Cloning BPF device.
|
||||||
|
#
|
||||||
|
set( PCAP_TYPE bpf )
|
||||||
|
AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
|
||||||
|
elseif( EXISTS /dev/bpf0 )
|
||||||
|
set( PCAP_TYPE bpf )
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX - many more BPF checks.
|
||||||
|
#
|
||||||
|
elseif( EXISTS /usr/include/net/pfilt.h )
|
||||||
|
#
|
||||||
|
# DEC OSF/1, Digital UNIX, Tru64 UNIX
|
||||||
|
#
|
||||||
|
set( PCAP_TYPE pf )
|
||||||
|
elseif( EXISTS /dev/enet )
|
||||||
|
set( PCAP_TYPE enet )
|
||||||
|
elseif( EXISTS /dev/nit )
|
||||||
|
set( PCAP_TYPE snit )
|
||||||
|
elseif( EXISTS /usr/include/sys/net/nit.h )
|
||||||
|
set( PCAP_TYPE nit )
|
||||||
|
elseif( EXISTS /usr/include/linux/socket.h )
|
||||||
|
set( PCAP_TYPE linux )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Do we have the wireless extensions?
|
||||||
|
#
|
||||||
|
check_include_file( linux/wireless.h HAVE_LINUX_WIRELESS_H )
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX - many more Linux checks.
|
||||||
|
#
|
||||||
|
elseif( EXISTS /usr/include/net/raw.h )
|
||||||
|
set( PCAP_TYPE snoop )
|
||||||
|
elseif( EXISTS /usr/include/odmi.h )
|
||||||
|
#
|
||||||
|
# On AIX, the BPF devices might not yet be present - they're
|
||||||
|
# created the first time libpcap runs after booting.
|
||||||
|
# We check for odmi.h instead.
|
||||||
|
#
|
||||||
|
set( PCAP_TYPE bpf )
|
||||||
|
elseif( /usr/include/sys/dlpi.h )
|
||||||
|
set( PCAP_TYPE dlpi )
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX - many more DLPI checks.
|
||||||
|
#
|
||||||
|
else()
|
||||||
|
set( PCAP_TYPE null )
|
||||||
|
endif()
|
||||||
|
endif( WIN32 )
|
||||||
|
message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}")
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Now figure out how we get a list of interfaces and addresses,
|
||||||
|
# if we support capturing. Don't bother if we don't support
|
||||||
|
# capturing.
|
||||||
|
#
|
||||||
|
if( NOT WIN32 )
|
||||||
|
#
|
||||||
|
# UN*X - figure out what type of interface list mechanism we
|
||||||
|
# have.
|
||||||
|
#
|
||||||
|
if( ${PCAP_TYPE} STREQUAL "null" )
|
||||||
|
#
|
||||||
|
# We can't capture, so we can't open any capture
|
||||||
|
# devices, so we won't return any interfaces.
|
||||||
|
#
|
||||||
|
set( FINDALLDEVS_TYPE null )
|
||||||
|
else()
|
||||||
|
check_function_exists( getifaddrs HAVE_GETIFADDRS )
|
||||||
|
if( ${HAVE_GETIFADDRS} )
|
||||||
|
#
|
||||||
|
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
|
||||||
|
# as well, just in case some platform is really weird.
|
||||||
|
#
|
||||||
|
check_include_file( ifaddrs.h HAVE_IFADDRS_H )
|
||||||
|
if( ${HAVE_IFADDRS_H} )
|
||||||
|
#
|
||||||
|
# We have the header, so we use "getifaddrs()" to
|
||||||
|
# get the list of interfaces.
|
||||||
|
#
|
||||||
|
set( FINDALLDEVS_TYPE getad )
|
||||||
|
else()
|
||||||
|
#
|
||||||
|
# We don't have the header - give up.
|
||||||
|
# XXX - we could also fall back on some other
|
||||||
|
# mechanism, but, for now, this'll catch this
|
||||||
|
# problem so that we can at least try to figure
|
||||||
|
# out something to do on systems with "getifaddrs()"
|
||||||
|
# but without "ifaddrs.h", if there is something
|
||||||
|
# we can do on those systems.
|
||||||
|
#
|
||||||
|
message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>." )
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
#
|
||||||
|
# Well, we don't have "getifaddrs()", so we have to use
|
||||||
|
# some other mechanism; determine what that mechanism is.
|
||||||
|
#
|
||||||
|
# The first thing we use is the type of capture mechanism,
|
||||||
|
# which is somewhat of a proxy for the OS we're using.
|
||||||
|
#
|
||||||
|
if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" )
|
||||||
|
#
|
||||||
|
# This might be Solaris 8 or later, with
|
||||||
|
# SIOCGLIFCONF, or it might be some other OS
|
||||||
|
# or some older version of Solaris, with
|
||||||
|
# just SIOCGIFCONF.
|
||||||
|
#
|
||||||
|
try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" )
|
||||||
|
message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" )
|
||||||
|
if( HAVE_SIOCGLIFCONF )
|
||||||
|
set( FINDALLDEVS_TYPE glifc )
|
||||||
|
else()
|
||||||
|
set( FINDALLDEVS_TYPE gifc )
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
#
|
||||||
|
# Assume we just have SIOCGIFCONF.
|
||||||
|
# (XXX - on at least later Linux kernels, there's
|
||||||
|
# another mechanism, and we should be using that
|
||||||
|
# instead.)
|
||||||
|
#
|
||||||
|
set( FINDALLDEVS_TYPE gifc )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}")
|
||||||
|
set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(GLOB PROJECT_SOURCE_LIST_CORE_H
|
||||||
|
*.h
|
||||||
|
pcap/*.h
|
||||||
|
)
|
||||||
|
set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} )
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
file(GLOB PROJECT_SOURCE_LIST_WIN32_H
|
||||||
|
Win32/Include/*.h
|
||||||
|
)
|
||||||
|
set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} )
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
#
|
||||||
|
# {Flex} and YACC/Berkeley YACC/Bison.
|
||||||
|
# From a mail message to the CMake mailing list by Andy Cedilnik of
|
||||||
|
# Kitware.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to find Flex, a Windows version of Flex, or Lex.
|
||||||
|
#
|
||||||
|
find_program(LEX_EXECUTABLE NAMES flex win_flex lex)
|
||||||
|
if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" )
|
||||||
|
message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." )
|
||||||
|
endif()
|
||||||
|
message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
|
||||||
|
SOURCE ${pcap_SOURCE_DIR}/scanner.l
|
||||||
|
COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l
|
||||||
|
DEPENDS ${pcap_SOURCE_DIR}/scanner.l
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Since scanner.c does not exist yet when cmake is run, mark
|
||||||
|
# it as generated.
|
||||||
|
#
|
||||||
|
# Since scanner.c includes grammar.h, mark that as a dependency.
|
||||||
|
#
|
||||||
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES
|
||||||
|
GENERATED TRUE
|
||||||
|
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add scanner.c to the list of sources.
|
||||||
|
#
|
||||||
|
#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to find YACC or Bison.
|
||||||
|
#
|
||||||
|
find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc)
|
||||||
|
if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" )
|
||||||
|
message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." )
|
||||||
|
endif()
|
||||||
|
message(STATUS "Parser generator: ${YACC_EXECUTABLE}")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create custom command for the scanner.
|
||||||
|
# Find out whether it's Bison or notby looking at the last component
|
||||||
|
# of the path (without a .exe extension, if this is Windows).
|
||||||
|
#
|
||||||
|
get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE)
|
||||||
|
if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" )
|
||||||
|
set( YACC_COMPATIBILITY_FLAG "-y" )
|
||||||
|
endif()
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
|
||||||
|
SOURCE ${pcap_SOURCE_DIR}/grammar.y
|
||||||
|
COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y
|
||||||
|
DEPENDS ${pcap_SOURCE_DIR}/grammar.y
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Since grammar.c does not exists yet when cmake is run, mark
|
||||||
|
# it as generated.
|
||||||
|
#
|
||||||
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES
|
||||||
|
GENERATED TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add grammar.c to the list of sources.
|
||||||
|
#
|
||||||
|
#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c)
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
#
|
||||||
|
# CMake does not love Windows.
|
||||||
|
#
|
||||||
|
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/GenVersion.bat" GenVersion_path)
|
||||||
|
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/VERSION" VERSION_path)
|
||||||
|
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/pcap_version.h.in" version_h_in_path)
|
||||||
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h" version_h_path)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||||
|
SOURCE ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
|
||||||
|
COMMAND ${GenVersion_path} ${VERSION_path} ${version_h_in_path} ${version_h_path}
|
||||||
|
DEPENDS ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
|
||||||
|
)
|
||||||
|
else( WIN32 )
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c
|
||||||
|
SOURCE ${pcap_SOURCE_DIR}/VERSION
|
||||||
|
COMMAND ${pcap_SOURCE_DIR}/gen_version_c.sh ${pcap_SOURCE_DIR}/VERSION ${CMAKE_CURRENT_BINARY_DIR}/version.c
|
||||||
|
DEPENDS ${pcap_SOURCE_DIR}/VERSION
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||||
|
SOURCE ${pcap_SOURCE_DIR}/VERSION
|
||||||
|
COMMAND ${pcap_SOURCE_DIR}/gen_version_header.sh ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||||
|
DEPENDS ${pcap_SOURCE_DIR}/VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Since version.c does not exists yet when cmake is run, mark
|
||||||
|
# it as generated.
|
||||||
|
#
|
||||||
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c PROPERTIES
|
||||||
|
GENERATED TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add version.c to the list of sources.
|
||||||
|
#
|
||||||
|
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/version.c)
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Since pcap_version.h does not exists yet when cmake is run, mark
|
||||||
|
# it as generated.
|
||||||
|
#
|
||||||
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h PROPERTIES
|
||||||
|
GENERATED TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add pcap_version.h to the list of headers.
|
||||||
|
#
|
||||||
|
set(PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h)
|
||||||
|
|
||||||
|
source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
|
||||||
|
source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Register targets
|
||||||
|
######################################
|
||||||
|
|
||||||
|
add_library(${LIBRARY_NAME}
|
||||||
|
${PROJECT_SOURCE_LIST_C}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/grammar.c
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/scanner.c
|
||||||
|
${PROJECT_SOURCE_LIST_H}
|
||||||
|
)
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
target_link_libraries ( ${LIBRARY_NAME}
|
||||||
|
packet
|
||||||
|
ws2_32
|
||||||
|
)
|
||||||
|
endif( WIN32 )
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Write out the config.h file
|
||||||
|
######################################
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
23
libpcap/GenVersion.bat
Normal file
23
libpcap/GenVersion.bat
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
REM
|
||||||
|
REM Automatically generate pcap_version.h based on pcap_version.h.in
|
||||||
|
REM for Windows
|
||||||
|
REM The version string comes from VERSION
|
||||||
|
REM @echo off
|
||||||
|
REM
|
||||||
|
|
||||||
|
setlocal enableextensions disabledelayedexpansion
|
||||||
|
|
||||||
|
set "search=%%%%LIBPCAP_VERSION%%%%"
|
||||||
|
set /p replace=<%1
|
||||||
|
|
||||||
|
if exist %3 del %3 2>nul
|
||||||
|
|
||||||
|
for /f "delims=" %%i in ('type %2' ) do (
|
||||||
|
set "line=%%i"
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
set "line=!line:%search%=%replace%!"
|
||||||
|
>>%3 echo(!line!
|
||||||
|
endlocal
|
||||||
|
)
|
||||||
|
|
||||||
|
echo pcap_version.h generated
|
||||||
@@ -16,7 +16,7 @@ does support packet capture but libpcap does not support that
|
|||||||
particular type. (If you have HP-UX, see below.) If your system uses a
|
particular type. (If you have HP-UX, see below.) If your system uses a
|
||||||
packet capture not supported by libpcap, please send us patches; don't
|
packet capture not supported by libpcap, please send us patches; don't
|
||||||
forget to include an autoconf fragment suitable for use in
|
forget to include an autoconf fragment suitable for use in
|
||||||
configure.in.
|
configure.ac.
|
||||||
|
|
||||||
It is possible to override the default packet capture type, although
|
It is possible to override the default packet capture type, although
|
||||||
the circumstance where this works are limited. For example if you have
|
the circumstance where this works are limited. For example if you have
|
||||||
@@ -31,40 +31,22 @@ You will need an ANSI C compiler to build libpcap. The configure script
|
|||||||
will abort if your compiler is not ANSI compliant. If this happens, use
|
will abort if your compiler is not ANSI compliant. If this happens, use
|
||||||
the generally available GNU C compiler (GCC).
|
the generally available GNU C compiler (GCC).
|
||||||
|
|
||||||
If you use flex, you must use version 2.4.6 or higher. The configure
|
You will need either Flex 2.5.31 or later, or a version of Lex
|
||||||
script automatically detects the version of flex and will not use it
|
compatible with it (if any exist), to build libpcap. The configure
|
||||||
unless it is new enough. You can use "flex -V" to see what version you
|
script will abort if there isn't any such program. If you have an older
|
||||||
have (unless it's really old). The current version of flex is available
|
version of Flex, or don't have a compatible version of Lex, the current
|
||||||
at flex.sourceforge.net and often comes packaged by means of the OS.
|
version of flex is available at flex.sourceforge.net.
|
||||||
As of this writing, the current version is 2.5.37.
|
|
||||||
|
|
||||||
If you use bison, you must use flex (and visa versa). The configure
|
You will need either Bison, Berkeley YACC, or a version of YACC
|
||||||
script automatically falls back to lex and yacc if both flex and bison
|
compatible with them (if any exist), to build libpcap. The configure
|
||||||
are not found.
|
script will abort if there isn't any such program. If you don't have
|
||||||
|
any such program, the current version of Bison can be found at
|
||||||
|
http://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC
|
||||||
|
can be found at http://invisible-island.net/byacc/.
|
||||||
|
|
||||||
Sometimes the stock C compiler does not interact well with flex and
|
Sometimes the stock C compiler does not interact well with Flex and
|
||||||
bison. The list of problems includes undefined references for alloca.
|
Bison. The list of problems includes undefined references for alloca.
|
||||||
You can get around this by installing gcc or manually disabling flex
|
You can get around this by installing GCC.
|
||||||
and bison with:
|
|
||||||
|
|
||||||
./configure --without-flex --without-bison
|
|
||||||
|
|
||||||
If your system only has AT&T lex, this is okay unless your libpcap
|
|
||||||
program uses other lex/yacc generated code. (Although it's possible to
|
|
||||||
map the yy* identifiers with a script, we use flex and bison so we
|
|
||||||
don't feel this is necessary.)
|
|
||||||
|
|
||||||
Some systems support the Berkeley Packet Filter natively; for example
|
|
||||||
out of the box OSF and BSD/OS have bpf. If your system does not support
|
|
||||||
bpf, you will need to pick up:
|
|
||||||
|
|
||||||
ftp://ftp.ee.lbl.gov/bpf-*.tar.Z
|
|
||||||
|
|
||||||
Note well: you MUST have kernel source for your operating system in
|
|
||||||
order to install bpf. An exception is SunOS 4; the bpf distribution
|
|
||||||
includes replacement kernel objects for some of the standard SunOS 4
|
|
||||||
network device drivers. See the bpf INSTALL document for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
If you use Solaris, there is a bug with bufmod(7) that is fixed in
|
If you use Solaris, there is a bug with bufmod(7) that is fixed in
|
||||||
Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
|
Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
|
||||||
@@ -239,11 +221,11 @@ the libpcap 0.6.2 source release, so this release of libpcap might also
|
|||||||
build without changes on UnixWare 7.
|
build without changes on UnixWare 7.
|
||||||
|
|
||||||
If linking tcpdump fails with "Undefined: _alloca" when using bison on
|
If linking tcpdump fails with "Undefined: _alloca" when using bison on
|
||||||
a Sun4, your version of bison is broken. In any case version 1.16 or
|
a Sun4, your version of Bison is broken. In any case version 1.16 or
|
||||||
higher is recommended (1.14 is known to cause problems 1.16 is known to
|
higher is recommended (1.14 is known to cause problems 1.16 is known to
|
||||||
work). Either pick up a current version from:
|
work). Either pick up a current version from:
|
||||||
|
|
||||||
ftp://ftp.gnu.org/pub/gnu/bison
|
http://ftp.gnu.org/gnu/bison/
|
||||||
|
|
||||||
or hack around it by inserting the lines:
|
or hack around it by inserting the lines:
|
||||||
|
|
||||||
@@ -289,6 +271,7 @@ FILES
|
|||||||
CHANGES - description of differences between releases
|
CHANGES - description of differences between releases
|
||||||
ChmodBPF/* - Mac OS X startup item to set ownership and permissions
|
ChmodBPF/* - Mac OS X startup item to set ownership and permissions
|
||||||
on /dev/bpf*
|
on /dev/bpf*
|
||||||
|
CMakeLists.txt - CMake file
|
||||||
CREDITS - people that have helped libpcap along
|
CREDITS - people that have helped libpcap along
|
||||||
INSTALL.txt - this file
|
INSTALL.txt - this file
|
||||||
LICENSE - the license under which tcpdump is distributed
|
LICENSE - the license under which tcpdump is distributed
|
||||||
@@ -317,7 +300,7 @@ config.guess - autoconf support
|
|||||||
config.h.in - autoconf input
|
config.h.in - autoconf input
|
||||||
config.sub - autoconf support
|
config.sub - autoconf support
|
||||||
configure - configure script (run this first)
|
configure - configure script (run this first)
|
||||||
configure.in - configure script source
|
configure.ac - configure script source
|
||||||
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
|
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
|
||||||
dlpisubs.h - DLPI-related function declarations
|
dlpisubs.h - DLPI-related function declarations
|
||||||
etherent.c - /etc/ethers support routines
|
etherent.c - /etc/ethers support routines
|
||||||
@@ -325,9 +308,6 @@ ethertype.h - Ethernet protocol types and names definitions
|
|||||||
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
|
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
|
||||||
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
|
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
|
||||||
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
|
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
|
||||||
fad-null.c - pcap_findalldevs() for systems without capture support
|
|
||||||
fad-sita.c - pcap_findalldevs() for systems with SITA support
|
|
||||||
fad-win32.c - pcap_findalldevs() for WinPcap
|
|
||||||
filtertest.c - test program for BPF compiler
|
filtertest.c - test program for BPF compiler
|
||||||
findalldevstest.c - test program for pcap_findalldevs()
|
findalldevstest.c - test program for pcap_findalldevs()
|
||||||
gencode.c - BPF code generation routines
|
gencode.c - BPF code generation routines
|
||||||
@@ -388,7 +368,6 @@ pcap_*.3pcap - manual entries for library functions
|
|||||||
pcap-filter.4 - manual entry for filter syntax
|
pcap-filter.4 - manual entry for filter syntax
|
||||||
pcap-linktype.4 - manual entry for link-layer header types
|
pcap-linktype.4 - manual entry for link-layer header types
|
||||||
ppp.h - Point to Point Protocol definitions
|
ppp.h - Point to Point Protocol definitions
|
||||||
runlex.sh - wrapper for Lex/Flex
|
|
||||||
savefile.c - offline support
|
savefile.c - offline support
|
||||||
scanner.l - filter string scanner
|
scanner.l - filter string scanner
|
||||||
sunatmpos.h - definitions for SunATM capturing
|
sunatmpos.h - definitions for SunATM capturing
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
# Auto-regenerate configure script or Makefile when things change.
|
# Auto-regenerate configure script or Makefile when things change.
|
||||||
# From autoconf.info . Works best with GNU Make.
|
# From autoconf.info . Works best with GNU Make.
|
||||||
#
|
#
|
||||||
${srcdir}/configure: configure.in aclocal.m4
|
${srcdir}/configure: configure.ac aclocal.m4
|
||||||
cd ${srcdir} && autoconf
|
cd ${srcdir} && autoconf
|
||||||
|
|
||||||
# autoheader might not change config.h.in, so touch a stamp file.
|
# autoheader might not change config.h.in, so touch a stamp file.
|
||||||
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
|
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
|
||||||
${srcdir}/stamp-h.in: configure.in aclocal.m4
|
${srcdir}/stamp-h.in: configure.ac aclocal.m4
|
||||||
cd ${srcdir} && autoheader
|
cd ${srcdir} && autoheader
|
||||||
echo timestamp > ${srcdir}/stamp-h.in
|
echo timestamp > ${srcdir}/stamp-h.in
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ LN_S = @LN_S@
|
|||||||
MKDEP = @MKDEP@
|
MKDEP = @MKDEP@
|
||||||
CCOPT = @V_CCOPT@
|
CCOPT = @V_CCOPT@
|
||||||
INCLS = -I. @V_INCLS@
|
INCLS = -I. @V_INCLS@
|
||||||
DEFS = @DEFS@ @V_DEFS@
|
DEFS = -DBUILDING_PCAP @DEFS@ @V_DEFS@
|
||||||
ADDLOBJS = @ADDLOBJS@
|
ADDLOBJS = @ADDLOBJS@
|
||||||
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
@@ -69,6 +69,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|||||||
INSTALL_DATA = @INSTALL_DATA@
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
|
|
||||||
|
LEX = @LEX@
|
||||||
|
YACC = @YACC@
|
||||||
|
|
||||||
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
||||||
# Also, gcc does not remove the .o before forking 'as', which can be a
|
# Also, gcc does not remove the .o before forking 'as', which can be a
|
||||||
# problem if you don't own the file but can write to the directory.
|
# problem if you don't own the file but can write to the directory.
|
||||||
@@ -76,11 +79,11 @@ RANLIB = @RANLIB@
|
|||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||||
|
|
||||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@
|
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@
|
||||||
FSRC = fad-@V_FINDALLDEVS@.c
|
FSRC = @V_FINDALLDEVS@
|
||||||
SSRC = @SSRC@
|
SSRC = @SSRC@
|
||||||
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
|
CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \
|
||||||
savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
|
etherent.c savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
|
||||||
bpf_image.c bpf_dump.c
|
bpf_image.c bpf_dump.c
|
||||||
GENSRC = scanner.c grammar.c bpf_filter.c version.c
|
GENSRC = scanner.c grammar.c bpf_filter.c version.c
|
||||||
LIBOBJS = @LIBOBJS@
|
LIBOBJS = @LIBOBJS@
|
||||||
@@ -96,6 +99,9 @@ PUBHDR = \
|
|||||||
pcap-namedb.h \
|
pcap-namedb.h \
|
||||||
pcap/bpf.h \
|
pcap/bpf.h \
|
||||||
pcap/bluetooth.h \
|
pcap/bluetooth.h \
|
||||||
|
pcap/can_socketcan.h \
|
||||||
|
pcap/dlt.h \
|
||||||
|
pcap/export-defs.h \
|
||||||
pcap/ipnet.h \
|
pcap/ipnet.h \
|
||||||
pcap/namedb.h \
|
pcap/namedb.h \
|
||||||
pcap/nflog.h \
|
pcap/nflog.h \
|
||||||
@@ -108,43 +114,49 @@ HDR = $(PUBHDR) \
|
|||||||
arcnet.h \
|
arcnet.h \
|
||||||
atmuni31.h \
|
atmuni31.h \
|
||||||
ethertype.h \
|
ethertype.h \
|
||||||
|
extract.h \
|
||||||
gencode.h \
|
gencode.h \
|
||||||
ieee80211.h \
|
ieee80211.h \
|
||||||
llc.h \
|
llc.h \
|
||||||
|
nametoaddr.h \
|
||||||
nlpid.h \
|
nlpid.h \
|
||||||
pcap-common.h \
|
pcap-common.h \
|
||||||
pcap-int.h \
|
pcap-int.h \
|
||||||
pcap-stdinc.h \
|
pcap-stdinc.h \
|
||||||
|
portability.h \
|
||||||
ppp.h \
|
ppp.h \
|
||||||
sf-pcap.h \
|
sf-pcap.h \
|
||||||
sf-pcap-ng.h \
|
sf-pcap-ng.h \
|
||||||
sunatmpos.h
|
sunatmpos.h
|
||||||
|
|
||||||
TESTS = \
|
TESTS = \
|
||||||
|
@VALGRINDTEST@ \
|
||||||
capturetest \
|
capturetest \
|
||||||
|
can_set_rfmon_test \
|
||||||
filtertest \
|
filtertest \
|
||||||
findalldevstest \
|
findalldevstest \
|
||||||
opentest \
|
opentest \
|
||||||
selpolltest \
|
reactivatetest \
|
||||||
valgrindtest
|
selpolltest
|
||||||
|
|
||||||
TESTS_SRC = \
|
TESTS_SRC = \
|
||||||
|
tests/valgrindtest.c \
|
||||||
tests/capturetest.c \
|
tests/capturetest.c \
|
||||||
|
tests/can_set_rfmon_test.c \
|
||||||
tests/filtertest.c \
|
tests/filtertest.c \
|
||||||
tests/findalldevstest.c \
|
tests/findalldevstest.c \
|
||||||
tests/opentest.c \
|
tests/opentest.c \
|
||||||
tests/reactivatetest.c \
|
tests/reactivatetest.c \
|
||||||
tests/selpolltest.c \
|
tests/selpolltest.c
|
||||||
tests/valgrindtest.c
|
|
||||||
|
|
||||||
GENHDR = \
|
GENHDR = \
|
||||||
scanner.h tokdefs.h version.h
|
scanner.h grammar.h pcap_version.h
|
||||||
|
|
||||||
TAGFILES = \
|
TAGFILES = \
|
||||||
$(SRC) $(HDR)
|
$(SRC) $(HDR)
|
||||||
|
|
||||||
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
||||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz \
|
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
||||||
lex.yy.c pcap-config
|
lex.yy.c pcap-config
|
||||||
|
|
||||||
MAN1 = pcap-config.1
|
MAN1 = pcap-config.1
|
||||||
@@ -224,6 +236,8 @@ EXTRA_DIST = \
|
|||||||
ChmodBPF/ChmodBPF \
|
ChmodBPF/ChmodBPF \
|
||||||
ChmodBPF/StartupParameters.plist \
|
ChmodBPF/StartupParameters.plist \
|
||||||
CREDITS \
|
CREDITS \
|
||||||
|
CMakeLists.txt \
|
||||||
|
GenVersion.bat \
|
||||||
INSTALL.txt \
|
INSTALL.txt \
|
||||||
LICENSE \
|
LICENSE \
|
||||||
Makefile.in \
|
Makefile.in \
|
||||||
@@ -246,29 +260,37 @@ EXTRA_DIST = \
|
|||||||
aclocal.m4 \
|
aclocal.m4 \
|
||||||
bpf/net/bpf_filter.c \
|
bpf/net/bpf_filter.c \
|
||||||
chmod_bpf \
|
chmod_bpf \
|
||||||
|
cmakeconfig.h.in \
|
||||||
|
cmake/preconfigure.cmake \
|
||||||
|
config/have_siocglifconf.c \
|
||||||
config.guess \
|
config.guess \
|
||||||
config.h.in \
|
config.h.in \
|
||||||
config.sub \
|
config.sub \
|
||||||
configure \
|
configure \
|
||||||
configure.in \
|
configure.ac \
|
||||||
dlpisubs.c \
|
dlpisubs.c \
|
||||||
dlpisubs.h \
|
dlpisubs.h \
|
||||||
fad-getad.c \
|
fad-getad.c \
|
||||||
fad-gifc.c \
|
fad-gifc.c \
|
||||||
fad-glifc.c \
|
fad-glifc.c \
|
||||||
fad-null.c \
|
fad-helpers.c \
|
||||||
fad-sita.c \
|
gen_version_c.sh \
|
||||||
fad-win32.c \
|
gen_version_header.sh \
|
||||||
grammar.y \
|
grammar.y \
|
||||||
install-sh \
|
install-sh \
|
||||||
lbl/os-aix4.h \
|
lbl/os-aix4.h \
|
||||||
|
lbl/os-aix7.h \
|
||||||
lbl/os-hpux11.h \
|
lbl/os-hpux11.h \
|
||||||
lbl/os-osf4.h \
|
lbl/os-osf4.h \
|
||||||
lbl/os-osf5.h \
|
lbl/os-osf5.h \
|
||||||
lbl/os-solaris2.h \
|
lbl/os-solaris2.h \
|
||||||
lbl/os-sunos4.h \
|
lbl/os-sunos4.h \
|
||||||
lbl/os-ultrix4.h \
|
lbl/os-ultrix4.h \
|
||||||
|
missing/getopt.c \
|
||||||
|
missing/getopt.h \
|
||||||
missing/snprintf.c \
|
missing/snprintf.c \
|
||||||
|
missing/strtok_r.c \
|
||||||
|
missing/win_snprintf.c \
|
||||||
mkdep \
|
mkdep \
|
||||||
msdos/bin2c.c \
|
msdos/bin2c.c \
|
||||||
msdos/common.dj \
|
msdos/common.dj \
|
||||||
@@ -289,10 +311,6 @@ EXTRA_DIST = \
|
|||||||
pcap-bt-linux.h \
|
pcap-bt-linux.h \
|
||||||
pcap-bt-monitor-linux.c \
|
pcap-bt-monitor-linux.c \
|
||||||
pcap-bt-monitor-linux.h \
|
pcap-bt-monitor-linux.h \
|
||||||
pcap-can-linux.c \
|
|
||||||
pcap-can-linux.h \
|
|
||||||
pcap-canusb-linux.c \
|
|
||||||
pcap-canusb-linux.h \
|
|
||||||
pcap-config.in \
|
pcap-config.in \
|
||||||
pcap-dag.c \
|
pcap-dag.c \
|
||||||
pcap-dag.h \
|
pcap-dag.h \
|
||||||
@@ -306,11 +324,14 @@ EXTRA_DIST = \
|
|||||||
pcap-libdlpi.c \
|
pcap-libdlpi.c \
|
||||||
pcap-linux.c \
|
pcap-linux.c \
|
||||||
pcap-namedb.h \
|
pcap-namedb.h \
|
||||||
|
pcap-new.c \
|
||||||
pcap-netfilter-linux.c \
|
pcap-netfilter-linux.c \
|
||||||
pcap-netfilter-linux.h \
|
pcap-netfilter-linux.h \
|
||||||
pcap-nit.c \
|
pcap-nit.c \
|
||||||
pcap-null.c \
|
pcap-null.c \
|
||||||
pcap-pf.c \
|
pcap-pf.c \
|
||||||
|
pcap-rpcap.c \
|
||||||
|
pcap-rpcap.h \
|
||||||
pcap-septel.c \
|
pcap-septel.c \
|
||||||
pcap-septel.h \
|
pcap-septel.h \
|
||||||
pcap-sita.h \
|
pcap-sita.h \
|
||||||
@@ -320,47 +341,25 @@ EXTRA_DIST = \
|
|||||||
pcap-snf.h \
|
pcap-snf.h \
|
||||||
pcap-snit.c \
|
pcap-snit.c \
|
||||||
pcap-snoop.c \
|
pcap-snoop.c \
|
||||||
|
pcap-tc.c \
|
||||||
|
pcap-tc.h \
|
||||||
pcap-usb-linux.c \
|
pcap-usb-linux.c \
|
||||||
pcap-usb-linux.h \
|
pcap-usb-linux.h \
|
||||||
pcap-win32.c \
|
pcap-win32.c \
|
||||||
runlex.sh \
|
remote-ext.h \
|
||||||
scanner.c.top \
|
sockutils.c \
|
||||||
|
sockutils.h \
|
||||||
scanner.l \
|
scanner.l \
|
||||||
|
tests/CMakeLists.txt \
|
||||||
|
pcap_version.h.in \
|
||||||
Win32/Include/Gnuc.h \
|
Win32/Include/Gnuc.h \
|
||||||
Win32/Include/addrinfo.h \
|
|
||||||
Win32/Include/bittypes.h \
|
|
||||||
Win32/Include/cdecl_ext.h \
|
|
||||||
Win32/Include/inetprivate.h \
|
|
||||||
Win32/Include/ip6_misc.h \
|
|
||||||
Win32/Include/sockstorage.h \
|
|
||||||
Win32/Include/arpa/nameser.h \
|
|
||||||
Win32/Include/net/if.h \
|
Win32/Include/net/if.h \
|
||||||
Win32/Include/net/netdb.h \
|
Win32/Prj/wpcap.sln \
|
||||||
Win32/Include/net/paths.h \
|
Win32/Prj/wpcap.vcxproj \
|
||||||
Win32/Prj/libpcap.dsp \
|
Win32/Prj/wpcap.vcxproj.filters
|
||||||
Win32/Prj/libpcap.dsw \
|
|
||||||
Win32/Src/ffs.c \
|
|
||||||
Win32/Src/gai_strerror.c \
|
|
||||||
Win32/Src/getaddrinfo.c \
|
|
||||||
Win32/Src/getnetbynm.c \
|
|
||||||
Win32/Src/getnetent.c \
|
|
||||||
Win32/Src/getopt.c \
|
|
||||||
Win32/Src/getservent.c \
|
|
||||||
Win32/Src/inet_aton.c \
|
|
||||||
Win32/Src/inet_net.c \
|
|
||||||
Win32/Src/inet_pton.c
|
|
||||||
|
|
||||||
all: libpcap.a shared pcap-config
|
all: libpcap.a shared pcap-config
|
||||||
|
|
||||||
# Inhibit implicit rule Make seems to have for using yacc/lex to
|
|
||||||
# recompile new scanner.c/grammar.c -- we ship ones which we want to
|
|
||||||
# use instead.
|
|
||||||
grammar.c:
|
|
||||||
echo "Not rebuilding grammar.c"
|
|
||||||
|
|
||||||
scanner.c:
|
|
||||||
echo "Not rebuilding scanner.c"
|
|
||||||
|
|
||||||
libpcap.a: $(OBJ)
|
libpcap.a: $(OBJ)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||||
@@ -444,14 +443,34 @@ libpcap.shareda: $(OBJ)
|
|||||||
#
|
#
|
||||||
libpcap.none:
|
libpcap.none:
|
||||||
|
|
||||||
scanner.o: scanner.c tokdefs.h
|
scanner.c: $(srcdir)/scanner.l
|
||||||
|
$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
|
||||||
|
scanner.h: scanner.c
|
||||||
|
## Recover from the removal of $@
|
||||||
|
@if test -f $@; then :; else \
|
||||||
|
rm -f scanner.c; \
|
||||||
|
$(MAKE) $(MAKEFLAGS) scanner.c; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
scanner.o: scanner.c grammar.h
|
||||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
$(CC) $(FULL_CFLAGS) -c scanner.c
|
||||||
|
|
||||||
pcap.o: version.h
|
pcap.o: pcap_version.h
|
||||||
|
|
||||||
|
grammar.c: $(srcdir)/grammar.y
|
||||||
|
$(YACC) -p pcap_ -o grammar.c -d $<
|
||||||
|
grammar.h: grammar.c
|
||||||
|
## Recover from the removal of $@
|
||||||
|
@if test -f $@; then :; else \
|
||||||
|
rm -f grammar.c; \
|
||||||
|
$(MAKE) $(MAKEFLAGS) grammar.c; \
|
||||||
|
fi
|
||||||
|
|
||||||
grammar.o: grammar.c
|
grammar.o: grammar.c
|
||||||
@rm -f $@
|
$(CC) $(FULL_CFLAGS) -c grammar.c
|
||||||
$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
|
||||||
|
gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
|
||||||
|
$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
|
||||||
|
|
||||||
version.o: version.c
|
version.o: version.c
|
||||||
$(CC) $(FULL_CFLAGS) -c version.c
|
$(CC) $(FULL_CFLAGS) -c version.c
|
||||||
@@ -459,32 +478,21 @@ version.o: version.c
|
|||||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||||
|
|
||||||
version.c: $(srcdir)/VERSION
|
strtok_r.o: $(srcdir)/missing/strtok_r.c
|
||||||
@rm -f $@
|
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
|
||||||
if grep GIT ${srcdir}/VERSION >/dev/null; then \
|
|
||||||
read ver <${srcdir}/VERSION; \
|
|
||||||
echo $$ver | tr -d '\012'; \
|
|
||||||
date +_%Y_%m_%d; \
|
|
||||||
else \
|
|
||||||
cat ${srcdir}/VERSION; \
|
|
||||||
fi | sed -e 's/.*/char pcap_version[] = "&";/' > $@
|
|
||||||
|
|
||||||
|
version.c: $(srcdir)/VERSION $(srcdir)/gen_version_c.sh
|
||||||
#
|
#
|
||||||
# NOTE: this really is supposed to be static; importing a string
|
# Older programs import this if they want to show the
|
||||||
# from a shared library does not work very well on many
|
# libpcap version number, rather than calling
|
||||||
# versions of UNIX (Solaris, Linux, and the BSDs, for example),
|
# pcap_lib_version(), so we need to export it.
|
||||||
# so we make the version string static and return it from
|
|
||||||
# a function, which does work.
|
|
||||||
#
|
#
|
||||||
version.h: $(srcdir)/VERSION
|
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
if grep GIT ${srcdir}/VERSION >/dev/null; then \
|
$(srcdir)/gen_version_c.sh $(srcdir)/VERSION $@
|
||||||
read ver <${srcdir}/VERSION; \
|
|
||||||
echo $$ver | tr -d '\012'; \
|
pcap_version.h: $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $(srcdir)/gen_version_header.sh
|
||||||
date +_%Y_%m_%d; \
|
@rm -f $@
|
||||||
else \
|
$(srcdir)/gen_version_header.sh $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $@
|
||||||
cat ${srcdir}/VERSION; \
|
|
||||||
fi | sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' > $@
|
|
||||||
|
|
||||||
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
||||||
rm -f bpf_filter.c
|
rm -f bpf_filter.c
|
||||||
@@ -521,6 +529,9 @@ tests: $(TESTS)
|
|||||||
capturetest: tests/capturetest.c libpcap.a
|
capturetest: tests/capturetest.c libpcap.a
|
||||||
$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
|
$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
|
can_set_rfmon_test: tests/can_set_rfmon_test.c libpcap.a
|
||||||
|
$(CC) $(FULL_CFLAGS) -I. -L. -o can_set_rfmon_test $(srcdir)/tests/can_set_rfmon_test.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
filtertest: tests/filtertest.c libpcap.a
|
filtertest: tests/filtertest.c libpcap.a
|
||||||
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
|
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
@@ -530,6 +541,9 @@ findalldevstest: tests/findalldevstest.c libpcap.a
|
|||||||
opentest: tests/opentest.c libpcap.a
|
opentest: tests/opentest.c libpcap.a
|
||||||
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
|
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
|
reactivatetest: tests/reactivatetest.c libpcap.a
|
||||||
|
$(CC) $(FULL_CFLAGS) -I. -L. -o reactivatetest $(srcdir)/tests/reactivatetest.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
selpolltest: tests/selpolltest.c libpcap.a
|
selpolltest: tests/selpolltest.c libpcap.a
|
||||||
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
|
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
|
||||||
|
|
||||||
@@ -716,10 +730,12 @@ distclean: clean
|
|||||||
rm -f Makefile config.cache config.log config.status \
|
rm -f Makefile config.cache config.log config.status \
|
||||||
config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \
|
config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \
|
||||||
stamp-h stamp-h.in
|
stamp-h stamp-h.in
|
||||||
rm -f version.h version.c
|
|
||||||
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
|
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
|
|
||||||
|
extags: $(TAGFILES)
|
||||||
|
ctags $(TAGFILES)
|
||||||
|
|
||||||
tags: $(TAGFILES)
|
tags: $(TAGFILES)
|
||||||
ctags -wtd $(TAGFILES)
|
ctags -wtd $(TAGFILES)
|
||||||
|
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
From f38b1fc263d65a53746108e2c9afacf1dc6a058a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Miller <daniel@bonsaiviking.com>
|
|
||||||
Date: Fri, 1 May 2015 14:44:28 +0000
|
|
||||||
Subject: [PATCH 1/2] Don't autogenerate Lex/Yacc files.
|
|
||||||
|
|
||||||
---
|
|
||||||
libpcap/Makefile.in | 33 ++++++++++-----------------------
|
|
||||||
libpcap/configure.in | 20 --------------------
|
|
||||||
2 files changed, 10 insertions(+), 43 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libpcap/Makefile.in b/libpcap/Makefile.in
|
|
||||||
index f317973..577b848 100644
|
|
||||||
--- a/libpcap/Makefile.in
|
|
||||||
+++ b/libpcap/Makefile.in
|
|
||||||
@@ -69,14 +69,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
|
||||||
RANLIB = @RANLIB@
|
|
||||||
|
|
||||||
-#
|
|
||||||
-# 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.
|
|
||||||
-#
|
|
||||||
-LEX = @V_LEX@
|
|
||||||
-YACC = @V_YACC@
|
|
||||||
-
|
|
||||||
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
|
||||||
# Also, gcc does not remove the .o before forking 'as', which can be a
|
|
||||||
# problem if you don't own the file but can write to the directory.
|
|
||||||
@@ -152,7 +144,7 @@ TAGFILES = \
|
|
||||||
$(SRC) $(HDR)
|
|
||||||
|
|
||||||
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
|
||||||
- $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
|
||||||
+ $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \
|
|
||||||
lex.yy.c pcap-config
|
|
||||||
|
|
||||||
MAN1 = pcap-config.1
|
|
||||||
@@ -360,6 +352,15 @@ EXTRA_DIST = \
|
|
||||||
|
|
||||||
all: libpcap.a shared pcap-config
|
|
||||||
|
|
||||||
+# Inhibit implicit rule Make seems to have for using yacc/lex to
|
|
||||||
+# recompile new scanner.c/grammar.c -- we ship ones which we want to
|
|
||||||
+# use instead.
|
|
||||||
+grammar.c:
|
|
||||||
+ echo "Not rebuilding grammar.c"
|
|
||||||
+
|
|
||||||
+scanner.c:
|
|
||||||
+ echo "Not rebuilding scanner.c"
|
|
||||||
+
|
|
||||||
libpcap.a: $(OBJ)
|
|
||||||
@rm -f $@
|
|
||||||
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
|
||||||
@@ -443,25 +444,11 @@ libpcap.shareda: $(OBJ)
|
|
||||||
#
|
|
||||||
libpcap.none:
|
|
||||||
|
|
||||||
-scanner.c: $(srcdir)/scanner.l
|
|
||||||
- @rm -f $@ $@.bottom
|
|
||||||
- $(srcdir)/runlex.sh $(LEX) -o$@ $<
|
|
||||||
- mv $@ $@.bottom
|
|
||||||
- cat $@.top $@.bottom > $@
|
|
||||||
- @rm $@.bottom
|
|
||||||
-
|
|
||||||
scanner.o: scanner.c tokdefs.h
|
|
||||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
|
||||||
|
|
||||||
pcap.o: version.h
|
|
||||||
|
|
||||||
-tokdefs.h: grammar.c
|
|
||||||
-grammar.c: $(srcdir)/grammar.y
|
|
||||||
- @rm -f grammar.c tokdefs.h
|
|
||||||
- $(YACC) -d $<
|
|
||||||
- mv y.tab.c grammar.c
|
|
||||||
- mv y.tab.h tokdefs.h
|
|
||||||
-
|
|
||||||
grammar.o: grammar.c
|
|
||||||
@rm -f $@
|
|
||||||
$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
|
||||||
diff --git a/libpcap/configure.in b/libpcap/configure.in
|
|
||||||
index be4b29e..ec87283 100644
|
|
||||||
--- a/libpcap/configure.in
|
|
||||||
+++ b/libpcap/configure.in
|
|
||||||
@@ -1051,24 +1051,6 @@ if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
|
|
||||||
AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
|
|
||||||
fi
|
|
||||||
|
|
||||||
-AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
|
|
||||||
-if test "$V_LEX" = lex ; then
|
|
||||||
-# Some versions of lex can't handle the definitions section of scanner.l .
|
|
||||||
-# Try lexing it and complain if it can't deal.
|
|
||||||
- AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
|
|
||||||
- if lex -t scanner.l > /dev/null 2>&1; then
|
|
||||||
- tcpdump_cv_capable_lex=yes
|
|
||||||
- else
|
|
||||||
- tcpdump_cv_capable_lex=insufficient
|
|
||||||
- fi)
|
|
||||||
- if test $tcpdump_cv_capable_lex = insufficient ; then
|
|
||||||
- AC_MSG_ERROR([Your operating system's lex is insufficient to compile
|
|
||||||
- libpcap. flex is a lex replacement that has many advantages, including
|
|
||||||
- being able to compile libpcap. For more information, see
|
|
||||||
- http://www.gnu.org/software/flex/flex.html .])
|
|
||||||
- fi
|
|
||||||
-fi
|
|
||||||
-
|
|
||||||
#
|
|
||||||
# Assume, by default, no support for shared libraries and V7/BSD convention
|
|
||||||
# for man pages (file formats in section 5, miscellaneous info in section 7).
|
|
||||||
@@ -1351,13 +1333,11 @@ AC_SUBST(V_CCOPT)
|
|
||||||
AC_SUBST(V_DEFS)
|
|
||||||
AC_SUBST(V_FINDALLDEVS)
|
|
||||||
AC_SUBST(V_INCLS)
|
|
||||||
-AC_SUBST(V_LEX)
|
|
||||||
AC_SUBST(V_PCAP)
|
|
||||||
AC_SUBST(V_SHLIB_CMD)
|
|
||||||
AC_SUBST(V_SHLIB_OPT)
|
|
||||||
AC_SUBST(V_SONAME_OPT)
|
|
||||||
AC_SUBST(V_RPATH_OPT)
|
|
||||||
-AC_SUBST(V_YACC)
|
|
||||||
AC_SUBST(ADDLOBJS)
|
|
||||||
AC_SUBST(ADDLARCHIVEOBJS)
|
|
||||||
AC_SUBST(SSRC)
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
From 7a42932439162be1f263986cdc7bbef78840a71a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Miller <daniel@bonsaiviking.com>
|
|
||||||
Date: Fri, 1 May 2015 14:53:42 +0000
|
|
||||||
Subject: [PATCH 2/2] Disable unnecessary features
|
|
||||||
|
|
||||||
The following features are disabled:
|
|
||||||
|
|
||||||
* monitor-mode sniffing of wireless interfaces on Linux, via libnl
|
|
||||||
* building shared libraries
|
|
||||||
* Bluetooth support
|
|
||||||
* canusb support
|
|
||||||
* CAN support
|
|
||||||
* dbus capture support
|
|
||||||
---
|
|
||||||
libpcap/configure.in | 24 ++++++++++++------------
|
|
||||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libpcap/configure.in b/libpcap/configure.in
|
|
||||||
index ec87283..ad2e437 100644
|
|
||||||
--- a/libpcap/configure.in
|
|
||||||
+++ b/libpcap/configure.in
|
|
||||||
@@ -450,10 +450,10 @@ linux)
|
|
||||||
# Do we have libnl?
|
|
||||||
#
|
|
||||||
AC_ARG_WITH(libnl,
|
|
||||||
- AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
|
|
||||||
+ AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]),
|
|
||||||
with_libnl=$withval,,)
|
|
||||||
|
|
||||||
- if test x$with_libnl != xno ; then
|
|
||||||
+ if test x$with_libnl = xyes ; then
|
|
||||||
have_any_nl="no"
|
|
||||||
|
|
||||||
incdir=-I/usr/include/libnl3
|
|
||||||
@@ -1301,8 +1301,8 @@ solaris*)
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(shared,
|
|
||||||
-AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
|
|
||||||
-test "x$enable_shared" = "xno" && DYEXT="none"
|
|
||||||
+AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@]))
|
|
||||||
+test "x$enable_shared" != "xyes" && DYEXT="none"
|
|
||||||
|
|
||||||
AC_PROG_RANLIB
|
|
||||||
AC_CHECK_TOOL([AR], [ar])
|
|
||||||
@@ -1457,9 +1457,9 @@ AC_SUBST(PCAP_SUPPORT_NETFILTER)
|
|
||||||
AC_SUBST(NETFILTER_SRC)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([bluetooth],
|
|
||||||
-[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
|
|
||||||
+[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
- [enable_bluetooth=ifsupportavailable])
|
|
||||||
+ [enable_bluetooth=no])
|
|
||||||
|
|
||||||
if test "x$enable_bluetooth" != "xno" ; then
|
|
||||||
dnl check for Bluetooth sniffing support
|
|
||||||
@@ -1536,9 +1536,9 @@ if test "x$enable_bluetooth" != "xno" ; then
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([canusb],
|
|
||||||
-[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
|
|
||||||
+[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
- [enable_canusb=ifsupportavailable])
|
|
||||||
+ [enable_canusb=no])
|
|
||||||
|
|
||||||
if test "x$enable_canusb" != "xno" ; then
|
|
||||||
dnl check for canusb support
|
|
||||||
@@ -1582,9 +1582,9 @@ if test "x$enable_canusb" != "xno" ; then
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([can],
|
|
||||||
-[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
|
|
||||||
+[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
- [enable_can=ifsupportavailable])
|
|
||||||
+ [enable_can=no])
|
|
||||||
|
|
||||||
if test "x$enable_can" != "xno" ; then
|
|
||||||
dnl check for CAN sniffing support
|
|
||||||
@@ -1619,9 +1619,9 @@ if test "x$enable_can" != "xno" ; then
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([dbus],
|
|
||||||
-[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
|
|
||||||
+[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
- [enable_dbus=ifavailable])
|
|
||||||
+ [enable_dbus=no])
|
|
||||||
|
|
||||||
if test "x$enable_dbus" != "xno"; then
|
|
||||||
if test "x$enable_dbus" = "xyes"; then
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
From 4523e52bb5c54f4d65cd3672e8f875c137b44f77 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Miller <daniel@bonsaiviking.com>
|
|
||||||
Date: Tue, 15 Sep 2015 13:16:39 +0000
|
|
||||||
Subject: [PATCH] Disable TPACKET_V3 in included libpcap. Still broken, see #34
|
|
||||||
|
|
||||||
---
|
|
||||||
libpcap/pcap-linux.c | 4 ++++
|
|
||||||
1 file changed, 4 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/libpcap/pcap-linux.c b/libpcap/pcap-linux.c
|
|
||||||
index a226da1..a17c250 100644
|
|
||||||
--- a/libpcap/pcap-linux.c
|
|
||||||
+++ b/libpcap/pcap-linux.c
|
|
||||||
@@ -188,6 +188,10 @@
|
|
||||||
# endif /* PACKET_HOST */
|
|
||||||
|
|
||||||
|
|
||||||
+ /* TPACKET_V3 is broken. Temporarily disabling support here until upstream
|
|
||||||
+ * libpcap addresses the issue. */
|
|
||||||
+#undef TPACKET3_HDRLEN
|
|
||||||
+
|
|
||||||
/* check for memory mapped access avaibility. We assume every needed
|
|
||||||
* struct is defined if the macro TPACKET_HDRLEN is defined, because it
|
|
||||||
* uses many ring related structs and macros */
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
From b91a93895633da9b8184691effc487d8b0c8e82c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Miller <daniel@bonsaiviking.com>
|
|
||||||
Date: Sun, 20 Sep 2015 18:45:22 +0000
|
|
||||||
Subject: [PATCH] Use a mutex on Windows to avoid a hang when accessing WinPCAP
|
|
||||||
driver
|
|
||||||
|
|
||||||
Reported by multiple users on Windows 8.1 and Windows Server 2012 R2.
|
|
||||||
Seems to hang when the WinPCAP driver is accessed via OpenServiceA by
|
|
||||||
multiple processes at once. Users report that this change, which uses a
|
|
||||||
mutex to avoid concurrent access, fixes the hang.
|
|
||||||
---
|
|
||||||
libpcap/fad-win32.c | 35 ++++++++++++++++++++++++++++++++++
|
|
||||||
libpcap/inet.c | 40 +++++++++++++++++++++++++++++++++++++++
|
|
||||||
libpcap/pcap-win32.c | 25 ++++++++++++++++++++++++
|
|
||||||
3 files changed, 100 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/libpcap/fad-win32.c b/libpcap/fad-win32.c
|
|
||||||
index 0c856b1..f849d40 100644
|
|
||||||
--- a/libpcap/fad-win32.c
|
|
||||||
+++ b/libpcap/fad-win32.c
|
|
||||||
@@ -49,6 +49,8 @@ pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
|
|
||||||
npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES];
|
|
||||||
LONG if_addr_size;
|
|
||||||
int res = 0;
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
|
|
||||||
if_addr_size = MAX_NETWORK_ADDRESSES;
|
|
||||||
|
|
||||||
@@ -65,6 +67,8 @@ pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
|
|
||||||
/*
|
|
||||||
* Get the list of addresses for the interface.
|
|
||||||
*/
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
if (!PacketGetNetInfoEx((void *)name, if_addrs, &if_addr_size)) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
@@ -75,8 +79,16 @@ pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
|
|
||||||
*
|
|
||||||
* We return an entry with an empty address list.
|
|
||||||
*/
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now add the addresses.
|
|
||||||
@@ -127,6 +139,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
char *AdaptersName;
|
|
||||||
ULONG NameLength;
|
|
||||||
char *name;
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
+
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find out how big a buffer we need.
|
|
||||||
@@ -149,6 +166,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
if (!PacketGetAdapterNames(NULL, &NameLength))
|
|
||||||
{
|
|
||||||
DWORD last_error = GetLastError();
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
if (last_error != ERROR_INSUFFICIENT_BUFFER)
|
|
||||||
{
|
|
||||||
@@ -158,6 +179,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
if (NameLength > 0)
|
|
||||||
AdaptersName = (char*) malloc(NameLength);
|
|
||||||
@@ -172,13 +197,23 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
free(AdaptersName);
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* "PacketGetAdapterNames()" returned a list of
|
|
||||||
diff --git a/libpcap/inet.c b/libpcap/inet.c
|
|
||||||
index e7d2104..359557f 100644
|
|
||||||
--- a/libpcap/inet.c
|
|
||||||
+++ b/libpcap/inet.c
|
|
||||||
@@ -983,8 +983,12 @@ pcap_lookupdev(errbuf)
|
|
||||||
{
|
|
||||||
DWORD dwVersion;
|
|
||||||
DWORD dwWindowsMajorVersion;
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
dwVersion = GetVersion(); /* get the OS version */
|
|
||||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
|
|
||||||
if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) {
|
|
||||||
/*
|
|
||||||
@@ -994,9 +998,21 @@ pcap_lookupdev(errbuf)
|
|
||||||
static char AdaptersName[8192];
|
|
||||||
|
|
||||||
if (PacketGetAdapterNames(AdaptersName,&NameLength) )
|
|
||||||
+ {
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
return (AdaptersName);
|
|
||||||
+ }
|
|
||||||
else
|
|
||||||
+ {
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
return NULL;
|
|
||||||
+ }
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Windows NT (NT 4.0, W2K, WXP). Convert the names to UNICODE for backward compatibility
|
|
||||||
@@ -1016,12 +1032,20 @@ pcap_lookupdev(errbuf)
|
|
||||||
|
|
||||||
if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
|
|
||||||
{
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
free(TAdaptersName);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
|
|
||||||
tAstr = (char*)TAdaptersName;
|
|
||||||
@@ -1056,6 +1080,10 @@ pcap_lookupdev(errbuf)
|
|
||||||
free(TAdaptersName);
|
|
||||||
return (char *)(AdaptersName);
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1073,11 +1101,23 @@ pcap_lookupnet(device, netp, maskp, errbuf)
|
|
||||||
LONG if_addr_size = 1;
|
|
||||||
struct sockaddr_in *t_addr;
|
|
||||||
unsigned int i;
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
if (!PacketGetNetInfoEx((void *)device, if_addrs, &if_addr_size)) {
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
*netp = *maskp = 0;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
for(i=0; i<MAX_NETWORK_ADDRESSES; i++)
|
|
||||||
{
|
|
||||||
diff --git a/libpcap/pcap-win32.c b/libpcap/pcap-win32.c
|
|
||||||
index f449f79..2e83e75 100644
|
|
||||||
--- a/libpcap/pcap-win32.c
|
|
||||||
+++ b/libpcap/pcap-win32.c
|
|
||||||
@@ -492,8 +492,16 @@ pcap_inject_win32(pcap_t *p, const void *buf, size_t size){
|
|
||||||
static void
|
|
||||||
pcap_cleanup_win32(pcap_t *p)
|
|
||||||
{
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
if (p->adapter != NULL) {
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
PacketCloseAdapter(p->adapter);
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
p->adapter = NULL;
|
|
||||||
}
|
|
||||||
if (p->Packet) {
|
|
||||||
@@ -508,6 +516,8 @@ pcap_activate_win32(pcap_t *p)
|
|
||||||
{
|
|
||||||
struct pcap_win *pw = p->priv;
|
|
||||||
NetType type;
|
|
||||||
+ HANDLE pcapMutex;
|
|
||||||
+ DWORD wait;
|
|
||||||
|
|
||||||
if (p->opt.rfmon) {
|
|
||||||
/*
|
|
||||||
@@ -521,11 +531,18 @@ pcap_activate_win32(pcap_t *p)
|
|
||||||
/* Init WinSock */
|
|
||||||
wsockinit();
|
|
||||||
|
|
||||||
+ pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
+ wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
+
|
|
||||||
p->adapter = PacketOpenAdapter(p->opt.source);
|
|
||||||
|
|
||||||
if (p->adapter == NULL)
|
|
||||||
{
|
|
||||||
/* Adapter detected but we are not able to open it. Return failure. */
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Error opening adapter: %s", pcap_win32strerror());
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
@@ -533,9 +550,17 @@ pcap_activate_win32(pcap_t *p)
|
|
||||||
/*get network type*/
|
|
||||||
if(PacketGetNetType (p->adapter,&type) == FALSE)
|
|
||||||
{
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Cannot determine the network type: %s", pcap_win32strerror());
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
+ if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
+ ReleaseMutex(pcapMutex);
|
|
||||||
+ }
|
|
||||||
+ CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
/*Set the linktype*/
|
|
||||||
switch (type.LinkType)
|
|
||||||
--
|
|
||||||
1.9.1
|
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ rsync -rv --delete ~/libpcap-X.Y/ ~/nmap/libpcap/
|
|||||||
git add -A libpcap
|
git add -A libpcap
|
||||||
cd libpcap
|
cd libpcap
|
||||||
./configure
|
./configure
|
||||||
make grammar.c scanner.c scanner.h tokdefs.h
|
make grammar.c scanner.c scanner.h
|
||||||
git add grammar.c scanner.c scanner.h tokdefs.h
|
git add grammar.c scanner.c scanner.h
|
||||||
cd ..
|
cd ..
|
||||||
# Apply patches.
|
# Apply patches.
|
||||||
git apply ~/NMAP_MODIFICATIONS/000*
|
git apply ~/NMAP_MODIFICATIONS/000*
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ These additions/extensions have been made to PCAP to allow it to
|
|||||||
capture packets from a SITA ACN device (and potentially others).
|
capture packets from a SITA ACN device (and potentially others).
|
||||||
|
|
||||||
To enable its support you need to ensure that the distribution has
|
To enable its support you need to ensure that the distribution has
|
||||||
a correct configure.in file; that can be created if neccessay by
|
a correct configure.ac file; that can be created if neccessay by
|
||||||
using the normal autoconf procedure of:
|
using the normal autoconf procedure of:
|
||||||
|
|
||||||
aclocal
|
aclocal
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.7.3
|
1.8.1
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
/* Define __P() macro, if necessary */
|
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#if __STDC__
|
|
||||||
#define __P(protos) protos
|
|
||||||
#else
|
|
||||||
#define __P(protos) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* inline foo */
|
/* inline foo */
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@@ -16,29 +6,3 @@
|
|||||||
#define inline
|
#define inline
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle new and old "dead" routine prototypes
|
|
||||||
*
|
|
||||||
* For example:
|
|
||||||
*
|
|
||||||
* __dead void foo(void) __attribute__((volatile));
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#ifndef __dead
|
|
||||||
#define __dead volatile
|
|
||||||
#endif
|
|
||||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
|
||||||
#ifndef __attribute__
|
|
||||||
#define __attribute__(args)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifndef __dead
|
|
||||||
#define __dead
|
|
||||||
#endif
|
|
||||||
#ifndef __attribute__
|
|
||||||
#define __attribute__(args)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,144 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HAVE_ADDRINFO
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error return codes from getaddrinfo()
|
|
||||||
*/
|
|
||||||
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
|
||||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
|
||||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
|
||||||
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
|
||||||
#define EAI_FAMILY 5 /* ai_family not supported */
|
|
||||||
#define EAI_MEMORY 6 /* memory allocation failure */
|
|
||||||
#define EAI_NODATA 7 /* no address associated with hostname */
|
|
||||||
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
|
||||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
|
||||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
|
||||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
|
||||||
#define EAI_BADHINTS 12
|
|
||||||
#define EAI_PROTOCOL 13
|
|
||||||
#define EAI_MAX 14
|
|
||||||
|
|
||||||
/* internal error */
|
|
||||||
#define NETDB_INTERNAL -1 /* see errno */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag values for getaddrinfo()
|
|
||||||
*/
|
|
||||||
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
|
||||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
|
||||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
|
||||||
/* valid flags for addrinfo */
|
|
||||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
|
||||||
|
|
||||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
|
||||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
|
||||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
|
||||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
|
||||||
/* special recommended flags for getipnodebyname */
|
|
||||||
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
|
|
||||||
|
|
||||||
struct addrinfo {
|
|
||||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
|
||||||
int ai_family; /* PF_xxx */
|
|
||||||
int ai_socktype; /* SOCK_xxx */
|
|
||||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
|
||||||
size_t ai_addrlen; /* length of ai_addr */
|
|
||||||
char *ai_canonname; /* canonical name for hostname */
|
|
||||||
struct sockaddr *ai_addr; /* binary address */
|
|
||||||
struct addrinfo *ai_next; /* next structure in linked list */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern void freeaddrinfo (struct addrinfo *);
|
|
||||||
extern void freehostent (struct hostent *);
|
|
||||||
extern char *gai_strerror (int);
|
|
||||||
extern int getaddrinfo (const char *, const char *,
|
|
||||||
const struct addrinfo *, struct addrinfo **);
|
|
||||||
extern int getnameinfo (const struct sockaddr *, size_t, char *,
|
|
||||||
size_t, char *, size_t, int);
|
|
||||||
extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
|
|
||||||
extern struct hostent *getipnodebyname (const char *, int, int, int *);
|
|
||||||
extern int inet_pton (int, const char *, void *);
|
|
||||||
extern const char *inet_ntop (int, const void *, char *, size_t);
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef EAI_BADHINTS
|
|
||||||
#define EAI_BADHINTS 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EAI_PROTOCOL
|
|
||||||
#define EAI_PROTOCOL 13
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EAI_MAX
|
|
||||||
#define EAI_MAX 14
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NETDB_INTERNAL
|
|
||||||
#define NETDB_INTERNAL -1 /* see errno */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef AI_MASK
|
|
||||||
/* valid flags for addrinfo */
|
|
||||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAVE_ADDRINFO */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Constants for getnameinfo()
|
|
||||||
*/
|
|
||||||
#ifndef NI_MAXHOST
|
|
||||||
#define NI_MAXHOST 1025
|
|
||||||
#endif
|
|
||||||
#ifndef NI_MAXSERV
|
|
||||||
#define NI_MAXSERV 32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag values for getnameinfo()
|
|
||||||
*/
|
|
||||||
#ifndef NI_NOFQDN
|
|
||||||
#define NI_NOFQDN 0x00000001
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NUMERICHOST
|
|
||||||
#define NI_NUMERICHOST 0x00000002
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NAMEREQD
|
|
||||||
#define NI_NAMEREQD 0x00000004
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NUMERICSERV
|
|
||||||
#define NI_NUMERICSERV 0x00000008
|
|
||||||
#endif
|
|
||||||
#ifndef NI_DGRAM
|
|
||||||
#define NI_DGRAM 0x00000010
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,349 +0,0 @@
|
|||||||
/*
|
|
||||||
* ++Copyright++ 1983, 1989, 1993
|
|
||||||
* -
|
|
||||||
* Copyright (c) 1983, 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
* -
|
|
||||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies, and that
|
|
||||||
* the name of Digital Equipment Corporation not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the document or software without
|
|
||||||
* specific, written prior permission.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
|
||||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
|
||||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
||||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
||||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
* SOFTWARE.
|
|
||||||
* -
|
|
||||||
* --Copyright--
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @(#)nameser.h 8.1 (Berkeley) 6/2/93
|
|
||||||
* nameser.h,v 1.2 1995/05/06 14:23:54 hjl Exp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _NAMESER_H_
|
|
||||||
#define _NAMESER_H_
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if (!defined(BSD)) || (BSD < 199306)
|
|
||||||
# include <sys/bitypes.h>
|
|
||||||
#else
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#else
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
#define __LITTLE_ENDIAN 1
|
|
||||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* revision information. this is the release date in YYYYMMDD format.
|
|
||||||
* it can change every day so the right thing to do with it is use it
|
|
||||||
* in preprocessor commands such as "#if (__BIND > 19931104)". do not
|
|
||||||
* compare for equality; rather, use it to determine whether your resolver
|
|
||||||
* is new enough to contain a certain feature.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define __BIND 19940417 /* interface version stamp */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define constants based on rfc883
|
|
||||||
*/
|
|
||||||
#define PACKETSZ 512 /* maximum packet size */
|
|
||||||
#define MAXDNAME 256 /* maximum domain name */
|
|
||||||
#define MAXCDNAME 255 /* maximum compressed domain name */
|
|
||||||
#define MAXLABEL 63 /* maximum length of domain label */
|
|
||||||
#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
|
|
||||||
#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
|
|
||||||
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
|
|
||||||
#define INT32SZ 4 /* for systems without 32-bit ints */
|
|
||||||
#define INT16SZ 2 /* for systems without 16-bit ints */
|
|
||||||
#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internet nameserver port number
|
|
||||||
*/
|
|
||||||
#define NAMESERVER_PORT 53
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Currently defined opcodes
|
|
||||||
*/
|
|
||||||
#define QUERY 0x0 /* standard query */
|
|
||||||
#define IQUERY 0x1 /* inverse query */
|
|
||||||
#define STATUS 0x2 /* nameserver status query */
|
|
||||||
/*#define xxx 0x3 *//* 0x3 reserved */
|
|
||||||
#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
|
|
||||||
#ifdef ALLOW_UPDATES
|
|
||||||
/* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
|
|
||||||
# define UPDATEA 0x9 /* add resource record */
|
|
||||||
# define UPDATED 0xa /* delete a specific resource record */
|
|
||||||
# define UPDATEDA 0xb /* delete all named resource record */
|
|
||||||
# define UPDATEM 0xc /* modify a specific resource record */
|
|
||||||
# define UPDATEMA 0xd /* modify all named resource record */
|
|
||||||
# define ZONEINIT 0xe /* initial zone transfer */
|
|
||||||
# define ZONEREF 0xf /* incremental zone referesh */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Currently defined response codes
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_ADDRINFO
|
|
||||||
#define NOERROR 0 /* no error */
|
|
||||||
#endif /* HAVE_ADDRINFO */
|
|
||||||
#define FORMERR 1 /* format error */
|
|
||||||
#define SERVFAIL 2 /* server failure */
|
|
||||||
#define NXDOMAIN 3 /* non existent domain */
|
|
||||||
#define NOTIMP 4 /* not implemented */
|
|
||||||
#define REFUSED 5 /* query refused */
|
|
||||||
#ifdef ALLOW_UPDATES
|
|
||||||
/* non standard */
|
|
||||||
# define NOCHANGE 0xf /* update failed to change db */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Type values for resources and queries
|
|
||||||
*/
|
|
||||||
#define T_A 1 /* host address */
|
|
||||||
#define T_NS 2 /* authoritative server */
|
|
||||||
#define T_MD 3 /* mail destination */
|
|
||||||
#define T_MF 4 /* mail forwarder */
|
|
||||||
#define T_CNAME 5 /* canonical name */
|
|
||||||
#define T_SOA 6 /* start of authority zone */
|
|
||||||
#define T_MB 7 /* mailbox domain name */
|
|
||||||
#define T_MG 8 /* mail group member */
|
|
||||||
#define T_MR 9 /* mail rename name */
|
|
||||||
#define T_NULL 10 /* null resource record */
|
|
||||||
#define T_WKS 11 /* well known service */
|
|
||||||
#define T_PTR 12 /* domain name pointer */
|
|
||||||
#define T_HINFO 13 /* host information */
|
|
||||||
#define T_MINFO 14 /* mailbox information */
|
|
||||||
#define T_MX 15 /* mail routing information */
|
|
||||||
#define T_TXT 16 /* text strings */
|
|
||||||
#define T_RP 17 /* responsible person */
|
|
||||||
#define T_AFSDB 18 /* AFS cell database */
|
|
||||||
#define T_X25 19 /* X_25 calling address */
|
|
||||||
#define T_ISDN 20 /* ISDN calling address */
|
|
||||||
#define T_RT 21 /* router */
|
|
||||||
#define T_NSAP 22 /* NSAP address */
|
|
||||||
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
|
|
||||||
#define T_SIG 24 /* security signature */
|
|
||||||
#define T_KEY 25 /* security key */
|
|
||||||
#define T_PX 26 /* X.400 mail mapping */
|
|
||||||
#define T_GPOS 27 /* geographical position (withdrawn) */
|
|
||||||
#define T_AAAA 28 /* IP6 Address */
|
|
||||||
#define T_LOC 29 /* Location Information */
|
|
||||||
/* non standard */
|
|
||||||
#define T_UINFO 100 /* user (finger) information */
|
|
||||||
#define T_UID 101 /* user ID */
|
|
||||||
#define T_GID 102 /* group ID */
|
|
||||||
#define T_UNSPEC 103 /* Unspecified format (binary data) */
|
|
||||||
/* Query type values which do not appear in resource records */
|
|
||||||
#define T_AXFR 252 /* transfer zone of authority */
|
|
||||||
#define T_MAILB 253 /* transfer mailbox records */
|
|
||||||
#define T_MAILA 254 /* transfer mail agent records */
|
|
||||||
#define T_ANY 255 /* wildcard match */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values for class field
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define C_IN 1 /* the arpa internet */
|
|
||||||
#define C_CHAOS 3 /* for chaos net (MIT) */
|
|
||||||
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
|
|
||||||
/* Query class values which do not appear in resource records */
|
|
||||||
#define C_ANY 255 /* wildcard match */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Status return codes for T_UNSPEC conversion routines
|
|
||||||
*/
|
|
||||||
#define CONV_SUCCESS 0
|
|
||||||
#define CONV_OVERFLOW (-1)
|
|
||||||
#define CONV_BADFMT (-2)
|
|
||||||
#define CONV_BADCKSUM (-3)
|
|
||||||
#define CONV_BADBUFLEN (-4)
|
|
||||||
|
|
||||||
#ifndef __BYTE_ORDER
|
|
||||||
#if (BSD >= 199103)
|
|
||||||
# include <machine/endian.h>
|
|
||||||
#else
|
|
||||||
#ifdef linux
|
|
||||||
# include <endian.h>
|
|
||||||
#else
|
|
||||||
#define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
|
|
||||||
#define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
|
||||||
#define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
|
|
||||||
|
|
||||||
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
|
|
||||||
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
|
|
||||||
defined(__alpha__) || defined(__alpha)
|
|
||||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
|
||||||
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
|
||||||
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
|
|
||||||
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
|
||||||
defined(__hppa) || defined(__hp9000) || \
|
|
||||||
defined(__hp9000s300) || defined(__hp9000s700) || \
|
|
||||||
defined (BIT_ZERO_ON_LEFT) || defined(m68k)
|
|
||||||
#define __BYTE_ORDER __BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#endif /* linux */
|
|
||||||
#endif /* BSD */
|
|
||||||
#endif /* __BYTE_ORDER */
|
|
||||||
|
|
||||||
#if !defined(__BYTE_ORDER) || \
|
|
||||||
(__BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN && \
|
|
||||||
__BYTE_ORDER != __PDP_ENDIAN)
|
|
||||||
/* you must determine what the correct bit order is for
|
|
||||||
* your compiler - the next line is an intentional error
|
|
||||||
* which will force your compiles to bomb until you fix
|
|
||||||
* the above macros.
|
|
||||||
*/
|
|
||||||
error "Undefined or invalid __BYTE_ORDER";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure for query header. The order of the fields is machine- and
|
|
||||||
* compiler-dependent, depending on the byte/bit order and the layout
|
|
||||||
* of bit fields. We use bit fields only in int variables, as this
|
|
||||||
* is all ANSI requires. This requires a somewhat confusing rearrangement.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned id :16; /* query identification number */
|
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
||||||
/* fields in third byte */
|
|
||||||
unsigned qr: 1; /* response flag */
|
|
||||||
unsigned opcode: 4; /* purpose of message */
|
|
||||||
unsigned aa: 1; /* authoritive answer */
|
|
||||||
unsigned tc: 1; /* truncated message */
|
|
||||||
unsigned rd: 1; /* recursion desired */
|
|
||||||
/* fields in fourth byte */
|
|
||||||
unsigned ra: 1; /* recursion available */
|
|
||||||
unsigned pr: 1; /* primary server req'd (!standard) */
|
|
||||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
|
||||||
unsigned rcode :4; /* response code */
|
|
||||||
#endif
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
|
|
||||||
/* fields in third byte */
|
|
||||||
unsigned rd :1; /* recursion desired */
|
|
||||||
unsigned tc :1; /* truncated message */
|
|
||||||
unsigned aa :1; /* authoritive answer */
|
|
||||||
unsigned opcode :4; /* purpose of message */
|
|
||||||
unsigned qr :1; /* response flag */
|
|
||||||
/* fields in fourth byte */
|
|
||||||
unsigned rcode :4; /* response code */
|
|
||||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
|
||||||
unsigned pr :1; /* primary server req'd (!standard) */
|
|
||||||
unsigned ra :1; /* recursion available */
|
|
||||||
#endif
|
|
||||||
/* remaining bytes */
|
|
||||||
unsigned qdcount :16; /* number of question entries */
|
|
||||||
unsigned ancount :16; /* number of answer entries */
|
|
||||||
unsigned nscount :16; /* number of authority entries */
|
|
||||||
unsigned arcount :16; /* number of resource entries */
|
|
||||||
} HEADER;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines for handling compressed domain names
|
|
||||||
*/
|
|
||||||
#define INDIR_MASK 0xc0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure for passing resource records around.
|
|
||||||
*/
|
|
||||||
struct rrec {
|
|
||||||
int16_t r_zone; /* zone number */
|
|
||||||
int16_t r_class; /* class number */
|
|
||||||
int16_t r_type; /* type number */
|
|
||||||
u_int32_t r_ttl; /* time to live */
|
|
||||||
int r_size; /* size of data area */
|
|
||||||
char *r_data; /* pointer to data */
|
|
||||||
};
|
|
||||||
|
|
||||||
//extern u_int16_t _getshort __P((const u_char *));
|
|
||||||
//extern u_int32_t _getlong __P((const u_char *));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inline versions of get/put short/long. Pointer is advanced.
|
|
||||||
*
|
|
||||||
* These macros demonstrate the property of C whereby it can be
|
|
||||||
* portable or it can be elegant but rarely both.
|
|
||||||
*/
|
|
||||||
#define GETSHORT(s, cp) { \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
(s) = ((u_int16_t)t_cp[0] << 8) \
|
|
||||||
| ((u_int16_t)t_cp[1]) \
|
|
||||||
; \
|
|
||||||
(cp) += INT16SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GETLONG(l, cp) { \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
(l) = ((u_int32_t)t_cp[0] << 24) \
|
|
||||||
| ((u_int32_t)t_cp[1] << 16) \
|
|
||||||
| ((u_int32_t)t_cp[2] << 8) \
|
|
||||||
| ((u_int32_t)t_cp[3]) \
|
|
||||||
; \
|
|
||||||
(cp) += INT32SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PUTSHORT(s, cp) { \
|
|
||||||
register u_int16_t t_s = (u_int16_t)(s); \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
*t_cp++ = t_s >> 8; \
|
|
||||||
*t_cp = t_s; \
|
|
||||||
(cp) += INT16SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PUTLONG(l, cp) { \
|
|
||||||
register u_int32_t t_l = (u_int32_t)(l); \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
*t_cp++ = t_l >> 24; \
|
|
||||||
*t_cp++ = t_l >> 16; \
|
|
||||||
*t_cp++ = t_l >> 8; \
|
|
||||||
*t_cp = t_l; \
|
|
||||||
(cp) += INT32SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !_NAMESER_H_ */
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef _BITTYPES_H
|
|
||||||
#define _BITTYPES_H
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT8_T
|
|
||||||
typedef unsigned char u_int8_t;
|
|
||||||
typedef signed char int8_t;
|
|
||||||
#endif /* HAVE_U_INT8_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT16_T
|
|
||||||
typedef unsigned short u_int16_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
#endif /* HAVE_U_INT16_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT32_T
|
|
||||||
typedef unsigned int u_int32_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
#endif /* HAVE_U_INT32_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT64_T
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
typedef unsigned _int64 u_int64_t;
|
|
||||||
typedef _int64 int64_t;
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
typedef unsigned long long u_int64_t;
|
|
||||||
typedef long long int64_t;
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* HAVE_U_INT64_T */
|
|
||||||
|
|
||||||
#ifndef PRId64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRId64 "I64d"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRId64 "lld"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRId64 */
|
|
||||||
|
|
||||||
#ifndef PRIo64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIo64 "I64o"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIo64 "llo"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIo64 */
|
|
||||||
|
|
||||||
#ifndef PRIx64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIx64 "I64x"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIx64 "llx"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIx64 */
|
|
||||||
|
|
||||||
#ifndef PRIu64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIu64 "I64u"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIu64 "llu"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIu64 */
|
|
||||||
|
|
||||||
#endif /* _BITTYPES_H */
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef HAVE_PORTABLE_PROTOTYPE
|
|
||||||
|
|
||||||
#if defined(__STDC__) || defined(__cplusplus)
|
|
||||||
#define __P(protos) protos /* full-blown ANSI C */
|
|
||||||
#else
|
|
||||||
#define __P(protos) () /* traditional C preprocessor */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !HAVE_PORTABLE_PROTOTYPE */
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 - 2003
|
|
||||||
* NetGroup, Politecnico di Torino (Italy)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Politecnico di Torino nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <net/netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <arpa/nameser.h>
|
|
||||||
|
|
||||||
extern void _sethtent(int f);
|
|
||||||
extern void _endhtent(void);
|
|
||||||
extern struct hostent *_gethtent(void);
|
|
||||||
extern struct hostent *_gethtbyname(const char *name);
|
|
||||||
extern struct hostent *_gethtbyaddr(const char *addr, int len,
|
|
||||||
int type);
|
|
||||||
extern int _validuser(FILE *hostf, const char *rhost,
|
|
||||||
const char *luser, const char *ruser, int baselen);
|
|
||||||
extern int _checkhost(const char *rhost, const char *lhost, int len);
|
|
||||||
#if 0
|
|
||||||
extern void putlong(u_long l, u_char *msgp);
|
|
||||||
extern void putshort(u_short l, u_char *msgp);
|
|
||||||
extern u_int32_t _getlong(register const u_char *msgp);
|
|
||||||
extern u_int16_t _getshort(register const u_char *msgp);
|
|
||||||
extern void p_query(char *msg);
|
|
||||||
extern void fp_query(char *msg, FILE *file);
|
|
||||||
extern char *p_cdname(char *cp, char *msg, FILE *file);
|
|
||||||
extern char *p_rr(char *cp, char *msg, FILE *file);
|
|
||||||
extern char *p_type(int type);
|
|
||||||
extern char * p_class(int class);
|
|
||||||
extern char *p_time(u_long value);
|
|
||||||
#endif
|
|
||||||
extern char * hostalias(const char *name);
|
|
||||||
extern void sethostfile(char *name);
|
|
||||||
extern void _res_close (void);
|
|
||||||
extern void ruserpass(const char *host, char **aname, char **apass);
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1993, 1994, 1997
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that: (1) source code distributions
|
|
||||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
||||||
* distributions including binary code include the above copyright notice and
|
|
||||||
* this paragraph in its entirety in the documentation or other materials
|
|
||||||
* provided with the distribution, and (3) all advertising materials mentioning
|
|
||||||
* features or use of this software display the following acknowledgement:
|
|
||||||
* ``This product includes software developed by the University of California,
|
|
||||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
||||||
* the University nor the names of its contributors may be used to endorse
|
|
||||||
* or promote products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
|
||||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000)
|
|
||||||
|
|
||||||
#define IN_LOOPBACKNET 127
|
|
||||||
|
|
||||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
|
||||||
/* IPv6 address */
|
|
||||||
struct in6_addr
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
u_int8_t u6_addr8[16];
|
|
||||||
u_int16_t u6_addr16[8];
|
|
||||||
u_int32_t u6_addr32[4];
|
|
||||||
} in6_u;
|
|
||||||
#define s6_addr in6_u.u6_addr8
|
|
||||||
#define s6_addr16 in6_u.u6_addr16
|
|
||||||
#define s6_addr32 in6_u.u6_addr32
|
|
||||||
#define s6_addr64 in6_u.u6_addr64
|
|
||||||
};
|
|
||||||
|
|
||||||
#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
|
||||||
#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined _MSC_VER) || (defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF))
|
|
||||||
typedef unsigned short sa_family_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
|
||||||
|
|
||||||
#define __SOCKADDR_COMMON(sa_prefix) \
|
|
||||||
sa_family_t sa_prefix##family
|
|
||||||
|
|
||||||
/* Ditto, for IPv6. */
|
|
||||||
struct sockaddr_in6
|
|
||||||
{
|
|
||||||
__SOCKADDR_COMMON (sin6_);
|
|
||||||
u_int16_t sin6_port; /* Transport layer port # */
|
|
||||||
u_int32_t sin6_flowinfo; /* IPv6 flow information */
|
|
||||||
struct in6_addr sin6_addr; /* IPv6 address */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
|
||||||
((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
|
|
||||||
(((u_int32_t *) (a))[2] == htonl (0xffff)))
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
|
||||||
((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
|
||||||
(((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
|
|
||||||
((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
|
||||||
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
|
||||||
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
|
|
||||||
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
|
|
||||||
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
|
|
||||||
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
|
|
||||||
|
|
||||||
#define nd_rd_type nd_rd_hdr.icmp6_type
|
|
||||||
#define nd_rd_code nd_rd_hdr.icmp6_code
|
|
||||||
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
|
|
||||||
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IPV6 extension headers
|
|
||||||
*/
|
|
||||||
#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
|
|
||||||
#define IPPROTO_IPV6 41 /* IPv6 header. */
|
|
||||||
#define IPPROTO_ROUTING 43 /* IPv6 routing header */
|
|
||||||
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
|
|
||||||
#define IPPROTO_ESP 50 /* encapsulating security payload */
|
|
||||||
#define IPPROTO_AH 51 /* authentication header */
|
|
||||||
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
|
||||||
#define IPPROTO_NONE 59 /* IPv6 no next header */
|
|
||||||
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
|
|
||||||
#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */
|
|
||||||
|
|
||||||
#define IPV6_RTHDR_TYPE_0 0
|
|
||||||
|
|
||||||
/* Option types and related macros */
|
|
||||||
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
|
|
||||||
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
|
|
||||||
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
|
|
||||||
#define IP6OPT_JUMBO_LEN 6
|
|
||||||
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
|
|
||||||
|
|
||||||
#define IP6OPT_RTALERT_LEN 4
|
|
||||||
#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
|
|
||||||
#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
|
|
||||||
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
|
|
||||||
#define IP6OPT_MINLEN 2
|
|
||||||
|
|
||||||
#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
|
|
||||||
#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
|
|
||||||
#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
|
|
||||||
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
|
|
||||||
#define IP6OPT_EID 0x8a /* 10 0 01010 */
|
|
||||||
|
|
||||||
#define IP6OPT_TYPE(o) ((o) & 0xC0)
|
|
||||||
#define IP6OPT_TYPE_SKIP 0x00
|
|
||||||
#define IP6OPT_TYPE_DISCARD 0x40
|
|
||||||
#define IP6OPT_TYPE_FORCEICMP 0x80
|
|
||||||
#define IP6OPT_TYPE_ICMP 0xC0
|
|
||||||
|
|
||||||
#define IP6OPT_MUTABLE 0x20
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
|
||||||
#ifndef EAI_ADDRFAMILY
|
|
||||||
struct addrinfo {
|
|
||||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
|
||||||
int ai_family; /* PF_xxx */
|
|
||||||
int ai_socktype; /* SOCK_xxx */
|
|
||||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
|
||||||
size_t ai_addrlen; /* length of ai_addr */
|
|
||||||
char *ai_canonname; /* canonical name for hostname */
|
|
||||||
struct sockaddr *ai_addr; /* binary address */
|
|
||||||
struct addrinfo *ai_next; /* next structure in linked list */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1980, 1983, 1988, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
|
|
||||||
* netdb.h,v 1.4 1995/08/14 04:05:04 hjl Exp
|
|
||||||
* -
|
|
||||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies, and that
|
|
||||||
* the name of Digital Equipment Corporation not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the document or software without
|
|
||||||
* specific, written prior permission.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
|
||||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
|
||||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
||||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
||||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
* SOFTWARE.
|
|
||||||
* -
|
|
||||||
* --Copyright--
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _NETDB_H_
|
|
||||||
#define _NETDB_H_
|
|
||||||
|
|
||||||
/* MingW64 defines _POSIX_THREAD_SAFE_FUNCTIONS.
|
|
||||||
*/
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT) && !defined(__MINGW64_VERSION_MAJOR)
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <net/paths.h>
|
|
||||||
|
|
||||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
|
||||||
#define _PATH_HOSTS __PATH_ETC_INET"/hosts"
|
|
||||||
#define _PATH_NETWORKS __PATH_ETC_INET"/networks"
|
|
||||||
#define _PATH_PROTOCOLS __PATH_ETC_INET"/protocols"
|
|
||||||
#define _PATH_SERVICES __PATH_ETC_INET"/services"
|
|
||||||
#define _PATH_RESCONF __PATH_ETC_INET"/resolv.conf"
|
|
||||||
#define _PATH_RPC __PATH_ETC_INET"/rpc"
|
|
||||||
|
|
||||||
struct rpcent {
|
|
||||||
char *r_name; /* name of server for this rpc program */
|
|
||||||
char **r_aliases; /* alias list */
|
|
||||||
int r_number; /* rpc program number */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
|
||||||
|
|
||||||
#define __NETDB_MAXALIASES 35
|
|
||||||
#define __NETDB_MAXADDRS 35
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error return codes from gethostbyname() and gethostbyaddr()
|
|
||||||
* (left in extern int h_errno).
|
|
||||||
*/
|
|
||||||
#define h_errno (*__h_errno_location ())
|
|
||||||
#else
|
|
||||||
extern int h_errno;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NETDB_INTERNAL -1 /* see errno */
|
|
||||||
#define NETDB_SUCCESS 0 /* no problem */
|
|
||||||
|
|
||||||
//#include <features.h>
|
|
||||||
|
|
||||||
void endhostent (void);
|
|
||||||
void endnetent (void);
|
|
||||||
void endprotoent (void);
|
|
||||||
void endservent (void);
|
|
||||||
void endrpcent (void);
|
|
||||||
struct hostent *gethostent (void);
|
|
||||||
struct netent *getnetbyaddr (long, int); /* u_long? */
|
|
||||||
struct netent *getnetbyname (const char *);
|
|
||||||
struct netent *getnetent (void);
|
|
||||||
struct protoent *getprotoent (void);
|
|
||||||
struct servent *getservent (void);
|
|
||||||
struct rpcent *getrpcent (void);
|
|
||||||
struct rpcent *getrpcbyname (const char *);
|
|
||||||
struct rpcent *getrpcbynumber (int);
|
|
||||||
void herror (const char *);
|
|
||||||
void sethostent (int);
|
|
||||||
/* void sethostfile (const char *); */
|
|
||||||
void setnetent (int);
|
|
||||||
void setprotoent (int);
|
|
||||||
void setservent (int);
|
|
||||||
void setrpcent (int);
|
|
||||||
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
|
||||||
struct hostent *gethostbyaddr_r (const char *__addr,
|
|
||||||
int __length, int __type,
|
|
||||||
struct hostent *__result,
|
|
||||||
char *__buffer, int __buflen, int *__h_errnop);
|
|
||||||
struct hostent *gethostbyname_r (const char * __name,
|
|
||||||
struct hostent *__result, char *__buffer,
|
|
||||||
int __buflen, int *__h_errnop);
|
|
||||||
struct hostent *gethostent_r (struct hostent *__result,
|
|
||||||
char *__buffer, int __buflen, int *__h_errnop);
|
|
||||||
struct netent *getnetbyaddr_r (long __net, int __type,
|
|
||||||
struct netent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct netent *getnetbyname_r (const char * __name,
|
|
||||||
struct netent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct netent *getnetent_r (struct netent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct protoent *getprotobyname_r (const char * __name,
|
|
||||||
struct protoent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct protoent *getprotobynumber_r (int __proto,
|
|
||||||
struct protoent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct protoent *getprotoent_r (struct protoent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservbyname_r (const char * __name,
|
|
||||||
const char *__proto, struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservbyport_r (int __port,
|
|
||||||
const char *__proto, struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservent_r (struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
|
|
||||||
int *__h_errno_location (void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_NETDB_H_ */
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1989 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)paths.h 5.15 (Berkeley) 5/29/91
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PATHS_H_
|
|
||||||
#define _PATHS_H_
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define __PATH_ETC_INET "/usr/etc/inet"
|
|
||||||
#else
|
|
||||||
#define __PATH_ETC_INET "/etc"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Default search path. */
|
|
||||||
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin:."
|
|
||||||
#define _PATH_DEFPATH_ROOT "/sbin:/bin:/usr/sbin:/usr/bin"
|
|
||||||
|
|
||||||
#define _PATH_BSHELL "/bin/sh"
|
|
||||||
#define _PATH_CONSOLE "/dev/console"
|
|
||||||
#define _PATH_CSHELL "/bin/csh"
|
|
||||||
#define _PATH_DEVDB "/var/run/dev.db"
|
|
||||||
#define _PATH_DEVNULL "/dev/null"
|
|
||||||
#define _PATH_DRUM "/dev/drum"
|
|
||||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
|
||||||
#define _PATH_KMEM "/dev/kmem"
|
|
||||||
#define _PATH_MAILDIR "/var/spool/mail"
|
|
||||||
#define _PATH_MAN "/usr/man"
|
|
||||||
#define _PATH_MEM "/dev/mem"
|
|
||||||
#define _PATH_LOGIN "/bin/login"
|
|
||||||
#define _PATH_NOLOGIN "/etc/nologin"
|
|
||||||
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
|
|
||||||
#define _PATH_SHELLS "/etc/shells"
|
|
||||||
#define _PATH_TTY "/dev/tty"
|
|
||||||
#define _PATH_UNIX "/vmlinux"
|
|
||||||
#define _PATH_VI "/usr/bin/vi"
|
|
||||||
|
|
||||||
/* Provide trailing slash, since mostly used for building pathnames. */
|
|
||||||
#define _PATH_DEV "/dev/"
|
|
||||||
#define _PATH_TMP "/tmp/"
|
|
||||||
#define _PATH_VARRUN "/var/run/"
|
|
||||||
#define _PATH_VARTMP "/var/tmp/"
|
|
||||||
|
|
||||||
#define _PATH_KLOG "/proc/kmsg"
|
|
||||||
#define _PATH_LOGCONF __PATH_ETC_INET"/syslog.conf"
|
|
||||||
#if 0
|
|
||||||
#define _PATH_LOGPID __PATH_ETC_INET"/syslog.pid"
|
|
||||||
#else
|
|
||||||
#define _PATH_LOGPID "/var/run/syslog.pid"
|
|
||||||
#endif
|
|
||||||
#define _PATH_LOG "/dev/log"
|
|
||||||
#define _PATH_CONSOLE "/dev/console"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define _PATH_UTMP "/var/adm/utmp"
|
|
||||||
#define _PATH_WTMP "/var/adm/wtmp"
|
|
||||||
#define _PATH_LASTLOG "/var/adm/lastlog"
|
|
||||||
#else
|
|
||||||
#define _PATH_UTMP "/var/run/utmp"
|
|
||||||
#define _PATH_WTMP "/var/log/wtmp"
|
|
||||||
#define _PATH_LASTLOG "/var/log/lastlog"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _PATH_LOCALE "/usr/lib/locale"
|
|
||||||
|
|
||||||
#define _PATH_RWHODIR "/var/spool/rwho"
|
|
||||||
|
|
||||||
#if _MIT_POSIX_THREADS
|
|
||||||
/* For the MIT pthreads */
|
|
||||||
#define _PATH_PTY "/dev/"
|
|
||||||
#define _PATH_TZDIR "/usr/lib/zoneinfo"
|
|
||||||
#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_PATHS_H_ */
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
struct sockaddr_storage {
|
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
||||||
u_int8_t __ss_len;
|
|
||||||
u_int8_t __ss_family;
|
|
||||||
u_int8_t fill[126];
|
|
||||||
#else
|
|
||||||
u_int8_t __ss_family;
|
|
||||||
u_int8_t fill[127];
|
|
||||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
|
||||||
};
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="libpcap" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
|
||||||
|
|
||||||
CFG=libpcap - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "libpcap.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "libpcap.mak" CFG="libpcap - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "libpcap - Win32 Release" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE "libpcap - Win32 Debug" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "libpcap - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "NDEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "libpcap - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "_DEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "libpcap - Win32 Release"
|
|
||||||
# Name "libpcap - Win32 Debug"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf_dump.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf\net\bpf_filter.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf_image.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\etherent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE="..\..\fad-win32.c"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\ffs.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\gencode.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getnetbynm.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getnetent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getservent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\grammar.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\inet.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_aton.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_net.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_pton.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\nametoaddr.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\optimize.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE="..\..\Pcap-win32.c"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\pcap.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\savefile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\scanner.c
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "libpcap"=".\libpcap.dsp" - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
28
libpcap/Win32/Prj/wpcap.sln
Normal file
28
libpcap/Win32/Prj/wpcap.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.40629.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
234
libpcap/Win32/Prj/wpcap.vcxproj
Normal file
234
libpcap/Win32/Prj/wpcap.vcxproj
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<SccProjectName />
|
||||||
|
<SccLocalPath />
|
||||||
|
<ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>.\Release\</OutDir>
|
||||||
|
<IntDir>.\Release\</IntDir>
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>.\Debug\</OutDir>
|
||||||
|
<IntDir>.\Debug\</IntDir>
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||||
|
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||||
|
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||||
|
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||||
|
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||||
|
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||||
|
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||||
|
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0409</Culture>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||||
|
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||||
|
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\bpf\net\bpf_filter.c" />
|
||||||
|
<ClCompile Include="..\..\bpf_dump.c" />
|
||||||
|
<ClCompile Include="..\..\bpf_image.c" />
|
||||||
|
<ClCompile Include="..\..\etherent.c" />
|
||||||
|
<ClCompile Include="..\..\fad-helpers.c" />
|
||||||
|
<ClCompile Include="..\..\gencode.c" />
|
||||||
|
<ClCompile Include="..\..\grammar.c" />
|
||||||
|
<ClCompile Include="..\..\inet.c" />
|
||||||
|
<ClCompile Include="..\..\missing\win_snprintf.c" />
|
||||||
|
<ClCompile Include="..\..\nametoaddr.c" />
|
||||||
|
<ClCompile Include="..\..\optimize.c" />
|
||||||
|
<ClCompile Include="..\..\pcap-common.c" />
|
||||||
|
<ClCompile Include="..\..\pcap-new.c" />
|
||||||
|
<ClCompile Include="..\..\pcap-rpcap.c" />
|
||||||
|
<ClCompile Include="..\..\pcap-win32.c" />
|
||||||
|
<ClCompile Include="..\..\pcap.c" />
|
||||||
|
<ClCompile Include="..\..\savefile.c" />
|
||||||
|
<ClCompile Include="..\..\scanner.c" />
|
||||||
|
<ClCompile Include="..\..\sf-pcap-ng.c" />
|
||||||
|
<ClCompile Include="..\..\sf-pcap.c" />
|
||||||
|
<ClCompile Include="..\..\sockutils.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\pcap-common.h" />
|
||||||
|
<ClInclude Include="..\..\pcap-int.h" />
|
||||||
|
<ClInclude Include="..\..\pcap-rpcap.h" />
|
||||||
|
<ClInclude Include="..\..\pcap-stdinc.h" />
|
||||||
|
<ClInclude Include="..\..\pcap.h" />
|
||||||
|
<ClInclude Include="..\..\remote-ext.h" />
|
||||||
|
<ClInclude Include="..\..\sockutils.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
107
libpcap/Win32/Prj/wpcap.vcxproj.filters
Normal file
107
libpcap/Win32/Prj/wpcap.vcxproj.filters
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\bpf_dump.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\bpf\net\bpf_filter.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\bpf_image.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\etherent.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\gencode.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\grammar.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\inet.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\nametoaddr.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\optimize.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\pcap.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\pcap-win32.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\savefile.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\scanner.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\sf-pcap.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\sf-pcap-ng.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\pcap-common.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\fad-helpers.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\missing\win_snprintf.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\pcap-new.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\pcap-rpcap.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\sockutils.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\pcap-stdinc.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\pcap-common.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\pcap.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\pcap-int.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\pcap-rpcap.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\remote-ext.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\sockutils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/net/gai_strerror.c,v 1.1 2005/04/06 12:45:51 ume Exp $");
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <netdb.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
|
|
||||||
/* for backward compatibility with userland code prior to 2553bis-02 */
|
|
||||||
static char *ai_errlist[] = {
|
|
||||||
"Success", /* 0 */
|
|
||||||
"Address family for hostname not supported", /* 1 */
|
|
||||||
"Temporary failure in name resolution", /* EAI_AGAIN */
|
|
||||||
"Invalid value for ai_flags", /* EAI_BADFLAGS */
|
|
||||||
"Non-recoverable failure in name resolution", /* EAI_FAIL */
|
|
||||||
"ai_family not supported", /* EAI_FAMILY */
|
|
||||||
"Memory allocation failure", /* EAI_MEMORY */
|
|
||||||
"No address associated with hostname", /* 7 */
|
|
||||||
"hostname nor servname provided, or not known", /* EAI_NONAME */
|
|
||||||
"servname not supported for ai_socktype", /* EAI_SERVICE */
|
|
||||||
"ai_socktype not supported", /* EAI_SOCKTYPE */
|
|
||||||
"System error returned in errno", /* EAI_SYSTEM */
|
|
||||||
"Invalid value for hints", /* EAI_BADHINTS */
|
|
||||||
"Resolved protocol is unknown" /* EAI_PROTOCOL */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef EAI_MAX
|
|
||||||
#define EAI_MAX (sizeof(ai_errlist)/sizeof(ai_errlist[0]))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* on MingW, gai_strerror is available.
|
|
||||||
We need to compile gai_strerrorA only for Cygwin
|
|
||||||
*/
|
|
||||||
#ifndef gai_strerror
|
|
||||||
|
|
||||||
char *
|
|
||||||
WSAAPI gai_strerrorA(int ecode)
|
|
||||||
{
|
|
||||||
if (ecode >= 0 && ecode < EAI_MAX)
|
|
||||||
return ai_errlist[ecode];
|
|
||||||
return "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* gai_strerror */
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983 Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms are permitted
|
|
||||||
* provided that the above copyright notice and this paragraph are
|
|
||||||
* duplicated in all such forms and that any documentation,
|
|
||||||
* advertising materials, and other materials related to such
|
|
||||||
* distribution and use acknowledge that the software was developed
|
|
||||||
* by the University of California, Berkeley. The name of the
|
|
||||||
* University may not be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
extern int _net_stayopen;
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetbyname(const char *name)
|
|
||||||
{
|
|
||||||
register struct netent *p;
|
|
||||||
register char **cp;
|
|
||||||
|
|
||||||
setnetent(_net_stayopen);
|
|
||||||
while (p = getnetent()) {
|
|
||||||
if (strcmp(p->n_name, name) == 0)
|
|
||||||
break;
|
|
||||||
for (cp = p->n_aliases; *cp != 0; cp++)
|
|
||||||
if (strcmp(*cp, name) == 0)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
found:
|
|
||||||
if (!_net_stayopen)
|
|
||||||
endnetent();
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983 Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms are permitted
|
|
||||||
* provided that the above copyright notice and this paragraph are
|
|
||||||
* duplicated in all such forms and that any documentation,
|
|
||||||
* advertising materials, and other materials related to such
|
|
||||||
* distribution and use acknowledge that the software was developed
|
|
||||||
* by the University of California, Berkeley. The name of the
|
|
||||||
* University may not be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
#define MAXALIASES 35
|
|
||||||
|
|
||||||
static char NETDB[] = _PATH_NETWORKS;
|
|
||||||
static FILE *netf = NULL;
|
|
||||||
static char line[BUFSIZ+1];
|
|
||||||
static struct netent net;
|
|
||||||
static char *net_aliases[MAXALIASES];
|
|
||||||
static char *any(char *, char *);
|
|
||||||
|
|
||||||
int _net_stayopen;
|
|
||||||
extern u_int32_t inet_network(const char *cp);
|
|
||||||
|
|
||||||
void
|
|
||||||
setnetent(f)
|
|
||||||
int f;
|
|
||||||
{
|
|
||||||
if (netf == NULL)
|
|
||||||
netf = fopen(NETDB, "r" );
|
|
||||||
else
|
|
||||||
rewind(netf);
|
|
||||||
_net_stayopen |= f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endnetent()
|
|
||||||
{
|
|
||||||
if (netf) {
|
|
||||||
fclose(netf);
|
|
||||||
netf = NULL;
|
|
||||||
}
|
|
||||||
_net_stayopen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetent()
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
register char *cp, **q;
|
|
||||||
|
|
||||||
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
again:
|
|
||||||
p = fgets(line, BUFSIZ, netf);
|
|
||||||
if (p == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (*p == '#')
|
|
||||||
goto again;
|
|
||||||
cp = any(p, "#\n");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp = '\0';
|
|
||||||
net.n_name = p;
|
|
||||||
cp = any(p, " \t");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp++ = '\0';
|
|
||||||
while (*cp == ' ' || *cp == '\t')
|
|
||||||
cp++;
|
|
||||||
p = any(cp, " \t");
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = '\0';
|
|
||||||
net.n_net = inet_network(cp);
|
|
||||||
net.n_addrtype = AF_INET;
|
|
||||||
q = net.n_aliases = net_aliases;
|
|
||||||
if (p != NULL)
|
|
||||||
cp = p;
|
|
||||||
while (cp && *cp) {
|
|
||||||
if (*cp == ' ' || *cp == '\t') {
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (q < &net_aliases[MAXALIASES - 1])
|
|
||||||
*q++ = cp;
|
|
||||||
cp = any(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
}
|
|
||||||
*q = NULL;
|
|
||||||
return (&net);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
any(cp, match)
|
|
||||||
register char *cp;
|
|
||||||
char *match;
|
|
||||||
{
|
|
||||||
register char *mp, c;
|
|
||||||
|
|
||||||
while (c = *cp) {
|
|
||||||
for (mp = match; *mp; mp++)
|
|
||||||
if (*mp == c)
|
|
||||||
return (cp);
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
return ((char *)0);
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <net/netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <arpa/nameser.h>
|
|
||||||
|
|
||||||
#define MAXALIASES 35
|
|
||||||
|
|
||||||
static char SERVDB[] = _PATH_SERVICES;
|
|
||||||
static FILE *servf = NULL;
|
|
||||||
static char line[BUFSIZ+1];
|
|
||||||
static struct servent serv;
|
|
||||||
static char *serv_aliases[MAXALIASES];
|
|
||||||
int _serv_stayopen;
|
|
||||||
|
|
||||||
void
|
|
||||||
setservent(f)
|
|
||||||
int f;
|
|
||||||
{
|
|
||||||
if (servf == NULL)
|
|
||||||
servf = fopen(SERVDB, "r" );
|
|
||||||
else
|
|
||||||
rewind(servf);
|
|
||||||
_serv_stayopen |= f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endservent()
|
|
||||||
{
|
|
||||||
if (servf) {
|
|
||||||
fclose(servf);
|
|
||||||
servf = NULL;
|
|
||||||
}
|
|
||||||
_serv_stayopen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct servent *
|
|
||||||
getservent()
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
register char *cp, **q;
|
|
||||||
|
|
||||||
if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
again:
|
|
||||||
if ((p = fgets(line, BUFSIZ, servf)) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (*p == '#')
|
|
||||||
goto again;
|
|
||||||
cp = strpbrk(p, "#\n");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp = '\0';
|
|
||||||
serv.s_name = p;
|
|
||||||
p = strpbrk(p, " \t");
|
|
||||||
if (p == NULL)
|
|
||||||
goto again;
|
|
||||||
*p++ = '\0';
|
|
||||||
while (*p == ' ' || *p == '\t')
|
|
||||||
p++;
|
|
||||||
cp = strpbrk(p, ",/");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp++ = '\0';
|
|
||||||
serv.s_port = htons((u_short)atoi(p));
|
|
||||||
serv.s_proto = cp;
|
|
||||||
q = serv.s_aliases = serv_aliases;
|
|
||||||
cp = strpbrk(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
while (cp && *cp) {
|
|
||||||
if (*cp == ' ' || *cp == '\t') {
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (q < &serv_aliases[MAXALIASES - 1])
|
|
||||||
*q++ = cp;
|
|
||||||
cp = strpbrk(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
}
|
|
||||||
*q = NULL;
|
|
||||||
return (&serv);
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the Kungliga Tekniska
|
|
||||||
* H<>gskolan and its contributors.
|
|
||||||
*
|
|
||||||
* 4. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
/* Minimal implementation of inet_aton.
|
|
||||||
* Cannot distinguish between failure and a local broadcast address. */
|
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
|
||||||
#define INADDR_NONE 0xffffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
|
||||||
inet_aton(const char *cp, struct in_addr *addr)
|
|
||||||
{
|
|
||||||
addr->s_addr = inet_addr(cp);
|
|
||||||
return (addr->s_addr == INADDR_NONE) ? 0 : 1;
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internet network address interpretation routine.
|
|
||||||
* The library routines call this routine to interpret
|
|
||||||
* network numbers.
|
|
||||||
*/
|
|
||||||
u_int32_t
|
|
||||||
inet_network(const char *cp)
|
|
||||||
{
|
|
||||||
register u_long val, base, n;
|
|
||||||
register char c;
|
|
||||||
u_long parts[4], *pp = parts;
|
|
||||||
register int i;
|
|
||||||
|
|
||||||
again:
|
|
||||||
/*
|
|
||||||
* Collect number up to ``.''.
|
|
||||||
* Values are specified as for C:
|
|
||||||
* 0x=hex, 0=octal, other=decimal.
|
|
||||||
*/
|
|
||||||
val = 0; base = 10;
|
|
||||||
/*
|
|
||||||
* The 4.4BSD version of this file also accepts 'x__' as a hexa
|
|
||||||
* number. I don't think this is correct. -- Uli
|
|
||||||
*/
|
|
||||||
if (*cp == '0') {
|
|
||||||
if (*++cp == 'x' || *cp == 'X')
|
|
||||||
base = 16, cp++;
|
|
||||||
else
|
|
||||||
base = 8;
|
|
||||||
}
|
|
||||||
while ((c = *cp)) {
|
|
||||||
if (isdigit(c)) {
|
|
||||||
val = (val * base) + (c - '0');
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (base == 16 && isxdigit(c)) {
|
|
||||||
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*cp == '.') {
|
|
||||||
if (pp >= parts + 4)
|
|
||||||
return (INADDR_NONE);
|
|
||||||
*pp++ = val, cp++;
|
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
if (*cp && !isspace(*cp))
|
|
||||||
return (INADDR_NONE);
|
|
||||||
*pp++ = val;
|
|
||||||
n = pp - parts;
|
|
||||||
if (n > 4)
|
|
||||||
return (INADDR_NONE);
|
|
||||||
for (val = 0, i = 0; i < (int)n; i++) {
|
|
||||||
val <<= 8;
|
|
||||||
val |= parts[i] & 0xff;
|
|
||||||
}
|
|
||||||
return (val);
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 Kungliga Tekniska H<>gskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the Kungliga Tekniska
|
|
||||||
* H<>gskolan and its contributors.
|
|
||||||
*
|
|
||||||
* 4. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#ifndef EAFNOSUPPORT
|
|
||||||
#define EAFNOSUPPORT 97 /* not present in errno.h provided with VC */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
int* _errno();
|
|
||||||
#define errno (*_errno())
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
int inet_aton(const char *cp, struct in_addr *addr);
|
|
||||||
|
|
||||||
int
|
|
||||||
inet_pton(int af, const char *src, void *dst)
|
|
||||||
{
|
|
||||||
if (af != AF_INET) {
|
|
||||||
errno = EAFNOSUPPORT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return inet_aton (src, dst);
|
|
||||||
}
|
|
||||||
112
libpcap/aclocal.m4
vendored
112
libpcap/aclocal.m4
vendored
@@ -102,6 +102,13 @@ AC_DEFUN(AC_LBL_C_INIT,
|
|||||||
# -Werror forces warnings to be errors.
|
# -Werror forces warnings to be errors.
|
||||||
#
|
#
|
||||||
ac_lbl_cc_force_warning_errors=-Werror
|
ac_lbl_cc_force_warning_errors=-Werror
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to have the compiler default to hiding symbols,
|
||||||
|
# so that only symbols explicitly exported with
|
||||||
|
# PCAP_API will be visible outside (shared) libraries.
|
||||||
|
#
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
|
||||||
else
|
else
|
||||||
$2="$$2 -I/usr/local/include"
|
$2="$$2 -I/usr/local/include"
|
||||||
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
||||||
@@ -114,6 +121,13 @@ AC_DEFUN(AC_LBL_C_INIT,
|
|||||||
# of which use -Werror to force warnings to be errors.
|
# of which use -Werror to force warnings to be errors.
|
||||||
#
|
#
|
||||||
ac_lbl_cc_force_warning_errors=-Werror
|
ac_lbl_cc_force_warning_errors=-Werror
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to have the compiler default to hiding symbols,
|
||||||
|
# so that only symbols explicitly exported with
|
||||||
|
# PCAP_API will be visible outside (shared) libraries.
|
||||||
|
#
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
hpux*)
|
hpux*)
|
||||||
@@ -188,6 +202,13 @@ AC_DEFUN(AC_LBL_C_INIT,
|
|||||||
# warnings to be treated as errors.
|
# warnings to be treated as errors.
|
||||||
#
|
#
|
||||||
ac_lbl_cc_force_warning_errors=-errwarn
|
ac_lbl_cc_force_warning_errors=-errwarn
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to have the compiler default to hiding symbols,
|
||||||
|
# so that only symbols explicitly exported with
|
||||||
|
# PCAP_API will be visible outside (shared) libraries.
|
||||||
|
#
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
ultrix*)
|
ultrix*)
|
||||||
@@ -249,7 +270,18 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
|
|||||||
[
|
[
|
||||||
AC_MSG_CHECKING([whether the compiler supports the $2 option])
|
AC_MSG_CHECKING([whether the compiler supports the $2 option])
|
||||||
save_CFLAGS="$CFLAGS"
|
save_CFLAGS="$CFLAGS"
|
||||||
|
if expr "x$2" : "x-W.*" >/dev/null
|
||||||
|
then
|
||||||
CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
|
CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
|
||||||
|
elif expr "x$2" : "x-f.*" >/dev/null
|
||||||
|
then
|
||||||
|
CFLAGS="$CFLAGS -Werror $2"
|
||||||
|
elif expr "x$2" : "x-m.*" >/dev/null
|
||||||
|
then
|
||||||
|
CFLAGS="$CFLAGS -Werror $2"
|
||||||
|
else
|
||||||
|
CFLAGS="$CFLAGS $2"
|
||||||
|
fi
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[],
|
[],
|
||||||
[return 0],
|
[return 0],
|
||||||
@@ -629,82 +661,6 @@ AC_DEFUN(AC_LBL_FIXINCLUDES,
|
|||||||
fi
|
fi
|
||||||
fi])
|
fi])
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Check for flex, default to lex
|
|
||||||
dnl Require flex 2.4 or higher
|
|
||||||
dnl Check for bison, default to yacc
|
|
||||||
dnl Default to lex/yacc if both flex and bison are not available
|
|
||||||
dnl
|
|
||||||
dnl If we're using flex and bison, pass -P to flex and -p to bison
|
|
||||||
dnl to define a prefix string for the lexer and parser
|
|
||||||
dnl
|
|
||||||
dnl If we're not using flex and bison, don't pass those options
|
|
||||||
dnl (as they might not work - although if "lex" is a wrapper for
|
|
||||||
dnl Flex and "yacc" is a wrapper for Bison, they will work), and
|
|
||||||
dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
|
|
||||||
dnl whether the wrapper is needed, as some people apparently, for
|
|
||||||
dnl some unknown reason, choose to use --without-flex and
|
|
||||||
dnl --without-bison on systems that have Flex and Bison, which
|
|
||||||
dnl means that the "yacc" they end up using is a wrapper that
|
|
||||||
dnl runs "bison -y", and at least some versions of Bison define
|
|
||||||
dnl YYBISON even if run with "-y", so we end up not compiling
|
|
||||||
dnl the yyparse wrapper and end up with a libpcap that doesn't
|
|
||||||
dnl define pcap_parse())
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl $1 (lex set)
|
|
||||||
dnl $2 (yacc appended)
|
|
||||||
dnl $3 (optional flex and bison -P prefix)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_LEX_AND_YACC,
|
|
||||||
[AC_ARG_WITH(flex, [ --without-flex don't use flex])
|
|
||||||
AC_ARG_WITH(bison, [ --without-bison don't use bison])
|
|
||||||
if test "$with_flex" = no ; then
|
|
||||||
$1=lex
|
|
||||||
else
|
|
||||||
AC_CHECK_PROGS($1, flex, lex)
|
|
||||||
fi
|
|
||||||
if test "$$1" = flex ; then
|
|
||||||
# The -V flag was added in 2.4
|
|
||||||
AC_MSG_CHECKING(for flex 2.4 or higher)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_flex_v24,
|
|
||||||
if flex -V >/dev/null 2>&1; then
|
|
||||||
ac_cv_lbl_flex_v24=yes
|
|
||||||
else
|
|
||||||
ac_cv_lbl_flex_v24=no
|
|
||||||
fi)
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_flex_v24)
|
|
||||||
if test $ac_cv_lbl_flex_v24 = no ; then
|
|
||||||
s="2.4 or higher required"
|
|
||||||
AC_MSG_WARN(ignoring obsolete flex executable ($s))
|
|
||||||
$1=lex
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "$with_bison" = no ; then
|
|
||||||
$2=yacc
|
|
||||||
else
|
|
||||||
AC_CHECK_PROGS($2, bison, yacc)
|
|
||||||
fi
|
|
||||||
if test "$$2" = bison ; then
|
|
||||||
$2="$$2 -y"
|
|
||||||
fi
|
|
||||||
if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
|
|
||||||
AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
|
|
||||||
$1=lex
|
|
||||||
$2=yacc
|
|
||||||
fi
|
|
||||||
if test "$$1" = flex -a -n "$3" ; then
|
|
||||||
$1="$$1 -P$3"
|
|
||||||
$2="$$2 -p $3"
|
|
||||||
else
|
|
||||||
AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Checks to see if union wait is used with WEXITSTATUS()
|
dnl Checks to see if union wait is used with WEXITSTATUS()
|
||||||
dnl
|
dnl
|
||||||
@@ -970,8 +926,12 @@ AC_DEFUN(AC_LBL_DEVEL,
|
|||||||
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
|
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
|
||||||
AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
|
AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
|
||||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
|
||||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
|
||||||
AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
|
||||||
|
AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
|
||||||
fi
|
fi
|
||||||
AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
|
AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -42,11 +42,11 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
|
|
||||||
#else /* WIN32 */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#if HAVE_INTTYPES_H
|
#if HAVE_INTTYPES_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
# define MLEN(m) ((m)->m_len)
|
# define MLEN(m) ((m)->m_len)
|
||||||
#endif /* defined(__hpux) || SOLARIS */
|
#endif /* defined(__hpux) || SOLARIS */
|
||||||
|
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <pcap/bpf.h>
|
#include <pcap/bpf.h>
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LBL_ALIGN
|
#ifndef LBL_ALIGN
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -216,6 +216,8 @@ enum {
|
|||||||
* rejects the filter; it contains VLAN tag information
|
* rejects the filter; it contains VLAN tag information
|
||||||
* For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
|
* For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
|
||||||
* in all other cases, p is a pointer to a buffer and buflen is its size.
|
* in all other cases, p is a pointer to a buffer and buflen is its size.
|
||||||
|
*
|
||||||
|
* Thanks to Ani Sinha <ani@arista.com> for providing initial implementation
|
||||||
*/
|
*/
|
||||||
u_int
|
u_int
|
||||||
bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
|
bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
|
||||||
@@ -577,7 +579,12 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case BPF_ALU|BPF_NEG:
|
case BPF_ALU|BPF_NEG:
|
||||||
A = -A;
|
/*
|
||||||
|
* Most BPF arithmetic is unsigned, but negation
|
||||||
|
* can't be unsigned; throw some casts to
|
||||||
|
* specify what we're trying to do.
|
||||||
|
*/
|
||||||
|
A = (u_int32)(-(int32)A);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case BPF_MISC|BPF_TAX:
|
case BPF_MISC|BPF_TAX:
|
||||||
@@ -631,7 +638,7 @@ bpf_validate(f, len)
|
|||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < (u_int)len; ++i) {
|
||||||
p = &f[i];
|
p = &f[i];
|
||||||
switch (BPF_CLASS(p->code)) {
|
switch (BPF_CLASS(p->code)) {
|
||||||
/*
|
/*
|
||||||
@@ -732,7 +739,7 @@ bpf_validate(f, len)
|
|||||||
#if defined(KERNEL) || defined(_KERNEL)
|
#if defined(KERNEL) || defined(_KERNEL)
|
||||||
if (from + p->k < from || from + p->k >= len)
|
if (from + p->k < from || from + p->k >= len)
|
||||||
#else
|
#else
|
||||||
if (from + p->k >= len)
|
if (from + p->k >= (u_int)len)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
@@ -740,7 +747,7 @@ bpf_validate(f, len)
|
|||||||
case BPF_JGT:
|
case BPF_JGT:
|
||||||
case BPF_JGE:
|
case BPF_JGE:
|
||||||
case BPF_JSET:
|
case BPF_JSET:
|
||||||
if (from + p->jt >= len || from + p->jf >= len)
|
if (from + p->jt >= (u_int)len || from + p->jf >= (u_int)len)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ bpf_dump(const struct bpf_program *p, int option)
|
|||||||
for (i = 0; i < n; ++insn, ++i) {
|
for (i = 0; i < n; ++insn, ++i) {
|
||||||
#ifdef BDEBUG
|
#ifdef BDEBUG
|
||||||
extern int bids[];
|
extern int bids[];
|
||||||
printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
|
if (bids[i] > 0)
|
||||||
|
printf("[%02d]", bids[i] - 1);
|
||||||
|
else
|
||||||
|
printf(" -- ");
|
||||||
#endif
|
#endif
|
||||||
puts(bpf_image(insn, i));
|
puts(bpf_image(insn, i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
#else /* WIN32 */
|
#else /* _WIN32 */
|
||||||
#if HAVE_INTTYPES_H
|
#if HAVE_INTTYPES_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#elif HAVE_STDINT_H
|
#elif HAVE_STDINT_H
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <sys/bitypes.h>
|
#include <sys/bitypes.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -306,13 +306,13 @@ bpf_image(p, n)
|
|||||||
fmt = "";
|
fmt = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(void)snprintf(operand, sizeof operand, fmt, v);
|
(void)pcap_snprintf(operand, sizeof operand, fmt, v);
|
||||||
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
|
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
|
||||||
(void)snprintf(image, sizeof image,
|
(void)pcap_snprintf(image, sizeof image,
|
||||||
"(%03d) %-8s %-16s jt %d\tjf %d",
|
"(%03d) %-8s %-16s jt %d\tjf %d",
|
||||||
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
|
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(image, sizeof image,
|
(void)pcap_snprintf(image, sizeof image,
|
||||||
"(%03d) %-8s %s",
|
"(%03d) %-8s %s",
|
||||||
n, op, operand);
|
n, op, operand);
|
||||||
}
|
}
|
||||||
|
|||||||
55
libpcap/cmake/preconfigure.cmake
Normal file
55
libpcap/cmake/preconfigure.cmake
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
if( NOT LIBPCAP_PRECONFIGURED )
|
||||||
|
set( LIBPCAP_PRECONFIGURED TRUE )
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# Parameters
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
option (USE_STATIC_RT "Use static Runtime" ON)
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Project setings
|
||||||
|
######################################
|
||||||
|
|
||||||
|
add_definitions( -DBUILDING_PCAP )
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
add_definitions( -D__STDC__ )
|
||||||
|
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
|
||||||
|
add_definitions( "-D_U_=" )
|
||||||
|
elseif( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
|
add_definitions( "-D_U_=__attribute__((unused))" )
|
||||||
|
else(MSVC)
|
||||||
|
add_definitions( "-D_U_=" )
|
||||||
|
endif( MSVC )
|
||||||
|
|
||||||
|
if (USE_STATIC_RT)
|
||||||
|
MESSAGE( STATUS "Use STATIC runtime" )
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||||
|
endif( MSVC )
|
||||||
|
else (USE_STATIC_RT)
|
||||||
|
MESSAGE( STATUS "Use DYNAMIC runtime" )
|
||||||
|
|
||||||
|
if( MSVC )
|
||||||
|
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||||
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
|
||||||
|
endif( MSVC )
|
||||||
|
endif (USE_STATIC_RT)
|
||||||
|
endif( NOT LIBPCAP_PRECONFIGURED )
|
||||||
345
libpcap/cmakeconfig.h.in
Normal file
345
libpcap/cmakeconfig.h.in
Normal file
@@ -0,0 +1,345 @@
|
|||||||
|
/* cmakeconfig.h.in */
|
||||||
|
|
||||||
|
/* Enable optimizer debugging */
|
||||||
|
#cmakedefine BDEBUG 1
|
||||||
|
|
||||||
|
/* define if you have a cloning BPF device */
|
||||||
|
#cmakedefine HAVE_CLONING_BPF 1
|
||||||
|
|
||||||
|
/* define if you have the DAG API */
|
||||||
|
#cmakedefine HAVE_DAG_API 1
|
||||||
|
|
||||||
|
/* define if you have dag_get_erf_types() */
|
||||||
|
#cmakedefine HAVE_DAG_GET_ERF_TYPES 1
|
||||||
|
|
||||||
|
/* define if you have dag_get_stream_erf_types() */
|
||||||
|
#cmakedefine HAVE_DAG_GET_STREAM_ERF_TYPES 1
|
||||||
|
|
||||||
|
/* define if you have streams capable DAG API */
|
||||||
|
#cmakedefine HAVE_DAG_STREAMS_API 1
|
||||||
|
|
||||||
|
/* define if you have vdag_set_device_info() */
|
||||||
|
#cmakedefine HAVE_DAG_VDAG 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#cmakedefine HAVE_DECL_ETHER_HOSTTON 1
|
||||||
|
|
||||||
|
/* define if you have a /dev/dlpi */
|
||||||
|
#cmakedefine HAVE_DEV_DLPI 1
|
||||||
|
|
||||||
|
/* if passive_req_t primitive exists */
|
||||||
|
#cmakedefine HAVE_DLPI_PASSIVE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ether_hostton' function. */
|
||||||
|
#cmakedefine HAVE_ETHER_HOSTTON 1
|
||||||
|
|
||||||
|
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||||
|
#cmakedefine HAVE_FSEEKO 1
|
||||||
|
|
||||||
|
/* on HP-UX 10.20 or later */
|
||||||
|
#cmakedefine HAVE_HPUX10_20_OR_LATER 1
|
||||||
|
|
||||||
|
/* on HP-UX 9.x */
|
||||||
|
#cmakedefine HAVE_HPUX9 1
|
||||||
|
|
||||||
|
/* if ppa_info_t_dl_module_id exists */
|
||||||
|
#cmakedefine HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#cmakedefine HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* if libdlpi exists */
|
||||||
|
#cmakedefine HAVE_LIBDLPI 1
|
||||||
|
|
||||||
|
/* if libnl exists */
|
||||||
|
#cmakedefine HAVE_LIBNL 1
|
||||||
|
|
||||||
|
/* if libnl exists and is version 2.x */
|
||||||
|
#cmakedefine HAVE_LIBNL_2_x 1
|
||||||
|
|
||||||
|
/* if libnl exists and is version 3.x */
|
||||||
|
#cmakedefine HAVE_LIBNL_3_x 1
|
||||||
|
|
||||||
|
/* libnl has NLE_FAILURE */
|
||||||
|
#cmakedefine HAVE_LIBNL_NLE 1
|
||||||
|
|
||||||
|
/* libnl has new-style socket api */
|
||||||
|
#cmakedefine HAVE_LIBNL_SOCKETS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#cmakedefine HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/compiler.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_COMPILER_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/ethtool.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_ETHTOOL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/if_bonding.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_IF_BONDING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/if_packet.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_IF_PACKET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_NET_TSTAMP_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_SOCKIOS_H 1
|
||||||
|
|
||||||
|
/* if tp_vlan_tci exists */
|
||||||
|
#cmakedefine HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/types.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <linux/wireless.h> header file. */
|
||||||
|
#cmakedefine HAVE_LINUX_WIRELESS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#cmakedefine HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netinet/ether.h> header file. */
|
||||||
|
#cmakedefine HAVE_NETINET_ETHER_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
|
||||||
|
#cmakedefine HAVE_NETINET_IF_ETHER_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netpacket/if_packet.h> header file. */
|
||||||
|
#cmakedefine HAVE_NETPACKET_IF_PACKET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netpacket/packet.h> header file. */
|
||||||
|
#cmakedefine HAVE_NETPACKET_PACKET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <net/if_media.h> header file. */
|
||||||
|
#cmakedefine HAVE_NET_IF_MEDIA_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||||
|
#cmakedefine HAVE_NET_PFVAR_H 1
|
||||||
|
|
||||||
|
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||||
|
#cmakedefine HAVE_OS_PROTO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if remote packet capture is to be supported */
|
||||||
|
#cmakedefine HAVE_REMOTE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <paths.h> header file. */
|
||||||
|
#cmakedefine HAVE_PATHS_H 1
|
||||||
|
|
||||||
|
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||||
|
#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
|
||||||
|
|
||||||
|
/* define if you have the Septel API */
|
||||||
|
#cmakedefine HAVE_SEPTEL_API 1
|
||||||
|
|
||||||
|
/* define if you have the Myricom SNF API */
|
||||||
|
#cmakedefine HAVE_SNF_API 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `snprintf' function. */
|
||||||
|
#cmakedefine HAVE_SNPRINTF 1
|
||||||
|
|
||||||
|
/* if struct sockaddr has the sa_len member */
|
||||||
|
#cmakedefine HAVE_SOCKADDR_SA_LEN 1
|
||||||
|
|
||||||
|
/* if struct sockaddr_storage exists */
|
||||||
|
#cmakedefine HAVE_SOCKADDR_STORAGE 1
|
||||||
|
|
||||||
|
/* define if socklen_t is defined */
|
||||||
|
#cmakedefine HAVE_SOCKLEN_T 1
|
||||||
|
|
||||||
|
/* On solaris */
|
||||||
|
#cmakedefine HAVE_SOLARIS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strerror' function. */
|
||||||
|
#cmakedefine HAVE_STRERROR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strlcpy' function. */
|
||||||
|
#cmakedefine HAVE_STRLCPY 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||||
|
#cmakedefine HAVE_STRUCT_BPF_TIMEVAL 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||||
|
#cmakedefine HAVE_STRUCT_ETHER_ADDR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/bitypes.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_BITYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/bufmod.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_BUFMOD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/dlpi_ext.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_DLPI_EXT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_IOCCOM_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_SOCKIO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* define if you have the TurboCap API */
|
||||||
|
#cmakedefine HAVE_TC_API 1
|
||||||
|
|
||||||
|
/* if if_packet.h has tpacket_stats defined */
|
||||||
|
#cmakedefine HAVE_TPACKET_STATS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#cmakedefine HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||||
|
#cmakedefine HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
|
#cmakedefine HAVE_VSNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */
|
||||||
|
#cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1
|
||||||
|
|
||||||
|
/* define if the system supports zerocopy BPF */
|
||||||
|
#cmakedefine HAVE_ZEROCOPY_BPF 1
|
||||||
|
|
||||||
|
/* define if your compiler has __attribute__ */
|
||||||
|
#cmakedefine HAVE___ATTRIBUTE__ 1
|
||||||
|
|
||||||
|
/* IPv6 */
|
||||||
|
#cmakedefine INET6 1
|
||||||
|
|
||||||
|
/* if unaligned access fails */
|
||||||
|
#cmakedefine LBL_ALIGN 1
|
||||||
|
|
||||||
|
/* path for device for USB sniffing */
|
||||||
|
#cmakedefine LINUX_USB_MON_DEV 1
|
||||||
|
|
||||||
|
/* if we need a pcap_parse wrapper around yyparse */
|
||||||
|
#cmakedefine NEED_YYPARSE_WRAPPER 1
|
||||||
|
|
||||||
|
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||||
|
#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1
|
||||||
|
|
||||||
|
/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
|
||||||
|
#cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON 1
|
||||||
|
|
||||||
|
/* do not use protochain */
|
||||||
|
#cmakedefine NO_PROTOCHAIN 1
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#cmakedefine PACKAGE_BUGREPORT 1
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#cmakedefine PACKAGE_NAME 1
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#cmakedefine PACKAGE_STRING 1
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#cmakedefine PACKAGE_TARNAME 1
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#cmakedefine PACKAGE_URL 1
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#cmakedefine PACKAGE_VERSION 1
|
||||||
|
|
||||||
|
/* /dev/dlpi directory */
|
||||||
|
#cmakedefine PCAP_DEV_PREFIX 1
|
||||||
|
|
||||||
|
/* target host supports Bluetooth sniffing */
|
||||||
|
#cmakedefine PCAP_SUPPORT_BT 1
|
||||||
|
|
||||||
|
/* target host supports Bluetooth Monitor */
|
||||||
|
#cmakedefine PCAP_SUPPORT_BT_MONITOR 1
|
||||||
|
|
||||||
|
/* support D-Bus sniffing */
|
||||||
|
#cmakedefine PCAP_SUPPORT_DBUS 1
|
||||||
|
|
||||||
|
/* target host supports netfilter sniffing */
|
||||||
|
#cmakedefine PCAP_SUPPORT_NETFILTER 1
|
||||||
|
|
||||||
|
/* use Linux packet ring capture if available */
|
||||||
|
#cmakedefine PCAP_SUPPORT_PACKET_RING 1
|
||||||
|
|
||||||
|
/* target host supports USB sniffing */
|
||||||
|
#cmakedefine PCAP_SUPPORT_USB 1
|
||||||
|
|
||||||
|
/* include ACN support */
|
||||||
|
#cmakedefine SITA 1
|
||||||
|
|
||||||
|
/* if struct sockaddr_hci has hci_channel member */
|
||||||
|
#cmakedefine SOCKADDR_HCI_HAS_HCI_CHANNEL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#cmakedefine STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Enable parser debugging */
|
||||||
|
#cmakedefine YYDEBUG 1
|
||||||
|
|
||||||
|
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||||
|
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||||
|
# define _DARWIN_USE_64_BIT_INODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
#cmakedefine _FILE_OFFSET_BITS 1
|
||||||
|
|
||||||
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
|
#cmakedefine _LARGEFILE_SOURCE 1
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
#cmakedefine _LARGE_FILES 1
|
||||||
|
|
||||||
|
/* define on AIX to get certain functions */
|
||||||
|
#cmakedefine _SUN 1
|
||||||
|
|
||||||
|
/* define if your compiler allows __attribute__((format)) without a warning */
|
||||||
|
#cmakedefine __ATTRIBUTE___FORMAT_OK 1
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||||
|
#cmakedefine const 1
|
||||||
|
|
||||||
|
/* Define as token for inline if inlining supported */
|
||||||
|
#cmakedefine inline 1
|
||||||
|
|
||||||
|
/* Define to `short' if int16_t not defined. */
|
||||||
|
#cmakedefine int16_t 1
|
||||||
|
|
||||||
|
/* Define to `int' if int32_t not defined. */
|
||||||
|
#cmakedefine int32_t 1
|
||||||
|
|
||||||
|
/* Define to `long long' if int64_t not defined. */
|
||||||
|
#cmakedefine int64_t 1
|
||||||
|
|
||||||
|
/* Define to `signed char' if int8_t not defined. */
|
||||||
|
#cmakedefine int8_t 1
|
||||||
|
|
||||||
|
/* on sinix */
|
||||||
|
#cmakedefine sinix 1
|
||||||
|
|
||||||
|
/* Define to `unsigned short' if u_int16_t not defined. */
|
||||||
|
#cmakedefine u_int16_t 1
|
||||||
|
|
||||||
|
/* Define to `unsigned int' if u_int32_t not defined. */
|
||||||
|
#cmakedefine u_int32_t 1
|
||||||
|
|
||||||
|
/* Define to `unsigned long long' if u_int64_t not defined. */
|
||||||
|
#cmakedefine u_int64_t 1
|
||||||
|
|
||||||
|
/* Define to `unsigned char' if u_int8_t not defined. */
|
||||||
|
#cmakedefine u_int8_t 1
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
/* Enable optimizer debugging */
|
/* Enable optimizer debugging */
|
||||||
#undef BDEBUG
|
#undef BDEBUG
|
||||||
@@ -124,16 +124,13 @@
|
|||||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||||
#undef HAVE_OS_PROTO_H
|
#undef HAVE_OS_PROTO_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <paths.h> header file. */
|
|
||||||
#undef HAVE_PATHS_H
|
|
||||||
|
|
||||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||||
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
|
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||||
|
|
||||||
/* define if you have a Septel API */
|
/* define if you have the Septel API */
|
||||||
#undef HAVE_SEPTEL_API
|
#undef HAVE_SEPTEL_API
|
||||||
|
|
||||||
/* define if you have Myricom SNF API */
|
/* define if you have the Myricom SNF API */
|
||||||
#undef HAVE_SNF_API
|
#undef HAVE_SNF_API
|
||||||
|
|
||||||
/* Define to 1 if you have the `snprintf' function. */
|
/* Define to 1 if you have the `snprintf' function. */
|
||||||
@@ -169,6 +166,9 @@
|
|||||||
/* Define to 1 if you have the `strlcpy' function. */
|
/* Define to 1 if you have the `strlcpy' function. */
|
||||||
#undef HAVE_STRLCPY
|
#undef HAVE_STRLCPY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtok_r' function. */
|
||||||
|
#undef HAVE_STRTOK_R
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||||
#undef HAVE_STRUCT_BPF_TIMEVAL
|
#undef HAVE_STRUCT_BPF_TIMEVAL
|
||||||
|
|
||||||
@@ -187,6 +187,9 @@
|
|||||||
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
||||||
#undef HAVE_SYS_IOCCOM_H
|
#undef HAVE_SYS_IOCCOM_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||||
|
#undef HAVE_SYS_SELECT_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||||
#undef HAVE_SYS_SOCKIO_H
|
#undef HAVE_SYS_SOCKIO_H
|
||||||
|
|
||||||
@@ -196,6 +199,9 @@
|
|||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
#undef HAVE_SYS_TYPES_H
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* define if you have the TurboCap API */
|
||||||
|
#undef HAVE_TC_API
|
||||||
|
|
||||||
/* if if_packet.h has tpacket_stats defined */
|
/* if if_packet.h has tpacket_stats defined */
|
||||||
#undef HAVE_TPACKET_STATS
|
#undef HAVE_TPACKET_STATS
|
||||||
|
|
||||||
@@ -205,9 +211,6 @@
|
|||||||
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||||
#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
||||||
|
|
||||||
/* define if version.h is generated in the build procedure */
|
|
||||||
#undef HAVE_VERSION_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
#undef HAVE_VSNPRINTF
|
#undef HAVE_VSNPRINTF
|
||||||
|
|
||||||
@@ -226,9 +229,6 @@
|
|||||||
/* path for device for USB sniffing */
|
/* path for device for USB sniffing */
|
||||||
#undef LINUX_USB_MON_DEV
|
#undef LINUX_USB_MON_DEV
|
||||||
|
|
||||||
/* if we need a pcap_parse wrapper around yyparse */
|
|
||||||
#undef NEED_YYPARSE_WRAPPER
|
|
||||||
|
|
||||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||||
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
|
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
|
||||||
|
|
||||||
@@ -265,12 +265,6 @@
|
|||||||
/* target host supports Bluetooth Monitor */
|
/* target host supports Bluetooth Monitor */
|
||||||
#undef PCAP_SUPPORT_BT_MONITOR
|
#undef PCAP_SUPPORT_BT_MONITOR
|
||||||
|
|
||||||
/* target host supports CAN sniffing */
|
|
||||||
#undef PCAP_SUPPORT_CAN
|
|
||||||
|
|
||||||
/* target host supports canusb */
|
|
||||||
#undef PCAP_SUPPORT_CANUSB
|
|
||||||
|
|
||||||
/* support D-Bus sniffing */
|
/* support D-Bus sniffing */
|
||||||
#undef PCAP_SUPPORT_DBUS
|
#undef PCAP_SUPPORT_DBUS
|
||||||
|
|
||||||
@@ -295,6 +289,10 @@
|
|||||||
/* Enable parser debugging */
|
/* Enable parser debugging */
|
||||||
#undef YYDEBUG
|
#undef YYDEBUG
|
||||||
|
|
||||||
|
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||||
|
`char[]'. */
|
||||||
|
#undef YYTEXT_POINTER
|
||||||
|
|
||||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||||
# define _DARWIN_USE_64_BIT_INODE 1
|
# define _DARWIN_USE_64_BIT_INODE 1
|
||||||
|
|||||||
6
libpcap/config/have_siocglifconf.c
Normal file
6
libpcap/config/have_siocglifconf.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
int main() {
|
||||||
|
ioctl(0, SIOCGLIFCONF, (char *)0);
|
||||||
|
}
|
||||||
1281
libpcap/configure
vendored
1281
libpcap/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -104,7 +104,7 @@ dnl in "aclocal.m4" uses it, so we would still have to test for it
|
|||||||
dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
||||||
dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
|
dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
|
||||||
dnl
|
dnl
|
||||||
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
|
AC_CHECK_HEADERS(sys/ioccom.h sys/select.h sys/sockio.h limits.h)
|
||||||
AC_CHECK_HEADERS(linux/types.h)
|
AC_CHECK_HEADERS(linux/types.h)
|
||||||
AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
|
AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
|
||||||
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
|
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
|
||||||
@@ -149,7 +149,7 @@ struct rtentry;
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
linux*)
|
linux*|uclinux*)
|
||||||
AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
|
AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
|
||||||
[
|
[
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -169,6 +169,13 @@ if test $needsnprintf = yes; then
|
|||||||
AC_LIBOBJ([snprintf])
|
AC_LIBOBJ([snprintf])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
needstrtok_r=no
|
||||||
|
AC_CHECK_FUNCS(strtok_r,,
|
||||||
|
[needstrtok_r=yes])
|
||||||
|
if test $needstrtok_r = yes; then
|
||||||
|
AC_LIBOBJ([strtok_r])
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Do this before checking for ether_hostton(), as it's a
|
# Do this before checking for ether_hostton(), as it's a
|
||||||
# "gethostbyname() -ish function".
|
# "gethostbyname() -ish function".
|
||||||
@@ -281,6 +288,13 @@ if test "$enable_protochain" = "disabled"; then
|
|||||||
fi
|
fi
|
||||||
AC_MSG_RESULT(${enable_protochain})
|
AC_MSG_RESULT(${enable_protochain})
|
||||||
|
|
||||||
|
#
|
||||||
|
# valgrindtest directly uses the native capture mechanism, but
|
||||||
|
# only tests with BPF and PF_PACKET sockets; only enable it if
|
||||||
|
# we have BPF or PF_PACKET sockets.
|
||||||
|
#
|
||||||
|
VALGRINDTEST=
|
||||||
|
|
||||||
#
|
#
|
||||||
# SITA support is mutually exclusive with native capture support;
|
# SITA support is mutually exclusive with native capture support;
|
||||||
# "--with-sita" selects SITA support.
|
# "--with-sita" selects SITA support.
|
||||||
@@ -292,7 +306,6 @@ AC_HELP_STRING([--with-sita],[include SITA support]),
|
|||||||
AC_DEFINE(SITA,1,[include ACN support])
|
AC_DEFINE(SITA,1,[include ACN support])
|
||||||
AC_MSG_NOTICE(Enabling SITA ACN support)
|
AC_MSG_NOTICE(Enabling SITA ACN support)
|
||||||
V_PCAP=sita
|
V_PCAP=sita
|
||||||
V_FINDALLDEVS=sita
|
|
||||||
fi
|
fi
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -318,8 +331,18 @@ elif test -r /dev/bpf -o -h /dev/bpf ; then
|
|||||||
#
|
#
|
||||||
V_PCAP=bpf
|
V_PCAP=bpf
|
||||||
AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
|
AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
|
||||||
|
|
||||||
|
#
|
||||||
|
# We have BPF, so build valgrindtest with "make test".
|
||||||
|
#
|
||||||
|
VALGRINDTEST=valgrindtest
|
||||||
elif test -r /dev/bpf0 ; then
|
elif test -r /dev/bpf0 ; then
|
||||||
V_PCAP=bpf
|
V_PCAP=bpf
|
||||||
|
|
||||||
|
#
|
||||||
|
# We have BPF, so build valgrindtest with "make test".
|
||||||
|
#
|
||||||
|
VALGRINDTEST=valgrindtest
|
||||||
elif test -r /usr/include/net/pfilt.h ; then
|
elif test -r /usr/include/net/pfilt.h ; then
|
||||||
V_PCAP=pf
|
V_PCAP=pf
|
||||||
elif test -r /dev/enet ; then
|
elif test -r /dev/enet ; then
|
||||||
@@ -330,6 +353,12 @@ elif test -r /usr/include/sys/net/nit.h ; then
|
|||||||
V_PCAP=nit
|
V_PCAP=nit
|
||||||
elif test -r /usr/include/linux/socket.h ; then
|
elif test -r /usr/include/linux/socket.h ; then
|
||||||
V_PCAP=linux
|
V_PCAP=linux
|
||||||
|
|
||||||
|
#
|
||||||
|
# XXX - this won't work with older kernels that have SOCK_PACKET
|
||||||
|
# sockets but not PF_PACKET sockets.
|
||||||
|
#
|
||||||
|
VALGRINDTEST=valgrindtest
|
||||||
elif test -r /usr/include/net/raw.h ; then
|
elif test -r /usr/include/net/raw.h ; then
|
||||||
V_PCAP=snoop
|
V_PCAP=snoop
|
||||||
elif test -r /usr/include/odmi.h ; then
|
elif test -r /usr/include/odmi.h ; then
|
||||||
@@ -341,6 +370,11 @@ elif test -r /usr/include/odmi.h ; then
|
|||||||
V_PCAP=bpf
|
V_PCAP=bpf
|
||||||
elif test -c /dev/bpf0 ; then # check again in case not readable
|
elif test -c /dev/bpf0 ; then # check again in case not readable
|
||||||
V_PCAP=bpf
|
V_PCAP=bpf
|
||||||
|
|
||||||
|
#
|
||||||
|
# We have BPF, so build valgrindtest with "make test".
|
||||||
|
#
|
||||||
|
VALGRINDTEST=valgrindtest
|
||||||
elif test -r /usr/include/sys/dlpi.h ; then
|
elif test -r /usr/include/sys/dlpi.h ; then
|
||||||
V_PCAP=dlpi
|
V_PCAP=dlpi
|
||||||
elif test -c /dev/enet ; then # check again in case not readable
|
elif test -c /dev/enet ; then # check again in case not readable
|
||||||
@@ -351,6 +385,7 @@ else
|
|||||||
V_PCAP=null
|
V_PCAP=null
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT($V_PCAP)
|
AC_MSG_RESULT($V_PCAP)
|
||||||
|
AC_SUBST(VALGRINDTEST)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Do capture-mechanism-dependent tests.
|
# Do capture-mechanism-dependent tests.
|
||||||
@@ -450,10 +485,10 @@ linux)
|
|||||||
# Do we have libnl?
|
# Do we have libnl?
|
||||||
#
|
#
|
||||||
AC_ARG_WITH(libnl,
|
AC_ARG_WITH(libnl,
|
||||||
AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]),
|
AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
|
||||||
with_libnl=$withval,,)
|
with_libnl=$withval,,)
|
||||||
|
|
||||||
if test x$with_libnl = xyes ; then
|
if test x$with_libnl != xno ; then
|
||||||
have_any_nl="no"
|
have_any_nl="no"
|
||||||
|
|
||||||
incdir=-I/usr/include/libnl3
|
incdir=-I/usr/include/libnl3
|
||||||
@@ -567,15 +602,30 @@ bpf)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
dag)
|
dag)
|
||||||
|
#
|
||||||
|
# --with-pcap=dag is the only way to get here, and it means
|
||||||
|
# "DAG support but nothing else"
|
||||||
|
#
|
||||||
V_DEFS="$V_DEFS -DDAG_ONLY"
|
V_DEFS="$V_DEFS -DDAG_ONLY"
|
||||||
|
xxx_only=yes
|
||||||
;;
|
;;
|
||||||
|
|
||||||
septel)
|
septel)
|
||||||
|
#
|
||||||
|
# --with-pcap=septel is the only way to get here, and it means
|
||||||
|
# "Septel support but nothing else"
|
||||||
|
#
|
||||||
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
|
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
|
||||||
|
xxx_only=yes
|
||||||
;;
|
;;
|
||||||
|
|
||||||
snf)
|
snf)
|
||||||
|
#
|
||||||
|
# --with-pcap=snf is the only way to get here, and it means
|
||||||
|
# "SNF support but nothing else"
|
||||||
|
#
|
||||||
V_DEFS="$V_DEFS -DSNF_ONLY"
|
V_DEFS="$V_DEFS -DSNF_ONLY"
|
||||||
|
xxx_only=yes
|
||||||
;;
|
;;
|
||||||
|
|
||||||
null)
|
null)
|
||||||
@@ -589,14 +639,8 @@ dnl Now figure out how we get a list of interfaces and addresses,
|
|||||||
dnl if we support capturing. Don't bother if we don't support
|
dnl if we support capturing. Don't bother if we don't support
|
||||||
dnl capturing.
|
dnl capturing.
|
||||||
dnl
|
dnl
|
||||||
if test "$V_PCAP" = null
|
if test "$V_PCAP" != null
|
||||||
then
|
then
|
||||||
#
|
|
||||||
# We can't capture, so we can't open any capture
|
|
||||||
# devices, so we won't return any interfaces.
|
|
||||||
#
|
|
||||||
V_FINDALLDEVS=null
|
|
||||||
else
|
|
||||||
AC_CHECK_FUNC(getifaddrs,[
|
AC_CHECK_FUNC(getifaddrs,[
|
||||||
#
|
#
|
||||||
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
|
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
|
||||||
@@ -607,7 +651,7 @@ else
|
|||||||
# We have the header, so we use "getifaddrs()" to
|
# We have the header, so we use "getifaddrs()" to
|
||||||
# get the list of interfaces.
|
# get the list of interfaces.
|
||||||
#
|
#
|
||||||
V_FINDALLDEVS=getad
|
V_FINDALLDEVS=fad-getad.c
|
||||||
],[
|
],[
|
||||||
#
|
#
|
||||||
# We don't have the header - give up.
|
# We don't have the header - give up.
|
||||||
@@ -650,9 +694,9 @@ else
|
|||||||
ac_cv_lbl_have_siocglifconf=no))
|
ac_cv_lbl_have_siocglifconf=no))
|
||||||
AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
|
AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
|
||||||
if test $ac_cv_lbl_have_siocglifconf = yes ; then
|
if test $ac_cv_lbl_have_siocglifconf = yes ; then
|
||||||
V_FINDALLDEVS=glifc
|
V_FINDALLDEVS=fad-glifc.c
|
||||||
else
|
else
|
||||||
V_FINDALLDEVS=gifc
|
V_FINDALLDEVS=fad-gifc.c
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -663,7 +707,7 @@ else
|
|||||||
# another mechanism, and we should be using that
|
# another mechanism, and we should be using that
|
||||||
# instead.)
|
# instead.)
|
||||||
#
|
#
|
||||||
V_FINDALLDEVS=gifc
|
V_FINDALLDEVS=fad-gifc.c
|
||||||
;;
|
;;
|
||||||
esac])
|
esac])
|
||||||
fi
|
fi
|
||||||
@@ -716,7 +760,7 @@ AC_MSG_RESULT(${enable_yydebug-no})
|
|||||||
|
|
||||||
# Check for Endace DAG card support.
|
# Check for Endace DAG card support.
|
||||||
AC_ARG_WITH([dag],
|
AC_ARG_WITH([dag],
|
||||||
AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
|
AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
|
||||||
[
|
[
|
||||||
if test "$withval" = no
|
if test "$withval" = no
|
||||||
then
|
then
|
||||||
@@ -732,14 +776,24 @@ AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "
|
|||||||
dag_root=$withval
|
dag_root=$withval
|
||||||
fi
|
fi
|
||||||
],[
|
],[
|
||||||
|
if test "$V_PCAP" = dag; then
|
||||||
|
# User requested DAG-only libpcap, so we'd better have
|
||||||
|
# the DAG API.
|
||||||
|
want_dag=yes
|
||||||
|
elif test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want DAG support.
|
||||||
|
want_dag=no
|
||||||
|
else
|
||||||
#
|
#
|
||||||
# Use DAG API if present, otherwise don't
|
# Use DAG API if present, otherwise don't
|
||||||
#
|
#
|
||||||
want_dag=ifpresent
|
want_dag=ifpresent
|
||||||
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_ARG_WITH([dag-includes],
|
AC_ARG_WITH([dag-includes],
|
||||||
AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
|
AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
|
||||||
[
|
[
|
||||||
# User wants DAG support and has specified a header directory, so use the provided value.
|
# User wants DAG support and has specified a header directory, so use the provided value.
|
||||||
want_dag=yes
|
want_dag=yes
|
||||||
@@ -747,35 +801,13 @@ AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
|
|||||||
],[])
|
],[])
|
||||||
|
|
||||||
AC_ARG_WITH([dag-libraries],
|
AC_ARG_WITH([dag-libraries],
|
||||||
AC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
|
AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
|
||||||
[
|
[
|
||||||
# User wants DAG support and has specified a library directory, so use the provided value.
|
# User wants DAG support and has specified a library directory, so use the provided value.
|
||||||
want_dag=yes
|
want_dag=yes
|
||||||
dag_lib_dir=$withval
|
dag_lib_dir=$withval
|
||||||
],[])
|
],[])
|
||||||
|
|
||||||
case "$V_PCAP" in
|
|
||||||
linux|bpf|dag)
|
|
||||||
#
|
|
||||||
# We support the DAG API if we're on Linux or BSD, or if we're
|
|
||||||
# building a DAG-only libpcap.
|
|
||||||
#
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# If the user explicitly requested DAG, tell them it's not
|
|
||||||
# supported.
|
|
||||||
#
|
|
||||||
# If they expressed no preference, don't include it.
|
|
||||||
#
|
|
||||||
if test $want_dag = yes; then
|
|
||||||
AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
|
|
||||||
elif test $want_dag = yes; then
|
|
||||||
want_dag=no
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ac_cv_lbl_dag_api=no
|
ac_cv_lbl_dag_api=no
|
||||||
if test "$want_dag" != no; then
|
if test "$want_dag" != no; then
|
||||||
|
|
||||||
@@ -801,14 +833,14 @@ if test "$want_dag" != no; then
|
|||||||
if test -r $dag_include_dir/dagapi.h; then
|
if test -r $dag_include_dir/dagapi.h; then
|
||||||
ac_cv_lbl_dag_api=yes
|
ac_cv_lbl_dag_api=yes
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = yes; then
|
if test "$ac_cv_lbl_dag_api" = yes; then
|
||||||
|
AC_MSG_RESULT([yes ($dag_include_dir)])
|
||||||
|
|
||||||
V_INCLS="$V_INCLS -I$dag_include_dir"
|
V_INCLS="$V_INCLS -I$dag_include_dir"
|
||||||
|
|
||||||
if test $V_PCAP != dag ; then
|
if test $V_PCAP != dag ; then
|
||||||
SSRC="pcap-dag.c"
|
SSRC="$SSRC pcap-dag.c"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# See if we can find a general version string.
|
# See if we can find a general version string.
|
||||||
@@ -837,28 +869,24 @@ if test $ac_cv_lbl_dag_api = yes; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
|
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
|
||||||
fi
|
else
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether we have the DAG API)
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = no; then
|
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
if test "$want_dag" = yes; then
|
|
||||||
# User wanted DAG support but we couldn't find it.
|
|
||||||
AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$V_PCAP" = dag; then
|
if test "$V_PCAP" = dag; then
|
||||||
# User requested "dag" capture type but the DAG API wasn't
|
# User requested "dag" capture type but we couldn't
|
||||||
# found.
|
# find the DAG API support.
|
||||||
AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
|
AC_MSG_ERROR([DAG support requested with --with-pcap=dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$want_dag" = yes; then
|
||||||
|
# User wanted DAG support but we couldn't find it.
|
||||||
|
AC_MSG_ERROR([DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_WITH(septel,
|
AC_ARG_WITH(septel,
|
||||||
AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, on Linux, if present@:>@]),
|
AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
|
||||||
[
|
[
|
||||||
if test "$withval" = no
|
if test "$withval" = no
|
||||||
then
|
then
|
||||||
@@ -872,38 +900,28 @@ AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in d
|
|||||||
septel_root=$withval
|
septel_root=$withval
|
||||||
fi
|
fi
|
||||||
],[
|
],[
|
||||||
|
if test "$V_PCAP" = septel; then
|
||||||
|
# User requested Septel-only libpcap, so we'd better have
|
||||||
|
# the Septel API.
|
||||||
|
want_septel=yes
|
||||||
|
elif test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want Septel support.
|
||||||
|
want_septel=no
|
||||||
|
else
|
||||||
#
|
#
|
||||||
# Use Septel API if present, otherwise don't
|
# Use Septel API if present, otherwise don't
|
||||||
#
|
#
|
||||||
want_septel=ifpresent
|
want_septel=ifpresent
|
||||||
septel_root=./../septel
|
|
||||||
])
|
|
||||||
ac_cv_lbl_septel_api=no
|
|
||||||
case "$V_PCAP" in
|
|
||||||
linux|septel)
|
|
||||||
#
|
|
||||||
# We support the Septel API if we're on Linux, or if we're building
|
|
||||||
# a Septel-only libpcap.
|
|
||||||
#
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# If the user explicitly requested Septel, tell them it's not
|
|
||||||
# supported.
|
|
||||||
#
|
|
||||||
# If they expressed no preference, don't include it.
|
|
||||||
#
|
|
||||||
if test $want_septel = yes; then
|
|
||||||
AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
|
|
||||||
elif test $want_septel = yes; then
|
|
||||||
want_septel=no
|
|
||||||
fi
|
fi
|
||||||
;;
|
])
|
||||||
esac
|
|
||||||
|
|
||||||
|
ac_cv_lbl_septel_api=no
|
||||||
if test "$with_septel" != no; then
|
if test "$with_septel" != no; then
|
||||||
AC_MSG_CHECKING(whether we have Septel API)
|
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether we have Septel API headers])
|
||||||
|
|
||||||
|
# If necessary, set default paths for Septel API headers and libraries.
|
||||||
if test -z "$septel_root"; then
|
if test -z "$septel_root"; then
|
||||||
septel_root=$srcdir/../septel
|
septel_root=$srcdir/../septel
|
||||||
fi
|
fi
|
||||||
@@ -911,35 +929,41 @@ if test "$with_septel" != no; then
|
|||||||
septel_tools_dir="$septel_root"
|
septel_tools_dir="$septel_root"
|
||||||
septel_include_dir="$septel_root/INC"
|
septel_include_dir="$septel_root/INC"
|
||||||
|
|
||||||
ac_cv_lbl_septel_api=no
|
|
||||||
if test -r "$septel_include_dir/msg.h"; then
|
if test -r "$septel_include_dir/msg.h"; then
|
||||||
|
ac_cv_lbl_septel_api=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$ac_cv_lbl_septel_api" = yes; then
|
||||||
|
AC_MSG_RESULT([yes ($septel_include_dir)])
|
||||||
|
|
||||||
V_INCLS="$V_INCLS -I$septel_include_dir"
|
V_INCLS="$V_INCLS -I$septel_include_dir"
|
||||||
ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
||||||
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
||||||
|
|
||||||
if test "$V_PCAP" != septel ; then
|
if test "$V_PCAP" != septel ; then
|
||||||
SSRC="pcap-septel.c"
|
SSRC="$SSRC pcap-septel.c"
|
||||||
fi
|
|
||||||
ac_cv_lbl_septel_api=yes
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_septel_api)
|
AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
|
||||||
if test $ac_cv_lbl_septel_api = no; then
|
|
||||||
if test "$want_septel" = yes; then
|
|
||||||
AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
|
AC_MSG_RESULT(no)
|
||||||
fi
|
|
||||||
|
if test "$V_PCAP" = septel; then
|
||||||
|
# User requested "septel" capture type but
|
||||||
|
# we couldn't find the Septel API support.
|
||||||
|
AC_MSG_ERROR([Septel support requested with --with-pcap=septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
|
if test "$want_septel" = yes; then
|
||||||
AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
|
# User wanted Septel support but we couldn't find it.
|
||||||
|
AC_MSG_ERROR([Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Myricom SNF support.
|
# Check for Myricom SNF support.
|
||||||
AC_ARG_WITH([snf],
|
AC_ARG_WITH([snf],
|
||||||
AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
|
AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
|
||||||
[
|
[
|
||||||
if test "$withval" = no
|
if test "$withval" = no
|
||||||
then
|
then
|
||||||
@@ -947,7 +971,7 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes",
|
|||||||
want_snf=no
|
want_snf=no
|
||||||
elif test "$withval" = yes
|
elif test "$withval" = yes
|
||||||
then
|
then
|
||||||
# User wants SNF support but hasn't specific a directory.
|
# User wants SNF support but hasn't specified a directory.
|
||||||
want_snf=yes
|
want_snf=yes
|
||||||
else
|
else
|
||||||
# User wants SNF support with a specified directory.
|
# User wants SNF support with a specified directory.
|
||||||
@@ -955,14 +979,24 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes",
|
|||||||
snf_root=$withval
|
snf_root=$withval
|
||||||
fi
|
fi
|
||||||
],[
|
],[
|
||||||
|
if test "$V_PCAP" = snf; then
|
||||||
|
# User requested Sniffer-only libpcap, so we'd better have
|
||||||
|
# the Sniffer API.
|
||||||
|
want_snf=yes
|
||||||
|
elif test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want SNF support.
|
||||||
|
want_snf=no
|
||||||
|
else
|
||||||
#
|
#
|
||||||
# Use Sniffer API if present, otherwise don't
|
# Use Sniffer API if present, otherwise don't
|
||||||
#
|
#
|
||||||
want_snf=ifpresent
|
want_snf=ifpresent
|
||||||
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_ARG_WITH([snf-includes],
|
AC_ARG_WITH([snf-includes],
|
||||||
AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
|
AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
|
||||||
[
|
[
|
||||||
# User wants SNF with specific header directory
|
# User wants SNF with specific header directory
|
||||||
want_snf=yes
|
want_snf=yes
|
||||||
@@ -970,40 +1004,19 @@ AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
|
|||||||
],[])
|
],[])
|
||||||
|
|
||||||
AC_ARG_WITH([snf-libraries],
|
AC_ARG_WITH([snf-libraries],
|
||||||
AC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
|
AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
|
||||||
[
|
[
|
||||||
# User wants SNF with specific lib directory
|
# User wants SNF with specific lib directory
|
||||||
want_snf=yes
|
want_snf=yes
|
||||||
snf_lib_dir=$withval
|
snf_lib_dir=$withval
|
||||||
],[])
|
],[])
|
||||||
|
|
||||||
case "$V_PCAP" in
|
|
||||||
bpf|linux|snf)
|
|
||||||
#
|
|
||||||
# We support the Sniffer API if we're on BSD, Linux, or if we're
|
|
||||||
# building a Sniffer-only libpcap.
|
|
||||||
#
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# If the user explicitly requested Sniffer, tell them it's not
|
|
||||||
# supported.
|
|
||||||
#
|
|
||||||
# If they expressed no preference, don't include it.
|
|
||||||
#
|
|
||||||
if test $want_snf = yes; then
|
|
||||||
AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
|
|
||||||
elif test $want_snf = yes; then
|
|
||||||
want_snf=no
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ac_cv_lbl_snf_api=no
|
ac_cv_lbl_snf_api=no
|
||||||
if test "$with_snf" != no; then
|
if test "$with_snf" != no; then
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether we have Myricom Sniffer API)
|
AC_MSG_CHECKING(whether we have Myricom Sniffer API)
|
||||||
|
|
||||||
|
# If necessary, set default paths for Sniffer headers and libraries.
|
||||||
if test -z "$snf_root"; then
|
if test -z "$snf_root"; then
|
||||||
snf_root=/opt/snf
|
snf_root=/opt/snf
|
||||||
fi
|
fi
|
||||||
@@ -1017,38 +1030,157 @@ if test "$with_snf" != no; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test -f "$snf_include_dir/snf.h"; then
|
if test -f "$snf_include_dir/snf.h"; then
|
||||||
ac_cv_lbl_snf_api=yes
|
# We found a header; make sure we can link with the library
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_snf_api = no; then
|
|
||||||
if test "$want_snf" = yes; then
|
|
||||||
AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
saved_ldflags=$LDFLAGS
|
saved_ldflags=$LDFLAGS
|
||||||
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
||||||
AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
|
AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
|
||||||
LDFLAGS="$saved_ldflags"
|
LDFLAGS="$saved_ldflags"
|
||||||
|
if test "$ac_cv_lbl_snf_api" = no; then
|
||||||
if test $ac_cv_lbl_snf_api = no; then
|
AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
|
||||||
if test "$want_snf" = yes; then
|
|
||||||
AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
|
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
if test "$ac_cv_lbl_snf_api" = yes; then
|
||||||
|
AC_MSG_RESULT([yes ($snf_root)])
|
||||||
|
|
||||||
V_INCLS="$V_INCLS -I$snf_include_dir"
|
V_INCLS="$V_INCLS -I$snf_include_dir"
|
||||||
LIBS="$LIBS -lsnf"
|
LIBS="$LIBS -lsnf"
|
||||||
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
||||||
|
|
||||||
if test "$V_PCAP" != snf ; then
|
if test "$V_PCAP" != snf ; then
|
||||||
SSRC="pcap-snf.c"
|
SSRC="$SSRC pcap-snf.c"
|
||||||
fi
|
fi
|
||||||
AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
|
|
||||||
|
AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
|
if test "$want_snf" = yes; then
|
||||||
|
# User requested "snf" capture type but
|
||||||
|
# we couldn't find the Sniffer API support.
|
||||||
|
AC_MSG_ERROR([Myricom Sniffer support requested with --with-pcap=snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$want_snf" = yes; then
|
||||||
|
AC_MSG_ERROR([Myricom Sniffer support requested with --with-snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
|
# Check for Riverbed TurboCap support.
|
||||||
AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
|
AC_ARG_WITH([turbocap],
|
||||||
|
AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
|
||||||
|
[
|
||||||
|
if test "$withval" = no
|
||||||
|
then
|
||||||
|
# User explicitly doesn't want TurboCap
|
||||||
|
want_turbocap=no
|
||||||
|
elif test "$withval" = yes
|
||||||
|
then
|
||||||
|
# User wants TurboCap support but hasn't specified a directory.
|
||||||
|
want_turbocap=yes
|
||||||
|
else
|
||||||
|
# User wants TurboCap support with a specified directory.
|
||||||
|
want_turbocap=yes
|
||||||
|
turbocap_root=$withval
|
||||||
|
fi
|
||||||
|
],[
|
||||||
|
if test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want TurboCap support.
|
||||||
|
want_turbocap=no
|
||||||
|
else
|
||||||
|
#
|
||||||
|
# Use TurboCap API if present, otherwise don't
|
||||||
|
#
|
||||||
|
want_turbocap=ifpresent
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
ac_cv_lbl_turbocap_api=no
|
||||||
|
if test "$want_turbocap" != no; then
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether TurboCap is supported)
|
||||||
|
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
if test ! -z "$turbocap_root"; then
|
||||||
|
TURBOCAP_CFLAGS="-I$turbocap_root/include"
|
||||||
|
TURBOCAP_LIBS="-L$turbocap_root/lib"
|
||||||
|
CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_TRY_COMPILE(
|
||||||
|
[
|
||||||
|
#include <TcApi.h>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
TC_INSTANCE a; TC_PORT b; TC_BOARD c;
|
||||||
|
TC_INSTANCE i;
|
||||||
|
(void)TcInstanceCreateByName("foo", &i);
|
||||||
|
],
|
||||||
|
ac_cv_lbl_turbocap_api=yes)
|
||||||
|
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
if test $ac_cv_lbl_turbocap_api = yes; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
|
||||||
|
SSRC="$SSRC pcap-tc.c"
|
||||||
|
V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
|
||||||
|
LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
|
||||||
|
|
||||||
|
AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
|
if test "$want_turbocap" = yes; then
|
||||||
|
# User wanted Turbo support but we couldn't find it.
|
||||||
|
AC_MSG_ERROR([TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Look for {f}lex.
|
||||||
|
#
|
||||||
|
AC_PROG_LEX
|
||||||
|
if test "$LEX" = ":"; then
|
||||||
|
AC_MSG_ERROR([Neither flex nor lex was found.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Make sure {f}lex supports the -P, --header-file, and --nounput flags
|
||||||
|
# and supports processing our scanner.l.
|
||||||
|
#
|
||||||
|
AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
|
||||||
|
if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
|
||||||
|
tcpdump_cv_capable_lex=yes
|
||||||
|
else
|
||||||
|
tcpdump_cv_capable_lex=insufficient
|
||||||
|
fi)
|
||||||
|
if test $tcpdump_cv_capable_lex = insufficient ; then
|
||||||
|
AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
|
||||||
|
libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Look for yacc/bison/byacc.
|
||||||
|
#
|
||||||
|
AC_PROG_YACC
|
||||||
|
|
||||||
|
#
|
||||||
|
# Make sure it supports the -p flag and supports processing our
|
||||||
|
# grammar.y.
|
||||||
|
#
|
||||||
|
AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
|
||||||
|
if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
|
||||||
|
tcpdump_cv_capable_yacc=yes
|
||||||
|
else
|
||||||
|
tcpdump_cv_capable_yacc=insufficient
|
||||||
|
fi)
|
||||||
|
if test $tcpdump_cv_capable_yacc = insufficient ; then
|
||||||
|
AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
|
||||||
|
libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1301,8 +1433,8 @@ solaris*)
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
AC_ARG_ENABLE(shared,
|
AC_ARG_ENABLE(shared,
|
||||||
AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@]))
|
AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
|
||||||
test "x$enable_shared" != "xyes" && DYEXT="none"
|
test "x$enable_shared" = "xno" && DYEXT="none"
|
||||||
|
|
||||||
AC_PROG_RANLIB
|
AC_PROG_RANLIB
|
||||||
AC_CHECK_TOOL([AR], [ar])
|
AC_CHECK_TOOL([AR], [ar])
|
||||||
@@ -1320,12 +1452,6 @@ AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
|
|||||||
|
|
||||||
AC_LBL_UNALIGNED_ACCESS
|
AC_LBL_UNALIGNED_ACCESS
|
||||||
|
|
||||||
#
|
|
||||||
# Makefile.in includes rules to generate version.h, so we assume
|
|
||||||
# that it will be generated if autoconf is used.
|
|
||||||
#
|
|
||||||
AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
|
|
||||||
|
|
||||||
rm -f net
|
rm -f net
|
||||||
ln -s ${srcdir}/bpf/net net
|
ln -s ${srcdir}/bpf/net net
|
||||||
|
|
||||||
@@ -1333,11 +1459,13 @@ AC_SUBST(V_CCOPT)
|
|||||||
AC_SUBST(V_DEFS)
|
AC_SUBST(V_DEFS)
|
||||||
AC_SUBST(V_FINDALLDEVS)
|
AC_SUBST(V_FINDALLDEVS)
|
||||||
AC_SUBST(V_INCLS)
|
AC_SUBST(V_INCLS)
|
||||||
|
AC_SUBST(V_LEX)
|
||||||
AC_SUBST(V_PCAP)
|
AC_SUBST(V_PCAP)
|
||||||
AC_SUBST(V_SHLIB_CMD)
|
AC_SUBST(V_SHLIB_CMD)
|
||||||
AC_SUBST(V_SHLIB_OPT)
|
AC_SUBST(V_SHLIB_OPT)
|
||||||
AC_SUBST(V_SONAME_OPT)
|
AC_SUBST(V_SONAME_OPT)
|
||||||
AC_SUBST(V_RPATH_OPT)
|
AC_SUBST(V_RPATH_OPT)
|
||||||
|
AC_SUBST(V_YACC)
|
||||||
AC_SUBST(ADDLOBJS)
|
AC_SUBST(ADDLOBJS)
|
||||||
AC_SUBST(ADDLARCHIVEOBJS)
|
AC_SUBST(ADDLARCHIVEOBJS)
|
||||||
AC_SUBST(SSRC)
|
AC_SUBST(SSRC)
|
||||||
@@ -1350,6 +1478,12 @@ AC_ARG_ENABLE([usb],
|
|||||||
[],
|
[],
|
||||||
[enable_usb=yes])
|
[enable_usb=yes])
|
||||||
|
|
||||||
|
if test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want USB support.
|
||||||
|
enable_usb=no
|
||||||
|
fi
|
||||||
|
|
||||||
if test "x$enable_usb" != "xno" ; then
|
if test "x$enable_usb" != "xno" ; then
|
||||||
dnl check for USB sniffing support
|
dnl check for USB sniffing support
|
||||||
AC_MSG_CHECKING(for USB sniffing support)
|
AC_MSG_CHECKING(for USB sniffing support)
|
||||||
@@ -1405,6 +1539,14 @@ AC_INCLUDES_DEFAULT
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
freebsd*)
|
||||||
|
#
|
||||||
|
# This just uses BPF in FreeBSD 8.4 and later; we don't need
|
||||||
|
# to check for anything special for capturing.
|
||||||
|
#
|
||||||
|
AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
;;
|
;;
|
||||||
@@ -1414,6 +1556,7 @@ AC_SUBST(PCAP_SUPPORT_USB)
|
|||||||
AC_SUBST(USB_SRC)
|
AC_SUBST(USB_SRC)
|
||||||
|
|
||||||
dnl check for netfilter sniffing support
|
dnl check for netfilter sniffing support
|
||||||
|
if test "xxx_only" != yes; then
|
||||||
AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
|
AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
|
||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
linux*)
|
linux*)
|
||||||
@@ -1453,13 +1596,20 @@ AC_INCLUDES_DEFAULT
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
AC_SUBST(PCAP_SUPPORT_NETFILTER)
|
AC_SUBST(PCAP_SUPPORT_NETFILTER)
|
||||||
AC_SUBST(NETFILTER_SRC)
|
AC_SUBST(NETFILTER_SRC)
|
||||||
|
|
||||||
AC_ARG_ENABLE([bluetooth],
|
AC_ARG_ENABLE([bluetooth],
|
||||||
[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])],
|
[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
|
||||||
[],
|
[],
|
||||||
[enable_bluetooth=no])
|
[enable_bluetooth=ifsupportavailable])
|
||||||
|
|
||||||
|
if test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want Bluetooth support.
|
||||||
|
enable_bluetooth=no
|
||||||
|
fi
|
||||||
|
|
||||||
if test "x$enable_bluetooth" != "xno" ; then
|
if test "x$enable_bluetooth" != "xno" ; then
|
||||||
dnl check for Bluetooth sniffing support
|
dnl check for Bluetooth sniffing support
|
||||||
@@ -1535,93 +1685,16 @@ if test "x$enable_bluetooth" != "xno" ; then
|
|||||||
AC_SUBST(BT_MONITOR_SRC)
|
AC_SUBST(BT_MONITOR_SRC)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE([canusb],
|
|
||||||
[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
[enable_canusb=no])
|
|
||||||
|
|
||||||
if test "x$enable_canusb" != "xno" ; then
|
|
||||||
dnl check for canusb support
|
|
||||||
case "$host_os" in
|
|
||||||
linux*|uclinux*)
|
|
||||||
AC_CHECK_HEADER(libusb-1.0/libusb.h,
|
|
||||||
[
|
|
||||||
AC_CHECK_LIB(usb-1.0, libusb_init,
|
|
||||||
[
|
|
||||||
AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
|
|
||||||
CANUSB_SRC=pcap-canusb-linux.c
|
|
||||||
LIBS="-lusb-1.0 -lpthread $LIBS"
|
|
||||||
ac_lbl_has_libusb=yes
|
|
||||||
],
|
|
||||||
ac_lbl_has_libusb=no,
|
|
||||||
-lpthread
|
|
||||||
)
|
|
||||||
],
|
|
||||||
ac_lbl_has_libusb=no
|
|
||||||
)
|
|
||||||
if test "x$ac_lbl_has_libusb" = "xyes" ; then
|
|
||||||
AC_MSG_NOTICE(canusb sniffing is supported)
|
|
||||||
else
|
|
||||||
if test "x$enable_canusb" = "xyes" ; then
|
|
||||||
AC_MSG_ERROR(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
|
|
||||||
else
|
|
||||||
AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test "x$enable_canusb" = "xyes" ; then
|
|
||||||
AC_MSG_ERROR(no canusb support implemented for $host_os)
|
|
||||||
else
|
|
||||||
AC_MSG_NOTICE(no canusb support implemented for $host_os)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
AC_SUBST(PCAP_SUPPORT_CANUSB)
|
|
||||||
AC_SUBST(CANUSB_SRC)
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([can],
|
|
||||||
[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=no@:>@])],
|
|
||||||
[],
|
|
||||||
[enable_can=no])
|
|
||||||
|
|
||||||
if test "x$enable_can" != "xno" ; then
|
|
||||||
dnl check for CAN sniffing support
|
|
||||||
case "$host_os" in
|
|
||||||
linux*)
|
|
||||||
AC_CHECK_HEADER(linux/can.h,
|
|
||||||
[
|
|
||||||
AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
|
|
||||||
CAN_SRC=pcap-can-linux.c
|
|
||||||
AC_MSG_NOTICE(CAN sniffing is supported)
|
|
||||||
],
|
|
||||||
[
|
|
||||||
if test "x$enable_can" = "xyes" ; then
|
|
||||||
AC_MSG_ERROR(CAN sniffing is not supported)
|
|
||||||
else
|
|
||||||
AC_MSG_NOTICE(CAN sniffing is not supported)
|
|
||||||
fi
|
|
||||||
],
|
|
||||||
[#include <sys/socket.h>]
|
|
||||||
)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test "x$enable_can" = "xyes" ; then
|
|
||||||
AC_MSG_ERROR(no CAN sniffing support implemented for $host_os)
|
|
||||||
else
|
|
||||||
AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
AC_SUBST(PCAP_SUPPORT_CAN)
|
|
||||||
AC_SUBST(CAN_SRC)
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([dbus],
|
AC_ARG_ENABLE([dbus],
|
||||||
[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])],
|
[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
|
||||||
[],
|
[],
|
||||||
[enable_dbus=no])
|
[enable_dbus=ifavailable])
|
||||||
|
|
||||||
|
if test "xxx_only" = yes; then
|
||||||
|
# User requested something-else-only pcap, so they don't
|
||||||
|
# want D-Bus support.
|
||||||
|
enable_dbus=no
|
||||||
|
fi
|
||||||
|
|
||||||
if test "x$enable_dbus" != "xno"; then
|
if test "x$enable_dbus" != "xno"; then
|
||||||
if test "x$enable_dbus" = "xyes"; then
|
if test "x$enable_dbus" = "xyes"; then
|
||||||
@@ -186,8 +186,8 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
|
|||||||
pkthdr.len = origlen;
|
pkthdr.len = origlen;
|
||||||
pkthdr.caplen = caplen;
|
pkthdr.caplen = caplen;
|
||||||
/* Insure caplen does not exceed snapshot */
|
/* Insure caplen does not exceed snapshot */
|
||||||
if (pkthdr.caplen > p->snapshot)
|
if (pkthdr.caplen > (bpf_u_int32)p->snapshot)
|
||||||
pkthdr.caplen = p->snapshot;
|
pkthdr.caplen = (bpf_u_int32)p->snapshot;
|
||||||
(*callback)(user, &pkthdr, pk);
|
(*callback)(user, &pkthdr, pk);
|
||||||
if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) {
|
if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) {
|
||||||
p->cc = ep - bufp;
|
p->cc = ep - bufp;
|
||||||
@@ -255,8 +255,29 @@ pcap_process_mactype(pcap_t *p, u_int mactype)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DL_IPV4
|
||||||
|
case DL_IPV4:
|
||||||
|
p->linktype = DLT_IPV4;
|
||||||
|
p->offset = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DL_IPV6
|
||||||
|
case DL_IPV6:
|
||||||
|
p->linktype = DLT_IPV6;
|
||||||
|
p->offset = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DL_IPNET
|
||||||
|
case DL_IPNET:
|
||||||
|
p->linktype = DLT_IPNET;
|
||||||
|
p->offset = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype %u",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x",
|
||||||
mactype);
|
mactype);
|
||||||
retv = -1;
|
retv = -1;
|
||||||
}
|
}
|
||||||
@@ -326,7 +347,7 @@ int
|
|||||||
pcap_alloc_databuf(pcap_t *p)
|
pcap_alloc_databuf(pcap_t *p)
|
||||||
{
|
{
|
||||||
p->bufsize = PKTBUFSIZE;
|
p->bufsize = PKTBUFSIZE;
|
||||||
p->buffer = (u_char *)malloc(p->bufsize + p->offset);
|
p->buffer = malloc(p->bufsize + p->offset);
|
||||||
if (p->buffer == NULL) {
|
if (p->buffer == NULL) {
|
||||||
strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -362,6 +383,6 @@ strioctl(int fd, int cmd, int len, char *dp)
|
|||||||
static void
|
static void
|
||||||
pcap_stream_err(const char *func, int err, char *errbuf)
|
pcap_stream_err(const char *func, int err, char *errbuf)
|
||||||
{
|
{
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
#else /* WIN32 */
|
#else /* _WIN32 */
|
||||||
#if HAVE_INTTYPES_H
|
#if HAVE_INTTYPES_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#elif HAVE_STDINT_H
|
#elif HAVE_STDINT_H
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <sys/bitypes.h>
|
#include <sys/bitypes.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|||||||
@@ -112,6 +112,9 @@
|
|||||||
#ifndef ETHERTYPE_PPPOES
|
#ifndef ETHERTYPE_PPPOES
|
||||||
#define ETHERTYPE_PPPOES 0x8864
|
#define ETHERTYPE_PPPOES 0x8864
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ETHERTYPE_8021AD
|
||||||
|
#define ETHERTYPE_8021AD 0x88a8
|
||||||
|
#endif
|
||||||
#ifndef ETHERTYPE_LOOPBACK
|
#ifndef ETHERTYPE_LOOPBACK
|
||||||
#define ETHERTYPE_LOOPBACK 0x9000
|
#define ETHERTYPE_LOOPBACK 0x9000
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
221
libpcap/extract.h
Normal file
221
libpcap/extract.h
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that: (1) source code distributions
|
||||||
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||||
|
* distributions including binary code include the above copyright notice and
|
||||||
|
* this paragraph in its entirety in the documentation or other materials
|
||||||
|
* provided with the distribution, and (3) all advertising materials mentioning
|
||||||
|
* features or use of this software display the following acknowledgement:
|
||||||
|
* ``This product includes software developed by the University of California,
|
||||||
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||||
|
* the University nor the names of its contributors may be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros to extract possibly-unaligned big-endian integral values.
|
||||||
|
*/
|
||||||
|
#ifdef LBL_ALIGN
|
||||||
|
/*
|
||||||
|
* The processor doesn't natively handle unaligned loads.
|
||||||
|
*/
|
||||||
|
#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
|
||||||
|
(defined(__alpha) || defined(__alpha__) || \
|
||||||
|
defined(__mips) || defined(__mips__))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a GCC-compatible compiler and we have __attribute__, which
|
||||||
|
* we assume that mean we have __attribute__((packed)), and this is
|
||||||
|
* MIPS or Alpha, which has instructions that can help when doing
|
||||||
|
* unaligned loads.
|
||||||
|
*
|
||||||
|
* Declare packed structures containing a uint16_t and a uint32_t,
|
||||||
|
* cast the pointer to point to one of those, and fetch through it;
|
||||||
|
* the GCC manual doesn't appear to explicitly say that
|
||||||
|
* __attribute__((packed)) causes the compiler to generate unaligned-safe
|
||||||
|
* code, but it apppears to do so.
|
||||||
|
*
|
||||||
|
* We do this in case the compiler can generate code using those
|
||||||
|
* instructions to do an unaligned load and pass stuff to "ntohs()" or
|
||||||
|
* "ntohl()", which might be better than than the code to fetch the
|
||||||
|
* bytes one at a time and assemble them. (That might not be the
|
||||||
|
* case on a little-endian platform, such as DEC's MIPS machines and
|
||||||
|
* Alpha machines, where "ntohs()" and "ntohl()" might not be done
|
||||||
|
* inline.)
|
||||||
|
*
|
||||||
|
* We do this only for specific architectures because, for example,
|
||||||
|
* at least some versions of GCC, when compiling for 64-bit SPARC,
|
||||||
|
* generate code that assumes alignment if we do this.
|
||||||
|
*
|
||||||
|
* XXX - add other architectures and compilers as possible and
|
||||||
|
* appropriate.
|
||||||
|
*
|
||||||
|
* HP's C compiler, indicated by __HP_cc being defined, supports
|
||||||
|
* "#pragma unaligned N" in version A.05.50 and later, where "N"
|
||||||
|
* specifies a number of bytes at which the typedef on the next
|
||||||
|
* line is aligned, e.g.
|
||||||
|
*
|
||||||
|
* #pragma unalign 1
|
||||||
|
* typedef uint16_t unaligned_uint16_t;
|
||||||
|
*
|
||||||
|
* to define unaligned_uint16_t as a 16-bit unaligned data type.
|
||||||
|
* This could be presumably used, in sufficiently recent versions of
|
||||||
|
* the compiler, with macros similar to those below. This would be
|
||||||
|
* useful only if that compiler could generate better code for PA-RISC
|
||||||
|
* or Itanium than would be generated by a bunch of shifts-and-ORs.
|
||||||
|
*
|
||||||
|
* DEC C, indicated by __DECC being defined, has, at least on Alpha,
|
||||||
|
* an __unaligned qualifier that can be applied to pointers to get the
|
||||||
|
* compiler to generate code that does unaligned loads and stores when
|
||||||
|
* dereferencing the pointer in question.
|
||||||
|
*
|
||||||
|
* XXX - what if the native C compiler doesn't support
|
||||||
|
* __attribute__((packed))? How can we get it to generate unaligned
|
||||||
|
* accesses for *specific* items?
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint16_t val;
|
||||||
|
} __attribute__((packed)) unaligned_uint16_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t val;
|
||||||
|
} __attribute__((packed)) unaligned_uint32_t;
|
||||||
|
|
||||||
|
static inline uint16_t
|
||||||
|
EXTRACT_16BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
EXTRACT_32BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t
|
||||||
|
EXTRACT_64BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
|
||||||
|
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* have to do it a byte at a time */
|
||||||
|
/*
|
||||||
|
* This isn't a GCC-compatible compiler, we don't have __attribute__,
|
||||||
|
* or we do but we don't know of any better way with this instruction
|
||||||
|
* set to do unaligned loads, so do unaligned loads of big-endian
|
||||||
|
* quantities the hard way - fetch the bytes one at a time and
|
||||||
|
* assemble them.
|
||||||
|
*/
|
||||||
|
#define EXTRACT_16BITS(p) \
|
||||||
|
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
|
||||||
|
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
|
||||||
|
#define EXTRACT_32BITS(p) \
|
||||||
|
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||||
|
#define EXTRACT_64BITS(p) \
|
||||||
|
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
|
||||||
|
#endif /* must special-case unaligned accesses */
|
||||||
|
#else /* LBL_ALIGN */
|
||||||
|
/*
|
||||||
|
* The processor natively handles unaligned loads, so we can just
|
||||||
|
* cast the pointer and fetch through it.
|
||||||
|
*/
|
||||||
|
static inline uint16_t
|
||||||
|
EXTRACT_16BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
EXTRACT_32BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t
|
||||||
|
EXTRACT_64BITS(const void *p)
|
||||||
|
{
|
||||||
|
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
|
||||||
|
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* LBL_ALIGN */
|
||||||
|
|
||||||
|
#define EXTRACT_24BITS(p) \
|
||||||
|
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
|
||||||
|
|
||||||
|
#define EXTRACT_40BITS(p) \
|
||||||
|
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
|
||||||
|
|
||||||
|
#define EXTRACT_48BITS(p) \
|
||||||
|
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
|
||||||
|
|
||||||
|
#define EXTRACT_56BITS(p) \
|
||||||
|
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros to extract possibly-unaligned little-endian integral values.
|
||||||
|
* XXX - do loads on little-endian machines that support unaligned loads?
|
||||||
|
*/
|
||||||
|
#define EXTRACT_LE_8BITS(p) (*(p))
|
||||||
|
#define EXTRACT_LE_16BITS(p) \
|
||||||
|
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||||
|
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||||
|
#define EXTRACT_LE_32BITS(p) \
|
||||||
|
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||||
|
#define EXTRACT_LE_24BITS(p) \
|
||||||
|
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||||
|
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||||
|
#define EXTRACT_LE_64BITS(p) \
|
||||||
|
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||||
|
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||||
@@ -144,7 +144,8 @@ get_sa_len(struct sockaddr *addr)
|
|||||||
* could be opened.
|
* could be opened.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||||
|
int (*check_usable)(const char *))
|
||||||
{
|
{
|
||||||
pcap_if_t *devlist = NULL;
|
pcap_if_t *devlist = NULL;
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
@@ -168,11 +169,50 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
* those.
|
* those.
|
||||||
*/
|
*/
|
||||||
if (getifaddrs(&ifap) != 0) {
|
if (getifaddrs(&ifap) != 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"getifaddrs: %s", pcap_strerror(errno));
|
"getifaddrs: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||||
|
/*
|
||||||
|
* If this entry has a colon followed by a number at
|
||||||
|
* the end, we assume it's a logical interface. Those
|
||||||
|
* are just the way you assign multiple IP addresses to
|
||||||
|
* a real interface on Linux, so an entry for a logical
|
||||||
|
* interface should be treated like the entry for the
|
||||||
|
* real interface; we do that by stripping off the ":"
|
||||||
|
* and the number.
|
||||||
|
*
|
||||||
|
* XXX - should we do this only on Linux?
|
||||||
|
*/
|
||||||
|
p = strchr(ifa->ifa_name, ':');
|
||||||
|
if (p != NULL) {
|
||||||
|
/*
|
||||||
|
* We have a ":"; is it followed by a number?
|
||||||
|
*/
|
||||||
|
q = p + 1;
|
||||||
|
while (isdigit((unsigned char)*q))
|
||||||
|
q++;
|
||||||
|
if (*q == '\0') {
|
||||||
|
/*
|
||||||
|
* All digits after the ":" until the end.
|
||||||
|
* Strip off the ":" and everything after
|
||||||
|
* it.
|
||||||
|
*/
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Can we capture on this device?
|
||||||
|
*/
|
||||||
|
if (!(*check_usable)(ifa->ifa_name)) {
|
||||||
|
/*
|
||||||
|
* No.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "ifa_addr" was apparently null on at least one
|
* "ifa_addr" was apparently null on at least one
|
||||||
* interface on some system. Therefore, we supply
|
* interface on some system. Therefore, we supply
|
||||||
@@ -222,40 +262,12 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
dstaddr_size = 0;
|
dstaddr_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If this entry has a colon followed by a number at
|
|
||||||
* the end, we assume it's a logical interface. Those
|
|
||||||
* are just the way you assign multiple IP addresses to
|
|
||||||
* a real interface on Linux, so an entry for a logical
|
|
||||||
* interface should be treated like the entry for the
|
|
||||||
* real interface; we do that by stripping off the ":"
|
|
||||||
* and the number.
|
|
||||||
*
|
|
||||||
* XXX - should we do this only on Linux?
|
|
||||||
*/
|
|
||||||
p = strchr(ifa->ifa_name, ':');
|
|
||||||
if (p != NULL) {
|
|
||||||
/*
|
|
||||||
* We have a ":"; is it followed by a number?
|
|
||||||
*/
|
|
||||||
q = p + 1;
|
|
||||||
while (isdigit((unsigned char)*q))
|
|
||||||
q++;
|
|
||||||
if (*q == '\0') {
|
|
||||||
/*
|
|
||||||
* All digits after the ":" until the end.
|
|
||||||
* Strip off the ":" and everything after
|
|
||||||
* it.
|
|
||||||
*/
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add information for this address to the list.
|
* Add information for this address to the list.
|
||||||
*/
|
*/
|
||||||
if (add_addr_to_iflist(&devlist, ifa->ifa_name,
|
if (add_addr_to_iflist(&devlist, ifa->ifa_name,
|
||||||
ifa->ifa_flags, addr, addr_size, netmask, addr_size,
|
if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags),
|
||||||
|
addr, addr_size, netmask, addr_size,
|
||||||
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
|
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
|
||||||
errbuf) < 0) {
|
errbuf) < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|||||||
@@ -132,12 +132,13 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||||||
* we already have that.
|
* we already have that.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||||
|
int (*check_usable)(const char *))
|
||||||
{
|
{
|
||||||
pcap_if_t *devlist = NULL;
|
pcap_if_t *devlist = NULL;
|
||||||
register int fd;
|
register int fd;
|
||||||
register struct ifreq *ifrp, *ifend, *ifnext;
|
register struct ifreq *ifrp, *ifend, *ifnext;
|
||||||
int n;
|
size_t n;
|
||||||
struct ifconf ifc;
|
struct ifconf ifc;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
unsigned buf_size;
|
unsigned buf_size;
|
||||||
@@ -154,7 +155,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"socket: %s", pcap_strerror(errno));
|
"socket: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -170,7 +171,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
buf = malloc(buf_size);
|
buf = malloc(buf_size);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"malloc: %s", pcap_strerror(errno));
|
"malloc: %s", pcap_strerror(errno));
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -181,7 +182,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
memset(buf, 0, buf_size);
|
memset(buf, 0, buf_size);
|
||||||
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|
||||||
&& errno != EINVAL) {
|
&& errno != EINVAL) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFCONF: %s", pcap_strerror(errno));
|
"SIOCGIFCONF: %s", pcap_strerror(errno));
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
free(buf);
|
free(buf);
|
||||||
@@ -236,6 +237,16 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
if (strncmp(ifrp->ifr_name, "dummy", 5) == 0)
|
if (strncmp(ifrp->ifr_name, "dummy", 5) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Can we capture on this device?
|
||||||
|
*/
|
||||||
|
if (!(*check_usable)(ifrp->ifr_name)) {
|
||||||
|
/*
|
||||||
|
* No.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the flags for this interface.
|
* Get the flags for this interface.
|
||||||
*/
|
*/
|
||||||
@@ -244,7 +255,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
||||||
if (errno == ENXIO)
|
if (errno == ENXIO)
|
||||||
continue;
|
continue;
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFFLAGS: %.*s: %s",
|
"SIOCGIFFLAGS: %.*s: %s",
|
||||||
(int)sizeof(ifrflags.ifr_name),
|
(int)sizeof(ifrflags.ifr_name),
|
||||||
ifrflags.ifr_name,
|
ifrflags.ifr_name,
|
||||||
@@ -268,7 +279,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
netmask = NULL;
|
netmask = NULL;
|
||||||
netmask_size = 0;
|
netmask_size = 0;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFNETMASK: %.*s: %s",
|
"SIOCGIFNETMASK: %.*s: %s",
|
||||||
(int)sizeof(ifrnetmask.ifr_name),
|
(int)sizeof(ifrnetmask.ifr_name),
|
||||||
ifrnetmask.ifr_name,
|
ifrnetmask.ifr_name,
|
||||||
@@ -299,7 +310,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
broadaddr = NULL;
|
broadaddr = NULL;
|
||||||
broadaddr_size = 0;
|
broadaddr_size = 0;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFBRDADDR: %.*s: %s",
|
"SIOCGIFBRDADDR: %.*s: %s",
|
||||||
(int)sizeof(ifrbroadaddr.ifr_name),
|
(int)sizeof(ifrbroadaddr.ifr_name),
|
||||||
ifrbroadaddr.ifr_name,
|
ifrbroadaddr.ifr_name,
|
||||||
@@ -338,7 +349,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
dstaddr = NULL;
|
dstaddr = NULL;
|
||||||
dstaddr_size = 0;
|
dstaddr_size = 0;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFDSTADDR: %.*s: %s",
|
"SIOCGIFDSTADDR: %.*s: %s",
|
||||||
(int)sizeof(ifrdstaddr.ifr_name),
|
(int)sizeof(ifrdstaddr.ifr_name),
|
||||||
ifrdstaddr.ifr_name,
|
ifrdstaddr.ifr_name,
|
||||||
@@ -391,10 +402,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
* Add information for this address to the list.
|
* Add information for this address to the list.
|
||||||
*/
|
*/
|
||||||
if (add_addr_to_iflist(&devlist, ifrp->ifr_name,
|
if (add_addr_to_iflist(&devlist, ifrp->ifr_name,
|
||||||
ifrflags.ifr_flags, &ifrp->ifr_addr,
|
if_flags_to_pcap_flags(ifrp->ifr_name, ifrflags.ifr_flags),
|
||||||
SA_LEN(&ifrp->ifr_addr), netmask, netmask_size,
|
&ifrp->ifr_addr, SA_LEN(&ifrp->ifr_addr),
|
||||||
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
|
netmask, netmask_size, broadaddr, broadaddr_size,
|
||||||
errbuf) < 0) {
|
dstaddr, dstaddr_size, errbuf) < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||||||
* SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
|
* SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||||
|
int (*check_usable)(const char *))
|
||||||
{
|
{
|
||||||
pcap_if_t *devlist = NULL;
|
pcap_if_t *devlist = NULL;
|
||||||
register int fd4, fd6, fd;
|
register int fd4, fd6, fd;
|
||||||
@@ -97,7 +98,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
fd4 = socket(AF_INET, SOCK_DGRAM, 0);
|
fd4 = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd4 < 0) {
|
if (fd4 < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"socket: %s", pcap_strerror(errno));
|
"socket: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
|
fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
if (fd6 < 0) {
|
if (fd6 < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"socket: %s", pcap_strerror(errno));
|
"socket: %s", pcap_strerror(errno));
|
||||||
(void)close(fd4);
|
(void)close(fd4);
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -120,7 +121,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
ifn.lifn_flags = 0;
|
ifn.lifn_flags = 0;
|
||||||
ifn.lifn_count = 0;
|
ifn.lifn_count = 0;
|
||||||
if (ioctl(fd4, SIOCGLIFNUM, (char *)&ifn) < 0) {
|
if (ioctl(fd4, SIOCGLIFNUM, (char *)&ifn) < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFNUM: %s", pcap_strerror(errno));
|
"SIOCGLIFNUM: %s", pcap_strerror(errno));
|
||||||
(void)close(fd6);
|
(void)close(fd6);
|
||||||
(void)close(fd4);
|
(void)close(fd4);
|
||||||
@@ -133,7 +134,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
buf_size = ifn.lifn_count * sizeof (struct lifreq);
|
buf_size = ifn.lifn_count * sizeof (struct lifreq);
|
||||||
buf = malloc(buf_size);
|
buf = malloc(buf_size);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"malloc: %s", pcap_strerror(errno));
|
"malloc: %s", pcap_strerror(errno));
|
||||||
(void)close(fd6);
|
(void)close(fd6);
|
||||||
(void)close(fd4);
|
(void)close(fd4);
|
||||||
@@ -149,7 +150,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
ifc.lifc_flags = 0;
|
ifc.lifc_flags = 0;
|
||||||
memset(buf, 0, buf_size);
|
memset(buf, 0, buf_size);
|
||||||
if (ioctl(fd4, SIOCGLIFCONF, (char *)&ifc) < 0) {
|
if (ioctl(fd4, SIOCGLIFCONF, (char *)&ifc) < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFCONF: %s", pcap_strerror(errno));
|
"SIOCGLIFCONF: %s", pcap_strerror(errno));
|
||||||
(void)close(fd6);
|
(void)close(fd6);
|
||||||
(void)close(fd4);
|
(void)close(fd4);
|
||||||
@@ -164,14 +165,6 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
ifend = (struct lifreq *)(buf + ifc.lifc_len);
|
ifend = (struct lifreq *)(buf + ifc.lifc_len);
|
||||||
|
|
||||||
for (; ifrp < ifend; ifrp++) {
|
for (; ifrp < ifend; ifrp++) {
|
||||||
/*
|
|
||||||
* IPv6 or not?
|
|
||||||
*/
|
|
||||||
if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
|
|
||||||
fd = fd6;
|
|
||||||
else
|
|
||||||
fd = fd4;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip entries that begin with "dummy".
|
* Skip entries that begin with "dummy".
|
||||||
* XXX - what are these? Is this Linux-specific?
|
* XXX - what are these? Is this Linux-specific?
|
||||||
@@ -180,27 +173,23 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
if (strncmp(ifrp->lifr_name, "dummy", 5) == 0)
|
if (strncmp(ifrp->lifr_name, "dummy", 5) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifdef HAVE_SOLARIS
|
|
||||||
/*
|
/*
|
||||||
* Skip entries that have a ":" followed by a number
|
* Can we capture on this device?
|
||||||
* at the end - those are Solaris virtual interfaces
|
|
||||||
* on which you can't capture.
|
|
||||||
*/
|
*/
|
||||||
p = strchr(ifrp->lifr_name, ':');
|
if (!(*check_usable)(ifrp->lifr_name)) {
|
||||||
if (p != NULL) {
|
|
||||||
/*
|
/*
|
||||||
* We have a ":"; is it followed by a number?
|
* No.
|
||||||
*/
|
|
||||||
while (isdigit((unsigned char)*p))
|
|
||||||
p++;
|
|
||||||
if (*p == '\0') {
|
|
||||||
/*
|
|
||||||
* All digits after the ":" until the end.
|
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
/*
|
||||||
|
* IPv6 or not?
|
||||||
|
*/
|
||||||
|
if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
|
||||||
|
fd = fd6;
|
||||||
|
else
|
||||||
|
fd = fd4;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the flags for this interface.
|
* Get the flags for this interface.
|
||||||
@@ -210,7 +199,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) {
|
if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) {
|
||||||
if (errno == ENXIO)
|
if (errno == ENXIO)
|
||||||
continue;
|
continue;
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFFLAGS: %.*s: %s",
|
"SIOCGLIFFLAGS: %.*s: %s",
|
||||||
(int)sizeof(ifrflags.lifr_name),
|
(int)sizeof(ifrflags.lifr_name),
|
||||||
ifrflags.lifr_name,
|
ifrflags.lifr_name,
|
||||||
@@ -233,7 +222,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
netmask = NULL;
|
netmask = NULL;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFNETMASK: %.*s: %s",
|
"SIOCGLIFNETMASK: %.*s: %s",
|
||||||
(int)sizeof(ifrnetmask.lifr_name),
|
(int)sizeof(ifrnetmask.lifr_name),
|
||||||
ifrnetmask.lifr_name,
|
ifrnetmask.lifr_name,
|
||||||
@@ -261,7 +250,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
broadaddr = NULL;
|
broadaddr = NULL;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFBRDADDR: %.*s: %s",
|
"SIOCGLIFBRDADDR: %.*s: %s",
|
||||||
(int)sizeof(ifrbroadaddr.lifr_name),
|
(int)sizeof(ifrbroadaddr.lifr_name),
|
||||||
ifrbroadaddr.lifr_name,
|
ifrbroadaddr.lifr_name,
|
||||||
@@ -296,7 +285,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
*/
|
*/
|
||||||
dstaddr = NULL;
|
dstaddr = NULL;
|
||||||
} else {
|
} else {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGLIFDSTADDR: %.*s: %s",
|
"SIOCGLIFDSTADDR: %.*s: %s",
|
||||||
(int)sizeof(ifrdstaddr.lifr_name),
|
(int)sizeof(ifrdstaddr.lifr_name),
|
||||||
ifrdstaddr.lifr_name,
|
ifrdstaddr.lifr_name,
|
||||||
@@ -341,7 +330,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
* Add information for this address to the list.
|
* Add information for this address to the list.
|
||||||
*/
|
*/
|
||||||
if (add_addr_to_iflist(&devlist, ifrp->lifr_name,
|
if (add_addr_to_iflist(&devlist, ifrp->lifr_name,
|
||||||
ifrflags.lifr_flags, (struct sockaddr *)&ifrp->lifr_addr,
|
if_flags_to_pcap_flags(ifrp->lifr_name, ifrflags.lifr_flags),
|
||||||
|
(struct sockaddr *)&ifrp->lifr_addr,
|
||||||
sizeof (struct sockaddr_storage),
|
sizeof (struct sockaddr_storage),
|
||||||
netmask, sizeof (struct sockaddr_storage),
|
netmask, sizeof (struct sockaddr_storage),
|
||||||
broadaddr, sizeof (struct sockaddr_storage),
|
broadaddr, sizeof (struct sockaddr_storage),
|
||||||
|
|||||||
884
libpcap/fad-helpers.c
Normal file
884
libpcap/fad-helpers.c
Normal file
@@ -0,0 +1,884 @@
|
|||||||
|
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the Computer Systems
|
||||||
|
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||||
|
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||||
|
* to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <pcap-stdinc.h>
|
||||||
|
#else /* _WIN32 */
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#ifndef MSDOS
|
||||||
|
#include <sys/file.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#ifdef HAVE_SYS_SOCKIO_H
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
||||||
|
struct rtentry; /* declarations in <net/if.h> */
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#if !defined(_WIN32) && !defined(__BORLANDC__)
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif /* !_WIN32 && !__BORLANDC__ */
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
#include <limits.h>
|
||||||
|
#else
|
||||||
|
#define INT_MAX 2147483647
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pcap-int.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OS_PROTO_H
|
||||||
|
#include "os-proto.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
/* Not all systems have IFF_LOOPBACK */
|
||||||
|
#ifdef IFF_LOOPBACK
|
||||||
|
#define ISLOOPBACK(name, flags) ((flags) & IFF_LOOPBACK)
|
||||||
|
#else
|
||||||
|
#define ISLOOPBACK(name, flags) ((name)[0] == 'l' && (name)[1] == 'o' && \
|
||||||
|
(isdigit((unsigned char)((name)[2])) || (name)[2] == '\0'))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IFF_UP
|
||||||
|
#define ISUP(flags) ((flags) & IFF_UP)
|
||||||
|
#else
|
||||||
|
#define ISUP(flags) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IFF_RUNNING
|
||||||
|
#define ISRUNNING(flags) ((flags) & IFF_RUNNING)
|
||||||
|
#else
|
||||||
|
#define ISRUNNING(flags) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map UN*X-style interface flags to libpcap flags.
|
||||||
|
*/
|
||||||
|
bpf_u_int32
|
||||||
|
if_flags_to_pcap_flags(const char *name _U_, u_int if_flags)
|
||||||
|
{
|
||||||
|
bpf_u_int32 pcap_flags;
|
||||||
|
|
||||||
|
pcap_flags = 0;
|
||||||
|
if (ISLOOPBACK(name, if_flags))
|
||||||
|
pcap_flags |= PCAP_IF_LOOPBACK;
|
||||||
|
if (ISUP(if_flags))
|
||||||
|
pcap_flags |= PCAP_IF_UP;
|
||||||
|
if (ISRUNNING(if_flags))
|
||||||
|
pcap_flags |= PCAP_IF_RUNNING;
|
||||||
|
return (pcap_flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static struct sockaddr *
|
||||||
|
dup_sockaddr(struct sockaddr *sa, size_t sa_length)
|
||||||
|
{
|
||||||
|
struct sockaddr *newsa;
|
||||||
|
|
||||||
|
if ((newsa = malloc(sa_length)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
return (memcpy(newsa, sa, sa_length));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct a "figure of merit" for an interface, for use when sorting
|
||||||
|
* the list of interfaces, in which interfaces that are up are superior
|
||||||
|
* to interfaces that aren't up, interfaces that are up and running are
|
||||||
|
* superior to interfaces that are up but not running, and non-loopback
|
||||||
|
* interfaces that are up and running are superior to loopback interfaces,
|
||||||
|
* and interfaces with the same flags have a figure of merit that's higher
|
||||||
|
* the lower the instance number.
|
||||||
|
*
|
||||||
|
* The goal is to try to put the interfaces most likely to be useful for
|
||||||
|
* capture at the beginning of the list.
|
||||||
|
*
|
||||||
|
* The figure of merit, which is lower the "better" the interface is,
|
||||||
|
* has the uppermost bit set if the interface isn't running, the bit
|
||||||
|
* below that set if the interface isn't up, the bit below that set
|
||||||
|
* if the interface is a loopback interface, and the interface index
|
||||||
|
* in the 29 bits below that. (Yes, we assume u_int is 32 bits.)
|
||||||
|
*/
|
||||||
|
static u_int
|
||||||
|
get_figure_of_merit(pcap_if_t *dev)
|
||||||
|
{
|
||||||
|
const char *cp;
|
||||||
|
u_int n;
|
||||||
|
|
||||||
|
if (strcmp(dev->name, "any") == 0) {
|
||||||
|
/*
|
||||||
|
* Give the "any" device an artificially high instance
|
||||||
|
* number, so it shows up after all other non-loopback
|
||||||
|
* interfaces.
|
||||||
|
*/
|
||||||
|
n = 0x1FFFFFFF; /* 29 all-1 bits */
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* A number at the end of the device name string is
|
||||||
|
* assumed to be a unit number.
|
||||||
|
*/
|
||||||
|
cp = dev->name + strlen(dev->name) - 1;
|
||||||
|
while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9')
|
||||||
|
cp--;
|
||||||
|
if (*cp >= '0' && *cp <= '9')
|
||||||
|
n = atoi(cp);
|
||||||
|
else
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
if (!(dev->flags & PCAP_IF_RUNNING))
|
||||||
|
n |= 0x80000000;
|
||||||
|
if (!(dev->flags & PCAP_IF_UP))
|
||||||
|
n |= 0x40000000;
|
||||||
|
if (dev->flags & PCAP_IF_LOOPBACK)
|
||||||
|
n |= 0x20000000;
|
||||||
|
return (n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to get a description for a given device.
|
||||||
|
* Returns a mallocated description if it could and NULL if it couldn't.
|
||||||
|
*
|
||||||
|
* XXX - on FreeBSDs that support it, should it get the sysctl named
|
||||||
|
* "dev.{adapter family name}.{adapter unit}.%desc" to get a description
|
||||||
|
* of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800"
|
||||||
|
* with my Cisco 350 card, so the name isn't entirely descriptive. The
|
||||||
|
* "dev.an.0.%pnpinfo" has a better description, although one might argue
|
||||||
|
* that the problem is really a driver bug - if it can find out that it's
|
||||||
|
* a Cisco 340 or 350, rather than an old Aironet card, it should use
|
||||||
|
* that in the description.
|
||||||
|
*
|
||||||
|
* Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD
|
||||||
|
* and OpenBSD let you get a description, but it's not generated by the OS,
|
||||||
|
* it's set with another ioctl that ifconfig supports; we use that to get
|
||||||
|
* a description in FreeBSD and OpenBSD, but if there is no such
|
||||||
|
* description available, it still might be nice to get some description
|
||||||
|
* string based on the device type or something such as that.
|
||||||
|
*
|
||||||
|
* In OS X, the System Configuration framework can apparently return
|
||||||
|
* names in 10.4 and later.
|
||||||
|
*
|
||||||
|
* It also appears that freedesktop.org's HAL offers an "info.product"
|
||||||
|
* string, but the HAL specification says it "should not be used in any
|
||||||
|
* UI" and "subsystem/capability specific properties" should be used
|
||||||
|
* instead and, in any case, I think HAL is being deprecated in
|
||||||
|
* favor of other stuff such as DeviceKit. DeviceKit doesn't appear
|
||||||
|
* to have any obvious product information for devices, but maybe
|
||||||
|
* I haven't looked hard enough.
|
||||||
|
*
|
||||||
|
* Using the System Configuration framework, or HAL, or DeviceKit, or
|
||||||
|
* whatever, would require that libpcap applications be linked with
|
||||||
|
* the frameworks/libraries in question. That shouldn't be a problem
|
||||||
|
* for programs linking with the shared version of libpcap (unless
|
||||||
|
* you're running on AIX - which I think is the only UN*X that doesn't
|
||||||
|
* support linking a shared library with other libraries on which it
|
||||||
|
* depends, and having an executable linked only with the first shared
|
||||||
|
* library automatically pick up the other libraries when started -
|
||||||
|
* and using HAL or whatever). Programs linked with the static
|
||||||
|
* version of libpcap would have to use pcap-config with the --static
|
||||||
|
* flag in order to get the right linker flags in order to pick up
|
||||||
|
* the additional libraries/frameworks; those programs need that anyway
|
||||||
|
* for libpcap 1.1 and beyond on Linux, as, by default, it requires
|
||||||
|
* -lnl.
|
||||||
|
*
|
||||||
|
* Do any other UN*Xes, or desktop environments support getting a
|
||||||
|
* description?
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
get_if_description(const char *name)
|
||||||
|
{
|
||||||
|
#ifdef SIOCGIFDESCR
|
||||||
|
char *description = NULL;
|
||||||
|
int s;
|
||||||
|
struct ifreq ifrdesc;
|
||||||
|
#ifndef IFDESCRSIZE
|
||||||
|
size_t descrlen = 64;
|
||||||
|
#else
|
||||||
|
size_t descrlen = IFDESCRSIZE;
|
||||||
|
#endif /* IFDESCRSIZE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the description for the interface.
|
||||||
|
*/
|
||||||
|
memset(&ifrdesc, 0, sizeof ifrdesc);
|
||||||
|
strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
|
||||||
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (s >= 0) {
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
/*
|
||||||
|
* On FreeBSD, if the buffer isn't big enough for the
|
||||||
|
* description, the ioctl succeeds, but the description
|
||||||
|
* isn't copied, ifr_buffer.length is set to the description
|
||||||
|
* length, and ifr_buffer.buffer is set to NULL.
|
||||||
|
*/
|
||||||
|
for (;;) {
|
||||||
|
free(description);
|
||||||
|
if ((description = malloc(descrlen)) != NULL) {
|
||||||
|
ifrdesc.ifr_buffer.buffer = description;
|
||||||
|
ifrdesc.ifr_buffer.length = descrlen;
|
||||||
|
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) {
|
||||||
|
if (ifrdesc.ifr_buffer.buffer ==
|
||||||
|
description)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
descrlen = ifrdesc.ifr_buffer.length;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Failed to get interface description.
|
||||||
|
*/
|
||||||
|
free(description);
|
||||||
|
description = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else /* __FreeBSD__ */
|
||||||
|
/*
|
||||||
|
* The only other OS that currently supports
|
||||||
|
* SIOCGIFDESCR is OpenBSD, and it has no way
|
||||||
|
* to get the description length - it's clamped
|
||||||
|
* to a maximum of IFDESCRSIZE.
|
||||||
|
*/
|
||||||
|
if ((description = malloc(descrlen)) != NULL) {
|
||||||
|
ifrdesc.ifr_data = (caddr_t)description;
|
||||||
|
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) {
|
||||||
|
/*
|
||||||
|
* Failed to get interface description.
|
||||||
|
*/
|
||||||
|
free(description);
|
||||||
|
description = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* __FreeBSD__ */
|
||||||
|
close(s);
|
||||||
|
if (description != NULL && strlen(description) == 0) {
|
||||||
|
/*
|
||||||
|
* Description is empty, so discard it.
|
||||||
|
*/
|
||||||
|
free(description);
|
||||||
|
description = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
/*
|
||||||
|
* For FreeBSD, if we didn't get a description, and this is
|
||||||
|
* a device with a name of the form usbusN, label it as a USB
|
||||||
|
* bus.
|
||||||
|
*/
|
||||||
|
if (description == NULL) {
|
||||||
|
if (strncmp(name, "usbus", 5) == 0) {
|
||||||
|
/*
|
||||||
|
* OK, it begins with "usbus".
|
||||||
|
*/
|
||||||
|
long busnum;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
busnum = strtol(name + 5, &p, 10);
|
||||||
|
if (errno == 0 && p != name + 5 && *p == '\0' &&
|
||||||
|
busnum >= 0 && busnum <= INT_MAX) {
|
||||||
|
/*
|
||||||
|
* OK, it's a valid number that's not
|
||||||
|
* bigger than INT_MAX. Construct
|
||||||
|
* a description from it.
|
||||||
|
*/
|
||||||
|
static const char descr_prefix[] = "USB bus number ";
|
||||||
|
size_t descr_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow enough room for a 32-bit bus number.
|
||||||
|
* sizeof (descr_prefix) includes the
|
||||||
|
* terminating NUL.
|
||||||
|
*/
|
||||||
|
descr_size = sizeof (descr_prefix) + 10;
|
||||||
|
description = malloc(descr_size);
|
||||||
|
if (description != NULL) {
|
||||||
|
pcap_snprintf(description, descr_size,
|
||||||
|
"%s%ld", descr_prefix, busnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (description);
|
||||||
|
#else /* SIOCGIFDESCR */
|
||||||
|
return (NULL);
|
||||||
|
#endif /* SIOCGIFDESCR */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look for a given device in the specified list of devices.
|
||||||
|
*
|
||||||
|
* If we find it, return 0 and set *curdev_ret to point to it.
|
||||||
|
*
|
||||||
|
* If we don't find it, check whether we can open it:
|
||||||
|
*
|
||||||
|
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||||
|
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||||
|
* it, as that probably means it exists but doesn't support
|
||||||
|
* packet capture.
|
||||||
|
*
|
||||||
|
* Otherwise, attempt to add an entry for it, with the specified
|
||||||
|
* ifnet flags and description, and, if that succeeds, return 0
|
||||||
|
* and set *curdev_ret to point to the new entry, otherwise
|
||||||
|
* return PCAP_ERROR and set errbuf to an error message. If we
|
||||||
|
* weren't given a description, try to get one.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
||||||
|
bpf_u_int32 flags, const char *description, char *errbuf)
|
||||||
|
{
|
||||||
|
pcap_t *p;
|
||||||
|
pcap_if_t *curdev, *prevdev, *nextdev;
|
||||||
|
u_int this_figure_of_merit, nextdev_figure_of_merit;
|
||||||
|
char open_errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Is there already an entry in the list for this interface?
|
||||||
|
*/
|
||||||
|
for (curdev = *alldevs; curdev != NULL; curdev = curdev->next) {
|
||||||
|
if (strcmp(name, curdev->name) == 0)
|
||||||
|
break; /* yes, we found it */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curdev == NULL) {
|
||||||
|
/*
|
||||||
|
* No, we didn't find it.
|
||||||
|
*
|
||||||
|
* Can we open this interface for live capture?
|
||||||
|
*
|
||||||
|
* We do this check so that interfaces that are
|
||||||
|
* supplied by the interface enumeration mechanism
|
||||||
|
* we're using but that don't support packet capture
|
||||||
|
* aren't included in the list. Loopback interfaces
|
||||||
|
* on Solaris are an example of this; we don't just
|
||||||
|
* omit loopback interfaces on all platforms because
|
||||||
|
* you *can* capture on loopback interfaces on some
|
||||||
|
* OSes.
|
||||||
|
*
|
||||||
|
* On OS X, we don't do this check if the device
|
||||||
|
* name begins with "wlt"; at least some versions
|
||||||
|
* of OS X offer monitor mode capturing by having
|
||||||
|
* a separate "monitor mode" device for each wireless
|
||||||
|
* adapter, rather than by implementing the ioctls
|
||||||
|
* that {Free,Net,Open,DragonFly}BSD provide.
|
||||||
|
* Opening that device puts the adapter into monitor
|
||||||
|
* mode, which, at least for some adapters, causes
|
||||||
|
* them to deassociate from the network with which
|
||||||
|
* they're associated.
|
||||||
|
*
|
||||||
|
* Instead, we try to open the corresponding "en"
|
||||||
|
* device (so that we don't end up with, for users
|
||||||
|
* without sufficient privilege to open capture
|
||||||
|
* devices, a list of adapters that only includes
|
||||||
|
* the wlt devices).
|
||||||
|
*/
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (strncmp(name, "wlt", 3) == 0) {
|
||||||
|
char *en_name;
|
||||||
|
size_t en_name_len;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to allocate a buffer for the "en"
|
||||||
|
* device's name.
|
||||||
|
*/
|
||||||
|
en_name_len = strlen(name) - 1;
|
||||||
|
en_name = malloc(en_name_len + 1);
|
||||||
|
if (en_name == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
strcpy(en_name, "en");
|
||||||
|
strcat(en_name, name + 3);
|
||||||
|
p = pcap_create(en_name, open_errbuf);
|
||||||
|
free(en_name);
|
||||||
|
} else
|
||||||
|
#endif /* __APPLE */
|
||||||
|
p = pcap_create(name, open_errbuf);
|
||||||
|
if (p == NULL) {
|
||||||
|
/*
|
||||||
|
* The attempt to create the pcap_t failed;
|
||||||
|
* that's probably an indication that we're
|
||||||
|
* out of memory.
|
||||||
|
*
|
||||||
|
* Don't bother including this interface,
|
||||||
|
* but don't treat it as an error.
|
||||||
|
*/
|
||||||
|
*curdev_ret = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
/* Small snaplen, so we don't try to allocate much memory. */
|
||||||
|
pcap_set_snaplen(p, 68);
|
||||||
|
ret = pcap_activate(p);
|
||||||
|
pcap_close(p);
|
||||||
|
switch (ret) {
|
||||||
|
|
||||||
|
case PCAP_ERROR_NO_SUCH_DEVICE:
|
||||||
|
case PCAP_ERROR_IFACE_NOT_UP:
|
||||||
|
/*
|
||||||
|
* We expect these two errors - they're the
|
||||||
|
* reason we try to open the device.
|
||||||
|
*
|
||||||
|
* PCAP_ERROR_NO_SUCH_DEVICE typically means
|
||||||
|
* "there's no such device *known to the
|
||||||
|
* OS's capture mechanism*", so, even though
|
||||||
|
* it might be a valid network interface, you
|
||||||
|
* can't capture on it (e.g., the loopback
|
||||||
|
* device in Solaris up to Solaris 10, or
|
||||||
|
* the vmnet devices in OS X with VMware
|
||||||
|
* Fusion). We don't include those devices
|
||||||
|
* in our list of devices, as there's no
|
||||||
|
* point in doing so - they're not available
|
||||||
|
* for capture.
|
||||||
|
*
|
||||||
|
* PCAP_ERROR_IFACE_NOT_UP means that the
|
||||||
|
* OS's capture mechanism doesn't work on
|
||||||
|
* interfaces not marked as up; some capture
|
||||||
|
* mechanisms *do* support that, so we no
|
||||||
|
* longer reject those interfaces out of hand,
|
||||||
|
* but we *do* want to reject them if they
|
||||||
|
* can't be opened for capture.
|
||||||
|
*/
|
||||||
|
*curdev_ret = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Yes, we can open it, or we can't, for some other
|
||||||
|
* reason.
|
||||||
|
*
|
||||||
|
* If we can open it, we want to offer it for
|
||||||
|
* capture, as you can capture on it. If we can't,
|
||||||
|
* we want to offer it for capture, so that, if
|
||||||
|
* the user tries to capture on it, they'll get
|
||||||
|
* an error and they'll know why they can't
|
||||||
|
* capture on it (e.g., insufficient permissions)
|
||||||
|
* or they'll report it as a problem (and then
|
||||||
|
* have the error message to provide as information).
|
||||||
|
*
|
||||||
|
* Allocate a new entry.
|
||||||
|
*/
|
||||||
|
curdev = malloc(sizeof(pcap_if_t));
|
||||||
|
if (curdev == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill in the entry.
|
||||||
|
*/
|
||||||
|
curdev->next = NULL;
|
||||||
|
curdev->name = strdup(name);
|
||||||
|
if (curdev->name == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
free(curdev);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (description == NULL) {
|
||||||
|
/*
|
||||||
|
* We weren't handed a description for the
|
||||||
|
* interface, so see if we can generate one
|
||||||
|
* ourselves.
|
||||||
|
*/
|
||||||
|
curdev->description = get_if_description(name);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* We were handed a description; make a copy.
|
||||||
|
*/
|
||||||
|
curdev->description = strdup(description);
|
||||||
|
if (curdev->description == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
free(curdev->name);
|
||||||
|
free(curdev);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curdev->addresses = NULL; /* list starts out as empty */
|
||||||
|
curdev->flags = flags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add it to the list, in the appropriate location.
|
||||||
|
* First, get the "figure of merit" for this
|
||||||
|
* interface.
|
||||||
|
*/
|
||||||
|
this_figure_of_merit = get_figure_of_merit(curdev);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now look for the last interface with an figure of merit
|
||||||
|
* less than or equal to the new interface's figure of
|
||||||
|
* merit.
|
||||||
|
*
|
||||||
|
* We start with "prevdev" being NULL, meaning we're before
|
||||||
|
* the first element in the list.
|
||||||
|
*/
|
||||||
|
prevdev = NULL;
|
||||||
|
for (;;) {
|
||||||
|
/*
|
||||||
|
* Get the interface after this one.
|
||||||
|
*/
|
||||||
|
if (prevdev == NULL) {
|
||||||
|
/*
|
||||||
|
* The next element is the first element.
|
||||||
|
*/
|
||||||
|
nextdev = *alldevs;
|
||||||
|
} else
|
||||||
|
nextdev = prevdev->next;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Are we at the end of the list?
|
||||||
|
*/
|
||||||
|
if (nextdev == NULL) {
|
||||||
|
/*
|
||||||
|
* Yes - we have to put the new entry
|
||||||
|
* after "prevdev".
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Is the new interface's figure of merit less
|
||||||
|
* than the next interface's figure of merit,
|
||||||
|
* meaning that the new interface is better
|
||||||
|
* than the next interface?
|
||||||
|
*/
|
||||||
|
nextdev_figure_of_merit = get_figure_of_merit(nextdev);
|
||||||
|
if (this_figure_of_merit < nextdev_figure_of_merit) {
|
||||||
|
/*
|
||||||
|
* Yes - we should put the new entry
|
||||||
|
* before "nextdev", i.e. after "prevdev".
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
prevdev = nextdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert before "nextdev".
|
||||||
|
*/
|
||||||
|
curdev->next = nextdev;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert after "prevdev" - unless "prevdev" is null,
|
||||||
|
* in which case this is the first interface.
|
||||||
|
*/
|
||||||
|
if (prevdev == NULL) {
|
||||||
|
/*
|
||||||
|
* This is the first interface. Pass back a
|
||||||
|
* pointer to it, and put "curdev" before
|
||||||
|
* "nextdev".
|
||||||
|
*/
|
||||||
|
*alldevs = curdev;
|
||||||
|
} else
|
||||||
|
prevdev->next = curdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
*curdev_ret = curdev;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to get a description for a given device, and then look for that
|
||||||
|
* device in the specified list of devices.
|
||||||
|
*
|
||||||
|
* If we find it, then, if the specified address isn't null, add it to
|
||||||
|
* the list of addresses for the device and return 0.
|
||||||
|
*
|
||||||
|
* If we don't find it, check whether we can open it:
|
||||||
|
*
|
||||||
|
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||||
|
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||||
|
* it, as that probably means it exists but doesn't support
|
||||||
|
* packet capture.
|
||||||
|
*
|
||||||
|
* Otherwise, attempt to add an entry for it, with the specified
|
||||||
|
* ifnet flags, and, if that succeeds, add the specified address
|
||||||
|
* to its list of addresses if that address is non-null, set
|
||||||
|
* *curdev_ret to point to the new entry, and return 0, otherwise
|
||||||
|
* return PCAP_ERROR and set errbuf to an error message.
|
||||||
|
*
|
||||||
|
* (We can get called with a null address because we might get a list
|
||||||
|
* of interface name/address combinations from the underlying OS, with
|
||||||
|
* the address being absent in some cases, rather than a list of
|
||||||
|
* interfaces with each interface having a list of addresses, so this
|
||||||
|
* call may be the only call made to add to the list, and we want to
|
||||||
|
* add interfaces even if they have no addresses.)
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
add_addr_to_iflist(pcap_if_t **alldevs, const char *name, bpf_u_int32 flags,
|
||||||
|
struct sockaddr *addr, size_t addr_size,
|
||||||
|
struct sockaddr *netmask, size_t netmask_size,
|
||||||
|
struct sockaddr *broadaddr, size_t broadaddr_size,
|
||||||
|
struct sockaddr *dstaddr, size_t dstaddr_size,
|
||||||
|
char *errbuf)
|
||||||
|
{
|
||||||
|
pcap_if_t *curdev;
|
||||||
|
|
||||||
|
if (add_or_find_if(&curdev, alldevs, name, flags, NULL, errbuf) == -1) {
|
||||||
|
/*
|
||||||
|
* Error - give up.
|
||||||
|
*/
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (curdev == NULL) {
|
||||||
|
/*
|
||||||
|
* Device wasn't added because it can't be opened.
|
||||||
|
* Not a fatal error.
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr == NULL) {
|
||||||
|
/*
|
||||||
|
* There's no address to add; this entry just meant
|
||||||
|
* "here's a new interface".
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "curdev" is an entry for this interface, and we have an
|
||||||
|
* address for it; add an entry for that address to the
|
||||||
|
* interface's list of addresses.
|
||||||
|
*
|
||||||
|
* Allocate the new entry and fill it in.
|
||||||
|
*/
|
||||||
|
return (add_addr_to_dev(curdev, addr, addr_size, netmask,
|
||||||
|
netmask_size, broadaddr, broadaddr_size, dstaddr,
|
||||||
|
dstaddr_size, errbuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add an entry to the list of addresses for an interface.
|
||||||
|
* "curdev" is the entry for that interface.
|
||||||
|
* If this is the first IP address added to the interface, move it
|
||||||
|
* in the list as appropriate.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
add_addr_to_dev(pcap_if_t *curdev,
|
||||||
|
struct sockaddr *addr, size_t addr_size,
|
||||||
|
struct sockaddr *netmask, size_t netmask_size,
|
||||||
|
struct sockaddr *broadaddr, size_t broadaddr_size,
|
||||||
|
struct sockaddr *dstaddr, size_t dstaddr_size,
|
||||||
|
char *errbuf)
|
||||||
|
{
|
||||||
|
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
|
||||||
|
|
||||||
|
curaddr = malloc(sizeof(pcap_addr_t));
|
||||||
|
if (curaddr == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
curaddr->next = NULL;
|
||||||
|
if (addr != NULL) {
|
||||||
|
curaddr->addr = dup_sockaddr(addr, addr_size);
|
||||||
|
if (curaddr->addr == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
free(curaddr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
curaddr->addr = NULL;
|
||||||
|
|
||||||
|
if (netmask != NULL) {
|
||||||
|
curaddr->netmask = dup_sockaddr(netmask, netmask_size);
|
||||||
|
if (curaddr->netmask == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
if (curaddr->addr != NULL)
|
||||||
|
free(curaddr->addr);
|
||||||
|
free(curaddr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
curaddr->netmask = NULL;
|
||||||
|
|
||||||
|
if (broadaddr != NULL) {
|
||||||
|
curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size);
|
||||||
|
if (curaddr->broadaddr == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
if (curaddr->netmask != NULL)
|
||||||
|
free(curaddr->netmask);
|
||||||
|
if (curaddr->addr != NULL)
|
||||||
|
free(curaddr->addr);
|
||||||
|
free(curaddr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
curaddr->broadaddr = NULL;
|
||||||
|
|
||||||
|
if (dstaddr != NULL) {
|
||||||
|
curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size);
|
||||||
|
if (curaddr->dstaddr == NULL) {
|
||||||
|
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"malloc: %s", pcap_strerror(errno));
|
||||||
|
if (curaddr->broadaddr != NULL)
|
||||||
|
free(curaddr->broadaddr);
|
||||||
|
if (curaddr->netmask != NULL)
|
||||||
|
free(curaddr->netmask);
|
||||||
|
if (curaddr->addr != NULL)
|
||||||
|
free(curaddr->addr);
|
||||||
|
free(curaddr);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
curaddr->dstaddr = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the end of the list of addresses.
|
||||||
|
*/
|
||||||
|
for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) {
|
||||||
|
nextaddr = prevaddr->next;
|
||||||
|
if (nextaddr == NULL) {
|
||||||
|
/*
|
||||||
|
* This is the end of the list.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevaddr == NULL) {
|
||||||
|
/*
|
||||||
|
* The list was empty; this is the first member.
|
||||||
|
*/
|
||||||
|
curdev->addresses = curaddr;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* "prevaddr" is the last member of the list; append
|
||||||
|
* this member to it.
|
||||||
|
*/
|
||||||
|
prevaddr->next = curaddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look for a given device in the specified list of devices.
|
||||||
|
*
|
||||||
|
* If we find it, return 0.
|
||||||
|
*
|
||||||
|
* If we don't find it, check whether we can open it:
|
||||||
|
*
|
||||||
|
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||||
|
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||||
|
* it, as that probably means it exists but doesn't support
|
||||||
|
* packet capture.
|
||||||
|
*
|
||||||
|
* Otherwise, attempt to add an entry for it, with the specified
|
||||||
|
* ifnet flags and description, and, if that succeeds, return 0
|
||||||
|
* and set *curdev_ret to point to the new entry, otherwise
|
||||||
|
* return PCAP_ERROR and set errbuf to an error message.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags,
|
||||||
|
const char *description, char *errbuf)
|
||||||
|
{
|
||||||
|
pcap_if_t *curdev;
|
||||||
|
|
||||||
|
return (add_or_find_if(&curdev, devlist, name, flags, description,
|
||||||
|
errbuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free a list of interfaces.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pcap_freealldevs(pcap_if_t *alldevs)
|
||||||
|
{
|
||||||
|
pcap_if_t *curdev, *nextdev;
|
||||||
|
pcap_addr_t *curaddr, *nextaddr;
|
||||||
|
|
||||||
|
for (curdev = alldevs; curdev != NULL; curdev = nextdev) {
|
||||||
|
nextdev = curdev->next;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free all addresses.
|
||||||
|
*/
|
||||||
|
for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) {
|
||||||
|
nextaddr = curaddr->next;
|
||||||
|
if (curaddr->addr)
|
||||||
|
free(curaddr->addr);
|
||||||
|
if (curaddr->netmask)
|
||||||
|
free(curaddr->netmask);
|
||||||
|
if (curaddr->broadaddr)
|
||||||
|
free(curaddr->broadaddr);
|
||||||
|
if (curaddr->dstaddr)
|
||||||
|
free(curaddr->dstaddr);
|
||||||
|
free(curaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the name string.
|
||||||
|
*/
|
||||||
|
free(curdev->name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the description string, if any.
|
||||||
|
*/
|
||||||
|
if (curdev->description != NULL)
|
||||||
|
free(curdev->description);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the interface.
|
||||||
|
*/
|
||||||
|
free(curdev);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* fad-sita.c: Packet capture interface additions for SITA ACN devices
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007 Fulko Hew, SITA INC Canada, Inc <fulko.hew@sita.aero>
|
|
||||||
*
|
|
||||||
* License: BSD
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. The names of the authors may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "pcap-int.h"
|
|
||||||
|
|
||||||
#include "pcap-sita.h"
|
|
||||||
|
|
||||||
extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
|
|
||||||
|
|
||||||
int pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) {
|
|
||||||
|
|
||||||
//printf("pcap_findalldevs()\n"); // fulko
|
|
||||||
|
|
||||||
*alldevsp = 0; /* initialize the returned variables before we do anything */
|
|
||||||
strcpy(errbuf, "");
|
|
||||||
if (acn_parse_hosts_file(errbuf)) /* scan the hosts file for potential IOPs */
|
|
||||||
{
|
|
||||||
//printf("pcap_findalldevs() returning BAD after parsehosts\n"); // fulko
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
//printf("pcap_findalldevs() got hostlist now finding devs\n"); // fulko
|
|
||||||
if (acn_findalldevs(errbuf)) /* then ask the IOPs for their monitorable devices */
|
|
||||||
{
|
|
||||||
//printf("pcap_findalldevs() returning BAD after findalldevs\n"); // fulko
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*alldevsp = acn_if_list;
|
|
||||||
acn_if_list = 0; /* then forget our list head, because someone will call pcap_freealldevs() to empty the malloc'ed stuff */
|
|
||||||
//printf("pcap_findalldevs() returning ZERO OK\n"); // fulko
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,283 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
|
|
||||||
* Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Politecnico di Torino, CACE Technologies
|
|
||||||
* nor the names of its contributors may be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pcap.h>
|
|
||||||
#include <pcap-int.h>
|
|
||||||
#include <Packet32.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
static int
|
|
||||||
pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
|
|
||||||
char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_if_t *curdev;
|
|
||||||
npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES];
|
|
||||||
LONG if_addr_size;
|
|
||||||
int res = 0;
|
|
||||||
HANDLE pcapMutex;
|
|
||||||
DWORD wait;
|
|
||||||
|
|
||||||
if_addr_size = MAX_NETWORK_ADDRESSES;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add an entry for this interface, with no addresses.
|
|
||||||
*/
|
|
||||||
if (add_or_find_if(&curdev, devlist, name, 0, desc, errbuf) == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the list of addresses for the interface.
|
|
||||||
*/
|
|
||||||
pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
if (!PacketGetNetInfoEx((void *)name, if_addrs, &if_addr_size)) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*
|
|
||||||
* We don't return an error, because this can happen with
|
|
||||||
* NdisWan interfaces, and we want to supply them even
|
|
||||||
* if we can't supply their addresses.
|
|
||||||
*
|
|
||||||
* We return an entry with an empty address list.
|
|
||||||
*/
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now add the addresses.
|
|
||||||
*/
|
|
||||||
while (if_addr_size-- > 0) {
|
|
||||||
/*
|
|
||||||
* "curdev" is an entry for this interface; add an entry for
|
|
||||||
* this address to its list of addresses.
|
|
||||||
*/
|
|
||||||
if(curdev == NULL)
|
|
||||||
break;
|
|
||||||
res = add_addr_to_dev(curdev,
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].IPAddress,
|
|
||||||
sizeof (struct sockaddr_storage),
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].SubnetMask,
|
|
||||||
sizeof (struct sockaddr_storage),
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].Broadcast,
|
|
||||||
sizeof (struct sockaddr_storage),
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
errbuf);
|
|
||||||
if (res == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a list of all interfaces that are up and that we can open.
|
|
||||||
* Returns -1 on error, 0 otherwise.
|
|
||||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
|
||||||
* were up and could be opened.
|
|
||||||
*
|
|
||||||
* Win32 implementation, based on WinPcap
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_if_t *devlist = NULL;
|
|
||||||
int ret = 0;
|
|
||||||
const char *desc;
|
|
||||||
char *AdaptersName;
|
|
||||||
ULONG NameLength;
|
|
||||||
char *name;
|
|
||||||
HANDLE pcapMutex;
|
|
||||||
DWORD wait;
|
|
||||||
|
|
||||||
pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find out how big a buffer we need.
|
|
||||||
*
|
|
||||||
* This call should always return FALSE; if the error is
|
|
||||||
* ERROR_INSUFFICIENT_BUFFER, NameLength will be set to
|
|
||||||
* the size of the buffer we need, otherwise there's a
|
|
||||||
* problem, and NameLength should be set to 0.
|
|
||||||
*
|
|
||||||
* It shouldn't require NameLength to be set, but,
|
|
||||||
* at least as of WinPcap 4.1.3, it checks whether
|
|
||||||
* NameLength is big enough before it checks for a
|
|
||||||
* NULL buffer argument, so, while it'll still do
|
|
||||||
* the right thing if NameLength is uninitialized and
|
|
||||||
* whatever junk happens to be there is big enough
|
|
||||||
* (because the pointer argument will be null), it's
|
|
||||||
* still reading an uninitialized variable.
|
|
||||||
*/
|
|
||||||
NameLength = 0;
|
|
||||||
if (!PacketGetAdapterNames(NULL, &NameLength))
|
|
||||||
{
|
|
||||||
DWORD last_error = GetLastError();
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
if (last_error != ERROR_INSUFFICIENT_BUFFER)
|
|
||||||
{
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
if (NameLength > 0)
|
|
||||||
AdaptersName = (char*) malloc(NameLength);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*alldevsp = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (AdaptersName == NULL)
|
|
||||||
{
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Cannot allocate enough memory to list the adapters.");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
|
||||||
wait = WaitForSingleObject(pcapMutex, INFINITE);
|
|
||||||
if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
free(AdaptersName);
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
|
|
||||||
ReleaseMutex(pcapMutex);
|
|
||||||
}
|
|
||||||
CloseHandle(pcapMutex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* "PacketGetAdapterNames()" returned a list of
|
|
||||||
* null-terminated ASCII interface name strings,
|
|
||||||
* terminated by a null string, followed by a list
|
|
||||||
* of null-terminated ASCII interface description
|
|
||||||
* strings, terminated by a null string.
|
|
||||||
* This means there are two ASCII nulls at the end
|
|
||||||
* of the first list.
|
|
||||||
*
|
|
||||||
* Find the end of the first list; that's the
|
|
||||||
* beginning of the second list.
|
|
||||||
*/
|
|
||||||
desc = &AdaptersName[0];
|
|
||||||
while (*desc != '\0' || *(desc + 1) != '\0')
|
|
||||||
desc++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Found it - "desc" points to the first of the two
|
|
||||||
* nulls at the end of the list of names, so the
|
|
||||||
* first byte of the list of descriptions is two bytes
|
|
||||||
* after it.
|
|
||||||
*/
|
|
||||||
desc += 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Loop over the elements in the first list.
|
|
||||||
*/
|
|
||||||
name = &AdaptersName[0];
|
|
||||||
while (*name != '\0') {
|
|
||||||
/*
|
|
||||||
* Add an entry for this interface.
|
|
||||||
*/
|
|
||||||
if (pcap_add_if_win32(&devlist, name, desc, errbuf) == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name += strlen(name) + 1;
|
|
||||||
desc += strlen(desc) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != -1) {
|
|
||||||
/*
|
|
||||||
* We haven't had any errors yet; do any platform-specific
|
|
||||||
* operations to add devices.
|
|
||||||
*/
|
|
||||||
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == -1) {
|
|
||||||
/*
|
|
||||||
* We had an error; free the list we've been constructing.
|
|
||||||
*/
|
|
||||||
if (devlist != NULL) {
|
|
||||||
pcap_freealldevs(devlist);
|
|
||||||
devlist = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*alldevsp = devlist;
|
|
||||||
free(AdaptersName);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
11
libpcap/gen_version_c.sh
Executable file
11
libpcap/gen_version_c.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
echo '#include <pcap/export-defs.h>' > "$2"
|
||||||
|
echo 'PCAP_API_DEF' >> "$2"
|
||||||
|
if grep GIT "$1" >/dev/null; then
|
||||||
|
read ver <"$1"
|
||||||
|
echo $ver | tr -d '\012'
|
||||||
|
date +_%Y_%m_%d
|
||||||
|
else
|
||||||
|
cat "$1"
|
||||||
|
fi | sed -e 's/.*/char pcap_version[] = "&";/' >> "$2"
|
||||||
|
|
||||||
19
libpcap/gen_version_header.sh
Executable file
19
libpcap/gen_version_header.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
print_version_string()
|
||||||
|
{
|
||||||
|
if grep GIT "$1" >/dev/null
|
||||||
|
then
|
||||||
|
read ver <"$1"
|
||||||
|
echo $ver | tr -d '\012'
|
||||||
|
date +_%Y_%m_%d
|
||||||
|
else
|
||||||
|
cat "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if test $# != 3
|
||||||
|
then
|
||||||
|
echo "Usage: gen_version_header.sh <version file> <template> <output file>" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
version_string=`print_version_string "$1"`
|
||||||
|
sed "s/%%LIBPCAP_VERSION%%/$version_string/" "$2" >"$3"
|
||||||
4503
libpcap/gencode.c
4503
libpcap/gencode.c
File diff suppressed because it is too large
Load Diff
@@ -281,85 +281,115 @@ struct qual {
|
|||||||
unsigned char pad;
|
unsigned char pad;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arth *gen_loadi(int);
|
struct _compiler_state;
|
||||||
struct arth *gen_load(int, struct arth *, int);
|
|
||||||
struct arth *gen_loadlen(void);
|
typedef struct _compiler_state compiler_state_t;
|
||||||
struct arth *gen_neg(struct arth *);
|
|
||||||
struct arth *gen_arth(int, struct arth *, struct arth *);
|
struct arth *gen_loadi(compiler_state_t *, int);
|
||||||
|
struct arth *gen_load(compiler_state_t *, int, struct arth *, int);
|
||||||
|
struct arth *gen_loadlen(compiler_state_t *);
|
||||||
|
struct arth *gen_neg(compiler_state_t *, struct arth *);
|
||||||
|
struct arth *gen_arth(compiler_state_t *, int, struct arth *, struct arth *);
|
||||||
|
|
||||||
void gen_and(struct block *, struct block *);
|
void gen_and(struct block *, struct block *);
|
||||||
void gen_or(struct block *, struct block *);
|
void gen_or(struct block *, struct block *);
|
||||||
void gen_not(struct block *);
|
void gen_not(struct block *);
|
||||||
|
|
||||||
struct block *gen_scode(const char *, struct qual);
|
struct block *gen_scode(compiler_state_t *, const char *, struct qual);
|
||||||
struct block *gen_ecode(const u_char *, struct qual);
|
struct block *gen_ecode(compiler_state_t *, const u_char *, struct qual);
|
||||||
struct block *gen_acode(const u_char *, struct qual);
|
struct block *gen_acode(compiler_state_t *, const u_char *, struct qual);
|
||||||
struct block *gen_mcode(const char *, const char *, unsigned int, struct qual);
|
struct block *gen_mcode(compiler_state_t *, const char *, const char *,
|
||||||
|
unsigned int, struct qual);
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
struct block *gen_mcode6(const char *, const char *, unsigned int, struct qual);
|
struct block *gen_mcode6(compiler_state_t *, const char *, const char *,
|
||||||
|
unsigned int, struct qual);
|
||||||
#endif
|
#endif
|
||||||
struct block *gen_ncode(const char *, bpf_u_int32, struct qual);
|
struct block *gen_ncode(compiler_state_t *, const char *, bpf_u_int32,
|
||||||
struct block *gen_proto_abbrev(int);
|
struct qual);
|
||||||
struct block *gen_relation(int, struct arth *, struct arth *, int);
|
struct block *gen_proto_abbrev(compiler_state_t *, int);
|
||||||
struct block *gen_less(int);
|
struct block *gen_relation(compiler_state_t *, int, struct arth *,
|
||||||
struct block *gen_greater(int);
|
struct arth *, int);
|
||||||
struct block *gen_byteop(int, int, int);
|
struct block *gen_less(compiler_state_t *, int);
|
||||||
struct block *gen_broadcast(int);
|
struct block *gen_greater(compiler_state_t *, int);
|
||||||
struct block *gen_multicast(int);
|
struct block *gen_byteop(compiler_state_t *, int, int, int);
|
||||||
struct block *gen_inbound(int);
|
struct block *gen_broadcast(compiler_state_t *, int);
|
||||||
|
struct block *gen_multicast(compiler_state_t *, int);
|
||||||
|
struct block *gen_inbound(compiler_state_t *, int);
|
||||||
|
|
||||||
struct block *gen_llc(void);
|
struct block *gen_llc(compiler_state_t *);
|
||||||
struct block *gen_llc_i(void);
|
struct block *gen_llc_i(compiler_state_t *);
|
||||||
struct block *gen_llc_s(void);
|
struct block *gen_llc_s(compiler_state_t *);
|
||||||
struct block *gen_llc_u(void);
|
struct block *gen_llc_u(compiler_state_t *);
|
||||||
struct block *gen_llc_s_subtype(bpf_u_int32);
|
struct block *gen_llc_s_subtype(compiler_state_t *, bpf_u_int32);
|
||||||
struct block *gen_llc_u_subtype(bpf_u_int32);
|
struct block *gen_llc_u_subtype(compiler_state_t *, bpf_u_int32);
|
||||||
|
|
||||||
struct block *gen_vlan(int);
|
struct block *gen_vlan(compiler_state_t *, int);
|
||||||
struct block *gen_mpls(int);
|
struct block *gen_mpls(compiler_state_t *, int);
|
||||||
|
|
||||||
struct block *gen_pppoed(void);
|
struct block *gen_pppoed(compiler_state_t *);
|
||||||
struct block *gen_pppoes(int);
|
struct block *gen_pppoes(compiler_state_t *, int);
|
||||||
|
|
||||||
struct block *gen_geneve(int);
|
struct block *gen_geneve(compiler_state_t *, int);
|
||||||
|
|
||||||
struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
struct block *gen_atmfield_code(compiler_state_t *, int, bpf_int32,
|
||||||
struct block *gen_atmtype_abbrev(int type);
|
bpf_u_int32, int);
|
||||||
struct block *gen_atmmulti_abbrev(int type);
|
struct block *gen_atmtype_abbrev(compiler_state_t *, int type);
|
||||||
|
struct block *gen_atmmulti_abbrev(compiler_state_t *, int type);
|
||||||
|
|
||||||
struct block *gen_mtp2type_abbrev(int type);
|
struct block *gen_mtp2type_abbrev(compiler_state_t *, int type);
|
||||||
struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
struct block *gen_mtp3field_code(compiler_state_t *, int, bpf_u_int32,
|
||||||
|
bpf_u_int32, int);
|
||||||
|
|
||||||
struct block *gen_pf_ifname(const char *);
|
struct block *gen_pf_ifname(compiler_state_t *, const char *);
|
||||||
struct block *gen_pf_rnr(int);
|
struct block *gen_pf_rnr(compiler_state_t *, int);
|
||||||
struct block *gen_pf_srnr(int);
|
struct block *gen_pf_srnr(compiler_state_t *, int);
|
||||||
struct block *gen_pf_ruleset(char *);
|
struct block *gen_pf_ruleset(compiler_state_t *, char *);
|
||||||
struct block *gen_pf_reason(int);
|
struct block *gen_pf_reason(compiler_state_t *, int);
|
||||||
struct block *gen_pf_action(int);
|
struct block *gen_pf_action(compiler_state_t *, int);
|
||||||
struct block *gen_pf_dir(int);
|
|
||||||
|
|
||||||
struct block *gen_p80211_type(int, int);
|
struct block *gen_p80211_type(compiler_state_t *, int, int);
|
||||||
struct block *gen_p80211_fcdir(int);
|
struct block *gen_p80211_fcdir(compiler_state_t *, int);
|
||||||
|
|
||||||
void bpf_optimize(struct block **);
|
/*
|
||||||
void bpf_error(const char *, ...)
|
* Representation of a program as a tree of blocks, plus current mark.
|
||||||
|
* A block is marked if only if its mark equals the current mark.
|
||||||
|
* Rather than traverse the code array, marking each item, 'cur_mark'
|
||||||
|
* is incremented. This automatically makes each element unmarked.
|
||||||
|
*/
|
||||||
|
#define isMarked(icp, p) ((p)->mark == (icp)->cur_mark)
|
||||||
|
#define unMarkAll(icp) (icp)->cur_mark += 1
|
||||||
|
#define Mark(icp, p) ((p)->mark = (icp)->cur_mark)
|
||||||
|
|
||||||
|
struct icode {
|
||||||
|
struct block *root;
|
||||||
|
int cur_mark;
|
||||||
|
};
|
||||||
|
|
||||||
|
void bpf_optimize(compiler_state_t *, struct icode *ic);
|
||||||
|
void bpf_syntax_error(compiler_state_t *, const char *);
|
||||||
|
void bpf_error(compiler_state_t *, const char *, ...)
|
||||||
__attribute__((noreturn))
|
__attribute__((noreturn))
|
||||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||||
__attribute__((format (printf, 1, 2)))
|
__attribute__((format (printf, 2, 3)))
|
||||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||||
;
|
;
|
||||||
|
|
||||||
void finish_parse(struct block *);
|
void finish_parse(compiler_state_t *, struct block *);
|
||||||
char *sdup(const char *);
|
char *sdup(compiler_state_t *, const char *);
|
||||||
|
|
||||||
struct bpf_insn *icode_to_fcode(struct block *, u_int *);
|
struct _opt_state;
|
||||||
int pcap_parse(void);
|
typedef struct _opt_state opt_state_t;
|
||||||
void lex_init(const char *);
|
|
||||||
void lex_cleanup(void);
|
struct bpf_insn *icode_to_fcode(compiler_state_t *, struct icode *,
|
||||||
|
struct block *, u_int *);
|
||||||
void sappend(struct slist *, struct slist *);
|
void sappend(struct slist *, struct slist *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Older versions of Bison don't put this declaration in
|
||||||
|
* grammar.h.
|
||||||
|
*/
|
||||||
|
int pcap_parse(void *, compiler_state_t *);
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
#define JT(b) ((b)->et.succ)
|
#define JT(b) ((b)->et.succ)
|
||||||
#define JF(b) ((b)->ef.succ)
|
#define JF(b) ((b)->ef.succ)
|
||||||
|
|
||||||
extern int no_optimize;
|
|
||||||
|
|||||||
1177
libpcap/grammar.c
1177
libpcap/grammar.c
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* We want a reentrant parser.
|
||||||
|
*/
|
||||||
|
%pure-parser
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We also want a reentrant scanner, so we have to pass the
|
||||||
|
* handle for the reentrant scanner to the parser, and the
|
||||||
|
* parser has to pass it to the lexical analyzer.
|
||||||
|
*
|
||||||
|
* We use void * rather than yyscan_t because, at least with some
|
||||||
|
* versions of Flex and Bison, if you use yyscan_t in %parse-param and
|
||||||
|
* %lex-param, you have to include scanner.h before grammar.h to get
|
||||||
|
* yyscan_t declared, and you have to include grammar.h before scanner.h
|
||||||
|
* to get YYSTYPE declared. Using void * breaks the cycle; the Flex
|
||||||
|
* documentation says yyscan_t is just a void *.
|
||||||
|
*/
|
||||||
|
%parse-param {void *yyscanner}
|
||||||
|
%lex-param {void *yyscanner}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* And we need to pass the compiler state to the scanner.
|
||||||
|
*/
|
||||||
|
%parse-param {compiler_state_t *cstate}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
|
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
|
||||||
@@ -25,16 +50,16 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
#else /* WIN32 */
|
#else /* _WIN32 */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#if __STDC__
|
#if __STDC__
|
||||||
struct mbuf;
|
struct mbuf;
|
||||||
struct rtentry;
|
struct rtentry;
|
||||||
@@ -42,13 +67,16 @@ struct rtentry;
|
|||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "pcap-int.h"
|
#include "pcap-int.h"
|
||||||
|
|
||||||
#include "gencode.h"
|
#include "gencode.h"
|
||||||
|
#include "grammar.h"
|
||||||
|
#include "scanner.h"
|
||||||
|
|
||||||
#ifdef HAVE_NET_PFVAR_H
|
#ifdef HAVE_NET_PFVAR_H
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/pfvar.h>
|
#include <net/pfvar.h>
|
||||||
@@ -169,31 +197,18 @@ str2tok(const char *str, const struct tok *toks)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int n_errors = 0;
|
|
||||||
|
|
||||||
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
|
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yyerror(const char *msg)
|
yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg)
|
||||||
{
|
{
|
||||||
++n_errors;
|
bpf_syntax_error(cstate, msg);
|
||||||
bpf_error("%s", msg);
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NEED_YYPARSE_WRAPPER
|
|
||||||
int yyparse(void);
|
|
||||||
|
|
||||||
int
|
|
||||||
pcap_parse()
|
|
||||||
{
|
|
||||||
return (yyparse());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NET_PFVAR_H
|
#ifdef HAVE_NET_PFVAR_H
|
||||||
static int
|
static int
|
||||||
pfreason_to_num(const char *reason)
|
pfreason_to_num(compiler_state_t *cstate, const char *reason)
|
||||||
{
|
{
|
||||||
const char *reasons[] = PFRES_NAMES;
|
const char *reasons[] = PFRES_NAMES;
|
||||||
int i;
|
int i;
|
||||||
@@ -202,12 +217,12 @@ pfreason_to_num(const char *reason)
|
|||||||
if (pcap_strcasecmp(reason, reasons[i]) == 0)
|
if (pcap_strcasecmp(reason, reasons[i]) == 0)
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
bpf_error("unknown PF reason");
|
bpf_error(cstate, "unknown PF reason");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pfaction_to_num(const char *action)
|
pfaction_to_num(compiler_state_t *cstate, const char *action)
|
||||||
{
|
{
|
||||||
if (pcap_strcasecmp(action, "pass") == 0 ||
|
if (pcap_strcasecmp(action, "pass") == 0 ||
|
||||||
pcap_strcasecmp(action, "accept") == 0)
|
pcap_strcasecmp(action, "accept") == 0)
|
||||||
@@ -226,15 +241,15 @@ pfaction_to_num(const char *action)
|
|||||||
return (PF_NORDR);
|
return (PF_NORDR);
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
bpf_error("unknown PF action");
|
bpf_error(cstate, "unknown PF action");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* !HAVE_NET_PFVAR_H */
|
#else /* !HAVE_NET_PFVAR_H */
|
||||||
static int
|
static int
|
||||||
pfreason_to_num(const char *reason)
|
pfreason_to_num(compiler_state_t *cstate, const char *reason)
|
||||||
{
|
{
|
||||||
bpf_error("libpcap was compiled on a machine without pf support");
|
bpf_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
|
||||||
/* this is to make the VC compiler happy */
|
/* this is to make the VC compiler happy */
|
||||||
@@ -242,9 +257,9 @@ pfreason_to_num(const char *reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pfaction_to_num(const char *action)
|
pfaction_to_num(compiler_state_t *cstate, const char *action)
|
||||||
{
|
{
|
||||||
bpf_error("libpcap was compiled on a machine without pf support");
|
bpf_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
|
||||||
/* this is to make the VC compiler happy */
|
/* this is to make the VC compiler happy */
|
||||||
@@ -329,7 +344,7 @@ pfaction_to_num(const char *action)
|
|||||||
%%
|
%%
|
||||||
prog: null expr
|
prog: null expr
|
||||||
{
|
{
|
||||||
finish_parse($2.b);
|
finish_parse(cstate, $2.b);
|
||||||
}
|
}
|
||||||
| null
|
| null
|
||||||
;
|
;
|
||||||
@@ -346,48 +361,48 @@ and: AND { $$ = $<blk>0; }
|
|||||||
or: OR { $$ = $<blk>0; }
|
or: OR { $$ = $<blk>0; }
|
||||||
;
|
;
|
||||||
id: nid
|
id: nid
|
||||||
| pnum { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
|
| pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||||
$$.q = $<blk>0.q); }
|
$$.q = $<blk>0.q); }
|
||||||
| paren pid ')' { $$ = $2; }
|
| paren pid ')' { $$ = $2; }
|
||||||
;
|
;
|
||||||
nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
|
nid: ID { $$.b = gen_scode(cstate, $1, $$.q = $<blk>0.q); }
|
||||||
| HID '/' NUM { $$.b = gen_mcode($1, NULL, $3,
|
| HID '/' NUM { $$.b = gen_mcode(cstate, $1, NULL, $3,
|
||||||
$$.q = $<blk>0.q); }
|
$$.q = $<blk>0.q); }
|
||||||
| HID NETMASK HID { $$.b = gen_mcode($1, $3, 0,
|
| HID NETMASK HID { $$.b = gen_mcode(cstate, $1, $3, 0,
|
||||||
$$.q = $<blk>0.q); }
|
$$.q = $<blk>0.q); }
|
||||||
| HID {
|
| HID {
|
||||||
/* Decide how to parse HID based on proto */
|
/* Decide how to parse HID based on proto */
|
||||||
$$.q = $<blk>0.q;
|
$$.q = $<blk>0.q;
|
||||||
if ($$.q.addr == Q_PORT)
|
if ($$.q.addr == Q_PORT)
|
||||||
bpf_error("'port' modifier applied to ip host");
|
bpf_error(cstate, "'port' modifier applied to ip host");
|
||||||
else if ($$.q.addr == Q_PORTRANGE)
|
else if ($$.q.addr == Q_PORTRANGE)
|
||||||
bpf_error("'portrange' modifier applied to ip host");
|
bpf_error(cstate, "'portrange' modifier applied to ip host");
|
||||||
else if ($$.q.addr == Q_PROTO)
|
else if ($$.q.addr == Q_PROTO)
|
||||||
bpf_error("'proto' modifier applied to ip host");
|
bpf_error(cstate, "'proto' modifier applied to ip host");
|
||||||
else if ($$.q.addr == Q_PROTOCHAIN)
|
else if ($$.q.addr == Q_PROTOCHAIN)
|
||||||
bpf_error("'protochain' modifier applied to ip host");
|
bpf_error(cstate, "'protochain' modifier applied to ip host");
|
||||||
$$.b = gen_ncode($1, 0, $$.q);
|
$$.b = gen_ncode(cstate, $1, 0, $$.q);
|
||||||
}
|
}
|
||||||
| HID6 '/' NUM {
|
| HID6 '/' NUM {
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
$$.b = gen_mcode6($1, NULL, $3,
|
$$.b = gen_mcode6(cstate, $1, NULL, $3,
|
||||||
$$.q = $<blk>0.q);
|
$$.q = $<blk>0.q);
|
||||||
#else
|
#else
|
||||||
bpf_error("'ip6addr/prefixlen' not supported "
|
bpf_error(cstate, "'ip6addr/prefixlen' not supported "
|
||||||
"in this configuration");
|
"in this configuration");
|
||||||
#endif /*INET6*/
|
#endif /*INET6*/
|
||||||
}
|
}
|
||||||
| HID6 {
|
| HID6 {
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
$$.b = gen_mcode6($1, 0, 128,
|
$$.b = gen_mcode6(cstate, $1, 0, 128,
|
||||||
$$.q = $<blk>0.q);
|
$$.q = $<blk>0.q);
|
||||||
#else
|
#else
|
||||||
bpf_error("'ip6addr' not supported "
|
bpf_error(cstate, "'ip6addr' not supported "
|
||||||
"in this configuration");
|
"in this configuration");
|
||||||
#endif /*INET6*/
|
#endif /*INET6*/
|
||||||
}
|
}
|
||||||
| EID {
|
| EID {
|
||||||
$$.b = gen_ecode($1, $$.q = $<blk>0.q);
|
$$.b = gen_ecode(cstate, $1, $$.q = $<blk>0.q);
|
||||||
/*
|
/*
|
||||||
* $1 was allocated by "pcap_ether_aton()",
|
* $1 was allocated by "pcap_ether_aton()",
|
||||||
* so we must free it now that we're done
|
* so we must free it now that we're done
|
||||||
@@ -396,7 +411,7 @@ nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
|
|||||||
free($1);
|
free($1);
|
||||||
}
|
}
|
||||||
| AID {
|
| AID {
|
||||||
$$.b = gen_acode($1, $$.q = $<blk>0.q);
|
$$.b = gen_acode(cstate, $1, $$.q = $<blk>0.q);
|
||||||
/*
|
/*
|
||||||
* $1 was allocated by "pcap_ether_aton()",
|
* $1 was allocated by "pcap_ether_aton()",
|
||||||
* so we must free it now that we're done
|
* so we must free it now that we're done
|
||||||
@@ -414,7 +429,7 @@ pid: nid
|
|||||||
| qid and id { gen_and($1.b, $3.b); $$ = $3; }
|
| qid and id { gen_and($1.b, $3.b); $$ = $3; }
|
||||||
| qid or id { gen_or($1.b, $3.b); $$ = $3; }
|
| qid or id { gen_or($1.b, $3.b); $$ = $3; }
|
||||||
;
|
;
|
||||||
qid: pnum { $$.b = gen_ncode(NULL, (bpf_u_int32)$1,
|
qid: pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||||
$$.q = $<blk>0.q); }
|
$$.q = $<blk>0.q); }
|
||||||
| pid
|
| pid
|
||||||
;
|
;
|
||||||
@@ -430,16 +445,16 @@ head: pqual dqual aqual { QSET($$.q, $1, $2, $3); }
|
|||||||
;
|
;
|
||||||
rterm: head id { $$ = $2; }
|
rterm: head id { $$ = $2; }
|
||||||
| paren expr ')' { $$.b = $2.b; $$.q = $1.q; }
|
| paren expr ')' { $$.b = $2.b; $$.q = $1.q; }
|
||||||
| pname { $$.b = gen_proto_abbrev($1); $$.q = qerr; }
|
| pname { $$.b = gen_proto_abbrev(cstate, $1); $$.q = qerr; }
|
||||||
| arth relop arth { $$.b = gen_relation($2, $1, $3, 0);
|
| arth relop arth { $$.b = gen_relation(cstate, $2, $1, $3, 0);
|
||||||
$$.q = qerr; }
|
$$.q = qerr; }
|
||||||
| arth irelop arth { $$.b = gen_relation($2, $1, $3, 1);
|
| arth irelop arth { $$.b = gen_relation(cstate, $2, $1, $3, 1);
|
||||||
$$.q = qerr; }
|
$$.q = qerr; }
|
||||||
| other { $$.b = $1; $$.q = qerr; }
|
| other { $$.b = $1; $$.q = qerr; }
|
||||||
| atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
|
| atmtype { $$.b = gen_atmtype_abbrev(cstate, $1); $$.q = qerr; }
|
||||||
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
|
| atmmultitype { $$.b = gen_atmmulti_abbrev(cstate, $1); $$.q = qerr; }
|
||||||
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
|
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
|
||||||
| mtp2type { $$.b = gen_mtp2type_abbrev($1); $$.q = qerr; }
|
| mtp2type { $$.b = gen_mtp2type_abbrev(cstate, $1); $$.q = qerr; }
|
||||||
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
|
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
|
||||||
;
|
;
|
||||||
/* protocol level qualifiers */
|
/* protocol level qualifiers */
|
||||||
@@ -509,54 +524,54 @@ pname: LINK { $$ = Q_LINK; }
|
|||||||
| NETBEUI { $$ = Q_NETBEUI; }
|
| NETBEUI { $$ = Q_NETBEUI; }
|
||||||
| RADIO { $$ = Q_RADIO; }
|
| RADIO { $$ = Q_RADIO; }
|
||||||
;
|
;
|
||||||
other: pqual TK_BROADCAST { $$ = gen_broadcast($1); }
|
other: pqual TK_BROADCAST { $$ = gen_broadcast(cstate, $1); }
|
||||||
| pqual TK_MULTICAST { $$ = gen_multicast($1); }
|
| pqual TK_MULTICAST { $$ = gen_multicast(cstate, $1); }
|
||||||
| LESS NUM { $$ = gen_less($2); }
|
| LESS NUM { $$ = gen_less(cstate, $2); }
|
||||||
| GREATER NUM { $$ = gen_greater($2); }
|
| GREATER NUM { $$ = gen_greater(cstate, $2); }
|
||||||
| CBYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); }
|
| CBYTE NUM byteop NUM { $$ = gen_byteop(cstate, $3, $2, $4); }
|
||||||
| INBOUND { $$ = gen_inbound(0); }
|
| INBOUND { $$ = gen_inbound(cstate, 0); }
|
||||||
| OUTBOUND { $$ = gen_inbound(1); }
|
| OUTBOUND { $$ = gen_inbound(cstate, 1); }
|
||||||
| VLAN pnum { $$ = gen_vlan($2); }
|
| VLAN pnum { $$ = gen_vlan(cstate, $2); }
|
||||||
| VLAN { $$ = gen_vlan(-1); }
|
| VLAN { $$ = gen_vlan(cstate, -1); }
|
||||||
| MPLS pnum { $$ = gen_mpls($2); }
|
| MPLS pnum { $$ = gen_mpls(cstate, $2); }
|
||||||
| MPLS { $$ = gen_mpls(-1); }
|
| MPLS { $$ = gen_mpls(cstate, -1); }
|
||||||
| PPPOED { $$ = gen_pppoed(); }
|
| PPPOED { $$ = gen_pppoed(cstate); }
|
||||||
| PPPOES pnum { $$ = gen_pppoes($2); }
|
| PPPOES pnum { $$ = gen_pppoes(cstate, $2); }
|
||||||
| PPPOES { $$ = gen_pppoes(-1); }
|
| PPPOES { $$ = gen_pppoes(cstate, -1); }
|
||||||
| GENEVE pnum { $$ = gen_geneve($2); }
|
| GENEVE pnum { $$ = gen_geneve(cstate, $2); }
|
||||||
| GENEVE { $$ = gen_geneve(-1); }
|
| GENEVE { $$ = gen_geneve(cstate, -1); }
|
||||||
| pfvar { $$ = $1; }
|
| pfvar { $$ = $1; }
|
||||||
| pqual p80211 { $$ = $2; }
|
| pqual p80211 { $$ = $2; }
|
||||||
| pllc { $$ = $1; }
|
| pllc { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
pfvar: PF_IFNAME ID { $$ = gen_pf_ifname($2); }
|
pfvar: PF_IFNAME ID { $$ = gen_pf_ifname(cstate, $2); }
|
||||||
| PF_RSET ID { $$ = gen_pf_ruleset($2); }
|
| PF_RSET ID { $$ = gen_pf_ruleset(cstate, $2); }
|
||||||
| PF_RNR NUM { $$ = gen_pf_rnr($2); }
|
| PF_RNR NUM { $$ = gen_pf_rnr(cstate, $2); }
|
||||||
| PF_SRNR NUM { $$ = gen_pf_srnr($2); }
|
| PF_SRNR NUM { $$ = gen_pf_srnr(cstate, $2); }
|
||||||
| PF_REASON reason { $$ = gen_pf_reason($2); }
|
| PF_REASON reason { $$ = gen_pf_reason(cstate, $2); }
|
||||||
| PF_ACTION action { $$ = gen_pf_action($2); }
|
| PF_ACTION action { $$ = gen_pf_action(cstate, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
p80211: TYPE type SUBTYPE subtype
|
p80211: TYPE type SUBTYPE subtype
|
||||||
{ $$ = gen_p80211_type($2 | $4,
|
{ $$ = gen_p80211_type(cstate, $2 | $4,
|
||||||
IEEE80211_FC0_TYPE_MASK |
|
IEEE80211_FC0_TYPE_MASK |
|
||||||
IEEE80211_FC0_SUBTYPE_MASK);
|
IEEE80211_FC0_SUBTYPE_MASK);
|
||||||
}
|
}
|
||||||
| TYPE type { $$ = gen_p80211_type($2,
|
| TYPE type { $$ = gen_p80211_type(cstate, $2,
|
||||||
IEEE80211_FC0_TYPE_MASK);
|
IEEE80211_FC0_TYPE_MASK);
|
||||||
}
|
}
|
||||||
| SUBTYPE type_subtype { $$ = gen_p80211_type($2,
|
| SUBTYPE type_subtype { $$ = gen_p80211_type(cstate, $2,
|
||||||
IEEE80211_FC0_TYPE_MASK |
|
IEEE80211_FC0_TYPE_MASK |
|
||||||
IEEE80211_FC0_SUBTYPE_MASK);
|
IEEE80211_FC0_SUBTYPE_MASK);
|
||||||
}
|
}
|
||||||
| DIR dir { $$ = gen_p80211_fcdir($2); }
|
| DIR dir { $$ = gen_p80211_fcdir(cstate, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
type: NUM
|
type: NUM
|
||||||
| ID { $$ = str2tok($1, ieee80211_types);
|
| ID { $$ = str2tok($1, ieee80211_types);
|
||||||
if ($$ == -1)
|
if ($$ == -1)
|
||||||
bpf_error("unknown 802.11 type name");
|
bpf_error(cstate, "unknown 802.11 type name");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -566,7 +581,7 @@ subtype: NUM
|
|||||||
for (i = 0;; i++) {
|
for (i = 0;; i++) {
|
||||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||||
/* Ran out of types */
|
/* Ran out of types */
|
||||||
bpf_error("unknown 802.11 type");
|
bpf_error(cstate, "unknown 802.11 type");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($<i>-1 == ieee80211_type_subtypes[i].type) {
|
if ($<i>-1 == ieee80211_type_subtypes[i].type) {
|
||||||
@@ -577,7 +592,7 @@ subtype: NUM
|
|||||||
|
|
||||||
$$ = str2tok($1, types);
|
$$ = str2tok($1, types);
|
||||||
if ($$ == -1)
|
if ($$ == -1)
|
||||||
bpf_error("unknown 802.11 subtype name");
|
bpf_error(cstate, "unknown 802.11 subtype name");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -585,7 +600,7 @@ type_subtype: ID { int i;
|
|||||||
for (i = 0;; i++) {
|
for (i = 0;; i++) {
|
||||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||||
/* Ran out of types */
|
/* Ran out of types */
|
||||||
bpf_error("unknown 802.11 type name");
|
bpf_error(cstate, "unknown 802.11 type name");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$$ = str2tok($1, ieee80211_type_subtypes[i].tok);
|
$$ = str2tok($1, ieee80211_type_subtypes[i].tok);
|
||||||
@@ -597,29 +612,29 @@ type_subtype: ID { int i;
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
pllc: LLC { $$ = gen_llc(); }
|
pllc: LLC { $$ = gen_llc(cstate); }
|
||||||
| LLC ID { if (pcap_strcasecmp($2, "i") == 0)
|
| LLC ID { if (pcap_strcasecmp($2, "i") == 0)
|
||||||
$$ = gen_llc_i();
|
$$ = gen_llc_i(cstate);
|
||||||
else if (pcap_strcasecmp($2, "s") == 0)
|
else if (pcap_strcasecmp($2, "s") == 0)
|
||||||
$$ = gen_llc_s();
|
$$ = gen_llc_s(cstate);
|
||||||
else if (pcap_strcasecmp($2, "u") == 0)
|
else if (pcap_strcasecmp($2, "u") == 0)
|
||||||
$$ = gen_llc_u();
|
$$ = gen_llc_u(cstate);
|
||||||
else {
|
else {
|
||||||
u_int subtype;
|
int subtype;
|
||||||
|
|
||||||
subtype = str2tok($2, llc_s_subtypes);
|
subtype = str2tok($2, llc_s_subtypes);
|
||||||
if (subtype != -1)
|
if (subtype != -1)
|
||||||
$$ = gen_llc_s_subtype(subtype);
|
$$ = gen_llc_s_subtype(cstate, subtype);
|
||||||
else {
|
else {
|
||||||
subtype = str2tok($2, llc_u_subtypes);
|
subtype = str2tok($2, llc_u_subtypes);
|
||||||
if (subtype == -1)
|
if (subtype == -1)
|
||||||
bpf_error("unknown LLC type name \"%s\"", $2);
|
bpf_error(cstate, "unknown LLC type name \"%s\"", $2);
|
||||||
$$ = gen_llc_u_subtype(subtype);
|
$$ = gen_llc_u_subtype(cstate, subtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* sigh, "rnr" is already a keyword for PF */
|
/* sigh, "rnr" is already a keyword for PF */
|
||||||
| LLC PF_RNR { $$ = gen_llc_s_subtype(LLC_RNR); }
|
| LLC PF_RNR { $$ = gen_llc_s_subtype(cstate, LLC_RNR); }
|
||||||
;
|
;
|
||||||
|
|
||||||
dir: NUM
|
dir: NUM
|
||||||
@@ -632,15 +647,15 @@ dir: NUM
|
|||||||
else if (pcap_strcasecmp($1, "dstods") == 0)
|
else if (pcap_strcasecmp($1, "dstods") == 0)
|
||||||
$$ = IEEE80211_FC1_DIR_DSTODS;
|
$$ = IEEE80211_FC1_DIR_DSTODS;
|
||||||
else
|
else
|
||||||
bpf_error("unknown 802.11 direction");
|
bpf_error(cstate, "unknown 802.11 direction");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
reason: NUM { $$ = $1; }
|
reason: NUM { $$ = $1; }
|
||||||
| ID { $$ = pfreason_to_num($1); }
|
| ID { $$ = pfreason_to_num(cstate, $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
action: ID { $$ = pfaction_to_num($1); }
|
action: ID { $$ = pfaction_to_num(cstate, $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
relop: '>' { $$ = BPF_JGT; }
|
relop: '>' { $$ = BPF_JGT; }
|
||||||
@@ -651,24 +666,24 @@ irelop: LEQ { $$ = BPF_JGT; }
|
|||||||
| '<' { $$ = BPF_JGE; }
|
| '<' { $$ = BPF_JGE; }
|
||||||
| NEQ { $$ = BPF_JEQ; }
|
| NEQ { $$ = BPF_JEQ; }
|
||||||
;
|
;
|
||||||
arth: pnum { $$ = gen_loadi($1); }
|
arth: pnum { $$ = gen_loadi(cstate, $1); }
|
||||||
| narth
|
| narth
|
||||||
;
|
;
|
||||||
narth: pname '[' arth ']' { $$ = gen_load($1, $3, 1); }
|
narth: pname '[' arth ']' { $$ = gen_load(cstate, $1, $3, 1); }
|
||||||
| pname '[' arth ':' NUM ']' { $$ = gen_load($1, $3, $5); }
|
| pname '[' arth ':' NUM ']' { $$ = gen_load(cstate, $1, $3, $5); }
|
||||||
| arth '+' arth { $$ = gen_arth(BPF_ADD, $1, $3); }
|
| arth '+' arth { $$ = gen_arth(cstate, BPF_ADD, $1, $3); }
|
||||||
| arth '-' arth { $$ = gen_arth(BPF_SUB, $1, $3); }
|
| arth '-' arth { $$ = gen_arth(cstate, BPF_SUB, $1, $3); }
|
||||||
| arth '*' arth { $$ = gen_arth(BPF_MUL, $1, $3); }
|
| arth '*' arth { $$ = gen_arth(cstate, BPF_MUL, $1, $3); }
|
||||||
| arth '/' arth { $$ = gen_arth(BPF_DIV, $1, $3); }
|
| arth '/' arth { $$ = gen_arth(cstate, BPF_DIV, $1, $3); }
|
||||||
| arth '%' arth { $$ = gen_arth(BPF_MOD, $1, $3); }
|
| arth '%' arth { $$ = gen_arth(cstate, BPF_MOD, $1, $3); }
|
||||||
| arth '&' arth { $$ = gen_arth(BPF_AND, $1, $3); }
|
| arth '&' arth { $$ = gen_arth(cstate, BPF_AND, $1, $3); }
|
||||||
| arth '|' arth { $$ = gen_arth(BPF_OR, $1, $3); }
|
| arth '|' arth { $$ = gen_arth(cstate, BPF_OR, $1, $3); }
|
||||||
| arth '^' arth { $$ = gen_arth(BPF_XOR, $1, $3); }
|
| arth '^' arth { $$ = gen_arth(cstate, BPF_XOR, $1, $3); }
|
||||||
| arth LSH arth { $$ = gen_arth(BPF_LSH, $1, $3); }
|
| arth LSH arth { $$ = gen_arth(cstate, BPF_LSH, $1, $3); }
|
||||||
| arth RSH arth { $$ = gen_arth(BPF_RSH, $1, $3); }
|
| arth RSH arth { $$ = gen_arth(cstate, BPF_RSH, $1, $3); }
|
||||||
| '-' arth %prec UMINUS { $$ = gen_neg($2); }
|
| '-' arth %prec UMINUS { $$ = gen_neg(cstate, $2); }
|
||||||
| paren narth ')' { $$ = $2; }
|
| paren narth ')' { $$ = $2; }
|
||||||
| LEN { $$ = gen_loadlen(); }
|
| LEN { $$ = gen_loadlen(cstate); }
|
||||||
;
|
;
|
||||||
byteop: '&' { $$ = '&'; }
|
byteop: '&' { $$ = '&'; }
|
||||||
| '|' { $$ = '|'; }
|
| '|' { $$ = '|'; }
|
||||||
@@ -697,15 +712,15 @@ atmfield: VPI { $$.atmfieldtype = A_VPI; }
|
|||||||
| VCI { $$.atmfieldtype = A_VCI; }
|
| VCI { $$.atmfieldtype = A_VCI; }
|
||||||
;
|
;
|
||||||
atmvalue: atmfieldvalue
|
atmvalue: atmfieldvalue
|
||||||
| relop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
|
| relop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
|
||||||
| irelop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
|
| irelop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
|
||||||
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||||
;
|
;
|
||||||
atmfieldvalue: NUM {
|
atmfieldvalue: NUM {
|
||||||
$$.atmfieldtype = $<blk>0.atmfieldtype;
|
$$.atmfieldtype = $<blk>0.atmfieldtype;
|
||||||
if ($$.atmfieldtype == A_VPI ||
|
if ($$.atmfieldtype == A_VPI ||
|
||||||
$$.atmfieldtype == A_VCI)
|
$$.atmfieldtype == A_VCI)
|
||||||
$$.b = gen_atmfield_code($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
|
$$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
atmlistvalue: atmfieldvalue
|
atmlistvalue: atmfieldvalue
|
||||||
@@ -730,8 +745,8 @@ mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
|||||||
| HSLS { $$.mtp3fieldtype = MH_SLS; }
|
| HSLS { $$.mtp3fieldtype = MH_SLS; }
|
||||||
;
|
;
|
||||||
mtp3value: mtp3fieldvalue
|
mtp3value: mtp3fieldvalue
|
||||||
| relop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
|
| relop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
|
||||||
| irelop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
|
| irelop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
|
||||||
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||||
;
|
;
|
||||||
mtp3fieldvalue: NUM {
|
mtp3fieldvalue: NUM {
|
||||||
@@ -744,7 +759,7 @@ mtp3fieldvalue: NUM {
|
|||||||
$$.mtp3fieldtype == MH_OPC ||
|
$$.mtp3fieldtype == MH_OPC ||
|
||||||
$$.mtp3fieldtype == MH_DPC ||
|
$$.mtp3fieldtype == MH_DPC ||
|
||||||
$$.mtp3fieldtype == MH_SLS)
|
$$.mtp3fieldtype == MH_SLS)
|
||||||
$$.b = gen_mtp3field_code($$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
|
$$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
mtp3listvalue: mtp3fieldvalue
|
mtp3listvalue: mtp3fieldvalue
|
||||||
|
|||||||
938
libpcap/inet.c
938
libpcap/inet.c
File diff suppressed because it is too large
Load Diff
23
libpcap/lbl/os-aix7.h
Normal file
23
libpcap/lbl/os-aix7.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that: (1) source code distributions
|
||||||
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||||
|
* distributions including binary code include the above copyright notice and
|
||||||
|
* this paragraph in its entirety in the documentation or other materials
|
||||||
|
* provided with the distribution, and (3) all advertising materials mentioning
|
||||||
|
* features or use of this software display the following acknowledgement:
|
||||||
|
* ``This product includes software developed by the University of California,
|
||||||
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||||
|
* the University nor the names of its contributors may be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Prototypes missing in AIX 7.x */
|
||||||
|
int ffs(int i);
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Prototypes missing in Digital UNIX 4.x */
|
/* Prototypes missing in Digital UNIX 4.x */
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||||
int vsnprintf(char *, size_t, const char *, va_list);
|
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||||
int pfopen(char *, int);
|
int pfopen(char *, int);
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes missing in Tru64 UNIX 5.x
|
* Prototypes missing in Tru64 UNIX 5.x
|
||||||
* XXX - "snprintf()" and "vsnprintf()" aren't missing, but you have to
|
* XXX - "pcap_snprintf()" and "pcap_vsnprintf()" aren't missing, but you have to
|
||||||
* #define the right value to get them defined by <stdio.h>.
|
* #define the right value to get them defined by <stdio.h>.
|
||||||
*/
|
*/
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||||
int vsnprintf(char *, size_t, const char *, va_list);
|
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||||
int pfopen(char *, int);
|
int pfopen(char *, int);
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,4 @@
|
|||||||
|
|
||||||
/* Prototypes missing in SunOS 5 */
|
/* Prototypes missing in SunOS 5 */
|
||||||
char *strerror(int);
|
char *strerror(int);
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ int fchmod(int, int);
|
|||||||
int fchown(int, int, int);
|
int fchown(int, int, int);
|
||||||
void endgrent(void);
|
void endgrent(void);
|
||||||
void endpwent(void);
|
void endpwent(void);
|
||||||
void endservent(void);
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
struct ether_addr;
|
struct ether_addr;
|
||||||
#endif
|
#endif
|
||||||
@@ -146,7 +145,6 @@ int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
|||||||
int setpgrp(int, int);
|
int setpgrp(int, int);
|
||||||
void setpwent(void);
|
void setpwent(void);
|
||||||
int setrlimit(int, struct rlimit *);
|
int setrlimit(int, struct rlimit *);
|
||||||
void setservent(int);
|
|
||||||
int setsockopt(int, int, int, char *, int);
|
int setsockopt(int, int, int, char *, int);
|
||||||
int shutdown(int, int);
|
int shutdown(int, int);
|
||||||
int sigblock(int);
|
int sigblock(int);
|
||||||
@@ -157,7 +155,7 @@ int sigsetmask(int);
|
|||||||
struct sigvec;
|
struct sigvec;
|
||||||
#endif
|
#endif
|
||||||
int sigvec(int, struct sigvec *, struct sigvec*);
|
int sigvec(int, struct sigvec *, struct sigvec*);
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||||
int socket(int, int, int);
|
int socket(int, int, int);
|
||||||
int socketpair(int, int, int, int *);
|
int socketpair(int, int, int, int *);
|
||||||
int symlink(const char *, const char *);
|
int symlink(const char *, const char *);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
int bcmp(const char *, const char *, u_int);
|
int bcmp(const char *, const char *, u_int);
|
||||||
void bcopy(const void *, void *, u_int);
|
void bcopy(const void *, void *, u_int);
|
||||||
void bzero(void *, u_int);
|
void bzero(void *, u_int);
|
||||||
void endservent(void);
|
|
||||||
int getopt(int, char * const *, const char *);
|
int getopt(int, char * const *, const char *);
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
struct timeval;
|
struct timeval;
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
int opterr = 1, /* if error message should be printed */
|
||||||
optind = 1, /* index into parent argv vector */
|
optind = 1, /* index into parent argv vector */
|
||||||
optopt, /* character checked for validity */
|
optopt, /* character checked for validity */
|
||||||
@@ -59,14 +61,17 @@ getopt(nargc, nargv, ostr)
|
|||||||
char * const *nargv;
|
char * const *nargv;
|
||||||
const char *ostr;
|
const char *ostr;
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
char *cp;
|
||||||
char *__progname="windump";
|
static char *__progname;
|
||||||
#else
|
|
||||||
extern char *__progname;
|
|
||||||
#endif
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
char *oli; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
|
if (__progname == NULL) {
|
||||||
|
if ((cp = strrchr(nargv[0], '/')) != NULL)
|
||||||
|
__progname = cp + 1;
|
||||||
|
else
|
||||||
|
__progname = nargv[0];
|
||||||
|
}
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
if (optreset || !*place) { /* update scanning pointer */
|
||||||
optreset = 0;
|
optreset = 0;
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||||
7
libpcap/missing/getopt.h
Normal file
7
libpcap/missing/getopt.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* Header for the getopt() we supply if the platform doesn't supply it.
|
||||||
|
*/
|
||||||
|
extern char *optarg; /* getopt(3) external variables */
|
||||||
|
extern int optind, opterr, optopt;
|
||||||
|
|
||||||
|
extern int getopt(int nargc, char * const *nargv, const char *ostr);
|
||||||
@@ -456,13 +456,13 @@ xyzprintf (struct state *state, const char *char_format, va_list ap)
|
|||||||
|
|
||||||
#ifndef HAVE_SNPRINTF
|
#ifndef HAVE_SNPRINTF
|
||||||
int
|
int
|
||||||
snprintf (char *str, size_t sz, const char *format, ...)
|
pcap_snprintf (char *str, size_t sz, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
ret = vsnprintf (str, sz, format, args);
|
ret = pcap_vsnprintf (str, sz, format, args);
|
||||||
|
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
{
|
{
|
||||||
@@ -473,7 +473,7 @@ snprintf (char *str, size_t sz, const char *format, ...)
|
|||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
ret2 = vsprintf (tmp, format, args);
|
ret2 = pcap_vsprintf (tmp, format, args);
|
||||||
if (ret != ret2 || strcmp(str, tmp))
|
if (ret != ret2 || strcmp(str, tmp))
|
||||||
abort ();
|
abort ();
|
||||||
free (tmp);
|
free (tmp);
|
||||||
@@ -518,13 +518,13 @@ asprintf (char **ret, const char *format, ...)
|
|||||||
|
|
||||||
#ifndef HAVE_ASNPRINTF
|
#ifndef HAVE_ASNPRINTF
|
||||||
int
|
int
|
||||||
asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
pcap_asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
val = vasnprintf (ret, max_sz, format, args);
|
val = pcap_vasnprintf (ret, max_sz, format, args);
|
||||||
|
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
{
|
{
|
||||||
@@ -534,7 +534,7 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
|||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
ret2 = vsprintf (tmp, format, args);
|
ret2 = pcap_vsprintf (tmp, format, args);
|
||||||
if (val != ret2 || strcmp(*ret, tmp))
|
if (val != ret2 || strcmp(*ret, tmp))
|
||||||
abort ();
|
abort ();
|
||||||
free (tmp);
|
free (tmp);
|
||||||
@@ -548,16 +548,16 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
|||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
#ifndef HAVE_VASPRINTF
|
||||||
int
|
int
|
||||||
vasprintf (char **ret, const char *format, va_list args)
|
pcap_vasprintf (char **ret, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
return vasnprintf (ret, 0, format, args);
|
return pcap_vasnprintf (ret, 0, format, args);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_VASNPRINTF
|
#ifndef HAVE_VASNPRINTF
|
||||||
int
|
int
|
||||||
vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
pcap_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
int st;
|
int st;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -600,7 +600,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
|||||||
|
|
||||||
#ifndef HAVE_VSNPRINTF
|
#ifndef HAVE_VSNPRINTF
|
||||||
int
|
int
|
||||||
vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
pcap_vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
struct state state;
|
struct state state;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
87
libpcap/missing/strtok_r.c
Normal file
87
libpcap/missing/strtok_r.c
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1998 Softweyr LLC. All rights reserved.
|
||||||
|
*
|
||||||
|
* strtok_r, from Berkeley strtok
|
||||||
|
* Oct 13, 1998 by Wes Peters <wes@softweyr.com>
|
||||||
|
*
|
||||||
|
* Copyright (c) 1988, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notices, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notices, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE
|
||||||
|
* REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* From: @(#)strtok.c 8.1 (Berkeley) 6/4/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "portability.h"
|
||||||
|
|
||||||
|
char *
|
||||||
|
pcap_strtok_r(char *s, const char *delim, char **last)
|
||||||
|
{
|
||||||
|
char *spanp, *tok;
|
||||||
|
int c, sc;
|
||||||
|
|
||||||
|
if (s == NULL && (s = *last) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
||||||
|
*/
|
||||||
|
cont:
|
||||||
|
c = *s++;
|
||||||
|
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
|
||||||
|
if (c == sc)
|
||||||
|
goto cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == 0) { /* no non-delimiter characters */
|
||||||
|
*last = NULL;
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
tok = s - 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
||||||
|
* Note that delim must have one NUL; we stop if we see that, too.
|
||||||
|
*/
|
||||||
|
for (;;) {
|
||||||
|
c = *s++;
|
||||||
|
spanp = (char *)delim;
|
||||||
|
do {
|
||||||
|
if ((sc = *spanp++) == c) {
|
||||||
|
if (c == 0)
|
||||||
|
s = NULL;
|
||||||
|
else
|
||||||
|
s[-1] = '\0';
|
||||||
|
*last = s;
|
||||||
|
return (tok);
|
||||||
|
}
|
||||||
|
} while (sc != 0);
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
31
libpcap/missing/win_snprintf.c
Normal file
31
libpcap/missing/win_snprintf.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX - _vsnprintf() and _snprintf() do *not* guarantee
|
||||||
|
* that str is null-terminated, but C99's vsnprintf()
|
||||||
|
* and snprintf() do, and we want to offer C99 behavior,
|
||||||
|
* so forcibly null-terminate the string.
|
||||||
|
*/
|
||||||
|
str[str_size - 1] = '\0';
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_snprintf(char *str, size_t str_size, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
ret = pcap_vsnprintf(str, str_size, format, args);
|
||||||
|
va_end(args);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
static void Abort (char *fmt,...)
|
static void Abort (const char *fmt,...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
|
|||||||
@@ -7,7 +7,13 @@
|
|||||||
|
|
||||||
default: check_gcclib all
|
default: check_gcclib all
|
||||||
|
|
||||||
GCCLIB = /djgpp/lib/gcc-lib/djgpp/3.31
|
#
|
||||||
|
# This value is normally not important. Used by 'dxe3gen' in
|
||||||
|
# msdos/pm_drvr/makefile.dj to make "dynamically loaded modules".
|
||||||
|
# But this is not finished.
|
||||||
|
#
|
||||||
|
#GCC_LIB = $(shell gcc -print-libgcc-file-name)
|
||||||
|
GCC_LIB = .
|
||||||
MAKEFILE = Makefile.dj
|
MAKEFILE = Makefile.dj
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -19,10 +25,11 @@ MAKEFILE = Makefile.dj
|
|||||||
|
|
||||||
WATT32_ROOT = $(subst \,/,$(WATT_ROOT))
|
WATT32_ROOT = $(subst \,/,$(WATT_ROOT))
|
||||||
|
|
||||||
|
OBJ_DIR = djgpp.obj
|
||||||
|
|
||||||
ifeq ($(wildcard $(GCCLIB)/libgcc.a),)
|
ifeq ($(wildcard $(GCC_LIB)),)
|
||||||
check_gcclib:
|
check_gcclib:
|
||||||
@echo libgcc.a not found. Set \"$(GCCLIB)\" to \"/djgpp/lib/gcc-lib/djgpp/3.X\"
|
@echo libgcc.a not found. Set \"$(GCC_LIB)\" to \"/djgpp/lib/gcc/djgpp/4.X/libgcc.a\"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +61,7 @@ ASM = nasm.exe -fbin -dDEBUG
|
|||||||
YACC = bison.exe
|
YACC = bison.exe
|
||||||
LEX = flex.exe
|
LEX = flex.exe
|
||||||
|
|
||||||
CFLAGS = -g -gcoff -O2 -Wall -I. -I$(WATT32_ROOT)/inc
|
CFLAGS = -g -O2 -Wall -I. -I$(WATT32_ROOT)/inc
|
||||||
|
|
||||||
ifeq ($(USE_EXCEPT),1)
|
ifeq ($(USE_EXCEPT),1)
|
||||||
CFLAGS += -DUSE_EXCEPT
|
CFLAGS += -DUSE_EXCEPT
|
||||||
@@ -70,7 +77,7 @@ ifeq ($(USE_32BIT_DRIVERS),1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
%.o: %.s
|
%.o: %.s
|
||||||
|
|||||||
@@ -6,43 +6,49 @@
|
|||||||
#
|
#
|
||||||
# c:\net\pcap> make -f msdos/makefile.dj
|
# c:\net\pcap> make -f msdos/makefile.dj
|
||||||
#
|
#
|
||||||
|
# Note: you should do a "set LFN=y" before running this makefile.
|
||||||
|
#
|
||||||
|
|
||||||
VPATH = missing msdos
|
VPATH = missing msdos bpf/net
|
||||||
|
|
||||||
PREREQUISITES = scanner.c grammar.c tokdefs.h version.h msdos/pkt_stub.inc
|
PREREQUISITES = scanner.c grammar.c tokdefs.h version.h msdos/pkt_stub.inc
|
||||||
|
|
||||||
include msdos/common.dj
|
include ./msdos/common.dj
|
||||||
|
|
||||||
DRIVER_DIR = ./msdos/pm_drvr
|
DRIVER_DIR = ./msdos/pm_drvr
|
||||||
|
|
||||||
CFLAGS += -DDEBUG -DNDIS_DEBUG -DHAVE_LIMITS_H -DHAVE_STRERROR \
|
CFLAGS += -DDEBUG -DNDIS_DEBUG -DHAVE_LIMITS_H -DHAVE_STRERROR -DHAVE_SNPRINTF -DHAVE_VSNPRINTF\
|
||||||
-D_U_='__attribute__((unused))' -DHAVE_VERSION_H
|
-D_U_='__attribute__((unused))'
|
||||||
|
|
||||||
# CFLAGS += -Dyylval=pcap_lval -DBDEBUG -DNDEBUG
|
CFLAGS += -Dyylval=pcap_lval # -DBDEBUG -DNDEBUG
|
||||||
|
|
||||||
SOURCES = grammar.c scanner.c bpf_filt.c bpf_imag.c bpf_dump.c \
|
SOURCES = grammar.c scanner.c bpf/net/bpf_filter.c bpf_image.c bpf_dump.c \
|
||||||
etherent.c gencode.c nametoad.c pcap-dos.c optimize.c \
|
etherent.c gencode.c nametoaddr.c pcap-common.c pcap-dos.c optimize.c \
|
||||||
savefile.c pcap.c inet.c msdos\pktdrvr.c msdos/ndis2.c \
|
savefile.c pcap.c sf-pcap.c sf-pcap-ng.c inet.c \
|
||||||
missing/snprintf.c
|
msdos/pktdrvr.c msdos/ndis2.c # missing/snprintf.c
|
||||||
|
|
||||||
OBJECTS = $(notdir $(SOURCES:.c=.o))
|
OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(SOURCES:.c=.o)))
|
||||||
TEMPBIN = tmp.bin
|
TEMPBIN = tmp.bin
|
||||||
|
|
||||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||||
PM_OBJECTS = $(addprefix $(DRIVER_DIR)/, \
|
PM_OBJECTS = $(addprefix $(OBJ_DIR)/, \
|
||||||
printk.o pci.o pci-scan.o bios32.o dma.o irq.o intwrap.o \
|
printk.o pci.o pci-scan.o bios32.o dma.o irq.o intwrap.o \
|
||||||
lock.o kmalloc.o quirks.o timer.o net_init.o)
|
lock.o kmalloc.o quirks.o timer.o net_init.o)
|
||||||
#
|
#
|
||||||
# Static link of drivers
|
# Static link of drivers
|
||||||
#
|
#
|
||||||
ifeq ($(USE_32BIT_MODULES),0)
|
ifeq ($(USE_32BIT_MODULES),0)
|
||||||
PM_OBJECTS += $(addprefix $(DRIVER_DIR)/, \
|
PM_OBJECTS += $(addprefix $(OBJ_DIR)/, \
|
||||||
accton.o 8390.o 3c503.o 3c509.o 3c59x.o 3c515.o \
|
accton.o 8390.o 3c503.o 3c509.o 3c59x.o 3c515.o \
|
||||||
3c575_cb.o 3c90x.o ne.o wd.o cs89x0.o rtl8139.o)
|
3c575_cb.o 3c90x.o ne.o wd.o cs89x0.o rtl8139.o)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: libpcap.a
|
TARGETS = msdos/bin2c.exe libpcap.a filtertest.exe findalldevstest.exe \
|
||||||
|
nonblocktest.exe opentest.exe
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
@echo 'Welcome to libpcap/djgpp with samples.'
|
||||||
|
|
||||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||||
$(PM_OBJECTS):
|
$(PM_OBJECTS):
|
||||||
@@ -53,6 +59,22 @@ libpcap.a: version.h $(OBJECTS) $(PM_OBJECTS)
|
|||||||
rm -f $@
|
rm -f $@
|
||||||
ar rs $@ $^
|
ar rs $@ $^
|
||||||
|
|
||||||
|
filtertest.exe: tests/filtertest.c libpcap.a
|
||||||
|
$(CC) $(CFLAGS) -Din_addr_t=u_long -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||||
|
@echo
|
||||||
|
|
||||||
|
findalldevstest.exe: tests/findalldevstest.c libpcap.a
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||||
|
@echo
|
||||||
|
|
||||||
|
nonblocktest.exe: tests/nonblocktest.c libpcap.a
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||||
|
@echo
|
||||||
|
|
||||||
|
opentest.exe: tests/opentest.c libpcap.a
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||||
|
@echo
|
||||||
|
|
||||||
msdos/pkt_stub.inc: msdos/bin2c.exe msdos/pkt_rx1.S
|
msdos/pkt_stub.inc: msdos/bin2c.exe msdos/pkt_rx1.S
|
||||||
$(ASM) -o $(TEMPBIN) -lmsdos/pkt_rx1.lst msdos/pkt_rx1.S
|
$(ASM) -o $(TEMPBIN) -lmsdos/pkt_rx1.lst msdos/pkt_rx1.S
|
||||||
./msdos/bin2c $(TEMPBIN) > $@
|
./msdos/bin2c $(TEMPBIN) > $@
|
||||||
@@ -61,8 +83,8 @@ msdos/pkt_stub.inc: msdos/bin2c.exe msdos/pkt_rx1.S
|
|||||||
grammar.c tokdefs.h: grammar.y
|
grammar.c tokdefs.h: grammar.y
|
||||||
rm -f grammar.c tokdefs.h
|
rm -f grammar.c tokdefs.h
|
||||||
$(YACC) --name-prefix=pcap_ --yacc --defines grammar.y
|
$(YACC) --name-prefix=pcap_ --yacc --defines grammar.y
|
||||||
mv -f y_tab.c grammar.c
|
mv -f y.tab.c grammar.c
|
||||||
mv -f y_tab.h tokdefs.h
|
mv -f y.tab.h tokdefs.h
|
||||||
|
|
||||||
version.h: ./VERSION
|
version.h: ./VERSION
|
||||||
@echo '/* Generated from VERSION. Do not edit */' > $@
|
@echo '/* Generated from VERSION. Do not edit */' > $@
|
||||||
@@ -76,31 +98,12 @@ msdos/bin2c.exe: msdos/bin2c.c
|
|||||||
$(CC) $*.c -o $*.exe
|
$(CC) $*.c -o $*.exe
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f Makefile.dj -C $(DRIVER_DIR) clean
|
rm -f $(OBJECTS) msdos/pkt_rx1.lst Makefile.bak .depend.dj $(PREREQUISITES)
|
||||||
$(MAKE) -f Makefile.dj -C libcpcap clean
|
# $(MAKE) -f Makefile.dj -C $(DRIVER_DIR) clean
|
||||||
rm -f $(OBJECTS) msdos/pkt_rx1.lst Makefile.bak $(PREREQUISITES)
|
|
||||||
|
|
||||||
vclean: clean
|
vclean: clean
|
||||||
rm -f libpcap.a msdos/bin2c.exe
|
rm -f $(TARGETS)
|
||||||
|
-rmdir $(OBJ_DIR)
|
||||||
#
|
|
||||||
# Generated dependencies; Due to some hacks in gcc 2.95 and djgpp 2.03
|
|
||||||
# we must prevent "$(DJDIR)/bin/../include/sys/version.h" from beeing
|
|
||||||
# included in dependency output (or else this makefile cannot be used on
|
|
||||||
# another machine). We therefore use a special 'specs' file during
|
|
||||||
# pre-processing.
|
|
||||||
#
|
|
||||||
MM_SPECS = specs.tmp
|
|
||||||
MAKEFILE = msdos/Makefile.dj
|
|
||||||
|
|
||||||
depend: $(PREREQUISITES)
|
|
||||||
@echo Generating dependencies..
|
|
||||||
@cp $(MAKEFILE) Makefile.bak
|
|
||||||
@echo "*cpp: %(cpp_cpu) %{posix:-D_POSIX_SOURCE} -remap" > $(MM_SPECS)
|
|
||||||
sed -e "/^# DO NOT DELETE THIS LINE/,$$d" < Makefile.bak > $(MAKEFILE)
|
|
||||||
echo "# DO NOT DELETE THIS LINE" >> $(MAKEFILE)
|
|
||||||
$(CC) -MM -specs=$(MM_SPECS) $(CFLAGS) $(SOURCES) >> $(MAKEFILE)
|
|
||||||
rm -f $(MM_SPECS)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Manually generated dependencies
|
# Manually generated dependencies
|
||||||
@@ -109,43 +112,16 @@ msdos/pktdrvr.c: msdos/pkt_stub.inc
|
|||||||
scanner.c: scanner.l
|
scanner.c: scanner.l
|
||||||
grammar.c tokdefs.h: grammar.y
|
grammar.c tokdefs.h: grammar.y
|
||||||
grammar.h: grammar.y
|
grammar.h: grammar.y
|
||||||
scanner.l: pcap-int.h pcap-namedb.h gencode.h grammar.h gnuc.h
|
scanner.l: pcap-int.h pcap-namedb.h gencode.h grammar.h
|
||||||
grammar.y: pcap-int.h gencode.h pcap-namedb.h gnuc.h
|
grammar.y: pcap-int.h gencode.h pcap-namedb.h
|
||||||
|
|
||||||
#
|
#
|
||||||
# Automatically generated dependencies
|
# Generate dependencies.
|
||||||
#
|
#
|
||||||
# DO NOT DELETE THIS LINE
|
REPLACE = sed -e 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/\1.o: /'
|
||||||
grammar.o: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h pf.h \
|
|
||||||
pcap-namedb.h
|
depend: $(PREREQUISITES)
|
||||||
scanner.o: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h pcap-namedb.h \
|
$(CC) -MM $(CFLAGS) $(SOURCES) | $(REPLACE) > .depend.dj
|
||||||
tokdefs.h
|
|
||||||
bpf_filt.o: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
-include .depend.dj
|
||||||
bpf_imag.o: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
bpf_dump.o: bpf_dump.c pcap.h pcap-bpf.h
|
|
||||||
etherent.o: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
|
||||||
gencode.o: gencode.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h ethertype.h nlpid.h llc.h gencode.h atmuni31.h sunatmpos.h \
|
|
||||||
ppp.h sll.h arcnet.h pf.h pcap-namedb.h
|
|
||||||
nametoad.o: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
|
||||||
pcap-namedb.h ethertype.h
|
|
||||||
pcap-dos.o: pcap-dos.c msdos/pm_drvr/pmdrvr.h msdos/pm_drvr/iface.h \
|
|
||||||
msdos/pm_drvr/lock.h msdos/pm_drvr/ioport.h pcap-dos.h pcap-int.h \
|
|
||||||
pcap.h pcap-bpf.h msdos/pm_drvr/kmalloc.h msdos/pm_drvr/bitops.h \
|
|
||||||
msdos/pm_drvr/timer.h msdos/pm_drvr/dma.h msdos/pm_drvr/irq.h \
|
|
||||||
msdos/pm_drvr/printk.h msdos/pm_drvr/pci.h msdos/pm_drvr/bios32.h \
|
|
||||||
msdos/pm_drvr/module.h msdos/pm_drvr/3c501.h msdos/pm_drvr/3c503.h \
|
|
||||||
msdos/pm_drvr/3c509.h msdos/pm_drvr/3c59x.h msdos/pm_drvr/3c515.h \
|
|
||||||
msdos/pm_drvr/3c90x.h msdos/pm_drvr/3c575_cb.h msdos/pm_drvr/ne.h \
|
|
||||||
msdos/pm_drvr/wd.h msdos/pm_drvr/accton.h msdos/pm_drvr/cs89x0.h \
|
|
||||||
msdos/pm_drvr/rtl8139.h msdos/pm_drvr/ne2k-pci.h msdos/pktdrvr.h
|
|
||||||
optimize.o: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
|
||||||
savefile.o: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
pcap.o: pcap.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h
|
|
||||||
inet.o: inet.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
pktdrvr.o: msdos/pktdrvr.c gnuc.h pcap-dos.h msdos/pm_drvr/lock.h \
|
|
||||||
pcap-int.h pcap.h pcap-bpf.h msdos/pktdrvr.h msdos/pkt_stub.inc
|
|
||||||
ndis2.o: msdos/ndis2.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h msdos/ndis2.h
|
|
||||||
snprintf.o: missing/snprintf.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ CC = wcc386.exe
|
|||||||
ASM = wasm.exe -$(MODEL) $(DEFS) -dDOSX -dDOS4GW -zq -bt=dos -fr=nul -d3 -s
|
ASM = wasm.exe -$(MODEL) $(DEFS) -dDOSX -dDOS4GW -zq -bt=dos -fr=nul -d3 -s
|
||||||
|
|
||||||
OBJS = $(OBJDIR)\grammar.obj $(OBJDIR)\scanner.obj $(OBJDIR)\pcap.obj &
|
OBJS = $(OBJDIR)\grammar.obj $(OBJDIR)\scanner.obj $(OBJDIR)\pcap.obj &
|
||||||
$(OBJDIR)\bpf_filt.obj $(OBJDIR)\bpf_imag.obj $(OBJDIR)\bpf_dump.obj &
|
$(OBJDIR)\bpf_filter.obj $(OBJDIR)\bpf_imag.obj $(OBJDIR)\bpf_dump.obj &
|
||||||
$(OBJDIR)\etherent.obj $(OBJDIR)\gencode.obj $(OBJDIR)\nametoad.obj &
|
$(OBJDIR)\etherent.obj $(OBJDIR)\gencode.obj $(OBJDIR)\nametoad.obj &
|
||||||
$(OBJDIR)\pcap-dos.obj $(OBJDIR)\pktdrvr.obj $(OBJDIR)\optimize.obj &
|
$(OBJDIR)\pcap-dos.obj $(OBJDIR)\pktdrvr.obj $(OBJDIR)\optimize.obj &
|
||||||
$(OBJDIR)\savefile.obj $(OBJDIR)\inet.obj $(OBJDIR)\ndis2.obj
|
$(OBJDIR)\savefile.obj $(OBJDIR)\inet.obj $(OBJDIR)\ndis2.obj
|
||||||
@@ -48,10 +48,13 @@ wlib.arg: msdos\makefile.wc
|
|||||||
%create $^@
|
%create $^@
|
||||||
for %f in ($(OBJS)) do %append $^@ +- %f
|
for %f in ($(OBJS)) do %append $^@ +- %f
|
||||||
|
|
||||||
$(OBJDIR)\pktdrvr.obj: msdos\pkt_stub.inc msdos\pktdrvr.c gnuc.h &
|
$(OBJDIR)\pktdrvr.obj: msdos\pkt_stub.inc msdos\pktdrvr.c &
|
||||||
pcap-dos.h pcap-int.h pcap.h msdos\pktdrvr.h
|
pcap-dos.h pcap-int.h pcap.h msdos\pktdrvr.h
|
||||||
*$(CC) $(CFLAGS) msdos\pktdrvr.c -fo=$@
|
*$(CC) $(CFLAGS) msdos\pktdrvr.c -fo=$@
|
||||||
|
|
||||||
|
$(OBJDIR)\bpf_filter.obj: bpf\net\bpf_filter.c
|
||||||
|
*$(CC) $(CFLAGS) bpf\net\bpf_filter.c -fo=$@
|
||||||
|
|
||||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c
|
$(OBJDIR)\ndis2.obj: msdos\ndis2.c
|
||||||
*$(CC) $(CFLAGS) msdos\ndis2.c -fo=$@
|
*$(CC) $(CFLAGS) msdos\ndis2.c -fo=$@
|
||||||
|
|
||||||
@@ -91,13 +94,13 @@ clean realclean vclean: .SYMBOLIC
|
|||||||
#
|
#
|
||||||
# dependencies
|
# dependencies
|
||||||
#
|
#
|
||||||
$(OBJDIR)\bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
$(OBJDIR)\bpf_filter.obj: bpf\net\bpf_filter.c pcap-int.h pcap.h pcap-bpf.h
|
||||||
|
|
||||||
$(OBJDIR)\bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
$(OBJDIR)\bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
||||||
|
|
||||||
$(OBJDIR)\bpf_dump.obj: bpf_dump.c pcap.h pcap-bpf.h
|
$(OBJDIR)\bpf_dump.obj: bpf_dump.c pcap.h pcap-bpf.h
|
||||||
|
|
||||||
$(OBJDIR)\etherent.obj: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-nam.h
|
$(OBJDIR)\etherent.obj: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
||||||
|
|
||||||
$(OBJDIR)\optimize.obj: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
$(OBJDIR)\optimize.obj: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
||||||
|
|
||||||
@@ -108,22 +111,22 @@ $(OBJDIR)\pcap.obj: pcap.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h
|
|||||||
$(OBJDIR)\inet.obj: inet.c pcap-int.h pcap.h pcap-bpf.h
|
$(OBJDIR)\inet.obj: inet.c pcap-int.h pcap.h pcap-bpf.h
|
||||||
|
|
||||||
$(OBJDIR)\grammar.obj: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
$(OBJDIR)\grammar.obj: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||||
pf.h pcap-nam.h
|
pcap-namedb.h
|
||||||
|
|
||||||
$(OBJDIR)\scanner.obj: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
$(OBJDIR)\scanner.obj: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||||
pcap-nam.h tokdefs.h
|
pcap-namedb.h tokdefs.h
|
||||||
|
|
||||||
$(OBJDIR)\gencode.obj: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
$(OBJDIR)\gencode.obj: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
||||||
ethertyp.h nlpid.h llc.h gencode.h atmuni31.h sunatmpo.h ppp.h sll.h &
|
ethertyp.h nlpid.h llc.h gencode.h atmuni31.h sunatmpo.h ppp.h sll.h &
|
||||||
arcnet.h pf.h pcap-nam.h
|
arcnet.h pcap-namedb.h
|
||||||
|
|
||||||
$(OBJDIR)\nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
$(OBJDIR)\nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||||
pcap-nam.h ethertyp.h
|
pcap-namedb.h ethertyp.h
|
||||||
|
|
||||||
$(OBJDIR)\pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h &
|
$(OBJDIR)\pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h &
|
||||||
msdos\pktdrvr.h
|
msdos\pktdrvr.h
|
||||||
|
|
||||||
$(OBJDIR)\pktdrvr.obj: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h &
|
$(OBJDIR)\pktdrvr.obj: msdos\pktdrvr.c pcap-dos.h pcap-int.h &
|
||||||
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
||||||
|
|
||||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
$(OBJDIR)\ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
;
|
;
|
||||||
%define ETH_MTU 1500 ; max data size on Ethernet
|
%define ETH_MTU 1500 ; max data size on Ethernet
|
||||||
%define ETH_MIN 60 ; min/max total frame size
|
%define ETH_MIN 60 ; min/max total frame size
|
||||||
%define ETH_MAX (ETH_MTU+2*6+2)
|
%define ETH_MAX (ETH_MTU+2*6+2) ; =1514
|
||||||
%define NUM_RX_BUF 32 ; # of RX element buffers
|
%define NUM_RX_BUF 32 ; # of RX element buffers
|
||||||
%define RX_SIZE (ETH_MAX+6) ; sizeof(RX_ELEMENT) = 1514+6
|
%define RX_SIZE (ETH_MAX+6) ; sizeof(RX_ELEMENT) = 1514+6
|
||||||
%idefine offset
|
%idefine offset
|
||||||
|
|||||||
@@ -10,19 +10,21 @@ supported:
|
|||||||
- GNU C 2.7+ with djgpp 2.01+ DOS extender
|
- GNU C 2.7+ with djgpp 2.01+ DOS extender
|
||||||
- Watcom C 11.x with DOS4GW extender
|
- Watcom C 11.x with DOS4GW extender
|
||||||
|
|
||||||
Note: the files in the libpcap.zip contains short trucated filenames.
|
Note: the files in the libpcap.zip contains short truncated filenames.
|
||||||
So for djgpp to work with these, disable the use of long file names by
|
So for djgpp to work with these, disable the use of long file names by
|
||||||
setting "LFN=n" in the environment.
|
setting "LFN=n" in the environment. On the other hand, if you get libpcap
|
||||||
|
from Github or the official libpcap.tar.gz, some filenames are beyond 8+3.
|
||||||
|
In this case set "LFN=y".
|
||||||
|
|
||||||
Files specific to DOS are pcap-dos.[ch] and the assembly and C files in
|
Files specific to DOS are pcap-dos.[ch] and the assembly and C files in
|
||||||
the MSDOS sub-directory. Remember to built lipcap libraries from the top
|
the MSDOS sub-directory. Remember to built the libpcap library from the top
|
||||||
install directory. And not from the MSDOS sub-directory.
|
install directory. And not from the MSDOS sub-directory.
|
||||||
|
|
||||||
Note for djgpp users:
|
Note for djgpp users:
|
||||||
If you got the libpcap from the official site www.tcpdump, then that
|
If you got the libpcap from the official site www.tcpdump, then that
|
||||||
distribution does NOT contain any sources for building 32-bit drivers.
|
distribution does NOT contain any sources for building 32-bit drivers.
|
||||||
Instead get the full version at
|
Instead get the full version at
|
||||||
http://www.bgnett.no/~giva/pcap/libpcap.zip
|
http://www.watt-32.net/pcap/libpcap.zip
|
||||||
|
|
||||||
and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
|
and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
|
||||||
|
|
||||||
@@ -49,30 +51,28 @@ The following packages and tools must be present for all targets.
|
|||||||
receive network data. It's mostly used to access the 'hosts'
|
receive network data. It's mostly used to access the 'hosts'
|
||||||
file and other <netdb.h> features. Get 'watt32s*.zip' at:
|
file and other <netdb.h> features. Get 'watt32s*.zip' at:
|
||||||
|
|
||||||
http://www.bgnett.no/~giva/
|
http://www.watt-32.net
|
||||||
|
|
||||||
2. Exception handler and disassember library (libexc.a) is needed if
|
2. Exception handler and disassember library (libexc.a) is needed if
|
||||||
"USE_EXCEPT = 1" in common.dj. Available at:
|
"USE_EXCEPT = 1" in common.dj. Available at:
|
||||||
|
|
||||||
http://www.bgnett.no/~giva/misc/exc_dx07.zip
|
http://www.watt-32.net/misc/exc_dx07.zip
|
||||||
|
|
||||||
3. Flex & Bison is used to generate parser for the filter handler
|
3. Flex & Bison is used to generate parser for the filter handler
|
||||||
pcap_compile:
|
pcap_compile:
|
||||||
|
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/flx254b.zip
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/flx254b.zip
|
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/bsn241b.zip
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsn128b.zip
|
|
||||||
|
|
||||||
4. NASM assembler v 0.98 or later is required when building djgpp and
|
4. NASM assembler v 0.98 or later is required when building djgpp and
|
||||||
Watcom targets:
|
Watcom targets:
|
||||||
|
http://www.nasm.us/
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/nasm098p.zip
|
|
||||||
|
|
||||||
5. sed (Stream Editor) is required for doing `make depend'.
|
5. sed (Stream Editor) is required for doing `make depend'.
|
||||||
It's available at
|
It's available at:
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/sed*.zip
|
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/sed422b.zip
|
||||||
|
|
||||||
A touch tool to update the time-stamp of a file. E.g.
|
A touch tool to update the time-stamp of a file. E.g.:
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/grep*.zip
|
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/grep29b.zip
|
||||||
|
|
||||||
6. For djgpp rm.exe and cp.exe are required. These should already be
|
6. For djgpp rm.exe and cp.exe are required. These should already be
|
||||||
part of your djgpp installation. Also required (experimental at the
|
part of your djgpp installation. Also required (experimental at the
|
||||||
@@ -121,10 +121,17 @@ Follow these steps in building libpcap:
|
|||||||
|
|
||||||
Note: Code in `USE_NDIS2' does not work at the moment.
|
Note: Code in `USE_NDIS2' does not work at the moment.
|
||||||
|
|
||||||
4. The resulting libraries are put in current directory. There's no
|
4. The resulting library is put in current directory. There's some
|
||||||
test-program for `libpcap'. Linking the library with `tcpdump' is
|
test-program for `libpcap': `filtertest.exe', `findalldevstest.exe',
|
||||||
the ultimate test anyway.
|
`nonblocktest.exe' and `opentest.exe'.
|
||||||
|
|
||||||
|
But linking the library with `tcpdump' is the ultimate test. DOS/djgpp
|
||||||
|
should now hopefully be a supported target. Get the sources at:
|
||||||
|
http://www.tcpdump.org/
|
||||||
|
or
|
||||||
|
https://github.com/the-tcpdump-group/tcpdump/
|
||||||
|
|
||||||
|
(click on the 'Download ZIP' on the right side of that page.)
|
||||||
|
|
||||||
|
|
||||||
Extensions to libpcap
|
Extensions to libpcap
|
||||||
@@ -132,14 +139,14 @@ Extensions to libpcap
|
|||||||
|
|
||||||
I've included some extra functions to DOS-libpcap:
|
I've included some extra functions to DOS-libpcap:
|
||||||
|
|
||||||
`pcap_config_hook (const char *name, const char *value)'
|
`pcap_config_hook (const char *keyword, const char *value)' :
|
||||||
|
|
||||||
Allows an application to set values of internal libpcap variables.
|
Allows an application to set values of internal libpcap variables.
|
||||||
`name' is typically a left-side keyword with an associated `value'
|
`keyword' and an associated `value' should be present in the `debug_tab[]'
|
||||||
that is called from application's configure process (see tcpdump's
|
array in pcap-dos.c (currently only used to set debug-levels and parameters
|
||||||
config.c file). libpcap keeps a set of tables that are searched for
|
for the 32-bit network drivers.) Thus an application using DOS-libpcap can
|
||||||
a name/value match. Currently only used to set debug-levels and
|
override the default value during it's configure process (see tcpdump's
|
||||||
parameters for the 32-bit network drivers.
|
msdos/config.c file for an extended example).
|
||||||
|
|
||||||
`pcap_set_wait (pcap_t *, void (*)(void), int)' :
|
`pcap_set_wait (pcap_t *, void (*)(void), int)' :
|
||||||
|
|
||||||
@@ -153,8 +160,7 @@ I've included some extra functions to DOS-libpcap:
|
|||||||
Happy sniffing !
|
Happy sniffing !
|
||||||
|
|
||||||
|
|
||||||
Gisle Vanem <giva@bgnett.no>
|
Gisle Vanem <gvanem@yahoo.no>
|
||||||
<gvanem@broadpark.no>
|
|
||||||
|
|
||||||
October 1999, 2004
|
October 1999, 2004, 2006, 2013
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,36 @@
|
|||||||
#include <netdnet/dnetdb.h>
|
#include <netdnet/dnetdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
|
|
||||||
#else /* WIN32 */
|
#ifdef INET6
|
||||||
|
/*
|
||||||
|
* To quote the MSDN page for getaddrinfo() at
|
||||||
|
*
|
||||||
|
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx
|
||||||
|
*
|
||||||
|
* "Support for getaddrinfo on Windows 2000 and older versions
|
||||||
|
* The getaddrinfo function was added to the Ws2_32.dll on Windows XP and
|
||||||
|
* later. To execute an application that uses this function on earlier
|
||||||
|
* versions of Windows, then you need to include the Ws2tcpip.h and
|
||||||
|
* Wspiapi.h files. When the Wspiapi.h include file is added, the
|
||||||
|
* getaddrinfo function is defined to the WspiapiGetAddrInfo inline
|
||||||
|
* function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo
|
||||||
|
* function is implemented in such a way that if the Ws2_32.dll or the
|
||||||
|
* Wship6.dll (the file containing getaddrinfo in the IPv6 Technology
|
||||||
|
* Preview for Windows 2000) does not include getaddrinfo, then a
|
||||||
|
* version of getaddrinfo is implemented inline based on code in the
|
||||||
|
* Wspiapi.h header file. This inline code will be used on older Windows
|
||||||
|
* platforms that do not natively support the getaddrinfo function."
|
||||||
|
*
|
||||||
|
* We use getaddrinfo(), so we include Wspiapi.h here. pcap-stdinc.h
|
||||||
|
* includes Ws2tcpip.h, so we don't need to include it ourselves.
|
||||||
|
*/
|
||||||
|
#include <Wspiapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h> /* concession to AIX */
|
#include <sys/types.h> /* concession to AIX */
|
||||||
@@ -42,9 +68,9 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#ifdef HAVE_ETHER_HOSTTON
|
#ifdef HAVE_ETHER_HOSTTON
|
||||||
/*
|
/*
|
||||||
* XXX - do we need any of this if <netinet/if_ether.h> doesn't declare
|
* XXX - do we need any of this if <netinet/if_ether.h> doesn't declare
|
||||||
@@ -62,7 +88,7 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||||||
#endif /* HAVE_ETHER_HOSTTON */
|
#endif /* HAVE_ETHER_HOSTTON */
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -74,6 +100,7 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||||||
|
|
||||||
#include "gencode.h"
|
#include "gencode.h"
|
||||||
#include <pcap/namedb.h>
|
#include <pcap/namedb.h>
|
||||||
|
#include "nametoaddr.h"
|
||||||
|
|
||||||
#ifdef HAVE_OS_PROTO_H
|
#ifdef HAVE_OS_PROTO_H
|
||||||
#include "os-proto.h"
|
#include "os-proto.h"
|
||||||
@@ -140,7 +167,7 @@ pcap_nametoaddrinfo(const char *name)
|
|||||||
bpf_u_int32
|
bpf_u_int32
|
||||||
pcap_nametonetaddr(const char *name)
|
pcap_nametonetaddr(const char *name)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
struct netent *np;
|
struct netent *np;
|
||||||
|
|
||||||
if ((np = getnetbyname(name)) != NULL)
|
if ((np = getnetbyname(name)) != NULL)
|
||||||
@@ -150,6 +177,15 @@ pcap_nametonetaddr(const char *name)
|
|||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* There's no "getnetbyname()" on Windows.
|
* There's no "getnetbyname()" on Windows.
|
||||||
|
*
|
||||||
|
* XXX - I guess we could use the BSD code to read
|
||||||
|
* C:\Windows\System32\drivers\etc/networks, assuming
|
||||||
|
* that's its home on all the versions of Windows
|
||||||
|
* we use, but that file probably just has the loopback
|
||||||
|
* network on 127/24 on 99 44/100% of Windows machines.
|
||||||
|
*
|
||||||
|
* (Heck, these days it probably just has that on 99 44/100%
|
||||||
|
* of *UN*X* machines.)
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -274,8 +310,14 @@ struct eproto {
|
|||||||
u_short p;
|
u_short p;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Static data base of ether protocol types. */
|
/*
|
||||||
struct eproto eproto_db[] = {
|
* Static data base of ether protocol types.
|
||||||
|
* tcpdump used to import this, and it's declared as an export on
|
||||||
|
* Debian, at least, so make it a public symbol, even though we
|
||||||
|
* don't officially export it by declaring it in a header file.
|
||||||
|
* (Programs *should* do this themselves, as tcpdump now does.)
|
||||||
|
*/
|
||||||
|
PCAP_API_DEF struct eproto eproto_db[] = {
|
||||||
{ "pup", ETHERTYPE_PUP },
|
{ "pup", ETHERTYPE_PUP },
|
||||||
{ "xns", ETHERTYPE_NS },
|
{ "xns", ETHERTYPE_NS },
|
||||||
{ "ip", ETHERTYPE_IP },
|
{ "ip", ETHERTYPE_IP },
|
||||||
@@ -383,7 +425,7 @@ __pcap_atodn(const char *s, bpf_u_int32 *addr)
|
|||||||
u_int node, area;
|
u_int node, area;
|
||||||
|
|
||||||
if (sscanf(s, "%d.%d", &area, &node) != 2)
|
if (sscanf(s, "%d.%d", &area, &node) != 2)
|
||||||
bpf_error("malformed decnet address '%s'", s);
|
return(0);
|
||||||
|
|
||||||
*addr = (area << AREASHIFT) & AREAMASK;
|
*addr = (area << AREASHIFT) & AREAMASK;
|
||||||
*addr |= (node & NODEMASK);
|
*addr |= (node & NODEMASK);
|
||||||
@@ -487,23 +529,20 @@ pcap_ether_hostton(const char *name)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u_short
|
int
|
||||||
__pcap_nametodnaddr(const char *name)
|
__pcap_nametodnaddr(const char *name, u_short *res)
|
||||||
{
|
{
|
||||||
#ifdef DECNETLIB
|
#ifdef DECNETLIB
|
||||||
struct nodeent *getnodebyname();
|
struct nodeent *getnodebyname();
|
||||||
struct nodeent *nep;
|
struct nodeent *nep;
|
||||||
unsigned short res;
|
|
||||||
|
|
||||||
nep = getnodebyname(name);
|
nep = getnodebyname(name);
|
||||||
if (nep == ((struct nodeent *)0))
|
if (nep == ((struct nodeent *)0))
|
||||||
bpf_error("unknown decnet host name '%s'\n", name);
|
return(0);
|
||||||
|
|
||||||
memcpy((char *)&res, (char *)nep->n_addr, sizeof(unsigned short));
|
memcpy((char *)res, (char *)nep->n_addr, sizeof(unsigned short));
|
||||||
return(res);
|
return(1);
|
||||||
#else
|
#else
|
||||||
bpf_error("decnet name support not included, '%s' cannot be translated\n",
|
|
||||||
name);
|
|
||||||
return(0);
|
return(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
* Copyright (c) 1994, 1996
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -32,29 +31,18 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef __cplusplus
|
||||||
#include "config.h"
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pcap.h>
|
/*
|
||||||
|
* Routines used for name-or-address-string-to-address resolution
|
||||||
|
* that are *not* exported to code using libpcap.
|
||||||
|
*/
|
||||||
|
int __pcap_atodn(const char *, bpf_u_int32 *);
|
||||||
|
int __pcap_atoin(const char *, bpf_u_int32 *);
|
||||||
|
int __pcap_nametodnaddr(const char *, u_short *);
|
||||||
|
|
||||||
/*
|
#ifdef __cplusplus
|
||||||
* Get a list of all interfaces that are up and that we can open.
|
|
||||||
* Returns -1 on error, 0 otherwise.
|
|
||||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
|
||||||
* were up and could be opened.
|
|
||||||
*
|
|
||||||
* This is the implementation used on platforms that have no support for
|
|
||||||
* packet capture.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Succeed, but don't return any interfaces; we return only those
|
|
||||||
* we can open, and we can't open any if there's no support
|
|
||||||
* for packet capture.
|
|
||||||
*/
|
|
||||||
*alldevsp = NULL;
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -87,7 +87,7 @@ bt_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|||||||
/* if bluetooth is not supported this this is not fatal*/
|
/* if bluetooth is not supported this this is not fatal*/
|
||||||
if (errno == EAFNOSUPPORT)
|
if (errno == EAFNOSUPPORT)
|
||||||
return 0;
|
return 0;
|
||||||
snprintf(err_str, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||||
"Can't open raw Bluetooth socket: %s", strerror(errno));
|
"Can't open raw Bluetooth socket: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ bt_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|||||||
dev_list = malloc(HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
dev_list = malloc(HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
||||||
if (!dev_list)
|
if (!dev_list)
|
||||||
{
|
{
|
||||||
snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %zu bytes for Bluetooth device list",
|
pcap_snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't allocate %zu bytes for Bluetooth device list",
|
||||||
HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
HCI_MAX_DEV * sizeof(*dev_req) + sizeof(*dev_list));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto done;
|
goto done;
|
||||||
@@ -105,7 +105,7 @@ bt_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|||||||
|
|
||||||
if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0)
|
if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0)
|
||||||
{
|
{
|
||||||
snprintf(err_str, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||||
"Can't get Bluetooth device list via ioctl: %s",
|
"Can't get Bluetooth device list via ioctl: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -116,8 +116,8 @@ bt_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|||||||
for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
|
for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
|
||||||
char dev_name[20], dev_descr[30];
|
char dev_name[20], dev_descr[30];
|
||||||
|
|
||||||
snprintf(dev_name, 20, BT_IFACE"%d", dev_req->dev_id);
|
pcap_snprintf(dev_name, 20, BT_IFACE"%d", dev_req->dev_id);
|
||||||
snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
|
pcap_snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
|
||||||
|
|
||||||
if (pcap_add_if(alldevsp, dev_name, 0,
|
if (pcap_add_if(alldevsp, dev_name, 0,
|
||||||
dev_descr, err_str) < 0)
|
dev_descr, err_str) < 0)
|
||||||
@@ -171,7 +171,7 @@ bt_create(const char *device, char *ebuf, int *is_ours)
|
|||||||
/* OK, it's probably ours. */
|
/* OK, it's probably ours. */
|
||||||
*is_ours = 1;
|
*is_ours = 1;
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_bt));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_bt));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@@ -190,17 +190,16 @@ bt_activate(pcap_t* handle)
|
|||||||
int err = PCAP_ERROR;
|
int err = PCAP_ERROR;
|
||||||
|
|
||||||
/* get bt interface id */
|
/* get bt interface id */
|
||||||
if (sscanf(handle->opt.source, BT_IFACE"%d", &dev_id) != 1)
|
if (sscanf(handle->opt.device, BT_IFACE"%d", &dev_id) != 1)
|
||||||
{
|
{
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't get Bluetooth device index from %s",
|
"Can't get Bluetooth device index from %s",
|
||||||
handle->opt.source);
|
handle->opt.device);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize some components of the pcap structure. */
|
/* Initialize some components of the pcap structure. */
|
||||||
handle->bufsize = handle->snapshot+BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header);
|
handle->bufsize = BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header)+handle->snapshot;
|
||||||
handle->offset = BT_CTRL_SIZE;
|
|
||||||
handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
|
handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
|
||||||
|
|
||||||
handle->read_op = bt_read_linux;
|
handle->read_op = bt_read_linux;
|
||||||
@@ -216,28 +215,28 @@ bt_activate(pcap_t* handle)
|
|||||||
/* Create HCI socket */
|
/* Create HCI socket */
|
||||||
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
||||||
if (handle->fd < 0) {
|
if (handle->fd < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't create raw socket: %s", strerror(errno));
|
"Can't create raw socket: %s", strerror(errno));
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->buffer = malloc(handle->bufsize);
|
handle->buffer = malloc(handle->bufsize);
|
||||||
if (!handle->buffer) {
|
if (!handle->buffer) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt = 1;
|
opt = 1;
|
||||||
if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
|
if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't enable data direction info: %s", strerror(errno));
|
"Can't enable data direction info: %s", strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt = 1;
|
opt = 1;
|
||||||
if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
|
if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't enable time stamp: %s", strerror(errno));
|
"Can't enable time stamp: %s", strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
@@ -248,7 +247,7 @@ bt_activate(pcap_t* handle)
|
|||||||
memset((void *) &flt.type_mask, 0xff, sizeof(flt.type_mask));
|
memset((void *) &flt.type_mask, 0xff, sizeof(flt.type_mask));
|
||||||
memset((void *) &flt.event_mask, 0xff, sizeof(flt.event_mask));
|
memset((void *) &flt.event_mask, 0xff, sizeof(flt.event_mask));
|
||||||
if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
|
if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't set filter: %s", strerror(errno));
|
"Can't set filter: %s", strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
@@ -261,7 +260,7 @@ bt_activate(pcap_t* handle)
|
|||||||
addr.hci_channel = HCI_CHANNEL_RAW;
|
addr.hci_channel = HCI_CHANNEL_RAW;
|
||||||
#endif
|
#endif
|
||||||
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't attach to device %d: %s", handlep->dev_id,
|
"Can't attach to device %d: %s", handlep->dev_id,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
@@ -282,7 +281,7 @@ bt_activate(pcap_t* handle)
|
|||||||
if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
|
if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
|
||||||
&handle->opt.buffer_size,
|
&handle->opt.buffer_size,
|
||||||
sizeof(handle->opt.buffer_size)) == -1) {
|
sizeof(handle->opt.buffer_size)) == -1) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SO_RCVBUF: %s", pcap_strerror(errno));
|
"SO_RCVBUF: %s", pcap_strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
@@ -305,16 +304,19 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct pcap_pkthdr pkth;
|
struct pcap_pkthdr pkth;
|
||||||
pcap_bluetooth_h4_header* bthdr;
|
pcap_bluetooth_h4_header* bthdr;
|
||||||
|
u_char *pktd;
|
||||||
|
int in = 0;
|
||||||
|
|
||||||
bthdr = (pcap_bluetooth_h4_header*) &handle->buffer[handle->offset];
|
pktd = (u_char *)handle->buffer + BT_CTRL_SIZE;
|
||||||
iv.iov_base = &handle->buffer[handle->offset+sizeof(pcap_bluetooth_h4_header)];
|
bthdr = (pcap_bluetooth_h4_header*)(void *)pktd;
|
||||||
|
iv.iov_base = pktd + sizeof(pcap_bluetooth_h4_header);
|
||||||
iv.iov_len = handle->snapshot;
|
iv.iov_len = handle->snapshot;
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
msg.msg_iov = &iv;
|
msg.msg_iov = &iv;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
msg.msg_control = handle->buffer;
|
msg.msg_control = handle->buffer;
|
||||||
msg.msg_controllen = handle->offset;
|
msg.msg_controllen = BT_CTRL_SIZE;
|
||||||
|
|
||||||
/* ignore interrupt system call error */
|
/* ignore interrupt system call error */
|
||||||
do {
|
do {
|
||||||
@@ -327,7 +329,7 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
|||||||
} while ((ret == -1) && (errno == EINTR));
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't receive packet: %s", strerror(errno));
|
"Can't receive packet: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -336,7 +338,6 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
|||||||
|
|
||||||
/* get direction and timestamp*/
|
/* get direction and timestamp*/
|
||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
int in=0;
|
|
||||||
while (cmsg) {
|
while (cmsg) {
|
||||||
switch (cmsg->cmsg_type) {
|
switch (cmsg->cmsg_type) {
|
||||||
case HCI_CMSG_DIR:
|
case HCI_CMSG_DIR:
|
||||||
@@ -357,9 +358,8 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
|||||||
pkth.caplen+=sizeof(pcap_bluetooth_h4_header);
|
pkth.caplen+=sizeof(pcap_bluetooth_h4_header);
|
||||||
pkth.len = pkth.caplen;
|
pkth.len = pkth.caplen;
|
||||||
if (handle->fcode.bf_insns == NULL ||
|
if (handle->fcode.bf_insns == NULL ||
|
||||||
bpf_filter(handle->fcode.bf_insns, &handle->buffer[handle->offset],
|
bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||||
pkth.len, pkth.caplen)) {
|
callback(user, &pkth, pktd);
|
||||||
callback(user, &pkth, &handle->buffer[handle->offset]);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0; /* didn't pass filter */
|
return 0; /* didn't pass filter */
|
||||||
@@ -368,7 +368,7 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
|||||||
static int
|
static int
|
||||||
bt_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
bt_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
|
||||||
"bluetooth devices");
|
"bluetooth devices");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
|||||||
} while ((ret == -1) && (errno == EINTR));
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't get stats via ioctl: %s", strerror(errno));
|
"Can't get stats via ioctl: %s", strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/mgmt.h>
|
|
||||||
|
|
||||||
#include "pcap/bluetooth.h"
|
#include "pcap/bluetooth.h"
|
||||||
#include "pcap-int.h"
|
#include "pcap-int.h"
|
||||||
@@ -49,6 +49,16 @@
|
|||||||
#define BT_CONTROL_SIZE 32
|
#define BT_CONTROL_SIZE 32
|
||||||
#define INTERFACE_NAME "bluetooth-monitor"
|
#define INTERFACE_NAME "bluetooth-monitor"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fields and alignment must match the declaration in the Linux kernel 3.4+.
|
||||||
|
* See struct hci_mon_hdr in include/net/bluetooth/hci_mon.h.
|
||||||
|
*/
|
||||||
|
struct hci_mon_hdr {
|
||||||
|
uint16_t opcode;
|
||||||
|
uint16_t index;
|
||||||
|
uint16_t len;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
int
|
int
|
||||||
bt_monitor_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
bt_monitor_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
||||||
{
|
{
|
||||||
@@ -72,13 +82,15 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct pcap_pkthdr pkth;
|
struct pcap_pkthdr pkth;
|
||||||
pcap_bluetooth_linux_monitor_header *bthdr;
|
pcap_bluetooth_linux_monitor_header *bthdr;
|
||||||
struct mgmt_hdr hdr;
|
u_char *pktd;
|
||||||
|
struct hci_mon_hdr hdr;
|
||||||
|
|
||||||
bthdr = (pcap_bluetooth_linux_monitor_header*) &handle->buffer[handle->offset];
|
pktd = (u_char *)handle->buffer + BT_CONTROL_SIZE;
|
||||||
|
bthdr = (pcap_bluetooth_linux_monitor_header*)(void *)pktd;
|
||||||
|
|
||||||
iv[0].iov_base = &hdr;
|
iv[0].iov_base = &hdr;
|
||||||
iv[0].iov_len = MGMT_HDR_SIZE;
|
iv[0].iov_len = sizeof(hdr);
|
||||||
iv[1].iov_base = &handle->buffer[handle->offset + sizeof(pcap_bluetooth_linux_monitor_header)];
|
iv[1].iov_base = pktd + sizeof(pcap_bluetooth_linux_monitor_header);
|
||||||
iv[1].iov_len = handle->snapshot;
|
iv[1].iov_len = handle->snapshot;
|
||||||
|
|
||||||
memset(&pkth.ts, 0, sizeof(pkth.ts));
|
memset(&pkth.ts, 0, sizeof(pkth.ts));
|
||||||
@@ -86,7 +98,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||||||
msg.msg_iov = iv;
|
msg.msg_iov = iv;
|
||||||
msg.msg_iovlen = 2;
|
msg.msg_iovlen = 2;
|
||||||
msg.msg_control = handle->buffer;
|
msg.msg_control = handle->buffer;
|
||||||
msg.msg_controllen = handle->offset;
|
msg.msg_controllen = BT_CONTROL_SIZE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = recvmsg(handle->fd, &msg, 0);
|
ret = recvmsg(handle->fd, &msg, 0);
|
||||||
@@ -98,12 +110,12 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||||||
} while ((ret == -1) && (errno == EINTR));
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't receive packet: %s", strerror(errno));
|
"Can't receive packet: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkth.caplen = ret - MGMT_HDR_SIZE + sizeof(pcap_bluetooth_linux_monitor_header);
|
pkth.caplen = ret - sizeof(hdr) + sizeof(pcap_bluetooth_linux_monitor_header);
|
||||||
pkth.len = pkth.caplen;
|
pkth.len = pkth.caplen;
|
||||||
|
|
||||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||||
@@ -118,9 +130,8 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||||||
bthdr->opcode = htons(hdr.opcode);
|
bthdr->opcode = htons(hdr.opcode);
|
||||||
|
|
||||||
if (handle->fcode.bf_insns == NULL ||
|
if (handle->fcode.bf_insns == NULL ||
|
||||||
bpf_filter(handle->fcode.bf_insns, &handle->buffer[handle->offset],
|
bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) {
|
||||||
pkth.len, pkth.caplen)) {
|
callback(user, &pkth, pktd);
|
||||||
callback(user, &pkth, &handle->buffer[handle->offset]);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0; /* didn't pass filter */
|
return 0; /* didn't pass filter */
|
||||||
@@ -129,7 +140,7 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
|
|||||||
static int
|
static int
|
||||||
bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_)
|
bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_)
|
||||||
{
|
{
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported yet");
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported yet");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +173,7 @@ bt_monitor_activate(pcap_t* handle)
|
|||||||
return PCAP_ERROR_RFMON_NOTSUP;
|
return PCAP_ERROR_RFMON_NOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->bufsize = handle->snapshot + BT_CONTROL_SIZE + sizeof(pcap_bluetooth_linux_monitor_header);
|
handle->bufsize = BT_CONTROL_SIZE + sizeof(pcap_bluetooth_linux_monitor_header) + handle->snapshot;
|
||||||
handle->offset = BT_CONTROL_SIZE;
|
|
||||||
handle->linktype = DLT_BLUETOOTH_LINUX_MONITOR;
|
handle->linktype = DLT_BLUETOOTH_LINUX_MONITOR;
|
||||||
|
|
||||||
handle->read_op = bt_monitor_read;
|
handle->read_op = bt_monitor_read;
|
||||||
@@ -177,14 +187,14 @@ bt_monitor_activate(pcap_t* handle)
|
|||||||
|
|
||||||
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
||||||
if (handle->fd < 0) {
|
if (handle->fd < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't create raw socket: %s", strerror(errno));
|
"Can't create raw socket: %s", strerror(errno));
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->buffer = malloc(handle->bufsize);
|
handle->buffer = malloc(handle->bufsize);
|
||||||
if (!handle->buffer) {
|
if (!handle->buffer) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
@@ -195,14 +205,14 @@ bt_monitor_activate(pcap_t* handle)
|
|||||||
addr.hci_channel = HCI_CHANNEL_MONITOR;
|
addr.hci_channel = HCI_CHANNEL_MONITOR;
|
||||||
|
|
||||||
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't attach to interface: %s", strerror(errno));
|
"Can't attach to interface: %s", strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt = 1;
|
opt = 1;
|
||||||
if (setsockopt(handle->fd, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt)) < 0) {
|
if (setsockopt(handle->fd, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Can't enable time stamp: %s", strerror(errno));
|
"Can't enable time stamp: %s", strerror(errno));
|
||||||
goto close_fail;
|
goto close_fail;
|
||||||
}
|
}
|
||||||
@@ -232,7 +242,7 @@ bt_monitor_create(const char *device, char *ebuf, int *is_ours)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*is_ours = 1;
|
*is_ours = 1;
|
||||||
p = pcap_create_common(device, ebuf, 0);
|
p = pcap_create_common(ebuf, 0);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -1,319 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009 Felix Obenhuber
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* SocketCan sniffing API implementation for Linux platform
|
|
||||||
* By Felix Obenhuber <felix@obenhuber.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "pcap-int.h"
|
|
||||||
#include "pcap-can-linux.h"
|
|
||||||
|
|
||||||
#ifdef NEED_STRERROR_H
|
|
||||||
#include "strerror.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <linux/can.h>
|
|
||||||
#include <linux/can/raw.h>
|
|
||||||
|
|
||||||
/* not yet defined anywhere */
|
|
||||||
#ifndef PF_CAN
|
|
||||||
#define PF_CAN 29
|
|
||||||
#endif
|
|
||||||
#ifndef AF_CAN
|
|
||||||
#define AF_CAN PF_CAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* forward declaration */
|
|
||||||
static int can_activate(pcap_t *);
|
|
||||||
static int can_read_linux(pcap_t *, int , pcap_handler , u_char *);
|
|
||||||
static int can_inject_linux(pcap_t *, const void *, size_t);
|
|
||||||
static int can_setfilter_linux(pcap_t *, struct bpf_program *);
|
|
||||||
static int can_setdirection_linux(pcap_t *, pcap_direction_t);
|
|
||||||
static int can_stats_linux(pcap_t *, struct pcap_stat *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Private data for capturing on Linux CANbus devices.
|
|
||||||
*/
|
|
||||||
struct pcap_can {
|
|
||||||
int ifindex; /* interface index of device we're bound to */
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
can_findalldevs(pcap_if_t **devlistp, char *errbuf)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* There are no platform-specific devices since each device
|
|
||||||
* exists as a regular network interface.
|
|
||||||
*
|
|
||||||
* XXX - true?
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcap_t *
|
|
||||||
can_create(const char *device, char *ebuf, int *is_ours)
|
|
||||||
{
|
|
||||||
const char *cp;
|
|
||||||
char *cpend;
|
|
||||||
long devnum;
|
|
||||||
pcap_t* p;
|
|
||||||
|
|
||||||
/* Does this look like a CANbus device? */
|
|
||||||
cp = strrchr(device, '/');
|
|
||||||
if (cp == NULL)
|
|
||||||
cp = device;
|
|
||||||
/* Does it begin with "can" or "vcan"? */
|
|
||||||
if (strncmp(cp, "can", 3) == 0) {
|
|
||||||
/* Begins with "can" */
|
|
||||||
cp += 3; /* skip past "can" */
|
|
||||||
} else if (strncmp(cp, "vcan", 4) == 0) {
|
|
||||||
/* Begins with "vcan" */
|
|
||||||
cp += 4;
|
|
||||||
} else {
|
|
||||||
/* Nope, doesn't begin with "can" or "vcan" */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* Yes - is "can" or "vcan" followed by a number from 0? */
|
|
||||||
devnum = strtol(cp, &cpend, 10);
|
|
||||||
if (cpend == cp || *cpend != '\0') {
|
|
||||||
/* Not followed by a number. */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (devnum < 0) {
|
|
||||||
/* Followed by a non-valid number. */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* OK, it's probably ours. */
|
|
||||||
*is_ours = 1;
|
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_can));
|
|
||||||
if (p == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
p->activate_op = can_activate;
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_activate(pcap_t* handle)
|
|
||||||
{
|
|
||||||
struct pcap_can *handlep = handle->priv;
|
|
||||||
struct sockaddr_can addr;
|
|
||||||
struct ifreq ifr;
|
|
||||||
|
|
||||||
/* Initialize some components of the pcap structure. */
|
|
||||||
handle->bufsize = 24;
|
|
||||||
handle->offset = 8;
|
|
||||||
handle->linktype = DLT_CAN_SOCKETCAN;
|
|
||||||
handle->read_op = can_read_linux;
|
|
||||||
handle->inject_op = can_inject_linux;
|
|
||||||
handle->setfilter_op = can_setfilter_linux;
|
|
||||||
handle->setdirection_op = can_setdirection_linux;
|
|
||||||
handle->set_datalink_op = NULL;
|
|
||||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
|
||||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
|
||||||
handle->stats_op = can_stats_linux;
|
|
||||||
|
|
||||||
/* Create socket */
|
|
||||||
handle->fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
|
|
||||||
if (handle->fd < 0)
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s",
|
|
||||||
errno, strerror(errno));
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get interface index */
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
|
||||||
strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name));
|
|
||||||
if (ioctl(handle->fd, SIOCGIFINDEX, &ifr) < 0)
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"Unable to get interface index: %s",
|
|
||||||
pcap_strerror(errno));
|
|
||||||
pcap_cleanup_live_common(handle);
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
handlep->ifindex = ifr.ifr_ifindex;
|
|
||||||
|
|
||||||
/* allocate butter */
|
|
||||||
handle->buffer = malloc(handle->bufsize);
|
|
||||||
if (!handle->buffer)
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
|
||||||
pcap_strerror(errno));
|
|
||||||
pcap_cleanup_live_common(handle);
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bind to the socket */
|
|
||||||
addr.can_family = AF_CAN;
|
|
||||||
addr.can_ifindex = handlep->ifindex;
|
|
||||||
if( bind( handle->fd, (struct sockaddr*)&addr, sizeof(addr) ) < 0 )
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't attach to device %d %d:%s",
|
|
||||||
handlep->ifindex, errno, strerror(errno));
|
|
||||||
pcap_cleanup_live_common(handle);
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handle->opt.rfmon)
|
|
||||||
{
|
|
||||||
/* Monitor mode doesn't apply to CAN devices. */
|
|
||||||
pcap_cleanup_live_common(handle);
|
|
||||||
return PCAP_ERROR_RFMON_NOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->selectable_fd = handle->fd;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
|
||||||
{
|
|
||||||
struct msghdr msg;
|
|
||||||
struct pcap_pkthdr pkth;
|
|
||||||
struct iovec iv;
|
|
||||||
struct can_frame* cf;
|
|
||||||
|
|
||||||
iv.iov_base = &handle->buffer[handle->offset];
|
|
||||||
iv.iov_len = handle->snapshot;
|
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
|
||||||
msg.msg_iov = &iv;
|
|
||||||
msg.msg_iovlen = 1;
|
|
||||||
msg.msg_control = handle->buffer;
|
|
||||||
msg.msg_controllen = handle->offset;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
pkth.caplen = recvmsg(handle->fd, &msg, 0);
|
|
||||||
if (handle->break_loop)
|
|
||||||
{
|
|
||||||
handle->break_loop = 0;
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
} while ((pkth.caplen == -1) && (errno == EINTR));
|
|
||||||
|
|
||||||
if (pkth.caplen == -1)
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s",
|
|
||||||
errno, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* adjust capture len according to frame len */
|
|
||||||
cf = (struct can_frame*)&handle->buffer[8];
|
|
||||||
pkth.caplen -= 8 - cf->can_dlc;
|
|
||||||
pkth.len = pkth.caplen;
|
|
||||||
|
|
||||||
cf->can_id = htonl( cf->can_id );
|
|
||||||
|
|
||||||
if( -1 == gettimeofday(&pkth.ts, NULL) )
|
|
||||||
{
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get time of day %d:%s",
|
|
||||||
errno, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(user, &pkth, &handle->buffer[8]);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
|
|
||||||
"can devices");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
stats->ps_recv = 0; /* number of packets received */
|
|
||||||
stats->ps_drop = 0; /* number of packets dropped */
|
|
||||||
stats->ps_ifdrop = 0; /* drops by interface -- only supported on some platforms */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_setfilter_linux(pcap_t *p, struct bpf_program *fp)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
can_setdirection_linux(pcap_t *p, pcap_direction_t d)
|
|
||||||
{
|
|
||||||
/* no support for PCAP_D_OUT */
|
|
||||||
if (d == PCAP_D_OUT)
|
|
||||||
{
|
|
||||||
snprintf(p->errbuf, sizeof(p->errbuf),
|
|
||||||
"Setting direction to PCAP_D_OUT is not supported on can");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->direction = d;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* eof */
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009 Felix Obenhuber
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prototypes for SocketCAN related functions
|
|
||||||
*/
|
|
||||||
pcap_t* can_create(const char *device, char *ebuf, int *is_ours);
|
|
||||||
int can_findalldevs(pcap_if_t **devlistp, char *errbuf);
|
|
||||||
@@ -1,474 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009 Felix Obenhuber
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* Sockettrace sniffing API implementation for Linux platform
|
|
||||||
* By Felix Obenhuber <felix@obenhuber.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <libusb-1.0/libusb.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "pcap-int.h"
|
|
||||||
#include "pcap-canusb-linux.h"
|
|
||||||
|
|
||||||
#define CANUSB_IFACE "canusb"
|
|
||||||
|
|
||||||
#define CANUSB_VID 0x0403
|
|
||||||
#define CANUSB_PID 0x8990
|
|
||||||
|
|
||||||
#define USE_THREAD 1
|
|
||||||
|
|
||||||
#if USE_THREAD == 0
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* forward declaration */
|
|
||||||
static int canusb_activate(pcap_t *);
|
|
||||||
static int canusb_read_linux(pcap_t *, int , pcap_handler , u_char *);
|
|
||||||
static int canusb_inject_linux(pcap_t *, const void *, size_t);
|
|
||||||
static int canusb_setfilter_linux(pcap_t *, struct bpf_program *);
|
|
||||||
static int canusb_setdirection_linux(pcap_t *, pcap_direction_t);
|
|
||||||
static int canusb_stats_linux(pcap_t *, struct pcap_stat *);
|
|
||||||
|
|
||||||
struct CAN_Msg
|
|
||||||
{
|
|
||||||
uint32_t timestamp;
|
|
||||||
uint32_t id;
|
|
||||||
uint32_t length;
|
|
||||||
uint8_t data[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Private data for capturing on Linux CANbus USB devices.
|
|
||||||
*/
|
|
||||||
struct pcap_canusb {
|
|
||||||
libusb_context *ctx;
|
|
||||||
libusb_device_handle *dev;
|
|
||||||
pthread_t worker;
|
|
||||||
int rdpipe, wrpipe;
|
|
||||||
volatile int loop;
|
|
||||||
};
|
|
||||||
|
|
||||||
int canusb_findalldevs(pcap_if_t **alldevsp, char *err_str)
|
|
||||||
{
|
|
||||||
libusb_context *fdctx;
|
|
||||||
libusb_device** devs;
|
|
||||||
unsigned char sernum[65];
|
|
||||||
int cnt, i;
|
|
||||||
|
|
||||||
if (libusb_init(&fdctx) != 0) {
|
|
||||||
/*
|
|
||||||
* XXX - if this doesn't just mean "no USB file system mounted",
|
|
||||||
* perhaps we should report a real error rather than just
|
|
||||||
* saying "no CANUSB devices".
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cnt = libusb_get_device_list(fdctx,&devs);
|
|
||||||
|
|
||||||
for(i=0;i<cnt;i++)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
// Check if this device is interesting.
|
|
||||||
struct libusb_device_descriptor desc;
|
|
||||||
libusb_get_device_descriptor(devs[i],&desc);
|
|
||||||
|
|
||||||
if ((desc.idVendor != CANUSB_VID) || (desc.idProduct != CANUSB_PID))
|
|
||||||
continue; //It is not, check next device
|
|
||||||
|
|
||||||
//It is!
|
|
||||||
libusb_device_handle *dh = NULL;
|
|
||||||
|
|
||||||
if ((ret = libusb_open(devs[i],&dh)) == 0)
|
|
||||||
{
|
|
||||||
char dev_name[30];
|
|
||||||
char dev_descr[50];
|
|
||||||
int n = libusb_get_string_descriptor_ascii(dh,desc.iSerialNumber,sernum,64);
|
|
||||||
sernum[n] = 0;
|
|
||||||
|
|
||||||
snprintf(dev_name, 30, CANUSB_IFACE"%s", sernum);
|
|
||||||
snprintf(dev_descr, 50, "CanUSB [%s]", sernum);
|
|
||||||
|
|
||||||
libusb_close(dh);
|
|
||||||
|
|
||||||
if (pcap_add_if(alldevsp, dev_name, 0, dev_descr, err_str) < 0)
|
|
||||||
{
|
|
||||||
libusb_free_device_list(devs,1);
|
|
||||||
libusb_exit(fdctx);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
libusb_free_device_list(devs,1);
|
|
||||||
libusb_exit(fdctx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static libusb_device_handle* canusb_opendevice(struct libusb_context *ctx, char* devserial)
|
|
||||||
{
|
|
||||||
libusb_device** devs;
|
|
||||||
unsigned char serial[65];
|
|
||||||
int cnt,i,n;
|
|
||||||
|
|
||||||
cnt = libusb_get_device_list(ctx,&devs);
|
|
||||||
|
|
||||||
for(i=0;i<cnt;i++)
|
|
||||||
{
|
|
||||||
// Check if this device is interesting.
|
|
||||||
struct libusb_device_descriptor desc;
|
|
||||||
libusb_get_device_descriptor(devs[i],&desc);
|
|
||||||
|
|
||||||
if ((desc.idVendor != CANUSB_VID) || (desc.idProduct != CANUSB_PID))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//Found one!
|
|
||||||
libusb_device_handle *dh = NULL;
|
|
||||||
|
|
||||||
if (libusb_open(devs[i],&dh) != 0) continue;
|
|
||||||
|
|
||||||
n = libusb_get_string_descriptor_ascii(dh,desc.iSerialNumber,serial,64);
|
|
||||||
serial[n] = 0;
|
|
||||||
|
|
||||||
if ((devserial) && (strcmp((char *)serial,devserial) != 0))
|
|
||||||
{
|
|
||||||
libusb_close(dh);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((libusb_kernel_driver_active(dh,0)) && (libusb_detach_kernel_driver(dh,0) != 0))
|
|
||||||
{
|
|
||||||
libusb_close(dh);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libusb_set_configuration(dh,1) != 0)
|
|
||||||
{
|
|
||||||
libusb_close(dh);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libusb_claim_interface(dh,0) != 0)
|
|
||||||
{
|
|
||||||
libusb_close(dh);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Fount it!
|
|
||||||
libusb_free_device_list(devs,1);
|
|
||||||
return dh;
|
|
||||||
}
|
|
||||||
|
|
||||||
libusb_free_device_list(devs,1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pcap_t *
|
|
||||||
canusb_create(const char *device, char *ebuf, int *is_ours)
|
|
||||||
{
|
|
||||||
const char *cp;
|
|
||||||
char *cpend;
|
|
||||||
long devnum;
|
|
||||||
pcap_t* p;
|
|
||||||
struct pcap_canusb *canusb;
|
|
||||||
|
|
||||||
/* Does this look like a DAG device? */
|
|
||||||
cp = strrchr(device, '/');
|
|
||||||
if (cp == NULL)
|
|
||||||
cp = device;
|
|
||||||
/* Does it begin with "canusb"? */
|
|
||||||
if (strncmp(cp, "canusb", 6) != 0) {
|
|
||||||
/* Nope, doesn't begin with "canusb" */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* Yes - is "canusb" followed by a number? */
|
|
||||||
cp += 6;
|
|
||||||
devnum = strtol(cp, &cpend, 10);
|
|
||||||
if (cpend == cp || *cpend != '\0') {
|
|
||||||
/* Not followed by a number. */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (devnum < 0) {
|
|
||||||
/* Followed by a non-valid number. */
|
|
||||||
*is_ours = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* OK, it's probably ours. */
|
|
||||||
*is_ours = 1;
|
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_canusb));
|
|
||||||
if (p == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
canusb = p->priv;
|
|
||||||
canusb->ctx = NULL;
|
|
||||||
canusb->dev = NULL;
|
|
||||||
canusb->rdpipe = -1;
|
|
||||||
canusb->wrpipe = -1;
|
|
||||||
|
|
||||||
p->activate_op = canusb_activate;
|
|
||||||
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void* canusb_capture_thread(void *arg)
|
|
||||||
{
|
|
||||||
struct pcap_canusb *canusb = arg;
|
|
||||||
int i;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint8_t rxsz, txsz;
|
|
||||||
} status;
|
|
||||||
|
|
||||||
fcntl(canusb->wrpipe, F_SETFL, O_NONBLOCK);
|
|
||||||
|
|
||||||
while(canusb->loop)
|
|
||||||
{
|
|
||||||
int sz;
|
|
||||||
struct CAN_Msg msg;
|
|
||||||
|
|
||||||
libusb_interrupt_transfer(canusb->dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
|
|
||||||
//HACK!!!!! -> drop buffered data, read new one by reading twice.
|
|
||||||
libusb_interrupt_transfer(canusb->dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
|
|
||||||
|
|
||||||
for(i = 0; i<status.rxsz; i++)
|
|
||||||
{
|
|
||||||
libusb_bulk_transfer(canusb->dev, 0x85, (unsigned char*)&msg, sizeof(msg), &sz, 100);
|
|
||||||
if(write(canusb->wrpipe, &msg, sizeof(msg)) < 0)
|
|
||||||
fprintf(stderr,"write() error: %s\n", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int canusb_startcapture(struct pcap_canusb* this)
|
|
||||||
{
|
|
||||||
int pipefd[2];
|
|
||||||
|
|
||||||
if (pipe(pipefd) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
this->rdpipe = pipefd[0];
|
|
||||||
this->wrpipe = pipefd[1];
|
|
||||||
|
|
||||||
this->loop = 1;
|
|
||||||
pthread_create(&this->worker, NULL, canusb_capture_thread, this);
|
|
||||||
|
|
||||||
return this->rdpipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void canusb_clearbufs(struct pcap_canusb* this)
|
|
||||||
{
|
|
||||||
unsigned char cmd[16];
|
|
||||||
int al;
|
|
||||||
|
|
||||||
cmd[0] = 1; //Empty incoming buffer
|
|
||||||
cmd[1] = 1; //Empty outgoing buffer
|
|
||||||
cmd[3] = 0; //Not a write to serial number
|
|
||||||
memset(&cmd[4],0,16-4);
|
|
||||||
|
|
||||||
libusb_interrupt_transfer(this->dev, 0x1,cmd,16,&al,100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void canusb_close(pcap_t* handle)
|
|
||||||
{
|
|
||||||
struct pcap_canusb *canusb = handle->priv;
|
|
||||||
|
|
||||||
canusb->loop = 0;
|
|
||||||
pthread_join(canusb->worker, NULL);
|
|
||||||
|
|
||||||
if (canusb->dev)
|
|
||||||
{
|
|
||||||
libusb_close(canusb->dev);
|
|
||||||
canusb->dev = NULL;
|
|
||||||
}
|
|
||||||
if (canusb->ctx)
|
|
||||||
{
|
|
||||||
libusb_exit(canusb->ctx);
|
|
||||||
canusb->ctx = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int canusb_activate(pcap_t* handle)
|
|
||||||
{
|
|
||||||
struct pcap_canusb *canusb = handle->priv;
|
|
||||||
char *serial;
|
|
||||||
|
|
||||||
if (libusb_init(&canusb->ctx) != 0) {
|
|
||||||
/*
|
|
||||||
* XXX - what causes this to fail?
|
|
||||||
*/
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "libusb_init() failed");
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->read_op = canusb_read_linux;
|
|
||||||
|
|
||||||
handle->inject_op = canusb_inject_linux;
|
|
||||||
handle->setfilter_op = canusb_setfilter_linux;
|
|
||||||
handle->setdirection_op = canusb_setdirection_linux;
|
|
||||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
|
||||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
|
||||||
handle->stats_op = canusb_stats_linux;
|
|
||||||
handle->cleanup_op = canusb_close;
|
|
||||||
|
|
||||||
/* Initialize some components of the pcap structure. */
|
|
||||||
handle->bufsize = 32;
|
|
||||||
handle->offset = 8;
|
|
||||||
handle->linktype = DLT_CAN_SOCKETCAN;
|
|
||||||
handle->set_datalink_op = NULL;
|
|
||||||
|
|
||||||
serial = handle->opt.source + strlen(CANUSB_IFACE);
|
|
||||||
|
|
||||||
canusb->dev = canusb_opendevice(canusb->ctx, serial);
|
|
||||||
if (!canusb->dev)
|
|
||||||
{
|
|
||||||
libusb_exit(canusb->ctx);
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't open USB Device");
|
|
||||||
return PCAP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
canusb_clearbufs(canusb);
|
|
||||||
|
|
||||||
handle->fd = canusb_startcapture(canusb);
|
|
||||||
handle->selectable_fd = handle->fd;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
canusb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
|
||||||
{
|
|
||||||
static struct timeval firstpacket = { -1, -1};
|
|
||||||
int i = 0;
|
|
||||||
struct CAN_Msg msg;
|
|
||||||
struct pcap_pkthdr pkth;
|
|
||||||
|
|
||||||
while(i < max_packets)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
usleep(10 * 1000);
|
|
||||||
n = read(handle->fd, &msg, sizeof(msg));
|
|
||||||
if (n <= 0)
|
|
||||||
break;
|
|
||||||
pkth.caplen = pkth.len = n;
|
|
||||||
pkth.caplen -= 4;
|
|
||||||
pkth.caplen -= 8 - msg.length;
|
|
||||||
|
|
||||||
if ((firstpacket.tv_sec == -1) && (firstpacket.tv_usec == -1))
|
|
||||||
gettimeofday(&firstpacket, NULL);
|
|
||||||
|
|
||||||
pkth.ts.tv_usec = firstpacket.tv_usec + (msg.timestamp % 100) * 10000;
|
|
||||||
pkth.ts.tv_sec = firstpacket.tv_usec + (msg.timestamp / 100);
|
|
||||||
if (pkth.ts.tv_usec > 1000000)
|
|
||||||
{
|
|
||||||
pkth.ts.tv_usec -= 1000000;
|
|
||||||
pkth.ts.tv_sec++;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(user, &pkth, (void*)&msg.id);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
canusb_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on canusb devices");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
canusb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
stats->ps_recv = 0; /* number of packets received */
|
|
||||||
stats->ps_drop = 0; /* number of packets dropped */
|
|
||||||
stats->ps_ifdrop = 0; /* drops by interface -- only supported on some platforms */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
canusb_setfilter_linux(pcap_t *p, struct bpf_program *fp)
|
|
||||||
{
|
|
||||||
/* not yet implemented */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
canusb_setdirection_linux(pcap_t *p, pcap_direction_t d)
|
|
||||||
{
|
|
||||||
/* no support for PCAP_D_OUT */
|
|
||||||
if (d == PCAP_D_OUT)
|
|
||||||
{
|
|
||||||
snprintf(p->errbuf, sizeof(p->errbuf),
|
|
||||||
"Setting direction to PCAP_D_OUT is not supported on this interface");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->direction = d;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* eof */
|
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <pcap-stdinc.h>
|
#include <pcap-stdinc.h>
|
||||||
#else /* WIN32 */
|
#else /* _WIN32 */
|
||||||
#if HAVE_INTTYPES_H
|
#if HAVE_INTTYPES_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#elif HAVE_STDINT_H
|
#elif HAVE_STDINT_H
|
||||||
@@ -37,11 +37,14 @@
|
|||||||
#include <sys/bitypes.h>
|
#include <sys/bitypes.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "pcap-int.h"
|
#include "pcap-int.h"
|
||||||
|
#include "extract.h"
|
||||||
|
#include "pcap/sll.h"
|
||||||
#include "pcap/usb.h"
|
#include "pcap/usb.h"
|
||||||
#include "pcap/nflog.h"
|
#include "pcap/nflog.h"
|
||||||
|
#include "pcap/can_socketcan.h"
|
||||||
|
|
||||||
#include "pcap-common.h"
|
#include "pcap-common.h"
|
||||||
|
|
||||||
@@ -351,7 +354,7 @@
|
|||||||
|
|
||||||
#define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
|
#define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
|
||||||
#define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
|
#define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
|
||||||
#define LINKTYPE_GPF_F 171 /* GPF-T (ITU-T G.7041/Y.1303) */
|
#define LINKTYPE_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
|
* Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
|
||||||
@@ -426,10 +429,17 @@
|
|||||||
#define LINKTYPE_A653_ICM 185
|
#define LINKTYPE_A653_ICM 185
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* USB packets, beginning with a USB setup header; requested by
|
* This used to be "USB packets, beginning with a USB setup header;
|
||||||
* Paolo Abeni <paolo.abeni@email.it>.
|
* requested by Paolo Abeni <paolo.abeni@email.it>."
|
||||||
|
*
|
||||||
|
* However, that header didn't work all that well - it left out some
|
||||||
|
* useful information - and was abandoned in favor of the DLT_USB_LINUX
|
||||||
|
* header.
|
||||||
|
*
|
||||||
|
* This is now used by FreeBSD for its BPF taps for USB; that has its
|
||||||
|
* own headers. So it is written, so it is done.
|
||||||
*/
|
*/
|
||||||
#define LINKTYPE_USB 186
|
#define LINKTYPE_USB_FREEBSD 186
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bluetooth HCI UART transport layer (part H:4); requested by
|
* Bluetooth HCI UART transport layer (part H:4); requested by
|
||||||
@@ -736,8 +746,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
|
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
|
||||||
* by Linux SocketCAN. See Documentation/networking/can.txt in the Linux
|
* by Linux SocketCAN, and with multi-byte numerical fields in that header
|
||||||
* source.
|
* in big-endian byte order.
|
||||||
|
*
|
||||||
|
* See Documentation/networking/can.txt in the Linux source.
|
||||||
*
|
*
|
||||||
* Requested by Felix Obenhuber <felix@obenhuber.de>.
|
* Requested by Felix Obenhuber <felix@obenhuber.de>.
|
||||||
*/
|
*/
|
||||||
@@ -959,7 +971,6 @@
|
|||||||
*/
|
*/
|
||||||
#define LINKTYPE_PROFIBUS_DL 257
|
#define LINKTYPE_PROFIBUS_DL 257
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apple's DLT_PKTAP headers.
|
* Apple's DLT_PKTAP headers.
|
||||||
*
|
*
|
||||||
@@ -1000,7 +1011,24 @@
|
|||||||
#define LINKTYPE_ZWAVE_R1_R2 261
|
#define LINKTYPE_ZWAVE_R1_R2 261
|
||||||
#define LINKTYPE_ZWAVE_R3 262
|
#define LINKTYPE_ZWAVE_R3 262
|
||||||
|
|
||||||
#define LINKTYPE_MATCHING_MAX 262 /* highest value in the "matching" range */
|
/*
|
||||||
|
* per Steve Karg <skarg@users.sourceforge.net>, formats for Wattstopper
|
||||||
|
* Digital Lighting Management room bus serial protocol captures.
|
||||||
|
*/
|
||||||
|
#define LINKTYPE_WATTSTOPPER_DLM 263
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ISO 14443 contactless smart card messages.
|
||||||
|
*/
|
||||||
|
#define LINKTYPE_ISO_14443 264
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Radio data system (RDS) groups. IEC 62106.
|
||||||
|
* Per Jonathan Brucker <jonathan.brucke@gmail.com>.
|
||||||
|
*/
|
||||||
|
#define LINKTYPE_RDS 265
|
||||||
|
|
||||||
|
#define LINKTYPE_MATCHING_MAX 265 /* highest value in the "matching" range */
|
||||||
|
|
||||||
static struct linktype_map {
|
static struct linktype_map {
|
||||||
int dlt;
|
int dlt;
|
||||||
@@ -1147,6 +1175,48 @@ linktype_to_dlt(int linktype)
|
|||||||
return linktype;
|
return linktype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define EXTRACT_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
|
||||||
|
* LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
|
||||||
|
* with the CAN ID being in host byte order.
|
||||||
|
*
|
||||||
|
* When reading a DLT_LINUX_SLL capture file, we need to check for those
|
||||||
|
* packets and convert the CAN ID from the byte order of the host that
|
||||||
|
* wrote the file to this host's byte order.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
|
||||||
|
{
|
||||||
|
u_int caplen = hdr->caplen;
|
||||||
|
u_int length = hdr->len;
|
||||||
|
struct sll_header *shdr = (struct sll_header *)buf;
|
||||||
|
u_int16_t protocol;
|
||||||
|
pcap_can_socketcan_hdr *chdr;
|
||||||
|
|
||||||
|
if (caplen < (u_int) sizeof(struct sll_header) ||
|
||||||
|
length < (u_int) sizeof(struct sll_header)) {
|
||||||
|
/* Not enough data to have the protocol field */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol = EXTRACT_16BITS(&shdr->sll_protocol);
|
||||||
|
if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SocketCAN packet; fix up the packet's header.
|
||||||
|
*/
|
||||||
|
chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
|
||||||
|
if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
|
||||||
|
length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
|
||||||
|
/* Not enough data to have the CAN ID */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chdr->can_id = SWAPLONG(chdr->can_id);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
|
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
|
||||||
* byte order when capturing (it's supplied directly from a
|
* byte order when capturing (it's supplied directly from a
|
||||||
@@ -1316,12 +1386,13 @@ swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
|
|||||||
u_int length = hdr->len;
|
u_int length = hdr->len;
|
||||||
u_int16_t size;
|
u_int16_t size;
|
||||||
|
|
||||||
if (caplen < (int) sizeof(nflog_hdr_t) || length < (int) sizeof(nflog_hdr_t)) {
|
if (caplen < (u_int) sizeof(nflog_hdr_t) ||
|
||||||
|
length < (u_int) sizeof(nflog_hdr_t)) {
|
||||||
/* Not enough data to have any TLVs. */
|
/* Not enough data to have any TLVs. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(nfhdr->nflog_version) == 0) {
|
if (nfhdr->nflog_version != 0) {
|
||||||
/* Unknown NFLOG version */
|
/* Unknown NFLOG version */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1371,6 +1442,10 @@ swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
|
|||||||
*/
|
*/
|
||||||
switch (linktype) {
|
switch (linktype) {
|
||||||
|
|
||||||
|
case DLT_LINUX_SLL:
|
||||||
|
swap_linux_sll_header(hdr, data);
|
||||||
|
break;
|
||||||
|
|
||||||
case DLT_USB_LINUX:
|
case DLT_USB_LINUX:
|
||||||
swap_linux_usb_header(hdr, data, 0);
|
swap_linux_usb_header(hdr, data, 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
.\"
|
.\"
|
||||||
.TH PCAP-CONFIG 1 "22 May 2009"
|
.TH PCAP-CONFIG 1 "15 February 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pcap-config \- write libpcap compiler and linker flags to standard output
|
pcap-config \- write libpcap compiler and linker flags to standard output
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|||||||
@@ -53,6 +53,99 @@ struct rtentry; /* declarations in <net/if.h> */
|
|||||||
#define DAG_MAX_BOARDS 32
|
#define DAG_MAX_BOARDS 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TYPE_AAL5
|
||||||
|
#define TYPE_AAL5 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_HDLC
|
||||||
|
#define TYPE_MC_HDLC 5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_RAW
|
||||||
|
#define TYPE_MC_RAW 6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_ATM
|
||||||
|
#define TYPE_MC_ATM 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_RAW_CHANNEL
|
||||||
|
#define TYPE_MC_RAW_CHANNEL 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_AAL5
|
||||||
|
#define TYPE_MC_AAL5 9
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_COLOR_HDLC_POS
|
||||||
|
#define TYPE_COLOR_HDLC_POS 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_COLOR_ETH
|
||||||
|
#define TYPE_COLOR_ETH 11
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_MC_AAL2
|
||||||
|
#define TYPE_MC_AAL2 12
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_IP_COUNTER
|
||||||
|
#define TYPE_IP_COUNTER 13
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_TCP_FLOW_COUNTER
|
||||||
|
#define TYPE_TCP_FLOW_COUNTER 14
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_DSM_COLOR_HDLC_POS
|
||||||
|
#define TYPE_DSM_COLOR_HDLC_POS 15
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_DSM_COLOR_ETH
|
||||||
|
#define TYPE_DSM_COLOR_ETH 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_COLOR_MC_HDLC_POS
|
||||||
|
#define TYPE_COLOR_MC_HDLC_POS 17
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_AAL2
|
||||||
|
#define TYPE_AAL2 18
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_COLOR_HASH_POS
|
||||||
|
#define TYPE_COLOR_HASH_POS 19
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_COLOR_HASH_ETH
|
||||||
|
#define TYPE_COLOR_HASH_ETH 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_INFINIBAND
|
||||||
|
#define TYPE_INFINIBAND 21
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_IPV4
|
||||||
|
#define TYPE_IPV4 22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_IPV6
|
||||||
|
#define TYPE_IPV6 23
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_RAW_LINK
|
||||||
|
#define TYPE_RAW_LINK 24
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_INFINIBAND_LINK
|
||||||
|
#define TYPE_INFINIBAND_LINK 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TYPE_PAD
|
||||||
|
#define TYPE_PAD 48
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ATM_CELL_SIZE 52
|
#define ATM_CELL_SIZE 52
|
||||||
#define ATM_HDR_SIZE 4
|
#define ATM_HDR_SIZE 4
|
||||||
|
|
||||||
@@ -144,10 +237,8 @@ delete_pcap_dag(pcap_t *p)
|
|||||||
static void
|
static void
|
||||||
dag_platform_cleanup(pcap_t *p)
|
dag_platform_cleanup(pcap_t *p)
|
||||||
{
|
{
|
||||||
struct pcap_dag *pd;
|
struct pcap_dag *pd = p->pr;
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
pd = p->priv;
|
|
||||||
#ifdef HAVE_DAG_STREAMS_API
|
#ifdef HAVE_DAG_STREAMS_API
|
||||||
if(dag_stop_stream(p->fd, pd->dag_stream) < 0)
|
if(dag_stop_stream(p->fd, pd->dag_stream) < 0)
|
||||||
fprintf(stderr,"dag_stop_stream: %s\n", strerror(errno));
|
fprintf(stderr,"dag_stop_stream: %s\n", strerror(errno));
|
||||||
@@ -165,7 +256,6 @@ dag_platform_cleanup(pcap_t *p)
|
|||||||
}
|
}
|
||||||
delete_pcap_dag(p);
|
delete_pcap_dag(p);
|
||||||
pcap_cleanup_live_common(p);
|
pcap_cleanup_live_common(p);
|
||||||
}
|
|
||||||
/* Note: don't need to call close(p->fd) here as dag_close(p->fd) does this. */
|
/* Note: don't need to call close(p->fd) here as dag_close(p->fd) does this. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,6 +264,7 @@ atexit_handler(void)
|
|||||||
{
|
{
|
||||||
while (pcap_dags != NULL) {
|
while (pcap_dags != NULL) {
|
||||||
if (pcap_dags->pid == getpid()) {
|
if (pcap_dags->pid == getpid()) {
|
||||||
|
if (pcap_dags->p != NULL)
|
||||||
dag_platform_cleanup(pcap_dags->p);
|
dag_platform_cleanup(pcap_dags->p);
|
||||||
} else {
|
} else {
|
||||||
delete_pcap_dag(pcap_dags->p);
|
delete_pcap_dag(pcap_dags->p);
|
||||||
@@ -634,7 +725,7 @@ static int dag_activate(pcap_t* handle)
|
|||||||
int n;
|
int n;
|
||||||
daginf_t* daginf;
|
daginf_t* daginf;
|
||||||
char * newDev = NULL;
|
char * newDev = NULL;
|
||||||
char * device = handle->opt.source;
|
char * device = handle->opt.device;
|
||||||
#ifdef HAVE_DAG_STREAMS_API
|
#ifdef HAVE_DAG_STREAMS_API
|
||||||
uint32_t mindata;
|
uint32_t mindata;
|
||||||
struct timeval maxwait;
|
struct timeval maxwait;
|
||||||
@@ -642,7 +733,7 @@ static int dag_activate(pcap_t* handle)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (device == NULL) {
|
if (device == NULL) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "device is NULL: %s", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "device is NULL: %s", pcap_strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,26 +742,26 @@ static int dag_activate(pcap_t* handle)
|
|||||||
#ifdef HAVE_DAG_STREAMS_API
|
#ifdef HAVE_DAG_STREAMS_API
|
||||||
newDev = (char *)malloc(strlen(device) + 16);
|
newDev = (char *)malloc(strlen(device) + 16);
|
||||||
if (newDev == NULL) {
|
if (newDev == NULL) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate string for device name: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate string for device name: %s", pcap_strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse input name to get dag device and stream number if provided */
|
/* Parse input name to get dag device and stream number if provided */
|
||||||
if (dag_parse_name(device, newDev, strlen(device) + 16, &handlep->dag_stream) < 0) {
|
if (dag_parse_name(device, newDev, strlen(device) + 16, &handlep->dag_stream) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: %s", pcap_strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
device = newDev;
|
device = newDev;
|
||||||
|
|
||||||
if (handlep->dag_stream%2) {
|
if (handlep->dag_stream%2) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture\n");
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (strncmp(device, "/dev/", 5) != 0) {
|
if (strncmp(device, "/dev/", 5) != 0) {
|
||||||
newDev = (char *)malloc(strlen(device) + 5);
|
newDev = (char *)malloc(strlen(device) + 5);
|
||||||
if (newDev == NULL) {
|
if (newDev == NULL) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate string for device name: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate string for device name: %s", pcap_strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
strcpy(newDev, "/dev/");
|
strcpy(newDev, "/dev/");
|
||||||
@@ -681,14 +772,14 @@ static int dag_activate(pcap_t* handle)
|
|||||||
|
|
||||||
/* setup device parameters */
|
/* setup device parameters */
|
||||||
if((handle->fd = dag_open((char *)device)) < 0) {
|
if((handle->fd = dag_open((char *)device)) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_open %s: %s", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_open %s: %s", device, pcap_strerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DAG_STREAMS_API
|
#ifdef HAVE_DAG_STREAMS_API
|
||||||
/* Open requested stream. Can fail if already locked or on error */
|
/* Open requested stream. Can fail if already locked or on error */
|
||||||
if (dag_attach_stream(handle->fd, handlep->dag_stream, 0, 0) < 0) {
|
if (dag_attach_stream(handle->fd, handlep->dag_stream, 0, 0) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_attach_stream: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_attach_stream: %s", pcap_strerror(errno));
|
||||||
goto failclose;
|
goto failclose;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +788,7 @@ static int dag_activate(pcap_t* handle)
|
|||||||
*/
|
*/
|
||||||
if (dag_get_stream_poll(handle->fd, handlep->dag_stream,
|
if (dag_get_stream_poll(handle->fd, handlep->dag_stream,
|
||||||
&mindata, &maxwait, &poll) < 0) {
|
&mindata, &maxwait, &poll) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s", pcap_strerror(errno));
|
||||||
goto faildetach;
|
goto faildetach;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,13 +813,13 @@ static int dag_activate(pcap_t* handle)
|
|||||||
|
|
||||||
if (dag_set_stream_poll(handle->fd, handlep->dag_stream,
|
if (dag_set_stream_poll(handle->fd, handlep->dag_stream,
|
||||||
mindata, &maxwait, &poll) < 0) {
|
mindata, &maxwait, &poll) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s\n", pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s", pcap_strerror(errno));
|
||||||
goto faildetach;
|
goto faildetach;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if((handlep->dag_mem_base = dag_mmap(handle->fd)) == MAP_FAILED) {
|
if((handlep->dag_mem_base = dag_mmap(handle->fd)) == MAP_FAILED) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_mmap %s: %s\n", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_mmap %s: %s", device, pcap_strerror(errno));
|
||||||
goto failclose;
|
goto failclose;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,22 +839,22 @@ static int dag_activate(pcap_t* handle)
|
|||||||
handle->snapshot = MIN_DAG_SNAPLEN;
|
handle->snapshot = MIN_DAG_SNAPLEN;
|
||||||
}
|
}
|
||||||
/* snap len has to be a multiple of 4 */
|
/* snap len has to be a multiple of 4 */
|
||||||
snprintf(conf, 30, "varlen slen=%d", (snaplen + 3) & ~3);
|
pcap_snprintf(conf, 30, "varlen slen=%d", (snaplen + 3) & ~3);
|
||||||
|
|
||||||
if(dag_configure(handle->fd, conf) < 0) {
|
if(dag_configure(handle->fd, conf) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_configure %s: %s\n", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_configure %s: %s", device, pcap_strerror(errno));
|
||||||
goto faildetach;
|
goto faildetach;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DAG_STREAMS_API
|
#ifdef HAVE_DAG_STREAMS_API
|
||||||
if(dag_start_stream(handle->fd, handlep->dag_stream) < 0) {
|
if(dag_start_stream(handle->fd, handlep->dag_stream) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_start_stream %s: %s\n", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_start_stream %s: %s", device, pcap_strerror(errno));
|
||||||
goto faildetach;
|
goto faildetach;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(dag_start(handle->fd) < 0) {
|
if(dag_start(handle->fd) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_start %s: %s\n", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_start %s: %s", device, pcap_strerror(errno));
|
||||||
goto failclose;
|
goto failclose;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_DAG_STREAMS_API */
|
#endif /* HAVE_DAG_STREAMS_API */
|
||||||
@@ -798,8 +889,8 @@ static int dag_activate(pcap_t* handle)
|
|||||||
if ((n = atoi(s)) == 0 || n == 16 || n == 32) {
|
if ((n = atoi(s)) == 0 || n == 16 || n == 32) {
|
||||||
handlep->dag_fcs_bits = n;
|
handlep->dag_fcs_bits = n;
|
||||||
} else {
|
} else {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"pcap_activate %s: bad ERF_FCS_BITS value (%d) in environment\n", device, n);
|
"pcap_activate %s: bad ERF_FCS_BITS value (%d) in environment", device, n);
|
||||||
goto failstop;
|
goto failstop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -826,7 +917,7 @@ static int dag_activate(pcap_t* handle)
|
|||||||
handle->bufsize = 0;
|
handle->bufsize = 0;
|
||||||
|
|
||||||
if (new_pcap_dag(handle) < 0) {
|
if (new_pcap_dag(handle) < 0) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "new_pcap_dag %s: %s\n", device, pcap_strerror(errno));
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "new_pcap_dag %s: %s", device, pcap_strerror(errno));
|
||||||
goto failstop;
|
goto failstop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,7 +1023,7 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
|
|||||||
/* OK, it's probably ours. */
|
/* OK, it's probably ours. */
|
||||||
*is_ours = 1;
|
*is_ours = 1;
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dag));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_dag));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -948,11 +1039,9 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
|
|||||||
p->tstamp_precision_count = 2;
|
p->tstamp_precision_count = 2;
|
||||||
p->tstamp_precision_list = malloc(2 * sizeof(u_int));
|
p->tstamp_precision_list = malloc(2 * sizeof(u_int));
|
||||||
if (p->tstamp_precision_list == NULL) {
|
if (p->tstamp_precision_list == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
if (p->tstamp_type_list != NULL)
|
pcap_close(p);
|
||||||
free(p->tstamp_type_list);
|
|
||||||
free(p);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;
|
p->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;
|
||||||
@@ -998,7 +1087,7 @@ dag_findalldevs(pcap_if_t **devlistp, char *errbuf)
|
|||||||
|
|
||||||
/* Try all the DAGs 0-DAG_MAX_BOARDS */
|
/* Try all the DAGs 0-DAG_MAX_BOARDS */
|
||||||
for (c = 0; c < DAG_MAX_BOARDS; c++) {
|
for (c = 0; c < DAG_MAX_BOARDS; c++) {
|
||||||
snprintf(name, 12, "dag%d", c);
|
pcap_snprintf(name, 12, "dag%d", c);
|
||||||
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
|
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1021,7 +1110,7 @@ dag_findalldevs(pcap_if_t **devlistp, char *errbuf)
|
|||||||
if (0 == dag_attach_stream(dagfd, stream, 0, 0)) {
|
if (0 == dag_attach_stream(dagfd, stream, 0, 0)) {
|
||||||
dag_detach_stream(dagfd, stream);
|
dag_detach_stream(dagfd, stream);
|
||||||
|
|
||||||
snprintf(name, 10, "dag%d:%d", c, stream);
|
pcap_snprintf(name, 10, "dag%d:%d", c, stream);
|
||||||
if (pcap_add_if(devlistp, name, 0, description, errbuf) == -1) {
|
if (pcap_add_if(devlistp, name, 0, description, errbuf) == -1) {
|
||||||
/*
|
/*
|
||||||
* Failure.
|
* Failure.
|
||||||
@@ -1097,7 +1186,7 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
|
|||||||
|
|
||||||
if (dag_get_stream_poll(p->fd, pd->dag_stream,
|
if (dag_get_stream_poll(p->fd, pd->dag_stream,
|
||||||
&mindata, &maxwait, &poll) < 0) {
|
&mindata, &maxwait, &poll) < 0) {
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s\n", pcap_strerror(errno));
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s", pcap_strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,7 +1201,7 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
|
|||||||
|
|
||||||
if (dag_set_stream_poll(p->fd, pd->dag_stream,
|
if (dag_set_stream_poll(p->fd, pd->dag_stream,
|
||||||
mindata, &maxwait, &poll) < 0) {
|
mindata, &maxwait, &poll) < 0) {
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s\n", pcap_strerror(errno));
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s", pcap_strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1135,7 +1224,7 @@ dag_get_datalink(pcap_t *p)
|
|||||||
memset(types, 0, 255);
|
memset(types, 0, 255);
|
||||||
|
|
||||||
if (p->dlt_list == NULL && (p->dlt_list = malloc(255*sizeof(*(p->dlt_list)))) == NULL) {
|
if (p->dlt_list == NULL && (p->dlt_list = malloc(255*sizeof(*(p->dlt_list)))) == NULL) {
|
||||||
(void)snprintf(p->errbuf, sizeof(p->errbuf), "malloc: %s", pcap_strerror(errno));
|
(void)pcap_snprintf(p->errbuf, sizeof(p->errbuf), "malloc: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1144,7 +1233,7 @@ dag_get_datalink(pcap_t *p)
|
|||||||
#ifdef HAVE_DAG_GET_STREAM_ERF_TYPES
|
#ifdef HAVE_DAG_GET_STREAM_ERF_TYPES
|
||||||
/* Get list of possible ERF types for this card */
|
/* Get list of possible ERF types for this card */
|
||||||
if (dag_get_stream_erf_types(p->fd, pd->dag_stream, types, 255) < 0) {
|
if (dag_get_stream_erf_types(p->fd, pd->dag_stream, types, 255) < 0) {
|
||||||
snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_stream_erf_types: %s", pcap_strerror(errno));
|
pcap_snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_stream_erf_types: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1242,7 @@ dag_get_datalink(pcap_t *p)
|
|||||||
#elif defined HAVE_DAG_GET_ERF_TYPES
|
#elif defined HAVE_DAG_GET_ERF_TYPES
|
||||||
/* Get list of possible ERF types for this card */
|
/* Get list of possible ERF types for this card */
|
||||||
if (dag_get_erf_types(p->fd, types, 255) < 0) {
|
if (dag_get_erf_types(p->fd, types, 255) < 0) {
|
||||||
snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_erf_types: %s", pcap_strerror(errno));
|
pcap_snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_erf_types: %s", pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,3 +1349,31 @@ dag_get_datalink(pcap_t *p)
|
|||||||
|
|
||||||
return p->linktype;
|
return p->linktype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DAG_ONLY
|
||||||
|
/*
|
||||||
|
* This libpcap build supports only DAG cards, not regular network
|
||||||
|
* interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are no regular interfaces, just DAG interfaces.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
*alldevsp = NULL;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attempts to open a regular interface fail.
|
||||||
|
*/
|
||||||
|
pcap_t *
|
||||||
|
pcap_create_interface(const char *device, char *errbuf)
|
||||||
|
{
|
||||||
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"This version of libpcap only supports DAG cards");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -10,97 +10,3 @@
|
|||||||
|
|
||||||
pcap_t *dag_create(const char *, char *, int *);
|
pcap_t *dag_create(const char *, char *, int *);
|
||||||
int dag_findalldevs(pcap_if_t **devlistp, char *errbuf);
|
int dag_findalldevs(pcap_if_t **devlistp, char *errbuf);
|
||||||
|
|
||||||
#ifndef TYPE_AAL5
|
|
||||||
#define TYPE_AAL5 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_HDLC
|
|
||||||
#define TYPE_MC_HDLC 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_RAW
|
|
||||||
#define TYPE_MC_RAW 6
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_ATM
|
|
||||||
#define TYPE_MC_ATM 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_RAW_CHANNEL
|
|
||||||
#define TYPE_MC_RAW_CHANNEL 8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_AAL5
|
|
||||||
#define TYPE_MC_AAL5 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_COLOR_HDLC_POS
|
|
||||||
#define TYPE_COLOR_HDLC_POS 10
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_COLOR_ETH
|
|
||||||
#define TYPE_COLOR_ETH 11
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_MC_AAL2
|
|
||||||
#define TYPE_MC_AAL2 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_IP_COUNTER
|
|
||||||
#define TYPE_IP_COUNTER 13
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_TCP_FLOW_COUNTER
|
|
||||||
#define TYPE_TCP_FLOW_COUNTER 14
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_DSM_COLOR_HDLC_POS
|
|
||||||
#define TYPE_DSM_COLOR_HDLC_POS 15
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_DSM_COLOR_ETH
|
|
||||||
#define TYPE_DSM_COLOR_ETH 16
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_COLOR_MC_HDLC_POS
|
|
||||||
#define TYPE_COLOR_MC_HDLC_POS 17
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_AAL2
|
|
||||||
#define TYPE_AAL2 18
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_COLOR_HASH_POS
|
|
||||||
#define TYPE_COLOR_HASH_POS 19
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_COLOR_HASH_ETH
|
|
||||||
#define TYPE_COLOR_HASH_ETH 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_INFINIBAND
|
|
||||||
#define TYPE_INFINIBAND 21
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_IPV4
|
|
||||||
#define TYPE_IPV4 22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_IPV6
|
|
||||||
#define TYPE_IPV6 23
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_RAW_LINK
|
|
||||||
#define TYPE_RAW_LINK 24
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TYPE_INFINIBAND_LINK
|
|
||||||
#define TYPE_INFINIBAND_LINK 25
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TYPE_PAD
|
|
||||||
#define TYPE_PAD 48
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ dbus_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
|||||||
message = dbus_connection_pop_message(handlep->conn);
|
message = dbus_connection_pop_message(handlep->conn);
|
||||||
|
|
||||||
while (!message) {
|
while (!message) {
|
||||||
// XXX handle->opt.timeout = timeout_ms;
|
/* XXX handle->opt.timeout = timeout_ms; */
|
||||||
if (!dbus_connection_read_write(handlep->conn, 100)) {
|
if (!dbus_connection_read_write(handlep->conn, 100)) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Connection closed");
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Connection closed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ dbus_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Disconnected");
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Disconnected");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ dbus_write(pcap_t *handle, const void *buf, size_t size)
|
|||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
|
|
||||||
if (!(msg = dbus_message_demarshal(buf, size, &error))) {
|
if (!(msg = dbus_message_demarshal(buf, size, &error))) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dbus_message_demarshal() failed: %s", error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dbus_message_demarshal() failed: %s", error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -160,21 +160,21 @@ dbus_activate(pcap_t *handle)
|
|||||||
#define N_RULES sizeof(rules)/sizeof(rules[0])
|
#define N_RULES sizeof(rules)/sizeof(rules[0])
|
||||||
|
|
||||||
struct pcap_dbus *handlep = handle->priv;
|
struct pcap_dbus *handlep = handle->priv;
|
||||||
const char *dev = handle->opt.source;
|
const char *dev = handle->opt.device;
|
||||||
|
|
||||||
DBusError error = DBUS_ERROR_INIT;
|
DBusError error = DBUS_ERROR_INIT;
|
||||||
int i;
|
u_int i;
|
||||||
|
|
||||||
if (strcmp(dev, "dbus-system") == 0) {
|
if (strcmp(dev, "dbus-system") == 0) {
|
||||||
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
|
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get system bus: %s", error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get system bus: %s", error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (strcmp(dev, "dbus-session") == 0) {
|
} else if (strcmp(dev, "dbus-session") == 0) {
|
||||||
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
|
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get session bus: %s", error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get session bus: %s", error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
@@ -183,19 +183,19 @@ dbus_activate(pcap_t *handle)
|
|||||||
const char *addr = dev + 7;
|
const char *addr = dev + 7;
|
||||||
|
|
||||||
if (!(handlep->conn = dbus_connection_open(addr, &error))) {
|
if (!(handlep->conn = dbus_connection_open(addr, &error))) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to open connection to: %s: %s", addr, error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to open connection to: %s: %s", addr, error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbus_bus_register(handlep->conn, &error)) {
|
if (!dbus_bus_register(handlep->conn, &error)) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to register bus %s: %s\n", addr, error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to register bus %s: %s\n", addr, error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.source);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.device);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ dbus_activate(pcap_t *handle)
|
|||||||
/* try without eavesdrop */
|
/* try without eavesdrop */
|
||||||
dbus_bus_add_match(handlep->conn, rules[i] + strlen(EAVESDROPPING_RULE), &error);
|
dbus_bus_add_match(handlep->conn, rules[i] + strlen(EAVESDROPPING_RULE), &error);
|
||||||
if (dbus_error_is_set(&error)) {
|
if (dbus_error_is_set(&error)) {
|
||||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to add bus match: %s\n", error.message);
|
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to add bus match: %s\n", error.message);
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
dbus_cleanup(handle);
|
dbus_cleanup(handle);
|
||||||
return PCAP_ERROR;
|
return PCAP_ERROR;
|
||||||
@@ -259,7 +259,7 @@ dbus_create(const char *device, char *ebuf, int *is_ours)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*is_ours = 1;
|
*is_ours = 1;
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dbus));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_dbus));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -153,10 +153,12 @@ static void dlpassive(int, char *);
|
|||||||
static int dlrawdatareq(int, const u_char *, int);
|
static int dlrawdatareq(int, const u_char *, int);
|
||||||
#endif
|
#endif
|
||||||
static int recv_ack(int, int, const char *, char *, char *, int *);
|
static int recv_ack(int, int, const char *, char *, char *, int *);
|
||||||
static char *dlstrerror(bpf_u_int32);
|
static char *dlstrerror(char *, size_t, bpf_u_int32);
|
||||||
static char *dlprim(bpf_u_int32);
|
static char *dlprim(char *, size_t, bpf_u_int32);
|
||||||
#if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H)
|
#if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H)
|
||||||
static char *get_release(bpf_u_int32 *, bpf_u_int32 *, bpf_u_int32 *);
|
#define GET_RELEASE_BUFSIZE 32
|
||||||
|
static void get_release(char *, size_t, bpf_u_int32 *, bpf_u_int32 *,
|
||||||
|
bpf_u_int32 *);
|
||||||
#endif
|
#endif
|
||||||
static int send_request(int, char *, int, char *, char *);
|
static int send_request(int, char *, int, char *, char *);
|
||||||
#ifdef HAVE_HPUX9
|
#ifdef HAVE_HPUX9
|
||||||
@@ -166,14 +168,6 @@ static int dlpi_kread(int, off_t, void *, u_int, char *);
|
|||||||
static int get_dlpi_ppa(int, const char *, int, char *);
|
static int get_dlpi_ppa(int, const char *, int, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XXX Needed by HP-UX (at least) */
|
|
||||||
static bpf_u_int32 ctlbuf[MAXDLBUF];
|
|
||||||
static struct strbuf ctl = {
|
|
||||||
MAXDLBUF,
|
|
||||||
0,
|
|
||||||
(char *)ctlbuf
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cast a buffer to "union DL_primitives" without provoking warnings
|
* Cast a buffer to "union DL_primitives" without provoking warnings
|
||||||
* from the compiler.
|
* from the compiler.
|
||||||
@@ -186,6 +180,12 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||||||
int cc;
|
int cc;
|
||||||
u_char *bp;
|
u_char *bp;
|
||||||
int flags;
|
int flags;
|
||||||
|
bpf_u_int32 ctlbuf[MAXDLBUF];
|
||||||
|
struct strbuf ctl = {
|
||||||
|
MAXDLBUF,
|
||||||
|
0,
|
||||||
|
(char *)ctlbuf
|
||||||
|
};
|
||||||
struct strbuf data;
|
struct strbuf data;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@@ -213,6 +213,9 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||||||
* would be DL_HP_RAWDATA_IND on HP-UX
|
* would be DL_HP_RAWDATA_IND on HP-UX
|
||||||
* if we're in raw mode?
|
* if we're in raw mode?
|
||||||
*/
|
*/
|
||||||
|
ctl.buf = (char *)ctlbuf;
|
||||||
|
ctl.maxlen = MAXDLBUF;
|
||||||
|
ctl.len = 0;
|
||||||
if (getmsg(p->fd, &ctl, &data, &flags) < 0) {
|
if (getmsg(p->fd, &ctl, &data, &flags) < 0) {
|
||||||
/* Don't choke when we get ptraced */
|
/* Don't choke when we get ptraced */
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
@@ -230,7 +233,7 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
|||||||
}
|
}
|
||||||
cc = data.len;
|
cc = data.len;
|
||||||
} while (cc == 0);
|
} while (cc == 0);
|
||||||
bp = p->buffer + p->offset;
|
bp = (u_char *)p->buffer + p->offset;
|
||||||
} else
|
} else
|
||||||
bp = p->bp;
|
bp = p->bp;
|
||||||
|
|
||||||
@@ -248,19 +251,19 @@ pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
|
|||||||
#if defined(DLIOCRAW)
|
#if defined(DLIOCRAW)
|
||||||
ret = write(p->fd, buf, size);
|
ret = write(p->fd, buf, size);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
#elif defined(DL_HP_RAWDLS)
|
#elif defined(DL_HP_RAWDLS)
|
||||||
if (pd->send_fd < 0) {
|
if (pd->send_fd < 0) {
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"send: Output FD couldn't be opened");
|
"send: Output FD couldn't be opened");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
ret = dlrawdatareq(pd->send_fd, buf, size);
|
ret = dlrawdatareq(pd->send_fd, buf, size);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -331,28 +334,12 @@ pcap_cleanup_dlpi(pcap_t *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pcap_activate_dlpi(pcap_t *p)
|
open_dlpi_device(const char *name, int *ppa, char *errbuf)
|
||||||
{
|
{
|
||||||
#ifdef DL_HP_RAWDLS
|
int status;
|
||||||
struct pcap_dlpi *pd = p->priv;
|
|
||||||
#endif
|
|
||||||
int status = 0;
|
|
||||||
int retv;
|
|
||||||
register char *cp;
|
|
||||||
int ppa;
|
|
||||||
#ifdef HAVE_SOLARIS
|
|
||||||
int isatm = 0;
|
|
||||||
#endif
|
|
||||||
register dl_info_ack_t *infop;
|
|
||||||
#ifdef HAVE_SYS_BUFMOD_H
|
|
||||||
bpf_u_int32 ss;
|
|
||||||
#ifdef HAVE_SOLARIS
|
|
||||||
register char *release;
|
|
||||||
bpf_u_int32 osmajor, osminor, osmicro;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
bpf_u_int32 buf[MAXDLBUF];
|
|
||||||
char dname[100];
|
char dname[100];
|
||||||
|
char *cp;
|
||||||
|
int fd;
|
||||||
#ifndef HAVE_DEV_DLPI
|
#ifndef HAVE_DEV_DLPI
|
||||||
char dname2[100];
|
char dname2[100];
|
||||||
#endif
|
#endif
|
||||||
@@ -361,9 +348,9 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
/*
|
/*
|
||||||
** Remove any "/dev/" on the front of the device.
|
** Remove any "/dev/" on the front of the device.
|
||||||
*/
|
*/
|
||||||
cp = strrchr(p->opt.source, '/');
|
cp = strrchr(name, '/');
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
strlcpy(dname, p->opt.source, sizeof(dname));
|
strlcpy(dname, name, sizeof(dname));
|
||||||
else
|
else
|
||||||
strlcpy(dname, cp + 1, sizeof(dname));
|
strlcpy(dname, cp + 1, sizeof(dname));
|
||||||
|
|
||||||
@@ -371,11 +358,9 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
* Split the device name into a device type name and a unit number;
|
* Split the device name into a device type name and a unit number;
|
||||||
* chop off the unit number, so "dname" is just a device type name.
|
* chop off the unit number, so "dname" is just a device type name.
|
||||||
*/
|
*/
|
||||||
cp = split_dname(dname, &ppa, p->errbuf);
|
cp = split_dname(dname, ppa, errbuf);
|
||||||
if (cp == NULL) {
|
if (cp == NULL)
|
||||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -390,13 +375,137 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
* device number, rather than hardwiring "/dev/dlpi".
|
* device number, rather than hardwiring "/dev/dlpi".
|
||||||
*/
|
*/
|
||||||
cp = "/dev/dlpi";
|
cp = "/dev/dlpi";
|
||||||
if ((p->fd = open(cp, O_RDWR)) < 0) {
|
if ((fd = open(cp, O_RDWR)) < 0) {
|
||||||
if (errno == EPERM || errno == EACCES)
|
if (errno == EPERM || errno == EACCES)
|
||||||
status = PCAP_ERROR_PERM_DENIED;
|
status = PCAP_ERROR_PERM_DENIED;
|
||||||
else
|
else
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s: %s", cp, pcap_strerror(errno));
|
"%s: %s", cp, pcap_strerror(errno));
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a table of all PPAs for that device, and search that
|
||||||
|
* table for the specified device type name and unit number.
|
||||||
|
*/
|
||||||
|
*ppa = get_dlpi_ppa(fd, dname, *ppa, errbuf);
|
||||||
|
if (*ppa < 0) {
|
||||||
|
close(fd);
|
||||||
|
return (*ppa);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* If the device name begins with "/", assume it begins with
|
||||||
|
* the pathname of the directory containing the device to open;
|
||||||
|
* otherwise, concatenate the device directory name and the
|
||||||
|
* device name.
|
||||||
|
*/
|
||||||
|
if (*name == '/')
|
||||||
|
strlcpy(dname, name, sizeof(dname));
|
||||||
|
else
|
||||||
|
pcap_snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
||||||
|
name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the unit number, and a pointer to the end of the device
|
||||||
|
* type name.
|
||||||
|
*/
|
||||||
|
cp = split_dname(dname, ppa, errbuf);
|
||||||
|
if (cp == NULL)
|
||||||
|
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a copy of the device pathname, and then remove the unit
|
||||||
|
* number from the device pathname.
|
||||||
|
*/
|
||||||
|
strlcpy(dname2, dname, sizeof(dname));
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
/* Try device without unit number */
|
||||||
|
if ((fd = open(dname, O_RDWR)) < 0) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
if (errno == EPERM || errno == EACCES)
|
||||||
|
status = PCAP_ERROR_PERM_DENIED;
|
||||||
|
else
|
||||||
|
status = PCAP_ERROR;
|
||||||
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
||||||
|
pcap_strerror(errno));
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try again with unit number */
|
||||||
|
if ((fd = open(dname2, O_RDWR)) < 0) {
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We provide an error message even
|
||||||
|
* for this error, for diagnostic
|
||||||
|
* purposes (so that, for example,
|
||||||
|
* the app can show the message if the
|
||||||
|
* user requests it).
|
||||||
|
*
|
||||||
|
* In it, we just report "No DLPI device
|
||||||
|
* found" with the device name, so people
|
||||||
|
* don't get confused and think, for example,
|
||||||
|
* that if they can't capture on "lo0"
|
||||||
|
* on Solaris prior to Solaris 11 the fix
|
||||||
|
* is to change libpcap (or the application
|
||||||
|
* that uses it) to look for something other
|
||||||
|
* than "/dev/lo0", as the fix is to use
|
||||||
|
* Solaris 11 or some operating system
|
||||||
|
* other than Solaris - you just *can't*
|
||||||
|
* capture on a loopback interface
|
||||||
|
* on Solaris prior to Solaris 11, the lack
|
||||||
|
* of a DLPI device for the loopback
|
||||||
|
* interface is just a symptom of that
|
||||||
|
* inability.
|
||||||
|
*/
|
||||||
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"%s: No DLPI device found", name);
|
||||||
|
} else {
|
||||||
|
if (errno == EPERM || errno == EACCES)
|
||||||
|
status = PCAP_ERROR_PERM_DENIED;
|
||||||
|
else
|
||||||
|
status = PCAP_ERROR;
|
||||||
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||||
|
dname2, pcap_strerror(errno));
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
/* XXX Assume unit zero */
|
||||||
|
*ppa = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
pcap_activate_dlpi(pcap_t *p)
|
||||||
|
{
|
||||||
|
#ifdef DL_HP_RAWDLS
|
||||||
|
struct pcap_dlpi *pd = p->priv;
|
||||||
|
#endif
|
||||||
|
int status = 0;
|
||||||
|
int retv;
|
||||||
|
int ppa;
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
int isatm = 0;
|
||||||
|
#endif
|
||||||
|
register dl_info_ack_t *infop;
|
||||||
|
#ifdef HAVE_SYS_BUFMOD_H
|
||||||
|
bpf_u_int32 ss;
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
char release[GET_RELEASE_BUFSIZE];
|
||||||
|
bpf_u_int32 osmajor, osminor, osmicro;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
bpf_u_int32 buf[MAXDLBUF];
|
||||||
|
|
||||||
|
p->fd = open_dlpi_device(p->opt.device, &ppa, p->errbuf);
|
||||||
|
if (p->fd < 0) {
|
||||||
|
status = p->fd;
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,101 +521,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
* to open it for reading only and, if that succeeds, just let
|
* to open it for reading only and, if that succeeds, just let
|
||||||
* the send attempts fail.
|
* the send attempts fail.
|
||||||
*/
|
*/
|
||||||
pd->send_fd = open(cp, O_RDWR);
|
pd->send_fd = open("/dev/dlpi", O_RDWR);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a table of all PPAs for that device, and search that
|
|
||||||
* table for the specified device type name and unit number.
|
|
||||||
*/
|
|
||||||
ppa = get_dlpi_ppa(p->fd, dname, ppa, p->errbuf);
|
|
||||||
if (ppa < 0) {
|
|
||||||
status = ppa;
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* If the device name begins with "/", assume it begins with
|
|
||||||
* the pathname of the directory containing the device to open;
|
|
||||||
* otherwise, concatenate the device directory name and the
|
|
||||||
* device name.
|
|
||||||
*/
|
|
||||||
if (*p->opt.source == '/')
|
|
||||||
strlcpy(dname, p->opt.source, sizeof(dname));
|
|
||||||
else
|
|
||||||
snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
|
||||||
p->opt.source);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the unit number, and a pointer to the end of the device
|
|
||||||
* type name.
|
|
||||||
*/
|
|
||||||
cp = split_dname(dname, &ppa, p->errbuf);
|
|
||||||
if (cp == NULL) {
|
|
||||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make a copy of the device pathname, and then remove the unit
|
|
||||||
* number from the device pathname.
|
|
||||||
*/
|
|
||||||
strlcpy(dname2, dname, sizeof(dname));
|
|
||||||
*cp = '\0';
|
|
||||||
|
|
||||||
/* Try device without unit number */
|
|
||||||
if ((p->fd = open(dname, O_RDWR)) < 0) {
|
|
||||||
if (errno != ENOENT) {
|
|
||||||
if (errno == EPERM || errno == EACCES)
|
|
||||||
status = PCAP_ERROR_PERM_DENIED;
|
|
||||||
else
|
|
||||||
status = PCAP_ERROR;
|
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
|
||||||
pcap_strerror(errno));
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try again with unit number */
|
|
||||||
if ((p->fd = open(dname2, O_RDWR)) < 0) {
|
|
||||||
if (errno == ENOENT) {
|
|
||||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We provide an error message even
|
|
||||||
* for this error, for diagnostic
|
|
||||||
* purposes (so that, for example,
|
|
||||||
* the app can show the message if the
|
|
||||||
* user requests it).
|
|
||||||
*
|
|
||||||
* In it, we just report "No DLPI device
|
|
||||||
* found" with the device name, so people
|
|
||||||
* don't get confused and think, for example,
|
|
||||||
* that if they can't capture on "lo0"
|
|
||||||
* on Solaris the fix is to change libpcap
|
|
||||||
* (or the application that uses it) to
|
|
||||||
* look for something other than "/dev/lo0",
|
|
||||||
* as the fix is to look for an operating
|
|
||||||
* system other than Solaris - you just
|
|
||||||
* *can't* capture on a loopback interface
|
|
||||||
* on Solaris, the lack of a DLPI device
|
|
||||||
* for the loopback interface is just a
|
|
||||||
* symptom of that inability.
|
|
||||||
*/
|
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"%s: No DLPI device found", p->opt.source);
|
|
||||||
} else {
|
|
||||||
if (errno == EPERM || errno == EACCES)
|
|
||||||
status = PCAP_ERROR_PERM_DENIED;
|
|
||||||
else
|
|
||||||
status = PCAP_ERROR;
|
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
|
||||||
dname2, pcap_strerror(errno));
|
|
||||||
}
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
/* XXX Assume unit zero */
|
|
||||||
ppa = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -627,7 +642,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
*/
|
*/
|
||||||
if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) {
|
if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"A_PROMISCON_REQ: %s", pcap_strerror(errno));
|
"A_PROMISCON_REQ: %s", pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -745,7 +760,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
*/
|
*/
|
||||||
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -763,10 +778,10 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
** Ask for bugid 1149065.
|
** Ask for bugid 1149065.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_SOLARIS
|
#ifdef HAVE_SOLARIS
|
||||||
release = get_release(&osmajor, &osminor, &osmicro);
|
get_release(release, sizeof (release), &osmajor, &osminor, &osmicro);
|
||||||
if (osmajor == 5 && (osminor <= 2 || (osminor == 3 && osmicro < 2)) &&
|
if (osmajor == 5 && (osminor <= 2 || (osminor == 3 && osmicro < 2)) &&
|
||||||
getenv("BUFMOD_FIXED") == NULL) {
|
getenv("BUFMOD_FIXED") == NULL) {
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"WARNING: bufmod is broken in SunOS %s; ignoring snaplen.",
|
"WARNING: bufmod is broken in SunOS %s; ignoring snaplen.",
|
||||||
release);
|
release);
|
||||||
ss = 0;
|
ss = 0;
|
||||||
@@ -786,7 +801,7 @@ pcap_activate_dlpi(pcap_t *p)
|
|||||||
*/
|
*/
|
||||||
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -841,7 +856,7 @@ split_dname(char *device, int *unitp, char *ebuf)
|
|||||||
*/
|
*/
|
||||||
cp = device + strlen(device) - 1;
|
cp = device + strlen(device) - 1;
|
||||||
if (*cp < '0' || *cp > '9') {
|
if (*cp < '0' || *cp > '9') {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
||||||
device);
|
device);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@@ -853,16 +868,16 @@ split_dname(char *device, int *unitp, char *ebuf)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
unit = strtol(cp, &eos, 10);
|
unit = strtol(cp, &eos, 10);
|
||||||
if (*eos != '\0') {
|
if (*eos != '\0') {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (errno == ERANGE || unit > INT_MAX) {
|
if (errno == ERANGE || unit > INT_MAX) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number too large",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number too large",
|
||||||
device);
|
device);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (unit < 0) {
|
if (unit < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number is negative",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number is negative",
|
||||||
device);
|
device);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@@ -960,6 +975,56 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Not all interfaces are DLPI interfaces, and thus not all interfaces
|
||||||
|
* can be opened with DLPI (for example, the loopback interface is not
|
||||||
|
* a DLPI interface on Solaris prior to Solaris 11), so try to open
|
||||||
|
* the specified interface; return 0 if we fail with PCAP_ERROR_NO_SUCH_DEVICE
|
||||||
|
* and 1 otherwise.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
is_dlpi_interface(const char *name)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int ppa;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
|
fd = open_dlpi_device(name, &ppa, errbuf);
|
||||||
|
if (fd < 0) {
|
||||||
|
/*
|
||||||
|
* Error - was it PCAP_ERROR_NO_SUCH_DEVICE?
|
||||||
|
*/
|
||||||
|
if (fd == PCAP_ERROR_NO_SUCH_DEVICE) {
|
||||||
|
/*
|
||||||
|
* Yes, so we can't open this because it's
|
||||||
|
* not a DLPI interface.
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* No, so, in the case where there's a single DLPI
|
||||||
|
* device for all interfaces of this type ("style
|
||||||
|
* 2" providers?), we don't know whether it's a DLPI
|
||||||
|
* interface or not, as we didn't try an attach.
|
||||||
|
* Say it is a DLPI device, so that the user can at
|
||||||
|
* least try to open it and report the error (which
|
||||||
|
* is probably "you don't have permission to open that
|
||||||
|
* DLPI device"; reporting those interfaces means
|
||||||
|
* users will ask "why am I getting a permissions error
|
||||||
|
* when I try to capture" rather than "why am I not
|
||||||
|
* seeing any interfaces", making the underlying problem
|
||||||
|
* clearer).
|
||||||
|
*/
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Success.
|
||||||
|
*/
|
||||||
|
close(fd);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
{
|
{
|
||||||
@@ -972,7 +1037,15 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
} buf;
|
} buf;
|
||||||
char baname[2+1+1];
|
char baname[2+1+1];
|
||||||
u_int i;
|
u_int i;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the list of regular interfaces first.
|
||||||
|
*/
|
||||||
|
if (pcap_findalldevs_interfaces(alldevsp, errbuf, is_dlpi_interface) == -1)
|
||||||
|
return (-1); /* failure */
|
||||||
|
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
/*
|
/*
|
||||||
* We may have to do special magic to get ATM devices.
|
* We may have to do special magic to get ATM devices.
|
||||||
*/
|
*/
|
||||||
@@ -989,12 +1062,12 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strioctl(fd, A_GET_UNITS, sizeof(buf), (char *)&buf) < 0) {
|
if (strioctl(fd, A_GET_UNITS, sizeof(buf), (char *)&buf) < 0) {
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "A_GET_UNITS: %s",
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "A_GET_UNITS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
for (i = 0; i < buf.nunits; i++) {
|
for (i = 0; i < buf.nunits; i++) {
|
||||||
snprintf(baname, sizeof baname, "ba%u", i);
|
pcap_snprintf(baname, sizeof baname, "ba%u", i);
|
||||||
if (pcap_add_if(alldevsp, baname, 0, NULL, errbuf) < 0)
|
if (pcap_add_if(alldevsp, baname, 0, NULL, errbuf) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -1015,7 +1088,7 @@ send_request(int fd, char *ptr, int len, char *what, char *ebuf)
|
|||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) {
|
if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"send_request: putmsg \"%s\": %s",
|
"send_request: putmsg \"%s\": %s",
|
||||||
what, pcap_strerror(errno));
|
what, pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -1029,6 +1102,8 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
union DL_primitives *dlp;
|
union DL_primitives *dlp;
|
||||||
struct strbuf ctl;
|
struct strbuf ctl;
|
||||||
int flags;
|
int flags;
|
||||||
|
char errmsgbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
char dlprimbuf[64];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear out "*uerror", so it's only set for DL_ERROR_ACK/DL_SYSERR,
|
* Clear out "*uerror", so it's only set for DL_ERROR_ACK/DL_SYSERR,
|
||||||
@@ -1043,7 +1118,7 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (getmsg(fd, &ctl, (struct strbuf*)NULL, &flags) < 0) {
|
if (getmsg(fd, &ctl, (struct strbuf*)NULL, &flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s getmsg: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s getmsg: %s",
|
||||||
what, pcap_strerror(errno));
|
what, pcap_strerror(errno));
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
@@ -1066,7 +1141,7 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
case DL_SYSERR:
|
case DL_SYSERR:
|
||||||
if (uerror != NULL)
|
if (uerror != NULL)
|
||||||
*uerror = dlp->error_ack.dl_unix_errno;
|
*uerror = dlp->error_ack.dl_unix_errno;
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s: UNIX error - %s",
|
"recv_ack: %s: UNIX error - %s",
|
||||||
what, pcap_strerror(dlp->error_ack.dl_unix_errno));
|
what, pcap_strerror(dlp->error_ack.dl_unix_errno));
|
||||||
if (dlp->error_ack.dl_unix_errno == EPERM ||
|
if (dlp->error_ack.dl_unix_errno == EPERM ||
|
||||||
@@ -1075,8 +1150,9 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
what, dlstrerror(dlp->error_ack.dl_errno));
|
"recv_ack: %s: %s", what,
|
||||||
|
dlstrerror(errmsgbuf, sizeof (errmsgbuf), dlp->error_ack.dl_errno));
|
||||||
if (dlp->error_ack.dl_errno == DL_BADPPA)
|
if (dlp->error_ack.dl_errno == DL_BADPPA)
|
||||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||||
else if (dlp->error_ack.dl_errno == DL_ACCESS)
|
else if (dlp->error_ack.dl_errno == DL_ACCESS)
|
||||||
@@ -1086,14 +1162,14 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s: Unexpected primitive ack %s",
|
"recv_ack: %s: Unexpected primitive ack %s",
|
||||||
what, dlprim(dlp->dl_primitive));
|
what, dlprim(dlprimbuf, sizeof (dlprimbuf), dlp->dl_primitive));
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctl.len < size) {
|
if (ctl.len < size) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s: Ack too small (%d < %d)",
|
"recv_ack: %s: Ack too small (%d < %d)",
|
||||||
what, ctl.len, size);
|
what, ctl.len, size);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
@@ -1102,10 +1178,8 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
dlstrerror(bpf_u_int32 dl_errno)
|
dlstrerror(char *errbuf, size_t errbufsize, bpf_u_int32 dl_errno)
|
||||||
{
|
{
|
||||||
static char errstring[6+2+8+1];
|
|
||||||
|
|
||||||
switch (dl_errno) {
|
switch (dl_errno) {
|
||||||
|
|
||||||
case DL_ACCESS:
|
case DL_ACCESS:
|
||||||
@@ -1206,16 +1280,14 @@ dlstrerror(bpf_u_int32 dl_errno)
|
|||||||
return ("Pending outstanding connect indications");
|
return ("Pending outstanding connect indications");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sprintf(errstring, "Error %02x", dl_errno);
|
pcap_snprintf(errbuf, errbufsize, "Error %02x", dl_errno);
|
||||||
return (errstring);
|
return (errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
dlprim(bpf_u_int32 prim)
|
dlprim(char *primbuf, size_t primbufsize, bpf_u_int32 prim)
|
||||||
{
|
{
|
||||||
static char primbuf[80];
|
|
||||||
|
|
||||||
switch (prim) {
|
switch (prim) {
|
||||||
|
|
||||||
case DL_INFO_REQ:
|
case DL_INFO_REQ:
|
||||||
@@ -1300,7 +1372,8 @@ dlprim(bpf_u_int32 prim)
|
|||||||
return ("DL_RESET_CON");
|
return ("DL_RESET_CON");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
(void) sprintf(primbuf, "unknown primitive 0x%x", prim);
|
pcap_snprintf(primbuf, primbufsize, "unknown primitive 0x%x",
|
||||||
|
prim);
|
||||||
return (primbuf);
|
return (primbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1412,28 +1485,29 @@ dlrawdatareq(int fd, const u_char *datap, int datalen)
|
|||||||
#endif /* DL_HP_RAWDLS */
|
#endif /* DL_HP_RAWDLS */
|
||||||
|
|
||||||
#if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H)
|
#if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H)
|
||||||
static char *
|
static void
|
||||||
get_release(bpf_u_int32 *majorp, bpf_u_int32 *minorp, bpf_u_int32 *microp)
|
get_release(char *buf, size_t bufsize, bpf_u_int32 *majorp,
|
||||||
|
bpf_u_int32 *minorp, bpf_u_int32 *microp)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
static char buf[32];
|
|
||||||
|
|
||||||
*majorp = 0;
|
*majorp = 0;
|
||||||
*minorp = 0;
|
*minorp = 0;
|
||||||
*microp = 0;
|
*microp = 0;
|
||||||
if (sysinfo(SI_RELEASE, buf, sizeof(buf)) < 0)
|
if (sysinfo(SI_RELEASE, buf, bufsize) < 0) {
|
||||||
return ("?");
|
strlcpy(buf, "?", bufsize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
cp = buf;
|
cp = buf;
|
||||||
if (!isdigit((unsigned char)*cp))
|
if (!isdigit((unsigned char)*cp))
|
||||||
return (buf);
|
return;
|
||||||
*majorp = strtol(cp, &cp, 10);
|
*majorp = strtol(cp, &cp, 10);
|
||||||
if (*cp++ != '.')
|
if (*cp++ != '.')
|
||||||
return (buf);
|
return;
|
||||||
*minorp = strtol(cp, &cp, 10);
|
*minorp = strtol(cp, &cp, 10);
|
||||||
if (*cp++ != '.')
|
if (*cp++ != '.')
|
||||||
return (buf);
|
return;
|
||||||
*microp = strtol(cp, &cp, 10);
|
*microp = strtol(cp, &cp, 10);
|
||||||
return (buf);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1521,21 +1595,21 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
|||||||
*/
|
*/
|
||||||
/* get the head first */
|
/* get the head first */
|
||||||
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
|
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
|
"get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
dlp = (dl_hp_ppa_ack_t *)ctl.buf;
|
dlp = (dl_hp_ppa_ack_t *)ctl.buf;
|
||||||
if (dlp->dl_primitive != DL_HP_PPA_ACK) {
|
if (dlp->dl_primitive != DL_HP_PPA_ACK) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa unexpected primitive ack 0x%x",
|
"get_dlpi_ppa: hpppa unexpected primitive ack 0x%x",
|
||||||
(bpf_u_int32)dlp->dl_primitive);
|
(bpf_u_int32)dlp->dl_primitive);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctl.len < DL_HP_PPA_ACK_SIZE) {
|
if (ctl.len < DL_HP_PPA_ACK_SIZE) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
||||||
ctl.len, (unsigned long)DL_HP_PPA_ACK_SIZE);
|
ctl.len, (unsigned long)DL_HP_PPA_ACK_SIZE);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
@@ -1543,7 +1617,7 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
|||||||
|
|
||||||
/* allocate buffer */
|
/* allocate buffer */
|
||||||
if ((ppa_data_buf = (char *)malloc(dlp->dl_length)) == NULL) {
|
if ((ppa_data_buf = (char *)malloc(dlp->dl_length)) == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa malloc: %s", pcap_strerror(errno));
|
"get_dlpi_ppa: hpppa malloc: %s", pcap_strerror(errno));
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
@@ -1552,13 +1626,13 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
|||||||
ctl.buf = (char *)ppa_data_buf;
|
ctl.buf = (char *)ppa_data_buf;
|
||||||
/* get the data */
|
/* get the data */
|
||||||
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
|
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
|
"get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
|
||||||
free(ppa_data_buf);
|
free(ppa_data_buf);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
if (ctl.len < dlp->dl_length) {
|
if (ctl.len < dlp->dl_length) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
||||||
ctl.len, (unsigned long)dlp->dl_length);
|
ctl.len, (unsigned long)dlp->dl_length);
|
||||||
free(ppa_data_buf);
|
free(ppa_data_buf);
|
||||||
@@ -1615,9 +1689,9 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
|||||||
* device number of a device with the name "/dev/<dev><unit>",
|
* device number of a device with the name "/dev/<dev><unit>",
|
||||||
* if such a device exists, as the old code did.
|
* if such a device exists, as the old code did.
|
||||||
*/
|
*/
|
||||||
snprintf(dname, sizeof(dname), "/dev/%s%d", device, unit);
|
pcap_snprintf(dname, sizeof(dname), "/dev/%s%d", device, unit);
|
||||||
if (stat(dname, &statbuf) < 0) {
|
if (stat(dname, &statbuf) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "stat: %s: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "stat: %s: %s",
|
||||||
dname, pcap_strerror(errno));
|
dname, pcap_strerror(errno));
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
@@ -1634,12 +1708,12 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == ap->dl_count) {
|
if (i == ap->dl_count) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"can't find /dev/dlpi PPA for %s%d", device, unit);
|
"can't find /dev/dlpi PPA for %s%d", device, unit);
|
||||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||||
}
|
}
|
||||||
if (ip->dl_hdw_state == HDW_DEAD) {
|
if (ip->dl_hdw_state == HDW_DEAD) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s%d: hardware state: DOWN\n", device, unit);
|
"%s%d: hardware state: DOWN\n", device, unit);
|
||||||
free(ppa_data_buf);
|
free(ppa_data_buf);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
@@ -1678,19 +1752,19 @@ get_dlpi_ppa(register int fd, register const char *ifname, register int unit,
|
|||||||
if (cp != NULL)
|
if (cp != NULL)
|
||||||
ifname = cp + 1;
|
ifname = cp + 1;
|
||||||
if (nlist(path_vmunix, &nl) < 0) {
|
if (nlist(path_vmunix, &nl) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "nlist %s failed",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "nlist %s failed",
|
||||||
path_vmunix);
|
path_vmunix);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (nl[NL_IFNET].n_value == 0) {
|
if (nl[NL_IFNET].n_value == 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"could't find %s kernel symbol",
|
"could't find %s kernel symbol",
|
||||||
nl[NL_IFNET].n_name);
|
nl[NL_IFNET].n_name);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
kd = open("/dev/kmem", O_RDONLY);
|
kd = open("/dev/kmem", O_RDONLY);
|
||||||
if (kd < 0) {
|
if (kd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "kmem open: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "kmem open: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -1712,7 +1786,7 @@ get_dlpi_ppa(register int fd, register const char *ifname, register int unit,
|
|||||||
return (ifnet.if_index);
|
return (ifnet.if_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Can't find %s", ifname);
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "Can't find %s", ifname);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1723,17 +1797,17 @@ dlpi_kread(register int fd, register off_t addr,
|
|||||||
register int cc;
|
register int cc;
|
||||||
|
|
||||||
if (lseek(fd, addr, SEEK_SET) < 0) {
|
if (lseek(fd, addr, SEEK_SET) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "lseek: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "lseek: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
cc = read(fd, buf, len);
|
cc = read(fd, buf, len);
|
||||||
if (cc < 0) {
|
if (cc < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "read: %s",
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "read: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
} else if (cc != len) {
|
} else if (cc != len) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,
|
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,
|
||||||
len);
|
len);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -1742,14 +1816,14 @@ dlpi_kread(register int fd, register off_t addr,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
pcap_t *
|
pcap_t *
|
||||||
pcap_create_interface(const char *device, char *ebuf)
|
pcap_create_interface(const char *device _U_, char *ebuf)
|
||||||
{
|
{
|
||||||
pcap_t *p;
|
pcap_t *p;
|
||||||
#ifdef DL_HP_RAWDLS
|
#ifdef DL_HP_RAWDLS
|
||||||
struct pcap_dlpi *pd;
|
struct pcap_dlpi *pd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dlpi));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_dlpi));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of DOS-libpcap
|
* This file is part of DOS-libpcap
|
||||||
* Ported to DOS/DOSX by G. Vanem <gvanem@broadpark.no>
|
* Ported to DOS/DOSX by G. Vanem <gvanem@yahoo.no>
|
||||||
*
|
*
|
||||||
* pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
|
* pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
|
||||||
* network drivers.
|
* network drivers.
|
||||||
@@ -149,11 +149,11 @@ struct pcap_dos {
|
|||||||
struct pcap_stat stat;
|
struct pcap_stat stat;
|
||||||
};
|
};
|
||||||
|
|
||||||
pcap_t *pcap_create_interface (const char *device, char *ebuf)
|
pcap_t *pcap_create_interface (const char *device _U_, char *ebuf)
|
||||||
{
|
{
|
||||||
pcap_t *p;
|
pcap_t *p;
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dos));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_dos));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@@ -167,8 +167,6 @@ pcap_t *pcap_create_interface (const char *device, char *ebuf)
|
|||||||
*/
|
*/
|
||||||
static int pcap_activate_dos (pcap_t *pcap)
|
static int pcap_activate_dos (pcap_t *pcap)
|
||||||
{
|
{
|
||||||
struct pcap_dos *pcapd = pcap->priv;
|
|
||||||
|
|
||||||
if (pcap->opt.rfmon) {
|
if (pcap->opt.rfmon) {
|
||||||
/*
|
/*
|
||||||
* No monitor mode on DOS.
|
* No monitor mode on DOS.
|
||||||
@@ -191,20 +189,23 @@ static int pcap_activate_dos (pcap_t *pcap)
|
|||||||
pcap->setdirection_op = NULL; /* Not implemented.*/
|
pcap->setdirection_op = NULL; /* Not implemented.*/
|
||||||
pcap->fd = ++ref_count;
|
pcap->fd = ++ref_count;
|
||||||
|
|
||||||
|
pcap->bufsize = ETH_MAX+100; /* add some margin */
|
||||||
|
pcap->buffer = calloc (pcap->bufsize, 1);
|
||||||
|
|
||||||
if (pcap->fd == 1) /* first time we're called */
|
if (pcap->fd == 1) /* first time we're called */
|
||||||
{
|
{
|
||||||
if (!init_watt32(pcap, pcap->opt.source, pcap->errbuf) ||
|
if (!init_watt32(pcap, pcap->opt.device, pcap->errbuf) ||
|
||||||
!first_init(pcap->opt.source, pcap->errbuf, pcap->opt.promisc))
|
!first_init(pcap->opt.device, pcap->errbuf, pcap->opt.promisc))
|
||||||
{
|
{
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
atexit (close_driver);
|
atexit (close_driver);
|
||||||
}
|
}
|
||||||
else if (stricmp(active_dev->name,pcap->opt.source))
|
else if (stricmp(active_dev->name,pcap->opt.device))
|
||||||
{
|
{
|
||||||
snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"Cannot use different devices simultaneously "
|
"Cannot use different devices simultaneously "
|
||||||
"(`%s' vs. `%s')", active_dev->name, pcap->opt.source);
|
"(`%s' vs. `%s')", active_dev->name, pcap->opt.device);
|
||||||
return (PCAP_ERROR);
|
return (PCAP_ERROR);
|
||||||
}
|
}
|
||||||
handle_to_device [pcap->fd-1] = active_dev;
|
handle_to_device [pcap->fd-1] = active_dev;
|
||||||
@@ -221,7 +222,6 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
struct pcap_dos *pd = p->priv;
|
struct pcap_dos *pd = p->priv;
|
||||||
struct pcap_pkthdr pcap;
|
struct pcap_pkthdr pcap;
|
||||||
struct timeval now, expiry = { 0,0 };
|
struct timeval now, expiry = { 0,0 };
|
||||||
BYTE *rx_buf;
|
|
||||||
int rx_len = 0;
|
int rx_len = 0;
|
||||||
|
|
||||||
if (p->opt.timeout > 0)
|
if (p->opt.timeout > 0)
|
||||||
@@ -253,13 +253,11 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
if (dev->peek_rx_buf)
|
if (dev->peek_rx_buf)
|
||||||
{
|
{
|
||||||
PCAP_ASSERT (dev->release_rx_buf);
|
PCAP_ASSERT (dev->release_rx_buf);
|
||||||
rx_len = (*dev->peek_rx_buf) (&rx_buf);
|
rx_len = (*dev->peek_rx_buf) (&p->buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BYTE buf [ETH_MAX+100]; /* add some margin */
|
rx_len = (*dev->copy_rx_buf) (p->buffer, p->snapshot);
|
||||||
rx_len = (*dev->copy_rx_buf) (buf, p->snapshot);
|
|
||||||
rx_buf = buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_len > 0) /* got a packet */
|
if (rx_len > 0) /* got a packet */
|
||||||
@@ -272,7 +270,7 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
pcap.len = rx_len;
|
pcap.len = rx_len;
|
||||||
|
|
||||||
if (callback &&
|
if (callback &&
|
||||||
(!p->fcode.bf_insns || bpf_filter(p->fcode.bf_insns, rx_buf, pcap.len, pcap.caplen)))
|
(!p->fcode.bf_insns || bpf_filter(p->fcode.bf_insns, p->buffer, pcap.len, pcap.caplen)))
|
||||||
{
|
{
|
||||||
filter_count++;
|
filter_count++;
|
||||||
|
|
||||||
@@ -280,11 +278,11 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
* capture.
|
* capture.
|
||||||
*/
|
*/
|
||||||
gettimeofday2 (&pcap.ts, NULL);
|
gettimeofday2 (&pcap.ts, NULL);
|
||||||
(*callback) (data, &pcap, rx_buf);
|
(*callback) (data, &pcap, p->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->release_rx_buf)
|
if (dev->release_rx_buf)
|
||||||
(*dev->release_rx_buf) (rx_buf);
|
(*dev->release_rx_buf) (p->buffer);
|
||||||
|
|
||||||
if (pcap_pkt_debug > 0)
|
if (pcap_pkt_debug > 0)
|
||||||
{
|
{
|
||||||
@@ -296,6 +294,18 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Has "pcap_breakloop()" been called?
|
||||||
|
*/
|
||||||
|
if (p->break_loop) {
|
||||||
|
/*
|
||||||
|
* Yes - clear the flag that indicates that it
|
||||||
|
* has, and return -2 to indicate that we were
|
||||||
|
* told to break out of the loop.
|
||||||
|
*/
|
||||||
|
p->break_loop = 0;
|
||||||
|
return (-2);
|
||||||
|
}
|
||||||
|
|
||||||
/* If not to wait for a packet or pcap_cleanup_dos() called from
|
/* If not to wait for a packet or pcap_cleanup_dos() called from
|
||||||
* e.g. SIGINT handler, exit loop now.
|
* e.g. SIGINT handler, exit loop now.
|
||||||
*/
|
*/
|
||||||
@@ -311,8 +321,8 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
kbhit(); /* a real CPU hog */
|
kbhit(); /* a real CPU hog */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (p->wait_proc)
|
if (pd->wait_proc)
|
||||||
(*p->wait_proc)(); /* call yield func */
|
(*pd->wait_proc)(); /* call yield func */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_len < 0) /* receive error */
|
if (rx_len < 0) /* receive error */
|
||||||
@@ -330,7 +340,6 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
|
|||||||
static int
|
static int
|
||||||
pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
|
pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
|
||||||
{
|
{
|
||||||
struct pcap_dos *pd = p->priv;
|
|
||||||
int rc, num = 0;
|
int rc, num = 0;
|
||||||
|
|
||||||
while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
|
while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
|
||||||
@@ -442,7 +451,7 @@ static void pcap_cleanup_dos (pcap_t *p)
|
|||||||
{
|
{
|
||||||
struct pcap_dos *pd;
|
struct pcap_dos *pd;
|
||||||
|
|
||||||
if (p && !exc_occured)
|
if (!exc_occured)
|
||||||
{
|
{
|
||||||
pd = p->priv;
|
pd = p->priv;
|
||||||
if (pcap_stats(p,NULL) < 0)
|
if (pcap_stats(p,NULL) < 0)
|
||||||
@@ -495,6 +504,8 @@ char *pcap_lookupdev (char *ebuf)
|
|||||||
int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
||||||
bpf_u_int32 *netmask, char *errbuf)
|
bpf_u_int32 *netmask, char *errbuf)
|
||||||
{
|
{
|
||||||
|
DWORD mask, net;
|
||||||
|
|
||||||
if (!_watt_is_init)
|
if (!_watt_is_init)
|
||||||
{
|
{
|
||||||
strcpy (errbuf, "pcap_open_offline() or pcap_activate() must be "
|
strcpy (errbuf, "pcap_open_offline() or pcap_activate() must be "
|
||||||
@@ -502,22 +513,25 @@ int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
*netmask = _w32_sin_mask;
|
mask = _w32_sin_mask;
|
||||||
*localnet = my_ip_addr & *netmask;
|
net = my_ip_addr & mask;
|
||||||
if (*localnet == 0)
|
if (net == 0)
|
||||||
{
|
{
|
||||||
if (IN_CLASSA(*netmask))
|
if (IN_CLASSA(*netmask))
|
||||||
*localnet = IN_CLASSA_NET;
|
net = IN_CLASSA_NET;
|
||||||
else if (IN_CLASSB(*netmask))
|
else if (IN_CLASSB(*netmask))
|
||||||
*localnet = IN_CLASSB_NET;
|
net = IN_CLASSB_NET;
|
||||||
else if (IN_CLASSC(*netmask))
|
else if (IN_CLASSC(*netmask))
|
||||||
*localnet = IN_CLASSC_NET;
|
net = IN_CLASSC_NET;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (errbuf, "inet class for 0x%lx unknown", *netmask);
|
pcap_snprintf (errbuf, PCAP_ERRBUF_SIZE, "inet class for 0x%lx unknown", mask);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*localnet = htonl (net);
|
||||||
|
*netmask = htonl (mask);
|
||||||
|
|
||||||
ARGSUSED (device);
|
ARGSUSED (device);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -525,17 +539,17 @@ int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
|
|||||||
/*
|
/*
|
||||||
* Get a list of all interfaces that are present and that we probe okay.
|
* Get a list of all interfaces that are present and that we probe okay.
|
||||||
* Returns -1 on error, 0 otherwise.
|
* Returns -1 on error, 0 otherwise.
|
||||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
* The list, as returned through "alldevsp", may be NULL if no interfaces
|
||||||
* were up and could be opened.
|
* were up and could be opened.
|
||||||
*/
|
*/
|
||||||
int pcap_findalldevs (pcap_if_t **alldevsp, char *errbuf)
|
int pcap_platform_finddevs (pcap_if_t **alldevsp, char *errbuf)
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct sockaddr_ll sa_ll_1, sa_ll_2;
|
struct sockaddr_in sa_ll_1, sa_ll_2;
|
||||||
struct sockaddr *addr, *netmask, *broadaddr, *dstaddr;
|
struct sockaddr *addr, *netmask, *broadaddr, *dstaddr;
|
||||||
pcap_if_t *devlist = NULL;
|
pcap_if_t *devlist = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t addr_size = sizeof(struct sockaddr_ll);
|
size_t addr_size = sizeof(*addr);
|
||||||
|
|
||||||
for (dev = (struct device*)dev_base; dev; dev = dev->next)
|
for (dev = (struct device*)dev_base; dev; dev = dev->next)
|
||||||
{
|
{
|
||||||
@@ -550,14 +564,14 @@ int pcap_findalldevs (pcap_if_t **alldevsp, char *errbuf)
|
|||||||
|
|
||||||
memset (&sa_ll_1, 0, sizeof(sa_ll_1));
|
memset (&sa_ll_1, 0, sizeof(sa_ll_1));
|
||||||
memset (&sa_ll_2, 0, sizeof(sa_ll_2));
|
memset (&sa_ll_2, 0, sizeof(sa_ll_2));
|
||||||
sa_ll_1.sll_family = AF_PACKET;
|
sa_ll_1.sin_family = AF_INET;
|
||||||
sa_ll_2.sll_family = AF_PACKET;
|
sa_ll_2.sin_family = AF_INET;
|
||||||
|
|
||||||
addr = (struct sockaddr*) &sa_ll_1;
|
addr = (struct sockaddr*) &sa_ll_1;
|
||||||
netmask = (struct sockaddr*) &sa_ll_1;
|
netmask = (struct sockaddr*) &sa_ll_1;
|
||||||
dstaddr = (struct sockaddr*) &sa_ll_1;
|
dstaddr = (struct sockaddr*) &sa_ll_1;
|
||||||
broadaddr = (struct sockaddr*) &sa_ll_2;
|
broadaddr = (struct sockaddr*) &sa_ll_2;
|
||||||
memset (&sa_ll_2.sll_addr, 0xFF, sizeof(sa_ll_2.sll_addr));
|
memset (&sa_ll_2.sin_addr, 0xFF, sizeof(sa_ll_2.sin_addr));
|
||||||
|
|
||||||
if (pcap_add_if(&devlist, dev->name, dev->flags,
|
if (pcap_add_if(&devlist, dev->name, dev->flags,
|
||||||
dev->long_name, errbuf) < 0)
|
dev->long_name, errbuf) < 0)
|
||||||
@@ -565,6 +579,7 @@ int pcap_findalldevs (pcap_if_t **alldevsp, char *errbuf)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if 0 /* Pkt drivers should have no addresses */
|
||||||
if (add_addr_to_iflist(&devlist, dev->name, dev->flags, addr, addr_size,
|
if (add_addr_to_iflist(&devlist, dev->name, dev->flags, addr, addr_size,
|
||||||
netmask, addr_size, broadaddr, addr_size,
|
netmask, addr_size, broadaddr, addr_size,
|
||||||
dstaddr, addr_size, errbuf) < 0)
|
dstaddr, addr_size, errbuf) < 0)
|
||||||
@@ -572,6 +587,7 @@ int pcap_findalldevs (pcap_if_t **alldevsp, char *errbuf)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devlist && ret < 0)
|
if (devlist && ret < 0)
|
||||||
@@ -605,10 +621,10 @@ void pcap_assert (const char *what, const char *file, unsigned line)
|
|||||||
*/
|
*/
|
||||||
void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait)
|
void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait)
|
||||||
{
|
{
|
||||||
struct pcap_dos *pd;
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
pd = p->priv;
|
struct pcap_dos *pd = p->priv;
|
||||||
|
|
||||||
pd->wait_proc = yield;
|
pd->wait_proc = yield;
|
||||||
p->opt.timeout = wait;
|
p->opt.timeout = wait;
|
||||||
}
|
}
|
||||||
@@ -635,7 +651,7 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||||||
|
|
||||||
if (!(*dev->probe)(dev)) /* call the xx_probe() function */
|
if (!(*dev->probe)(dev)) /* call the xx_probe() function */
|
||||||
{
|
{
|
||||||
sprintf (ebuf, "failed to detect device `%s'", dev_name);
|
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to detect device `%s'", dev_name);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
probed_dev = dev; /* device is probed okay and may be used */
|
probed_dev = dev; /* device is probed okay and may be used */
|
||||||
@@ -657,7 +673,7 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||||||
|
|
||||||
if (!(*dev->open)(dev))
|
if (!(*dev->open)(dev))
|
||||||
{
|
{
|
||||||
sprintf (ebuf, "failed to activate device `%s'", dev_name);
|
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to activate device `%s'", dev_name);
|
||||||
if (pktInfo.error && !strncmp(dev->name,"pkt",3))
|
if (pktInfo.error && !strncmp(dev->name,"pkt",3))
|
||||||
{
|
{
|
||||||
strcat (ebuf, ": ");
|
strcat (ebuf, ": ");
|
||||||
@@ -679,14 +695,14 @@ open_driver (const char *dev_name, char *ebuf, int promisc)
|
|||||||
*/
|
*/
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
sprintf (ebuf, "device `%s' not supported", dev_name);
|
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not supported", dev_name);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
not_probed:
|
not_probed:
|
||||||
if (!probed_dev)
|
if (!probed_dev)
|
||||||
{
|
{
|
||||||
sprintf (ebuf, "device `%s' not probed", dev_name);
|
pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not probed", dev_name);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
return (dev);
|
return (dev);
|
||||||
@@ -756,7 +772,7 @@ static void exc_handler (int sig)
|
|||||||
fprintf (stderr, "Catching signal %d.\n", sig);
|
fprintf (stderr, "Catching signal %d.\n", sig);
|
||||||
}
|
}
|
||||||
exc_occured = 1;
|
exc_occured = 1;
|
||||||
pcap_cleanup_dos (NULL);
|
close_driver();
|
||||||
}
|
}
|
||||||
#endif /* __DJGPP__ */
|
#endif /* __DJGPP__ */
|
||||||
|
|
||||||
@@ -933,7 +949,7 @@ static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
|
|||||||
if (_watt_is_init)
|
if (_watt_is_init)
|
||||||
sock_exit();
|
sock_exit();
|
||||||
|
|
||||||
env = getenv ("PCAP_DEBUG");
|
env = getenv ("PCAP_TRACE");
|
||||||
if (env && atoi(env) > 0 &&
|
if (env && atoi(env) > 0 &&
|
||||||
pcap_pkt_debug < 0) /* if not already set */
|
pcap_pkt_debug < 0) /* if not already set */
|
||||||
{
|
{
|
||||||
@@ -973,7 +989,7 @@ static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
|
|||||||
}
|
}
|
||||||
else if (rc && using_pktdrv)
|
else if (rc && using_pktdrv)
|
||||||
{
|
{
|
||||||
sprintf (err_buf, "sock_init() failed, code %d", rc);
|
pcap_snprintf (err_buf, PCAP_ERRBUF_SIZE, "sock_init() failed, code %d", rc);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,9 +1069,9 @@ static const struct config_table debug_tab[] = {
|
|||||||
* pcap_config_hook() is an extension to application's config
|
* pcap_config_hook() is an extension to application's config
|
||||||
* handling. Uses Watt-32's config-table function.
|
* handling. Uses Watt-32's config-table function.
|
||||||
*/
|
*/
|
||||||
int pcap_config_hook (const char *name, const char *value)
|
int pcap_config_hook (const char *keyword, const char *value)
|
||||||
{
|
{
|
||||||
return parse_config_table (debug_tab, NULL, name, value);
|
return parse_config_table (debug_tab, NULL, keyword, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
.\"
|
.\"
|
||||||
.TH PCAP-FILTER @MAN_MISC_INFO@ "17 May 2013"
|
.TH PCAP-FILTER @MAN_MISC_INFO@ "3 August 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pcap-filter \- packet filter syntax
|
pcap-filter \- packet filter syntax
|
||||||
.br
|
.br
|
||||||
@@ -298,7 +298,7 @@ of protocol type \fIprotocol\fP.
|
|||||||
\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
|
\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
|
||||||
\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
|
\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
|
||||||
Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
|
Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
|
||||||
keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
|
keywords and must be escaped via backslash (\\).
|
||||||
Note that this primitive does not chase the protocol header chain.
|
Note that this primitive does not chase the protocol header chain.
|
||||||
.IP "\fBip6 proto \fIprotocol\fR"
|
.IP "\fBip6 proto \fIprotocol\fR"
|
||||||
True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
|
True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
|
||||||
@@ -372,9 +372,9 @@ True if the packet is of ether type \fIprotocol\fR.
|
|||||||
Note these identifiers are also keywords
|
Note these identifiers are also keywords
|
||||||
and must be escaped via backslash (\\).
|
and must be escaped via backslash (\\).
|
||||||
.IP
|
.IP
|
||||||
[In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), Token Ring
|
[In the case of FDDI (e.g., `\fBfddi proto arp\fR'), Token Ring
|
||||||
(e.g., `\fBtr protocol arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
|
(e.g., `\fBtr proto arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
|
||||||
`\fBwlan protocol arp\fR'), for most of those protocols, the
|
`\fBwlan proto arp\fR'), for most of those protocols, the
|
||||||
protocol identification comes from the 802.2 Logical Link Control (LLC)
|
protocol identification comes from the 802.2 Logical Link Control (LLC)
|
||||||
header, which is usually layered on top of the FDDI, Token Ring, or
|
header, which is usually layered on top of the FDDI, Token Ring, or
|
||||||
802.11 header.
|
802.11 header.
|
||||||
@@ -879,8 +879,7 @@ The following TCP flags field values are available: \fBtcp-fin\fP,
|
|||||||
.LP
|
.LP
|
||||||
Primitives may be combined using:
|
Primitives may be combined using:
|
||||||
.IP
|
.IP
|
||||||
A parenthesized group of primitives and operators
|
A parenthesized group of primitives and operators.
|
||||||
(parentheses are special to the Shell and must be escaped).
|
|
||||||
.IP
|
.IP
|
||||||
Negation (`\fB!\fP' or `\fBnot\fP').
|
Negation (`\fB!\fP' or `\fBnot\fP').
|
||||||
.IP
|
.IP
|
||||||
|
|||||||
@@ -40,12 +40,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(_WIN32)
|
||||||
|
/*
|
||||||
|
* Make sure Packet32.h doesn't define BPF structures that we've
|
||||||
|
* probably already defined as a result of including <pcap/pcap.h>.
|
||||||
|
*/
|
||||||
|
#define BPF_MAJOR_VERSION
|
||||||
#include <Packet32.h>
|
#include <Packet32.h>
|
||||||
extern CRITICAL_SECTION g_PcapCompileCriticalSection;
|
#elif defined(MSDOS)
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
#ifdef MSDOS
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -106,9 +108,9 @@ extern CRITICAL_SECTION g_PcapCompileCriticalSection;
|
|||||||
#define MAXIMUM_SNAPLEN 262144
|
#define MAXIMUM_SNAPLEN 262144
|
||||||
|
|
||||||
struct pcap_opt {
|
struct pcap_opt {
|
||||||
char *source;
|
char *device;
|
||||||
int timeout; /* timeout for buffering */
|
int timeout; /* timeout for buffering */
|
||||||
int buffer_size;
|
u_int buffer_size;
|
||||||
int promisc;
|
int promisc;
|
||||||
int rfmon; /* monitor mode */
|
int rfmon; /* monitor mode */
|
||||||
int immediate; /* immediate mode - deliver packets as soon as they arrive */
|
int immediate; /* immediate mode - deliver packets as soon as they arrive */
|
||||||
@@ -126,11 +128,19 @@ typedef int (*set_datalink_op_t)(pcap_t *, int);
|
|||||||
typedef int (*getnonblock_op_t)(pcap_t *, char *);
|
typedef int (*getnonblock_op_t)(pcap_t *, char *);
|
||||||
typedef int (*setnonblock_op_t)(pcap_t *, int, char *);
|
typedef int (*setnonblock_op_t)(pcap_t *, int, char *);
|
||||||
typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
|
typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
|
typedef struct pcap_stat *(*stats_ex_op_t)(pcap_t *, int *);
|
||||||
typedef int (*setbuff_op_t)(pcap_t *, int);
|
typedef int (*setbuff_op_t)(pcap_t *, int);
|
||||||
typedef int (*setmode_op_t)(pcap_t *, int);
|
typedef int (*setmode_op_t)(pcap_t *, int);
|
||||||
typedef int (*setmintocopy_op_t)(pcap_t *, int);
|
typedef int (*setmintocopy_op_t)(pcap_t *, int);
|
||||||
typedef Adapter *(*getadapter_op_t)(pcap_t *);
|
typedef HANDLE (*getevent_op_t)(pcap_t *);
|
||||||
|
typedef int (*oid_get_request_op_t)(pcap_t *, bpf_u_int32, void *, size_t *);
|
||||||
|
typedef int (*oid_set_request_op_t)(pcap_t *, bpf_u_int32, const void *, size_t *);
|
||||||
|
typedef u_int (*sendqueue_transmit_op_t)(pcap_t *, pcap_send_queue *, int);
|
||||||
|
typedef int (*setuserbuffer_op_t)(pcap_t *, int);
|
||||||
|
typedef int (*live_dump_op_t)(pcap_t *, char *, int, int);
|
||||||
|
typedef int (*live_dump_ended_op_t)(pcap_t *, int);
|
||||||
|
typedef PAirpcapHandle (*get_airpcap_handle_op_t)(pcap_t *);
|
||||||
#endif
|
#endif
|
||||||
typedef void (*cleanup_op_t)(pcap_t *);
|
typedef void (*cleanup_op_t)(pcap_t *);
|
||||||
|
|
||||||
@@ -145,24 +155,22 @@ struct pcap {
|
|||||||
read_op_t read_op;
|
read_op_t read_op;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method to call to read to read packets from a savefile.
|
* Method to call to read packets from a savefile.
|
||||||
*/
|
*/
|
||||||
int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
|
int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
ADAPTER *adapter;
|
ADAPTER *adapter;
|
||||||
LPPACKET Packet;
|
|
||||||
int nonblock;
|
|
||||||
#else
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
int selectable_fd;
|
int selectable_fd;
|
||||||
#endif /* WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read buffer.
|
* Read buffer.
|
||||||
*/
|
*/
|
||||||
int bufsize;
|
u_int bufsize;
|
||||||
u_char *buffer;
|
void *buffer;
|
||||||
u_char *bp;
|
u_char *bp;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
@@ -172,7 +180,7 @@ struct pcap {
|
|||||||
|
|
||||||
int swapped;
|
int swapped;
|
||||||
FILE *rfile; /* null if live capture, non-null if savefile */
|
FILE *rfile; /* null if live capture, non-null if savefile */
|
||||||
int fddipad;
|
u_int fddipad;
|
||||||
struct pcap *next; /* list of open pcaps that need stuff cleared on close */
|
struct pcap *next; /* list of open pcaps that need stuff cleared on close */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -199,6 +207,10 @@ struct pcap {
|
|||||||
*/
|
*/
|
||||||
u_char *pkt;
|
u_char *pkt;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct pcap_stat stat; /* used for pcap_stats_ex() */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We're accepting only packets in this direction/these directions. */
|
/* We're accepting only packets in this direction/these directions. */
|
||||||
pcap_direction_t direction;
|
pcap_direction_t direction;
|
||||||
|
|
||||||
@@ -240,15 +252,23 @@ struct pcap {
|
|||||||
*/
|
*/
|
||||||
pcap_handler oneshot_callback;
|
pcap_handler oneshot_callback;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
/*
|
/*
|
||||||
* These are, at least currently, specific to the Win32 NPF
|
* These are, at least currently, specific to the Win32 NPF
|
||||||
* driver.
|
* driver.
|
||||||
*/
|
*/
|
||||||
|
stats_ex_op_t stats_ex_op;
|
||||||
setbuff_op_t setbuff_op;
|
setbuff_op_t setbuff_op;
|
||||||
setmode_op_t setmode_op;
|
setmode_op_t setmode_op;
|
||||||
setmintocopy_op_t setmintocopy_op;
|
setmintocopy_op_t setmintocopy_op;
|
||||||
getadapter_op_t getadapter_op;
|
getevent_op_t getevent_op;
|
||||||
|
oid_get_request_op_t oid_get_request_op;
|
||||||
|
oid_set_request_op_t oid_set_request_op;
|
||||||
|
sendqueue_transmit_op_t sendqueue_transmit_op;
|
||||||
|
setuserbuffer_op_t setuserbuffer_op;
|
||||||
|
live_dump_op_t live_dump_op;
|
||||||
|
live_dump_ended_op_t live_dump_ended_op;
|
||||||
|
get_airpcap_handle_op_t get_airpcap_handle_op;
|
||||||
#endif
|
#endif
|
||||||
cleanup_op_t cleanup_op;
|
cleanup_op_t cleanup_op;
|
||||||
};
|
};
|
||||||
@@ -338,34 +358,15 @@ struct oneshot_userdata {
|
|||||||
pcap_t *pd;
|
pcap_t *pd;
|
||||||
};
|
};
|
||||||
|
|
||||||
int yylex(void);
|
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
#define min(a, b) ((a) > (b) ? (b) : (a))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XXX should these be in pcap.h? */
|
|
||||||
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
|
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
|
||||||
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
|
|
||||||
|
|
||||||
#ifndef HAVE_STRLCPY
|
|
||||||
#define strlcpy(x, y, z) \
|
|
||||||
(strncpy((x), (y), (z)), \
|
|
||||||
((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
|
|
||||||
strlen((y)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if !defined(HAVE_SNPRINTF)
|
#include "portability.h"
|
||||||
#define snprintf pcap_snprintf
|
|
||||||
extern int snprintf (char *, size_t, const char *, ...);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(HAVE_VSNPRINTF)
|
|
||||||
#define vsnprintf pcap_vsnprintf
|
|
||||||
extern int vsnprintf (char *, size_t, const char *, va_list ap);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does the packet count argument to a module's read routine say
|
* Does the packet count argument to a module's read routine say
|
||||||
@@ -376,7 +377,7 @@ extern int vsnprintf (char *, size_t, const char *, va_list ap);
|
|||||||
/*
|
/*
|
||||||
* Routines that most pcap implementations can use for non-blocking mode.
|
* Routines that most pcap implementations can use for non-blocking mode.
|
||||||
*/
|
*/
|
||||||
#if !defined(WIN32) && !defined(MSDOS)
|
#if !defined(_WIN32) && !defined(MSDOS)
|
||||||
int pcap_getnonblock_fd(pcap_t *, char *);
|
int pcap_getnonblock_fd(pcap_t *, char *);
|
||||||
int pcap_setnonblock_fd(pcap_t *p, int, char *);
|
int pcap_setnonblock_fd(pcap_t *p, int, char *);
|
||||||
#endif
|
#endif
|
||||||
@@ -393,38 +394,43 @@ int pcap_setnonblock_fd(pcap_t *p, int, char *);
|
|||||||
* by pcap_create routines.
|
* by pcap_create routines.
|
||||||
*/
|
*/
|
||||||
pcap_t *pcap_create_interface(const char *, char *);
|
pcap_t *pcap_create_interface(const char *, char *);
|
||||||
pcap_t *pcap_create_common(const char *, char *, size_t);
|
pcap_t *pcap_create_common(char *, size_t);
|
||||||
int pcap_do_addexit(pcap_t *);
|
int pcap_do_addexit(pcap_t *);
|
||||||
void pcap_add_to_pcaps_to_close(pcap_t *);
|
void pcap_add_to_pcaps_to_close(pcap_t *);
|
||||||
void pcap_remove_from_pcaps_to_close(pcap_t *);
|
void pcap_remove_from_pcaps_to_close(pcap_t *);
|
||||||
void pcap_cleanup_live_common(pcap_t *);
|
void pcap_cleanup_live_common(pcap_t *);
|
||||||
int pcap_not_initialized(pcap_t *);
|
|
||||||
int pcap_check_activated(pcap_t *);
|
int pcap_check_activated(pcap_t *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal interfaces for "pcap_findalldevs()".
|
* Internal interfaces for "pcap_findalldevs()".
|
||||||
*
|
*
|
||||||
* "pcap_findalldevs_interfaces()" finds interfaces using the
|
|
||||||
* "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.).
|
|
||||||
*
|
|
||||||
* "pcap_platform_finddevs()" is a platform-dependent routine to
|
* "pcap_platform_finddevs()" is a platform-dependent routine to
|
||||||
* add devices not found by the "standard" mechanisms.
|
* find local network interfaces.
|
||||||
|
*
|
||||||
|
* "pcap_findalldevs_interfaces()" is a helper to find those interfaces
|
||||||
|
* using the "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.).
|
||||||
*
|
*
|
||||||
* "pcap_add_if()" adds an interface to the list of interfaces, for
|
* "pcap_add_if()" adds an interface to the list of interfaces, for
|
||||||
* use by various "find interfaces" routines.
|
* use by various "find interfaces" routines.
|
||||||
*/
|
*/
|
||||||
int pcap_findalldevs_interfaces(pcap_if_t **, char *);
|
|
||||||
int pcap_platform_finddevs(pcap_if_t **, char *);
|
int pcap_platform_finddevs(pcap_if_t **, char *);
|
||||||
int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
|
#if !defined(_WIN32) && !defined(MSDOS)
|
||||||
size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
|
int pcap_findalldevs_interfaces(pcap_if_t **, char *,
|
||||||
struct sockaddr *, size_t, char *);
|
int (*)(const char *));
|
||||||
|
#endif
|
||||||
|
int add_addr_to_iflist(pcap_if_t **, const char *, bpf_u_int32,
|
||||||
|
struct sockaddr *, size_t, struct sockaddr *, size_t,
|
||||||
|
struct sockaddr *, size_t, struct sockaddr *, size_t, char *);
|
||||||
int add_addr_to_dev(pcap_if_t *, struct sockaddr *, size_t,
|
int add_addr_to_dev(pcap_if_t *, struct sockaddr *, size_t,
|
||||||
struct sockaddr *, size_t, struct sockaddr *, size_t,
|
struct sockaddr *, size_t, struct sockaddr *, size_t,
|
||||||
struct sockaddr *dstaddr, size_t, char *errbuf);
|
struct sockaddr *dstaddr, size_t, char *errbuf);
|
||||||
int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *);
|
int pcap_add_if(pcap_if_t **, const char *, bpf_u_int32, const char *,
|
||||||
struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
|
char *);
|
||||||
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
|
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, bpf_u_int32,
|
||||||
const char *, char *);
|
const char *, char *);
|
||||||
|
#ifndef _WIN32
|
||||||
|
bpf_u_int32 if_flags_to_pcap_flags(const char *, u_int);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal interfaces for "pcap_open_offline()".
|
* Internal interfaces for "pcap_open_offline()".
|
||||||
@@ -448,8 +454,8 @@ void sf_cleanup(pcap_t *p);
|
|||||||
*/
|
*/
|
||||||
void pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
|
void pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
char *pcap_win32strerror(void);
|
void pcap_win32_err_to_str(DWORD, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int install_bpf_program(pcap_t *, struct bpf_program *);
|
int install_bpf_program(pcap_t *, struct bpf_program *);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||||||
* dlpi_open() will not fail if the underlying link does not support
|
* dlpi_open() will not fail if the underlying link does not support
|
||||||
* passive mode. See dlpi(7P) for details.
|
* passive mode. See dlpi(7P) for details.
|
||||||
*/
|
*/
|
||||||
retv = dlpi_open(p->opt.source, &dh, DLPI_RAW|DLPI_PASSIVE);
|
retv = dlpi_open(p->opt.device, &dh, DLPI_RAW|DLPI_PASSIVE);
|
||||||
if (retv != DLPI_SUCCESS) {
|
if (retv != DLPI_SUCCESS) {
|
||||||
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK)
|
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK)
|
||||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||||
@@ -115,7 +115,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||||||
status = PCAP_ERROR_PERM_DENIED;
|
status = PCAP_ERROR_PERM_DENIED;
|
||||||
else
|
else
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
pcap_libdlpi_err(p->opt.source, "dlpi_open", retv,
|
pcap_libdlpi_err(p->opt.device, "dlpi_open", retv,
|
||||||
p->errbuf);
|
p->errbuf);
|
||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||||||
/* Bind with DLPI_ANY_SAP. */
|
/* Bind with DLPI_ANY_SAP. */
|
||||||
if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
|
if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
pcap_libdlpi_err(p->opt.source, "dlpi_bind", retv, p->errbuf);
|
pcap_libdlpi_err(p->opt.device, "dlpi_bind", retv, p->errbuf);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||||||
/* Determine link type. */
|
/* Determine link type. */
|
||||||
if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
|
if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
pcap_libdlpi_err(p->opt.source, "dlpi_info", retv, p->errbuf);
|
pcap_libdlpi_err(p->opt.device, "dlpi_info", retv, p->errbuf);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
|||||||
*/
|
*/
|
||||||
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
||||||
status = PCAP_ERROR;
|
status = PCAP_ERROR;
|
||||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
|
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -258,13 +258,24 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
|||||||
err = PCAP_ERROR_PERM_DENIED;
|
err = PCAP_ERROR_PERM_DENIED;
|
||||||
else
|
else
|
||||||
err = PCAP_ERROR;
|
err = PCAP_ERROR;
|
||||||
pcap_libdlpi_err(p->opt.source, "dlpi_promiscon" STRINGIFY(level),
|
pcap_libdlpi_err(p->opt.device, "dlpi_promiscon" STRINGIFY(level),
|
||||||
retv, p->errbuf);
|
retv, p->errbuf);
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Presumably everything returned by dlpi_walk() is a DLPI device,
|
||||||
|
* so there's no work to be done here to check whether name refers
|
||||||
|
* to a DLPI device.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
is_dlpi_interface(const char *name _U_)
|
||||||
|
{
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In Solaris, the "standard" mechanism" i.e SIOCGLIFCONF will only find
|
* In Solaris, the "standard" mechanism" i.e SIOCGLIFCONF will only find
|
||||||
* network links that are plumbed and are up. dlpi_walk(3DLPI) will find
|
* network links that are plumbed and are up. dlpi_walk(3DLPI) will find
|
||||||
@@ -279,12 +290,18 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
|||||||
linkwalk_t lw = {NULL, 0};
|
linkwalk_t lw = {NULL, 0};
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the list of regular interfaces first.
|
||||||
|
*/
|
||||||
|
if (pcap_findalldevs_interfaces(alldevsp, errbuf, is_dlpi_interface) == -1)
|
||||||
|
return (-1); /* failure */
|
||||||
|
|
||||||
/* dlpi_walk() for loopback will be added here. */
|
/* dlpi_walk() for loopback will be added here. */
|
||||||
|
|
||||||
dlpi_walk(list_interfaces, &lw, 0);
|
dlpi_walk(list_interfaces, &lw, 0);
|
||||||
|
|
||||||
if (lw.lw_err != 0) {
|
if (lw.lw_err != 0) {
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"dlpi_walk: %s", pcap_strerror(lw.lw_err));
|
"dlpi_walk: %s", pcap_strerror(lw.lw_err));
|
||||||
retv = -1;
|
retv = -1;
|
||||||
goto done;
|
goto done;
|
||||||
@@ -337,7 +354,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
msglen = p->bufsize;
|
msglen = p->bufsize;
|
||||||
bufp = p->buffer + p->offset;
|
bufp = (u_char *)p->buffer + p->offset;
|
||||||
|
|
||||||
retv = dlpi_recv(pd->dlpi_hd, NULL, NULL, bufp,
|
retv = dlpi_recv(pd->dlpi_hd, NULL, NULL, bufp,
|
||||||
&msglen, -1, NULL);
|
&msglen, -1, NULL);
|
||||||
@@ -404,16 +421,16 @@ pcap_cleanup_libdlpi(pcap_t *p)
|
|||||||
static void
|
static void
|
||||||
pcap_libdlpi_err(const char *linkname, const char *func, int err, char *errbuf)
|
pcap_libdlpi_err(const char *linkname, const char *func, int err, char *errbuf)
|
||||||
{
|
{
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "libpcap: %s failed on %s: %s",
|
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "libpcap: %s failed on %s: %s",
|
||||||
func, linkname, dlpi_strerror(err));
|
func, linkname, dlpi_strerror(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
pcap_t *
|
pcap_t *
|
||||||
pcap_create_interface(const char *device, char *ebuf)
|
pcap_create_interface(const char *device _U_, char *ebuf)
|
||||||
{
|
{
|
||||||
pcap_t *p;
|
pcap_t *p;
|
||||||
|
|
||||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dlpi));
|
p = pcap_create_common(ebuf, sizeof (struct pcap_dlpi));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
.\"
|
.\"
|
||||||
.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "12 March 2011"
|
.TH PCAP-LINKTYPE @MAN_MISC_INFO@ "7 April 2014"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pcap-linktype \- link-layer header types supported by libpcap
|
pcap-linktype \- link-layer header types supported by libpcap
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user