Skip to content

Commit 029acb9

Browse files
committed
tcpreplay: extend configurability of injection library
tcpreplay can inject packets using a number of mechanisms/libraries. A default one is PF_PACKET, another one is libdnet, and also libpcap. This change adds a menu configuration to select the preffered one. However, if another library selects (libpcap for example), this would also affect the library. Signed-off-by: Alexandru Ardelean <[email protected]>
1 parent ffa24c1 commit 029acb9

File tree

2 files changed

+77
-7
lines changed

2 files changed

+77
-7
lines changed

net/tcpreplay/Config.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
menu "Configuration"
2+
depends on PACKAGE_tcpreplay-dependencies
3+
4+
choice
5+
prompt "Preferred injection mechanism"
6+
default TCPREPLAY_PF_PACKET
7+
8+
config TCPREPLAY_PF_PACKET
9+
bool "Linux PF_PACKET"
10+
11+
config TCPREPLAY_LIBDNET
12+
bool "libdnet"
13+
select PACKAGE_libdnet
14+
15+
config CONFIG_TCPREPLAY_LIBPCAP_INJECT
16+
bool "libpcap inject() function"
17+
select PACKAGE_libpcap
18+
19+
config CONFIG_TCPREPLAY_LIBPCAP_SEND_PACKET
20+
bool "libpcap sendpacket() function"
21+
select PACKAGE_libpcap
22+
23+
config TCPREPLAY_LIBBPF
24+
bool "libbpf"
25+
select PACKAGE_libbpf
26+
27+
endchoice
28+
29+
endmenu

net/tcpreplay/Makefile

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=tcpreplay
1111
PKG_VERSION:=4.5.2
12-
PKG_RELEASE:=1
12+
PKG_RELEASE:=2
1313

1414
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
1515
PKG_SOURCE_URL:=https://github.com/appneta/tcpreplay/releases/download/v$(PKG_VERSION)
@@ -29,13 +29,30 @@ TCPREPLAY_MODULES:= \
2929
tcpbridge tcpcapinfo tcpliveplay tcpprep \
3030
tcpreplay tcpreplay-edit tcprewrite
3131

32-
define Package/tcpreplay/default
32+
define Package/tcpreplay/base
3333
SUBMENU:=Tcpreplay
3434
SECTION:=net
3535
CATEGORY:=Network
3636
URL:=http://tcpreplay.appneta.com/
3737
MAINTAINER:=Alexandru Ardelean <[email protected]>
38-
DEPENDS:=+librt +libpcap +libdnet +USE_MUSL:musl-fts
38+
endef
39+
40+
define Package/tcpreplay/default
41+
$(call Package/tcpreplay/base)
42+
DEPENDS:=+librt +USE_MUSL:musl-fts \
43+
+PACKAGE_lidnet:libdnet \
44+
+PACKAGE_libpcap:libpcap \
45+
+PACKAGE_libbpf:libbpf \
46+
+tcpreplay-dependencies
47+
endef
48+
49+
define Package/tcpreplay-dependencies
50+
$(call Package/tcpreplay/base)
51+
TITLE:=Dependency handling for tcpreplay packages
52+
endef
53+
54+
define Package/tcpreplay-dependencies/config
55+
source "$(SOURCE)/Config.in"
3956
endef
4057

4158
define Package/tcpbridge
@@ -116,6 +133,10 @@ define Package/tcprewrite/description
116133
Rewrite/edit the packets in a pcap file
117134
endef
118135

136+
define Package/tcpreplay-dependencies/description
137+
A meta package to select preferred library for tcpreplay (libdnet, libpcap, libbpf, etc).
138+
endef
139+
119140
define Package/tcpreplay-all/description
120141
Tcpreplay is a suite of free Open Source utilities for
121142
editing and replaying previously captured network traffic.
@@ -139,10 +160,24 @@ CONFIGURE_VARS += \
139160
ac_cv_path_pcncfg=no
140161

141162
CONFIGURE_ARGS += \
142-
--enable-force-pf \
143-
--enable-dynamic-link \
144-
--with-libdnet="$(STAGING_DIR)/usr" \
145-
--with-libpcap="$(STAGING_DIR)/usr"
163+
--enable-dynamic-link
164+
165+
ifneq ($(CONFIG_TCPREPLAY_LIBBPF),)
166+
CONFIGURE_ARGS += \
167+
--enable-force-bpf
168+
else ifneq ($(CONFIG_TCPREPLAY_LIBPCAP_INJECT),)
169+
CONFIGURE_ARGS += \
170+
--enable-force-inject
171+
else ifneq ($(CONFIG_TCPREPLAY_LIBPCAP_SEND_PACKET),)
172+
CONFIGURE_ARGS += \
173+
--enable-force-sendpacket
174+
else ifneq ($(CONFIG_TCPREPLAY_LIBDNET),)
175+
CONFIGURE_ARGS += \
176+
--enable-force-libdnet
177+
else
178+
CONFIGURE_ARGS += \
179+
--enable-force-pf
180+
endif
146181

147182
TARGET_CFLAGS += -std=gnu11
148183

@@ -153,10 +188,16 @@ define tcpreplayTemplate
153188
endef
154189
endef
155190

191+
define Package/tcpreplay-dependencies/install
192+
:
193+
endef
194+
156195
define Package/tcpreplay-all/install
157196
:
158197
endef
159198

199+
$(eval $(call BuildPackage,tcpreplay-dependencies))
200+
160201
$(foreach m, $(TCPREPLAY_MODULES), \
161202
$(eval $(call tcpreplayTemplate,$(m))) \
162203
$(eval $(call BuildPackage,$(m))) \

0 commit comments

Comments
 (0)