4 ###################################################################
6 # Copyright (c) 2006 Frederic Heem, <frederic.heem@telsey.it>
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
13 # * Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
16 # * Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in
18 # the documentation and/or other materials provided with the
21 # * Neither the name of the Telsey nor the names of its
22 # contributors may be used to endorse or promote products derived
23 # from this software without specific prior written permission.
25 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 # POSSIBILITY OF SUCH DAMAGE.
38 ###################################################################
40 # Find the PCAP includes and library
41 # http://www.tcpdump.org/
43 # The environment variable PCAPDIR allows to specficy where to find
44 # libpcap in non standard location.
46 # PCAP_INCLUDE_DIRS - where to find pcap.h, etc.
47 # PCAP_LIBRARIES - List of libraries when using pcap.
48 # PCAP_FOUND - True if pcap found.
51 IF(EXISTS $ENV{PCAPDIR})
52 FIND_PATH(PCAP_INCLUDE_DIR
61 FIND_LIBRARY(PCAP_LIBRARY
70 ELSE(EXISTS $ENV{PCAPDIR})
71 FIND_PATH(PCAP_INCLUDE_DIR
77 FIND_LIBRARY(PCAP_LIBRARY
82 ENDIF(EXISTS $ENV{PCAPDIR})
84 SET(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
85 SET(PCAP_LIBRARIES ${PCAP_LIBRARY})
88 MESSAGE(STATUS "Pcap include dirs set to ${PCAP_INCLUDE_DIRS}")
89 ELSE(PCAP_INCLUDE_DIRS)
90 MESSAGE(FATAL " Pcap include dirs cannot be found")
91 ENDIF(PCAP_INCLUDE_DIRS)
94 MESSAGE(STATUS "Pcap library set to ${PCAP_LIBRARIES}")
96 MESSAGE(FATAL "Pcap library cannot be found")
100 INCLUDE(CheckFunctionExists)
101 SET(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
102 SET(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES})
103 CHECK_FUNCTION_EXISTS("pcap_breakloop" HAVE_PCAP_BREAKLOOP)
104 CHECK_FUNCTION_EXISTS("pcap_datalink_name_to_val" HAVE_PCAP_DATALINK_NAME_TO_VAL)
105 CHECK_FUNCTION_EXISTS("pcap_datalink_val_to_name" HAVE_PCAP_DATALINK_VAL_TO_NAME)
106 CHECK_FUNCTION_EXISTS("pcap_findalldevs" HAVE_PCAP_FINDALLDEVS)
107 CHECK_FUNCTION_EXISTS("pcap_freecode" HAVE_PCAP_FREECODE)
108 CHECK_FUNCTION_EXISTS("pcap_get_selectable_fd" HAVE_PCAP_GET_SELECTABLE_FD)
109 CHECK_FUNCTION_EXISTS("pcap_lib_version" HAVE_PCAP_LIB_VERSION)
110 CHECK_FUNCTION_EXISTS("pcap_list_datalinks" HAVE_PCAP_LIST_DATALINKS)
111 CHECK_FUNCTION_EXISTS("pcap_open_dead" HAVE_PCAP_OPEN_DEAD)
112 CHECK_FUNCTION_EXISTS("pcap_set_datalink" HAVE_PCAP_SET_DATALINK)
116 IF(PCAP_INCLUDE_DIRS AND PCAP_LIBRARIES)
117 SET( PCAP_FOUND "YES" )
118 ENDIF(PCAP_INCLUDE_DIRS AND PCAP_LIBRARIES)