summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc/CMakeLists.txt
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-17 14:02:34 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-08-17 16:10:03 +0200
commit7ae3d85c7249b9e8846bc87fdf44e8621a370565 (patch)
tree89a861ef5dd33a2055650347beddfb4ca39a9a35 /src/ipcpd/shim-eth-llc/CMakeLists.txt
parentaa3416215e980a2ec87ac259be0ea39f1caf96df (diff)
downloadouroboros-7ae3d85c7249b9e8846bc87fdf44e8621a370565.tar.gz
ouroboros-7ae3d85c7249b9e8846bc87fdf44e8621a370565.zip
ipcpd: Support Berkeley Packet Filter in LLC shim
This adds support reading Ethernet frames using the Berkeley Packet Filter (BPF). Ouroboros now fully runs on OS X Sierra.
Diffstat (limited to 'src/ipcpd/shim-eth-llc/CMakeLists.txt')
-rw-r--r--src/ipcpd/shim-eth-llc/CMakeLists.txt63
1 files changed, 43 insertions, 20 deletions
diff --git a/src/ipcpd/shim-eth-llc/CMakeLists.txt b/src/ipcpd/shim-eth-llc/CMakeLists.txt
index 12bfb42e..21003cf0 100644
--- a/src/ipcpd/shim-eth-llc/CMakeLists.txt
+++ b/src/ipcpd/shim-eth-llc/CMakeLists.txt
@@ -17,31 +17,54 @@ find_path(NETMAP_C_INCLUDE_DIR
HINTS /usr/include /usr/local/include
)
-protobuf_generate_c(SHIM_ETH_LLC_PROTO_SRCS SHIM_ETH_LLC_PROTO_HDRS
- shim_eth_llc_messages.proto)
-
-set(IPCP_SHIM_ETH_LLC_TARGET ipcpd-shim-eth-llc
- CACHE STRING "IPCP_SHIM_ETH_LLC_TARGET")
-
-set(SHIM_ETH_LLC_SOURCES
- # Add source files here
- ${CMAKE_CURRENT_SOURCE_DIR}/main.c)
+find_path(BPF_C_INCLUDE_DIR
+ net/bpf.h
+ HINTS /usr/include /usr/local/include
+ )
-add_executable(ipcpd-shim-eth-llc ${SHIM_ETH_LLC_SOURCES} ${IPCP_SOURCES}
- ${SHIM_ETH_LLC_PROTO_SRCS})
-target_link_libraries(ipcpd-shim-eth-llc LINK_PUBLIC ouroboros
- ${PROTOBUF_C_LIBRARY})
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
+ NOT BPF_C_INCLUDE_DIR STREQUAL "BPF_C_INCLUDE_DIR-NOTFOUND")
+ message(STATUS "Found Berkeley Packet Filter headers in ${BPF_C_INCLUDE_DIR}")
+ set(HAVE_BPF "1" CACHE STRING "Have Berkeley Packet Filter")
+endif ()
-if (NOT ${NETMAP_C_INCLUDE_DIR} STREQUAL "NETMAP_C_INCLUDE_DIR-NOTFOUND")
+if (NOT NETMAP_C_INCLUDE_DIR STREQUAL "NETMAP_C_INCLUDE_DIR-NOTFOUND")
message(STATUS "Found netmap headers in ${NETMAP_C_INCLUDE_DIR}")
- include_directories(${NETMAP_C_INCLUDE_DIR})
set(HAVE_NETMAP "1" CACHE STRING "Have netmap")
test_and_set_c_compiler_flag_global(-std=c99)
endif ()
-include(AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES Debug)
- add_compile_flags(ipcpd-shim-eth-llc -DCONFIG_OUROBOROS_DEBUG)
-endif (CMAKE_BUILD_TYPE MATCHES Debug)
+if (HAVE_NETMAP OR HAVE_BPF OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ message(STATUS "Supported raw Ethernet API found, building shim-eth-llc")
+ protobuf_generate_c(SHIM_ETH_LLC_PROTO_SRCS SHIM_ETH_LLC_PROTO_HDRS
+ shim_eth_llc_messages.proto)
+
+ set(SHIM_ETH_LLC_SOURCES
+ # Add source files here
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.c
+ )
+
+ set(IPCP_SHIM_ETH_LLC_TARGET ipcpd-shim-eth-llc
+ CACHE STRING "IPCP_SHIM_ETH_LLC_TARGET")
+
+ add_executable(ipcpd-shim-eth-llc ${SHIM_ETH_LLC_SOURCES} ${IPCP_SOURCES}
+ ${SHIM_ETH_LLC_PROTO_SRCS})
+
+ if (HAVE_BPF AND NOT APPLE)
+ target_include_directories(ipcpd-shim-eth-llc PUBLIC ${BPF_C_INCLUDE_DIR})
+ endif ()
+
+ if (HAVE_NETMAP AND NOT APPLE)
+ target_include_directories(ipcpd-shim-eth-llc PUBLIC ${NETMAP_C_INCLUDE_DIR})
+ endif ()
-install(TARGETS ipcpd-shim-eth-llc RUNTIME DESTINATION sbin)
+ target_link_libraries(ipcpd-shim-eth-llc LINK_PUBLIC ouroboros
+ ${PROTOBUF_C_LIBRARY})
+
+ include(AddCompileFlags)
+ if (CMAKE_BUILD_TYPE MATCHES Debug)
+ add_compile_flags(ipcpd-shim-eth-llc -DCONFIG_OUROBOROS_DEBUG)
+ endif (CMAKE_BUILD_TYPE MATCHES Debug)
+
+ install(TARGETS ipcpd-shim-eth-llc RUNTIME DESTINATION sbin)
+endif ()