Skip to content

Commit 6dd2390

Browse files
jukkarkartben
authored andcommitted
samples: net: txtime: Refactor VLAN support
Move the common VLAN setup code to samples/net/common directory so that other network samples can utilize that too. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent f47c5a6 commit 6dd2390

File tree

5 files changed

+9
-197
lines changed

5 files changed

+9
-197
lines changed

samples/net/sockets/txtime/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
66
project(sockets_txtime)
77

88
target_sources(app PRIVATE src/main.c)
9-
target_sources_ifdef(CONFIG_NET_VLAN app PRIVATE src/vlan.c)
9+
10+
include(${ZEPHYR_BASE}/samples/net/common/common.cmake)

samples/net/sockets/txtime/Kconfig

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -63,42 +63,5 @@ config NET_SAMPLE_PACKET_TXTIME
6363
but for purpose of this sample application, we set the time in
6464
microseconds in this config option.
6565

66-
config NET_SAMPLE_IFACE2_MY_IPV6_ADDR
67-
string "My IPv6 address for second interface"
68-
help
69-
The value depends on your network setup.
70-
71-
config NET_SAMPLE_IFACE2_MY_IPV4_ADDR
72-
string "My IPv4 address for second interface"
73-
help
74-
The value depends on your network setup.
75-
76-
config NET_SAMPLE_IFACE2_VLAN_TAG
77-
int "VLAN tag for second interface"
78-
default 100
79-
range 0 4094
80-
depends on NET_VLAN
81-
help
82-
Set VLAN (virtual LAN) tag (id) that is used in the sample
83-
application.
84-
85-
config NET_SAMPLE_IFACE3_MY_IPV6_ADDR
86-
string "My IPv6 address for third interface"
87-
help
88-
The value depends on your network setup.
89-
90-
config NET_SAMPLE_IFACE3_MY_IPV4_ADDR
91-
string "My IPv4 address for third interface"
92-
help
93-
The value depends on your network setup.
94-
95-
config NET_SAMPLE_IFACE3_VLAN_TAG
96-
int "VLAN tag for third interface"
97-
default 200
98-
range 0 4094
99-
depends on NET_VLAN
100-
help
101-
Set VLAN (virtual LAN) tag (id) that is used in the sample
102-
application.
103-
66+
source "samples/net/common/Kconfig"
10467
source "Kconfig.zephyr"

samples/net/sockets/txtime/overlay-vlan.conf

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
1111
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
1212
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
1313

14-
# Second ethernet interface will have these settings
15-
CONFIG_NET_SAMPLE_IFACE2_MY_IPV6_ADDR="2001:db8:100::1"
16-
# TEST-NET-2 from RFC 5737
17-
CONFIG_NET_SAMPLE_IFACE2_MY_IPV4_ADDR="198.51.100.1"
18-
# VLAN tag for the second interface
19-
CONFIG_NET_SAMPLE_IFACE2_VLAN_TAG=100
14+
# First VLAN interface will have these settings
15+
CONFIG_NET_SAMPLE_COMMON_VLAN_SETUP_1="100;2001:db8:100::1/64,198.51.100.1/24"
2016

21-
# Settings for the third network interface
22-
CONFIG_NET_SAMPLE_IFACE3_MY_IPV6_ADDR="2001:db8:200::1"
23-
# TEST-NET-3 from RFC 5737
24-
CONFIG_NET_SAMPLE_IFACE3_MY_IPV4_ADDR="203.0.113.1"
25-
# VLAN tag for the second interface
26-
CONFIG_NET_SAMPLE_IFACE3_VLAN_TAG=200
17+
# Second VLAN interface will have these settings
18+
CONFIG_NET_SAMPLE_COMMON_VLAN_SETUP_2="200;2001:db8:200::1/64,203.0.113.1/24"

samples/net/sockets/txtime/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ LOG_MODULE_REGISTER(net_txtime_sample, LOG_LEVEL_DBG);
2222
#include <zephyr/net/ethernet.h>
2323
#include <zephyr/net/ethernet_mgmt.h>
2424

25+
#include "net_sample_common.h"
26+
2527
#define APP_BANNER "Run SO_TXTIME client"
2628

2729
#define DHCPV4_MASK (NET_EVENT_IPV4_DHCP_BOUND | \
@@ -63,8 +65,6 @@ K_SEM_DEFINE(run_app, 0, 1);
6365
static bool want_to_quit;
6466
static bool connected;
6567

66-
extern int init_vlan(void);
67-
6868
static void quit(void)
6969
{
7070
k_sem_give(&quit_lock);

samples/net/sockets/txtime/src/vlan.c

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)