Skip to content

Commit 05b9ffb

Browse files
aurel32fabiobaltieri
authored andcommitted
net: mqtt_sn: document address size and add support for IPv6
Add guidelines in Kconfig explaining the minimum required MQTT_SN_LIB_MAX_ADDR_SIZE for UDP transport and IPv4 and or IPv6. Also explain when this value might need to be changed. Use these values to provide a sane default for IPv4 and IPv6. Signed-off-by: Aurelien Jarno <[email protected]>
1 parent 3d77a76 commit 05b9ffb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

samples/net/mqtt_sn_publisher/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
3737
CONFIG_MQTT_SN_LIB=y
3838
CONFIG_MQTT_SN_TRANSPORT_UDP=y
3939
CONFIG_MQTT_SN_LIB_BROADCAST_RADIUS=1
40-
CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE=24
4140
CONFIG_NET_SAMPLE_MQTT_SN_STATIC_GATEWAY=y
4241
CONFIG_NET_SAMPLE_MQTT_SN_GATEWAY_ADDRESS="192.0.2.2:10000"
4342
CONFIG_NET_SAMPLE_MQTT_SN_BROADCAST_ADDRESS="225.1.1.1:1883"

subsys/net/lib/mqtt_sn/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ config MQTT_SN_LIB_MAX_GATEWAYS
3838

3939
config MQTT_SN_LIB_MAX_ADDR_SIZE
4040
int "Maximum address size for the transport"
41+
default 24 if NET_IPV6
42+
default 8 if NET_IPV4
4143
default 21
4244
range 1 $(UINT8_MAX)
4345
help
4446
The MQTT_SN library stores addresses internally and thus
4547
needs to know how long your addresses are. Set this to the maximum
4648
length in bytes of the address data structure for your implemented transport.
4749

50+
A UDP transport requires at least 8 bytes on IPv4 and 24 bytes on
51+
IPv6, corresponding to the sizes of the sockaddr_in and sockaddr_in6
52+
structs. For an out-of-tree transport, you may need to adjust this
53+
value.
54+
4855
config MQTT_SN_LIB_BROADCAST_RADIUS
4956
int "Radius for broadcast messages"
5057
default 1

0 commit comments

Comments
 (0)