apps/examples/udp: The UDP test example has been extend to support IPv6 domain sockets
This commit is contained in:
parent
2becaa5455
commit
a49685c155
@ -121,18 +121,19 @@ $(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c
|
|||||||
|
|
||||||
$(HOST_OBJS): %$(HOSTOBJEXT): %.c
|
$(HOST_OBJS): %$(HOSTOBJEXT): %.c
|
||||||
@echo "CC: $<"
|
@echo "CC: $<"
|
||||||
@$(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
$(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
||||||
|
|
||||||
|
config.h: $(TOPDIR)/include/nuttx/config.h
|
||||||
|
@echo "CP: $<"
|
||||||
|
$(Q) cp $< $@
|
||||||
|
|
||||||
$(HOST_BIN): config.h $(HOST_OBJS)
|
$(HOST_BIN): config.h $(HOST_OBJS)
|
||||||
@echo "LD: $@"
|
@echo "LD: $@"
|
||||||
@$(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
$(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
||||||
|
|
||||||
config.h: $(TOPDIR)/include/nuttx/config.h
|
|
||||||
@cp $< $@
|
|
||||||
|
|
||||||
.built: config.h $(TARG_OBJS)
|
.built: config.h $(TARG_OBJS)
|
||||||
$(call ARCHIVE, $(TARG_BIN), $(TARG_OBJS))
|
$(call ARCHIVE, $(TARG_BIN), $(TARG_OBJS))
|
||||||
@touch .built
|
$(Q) touch .built
|
||||||
|
|
||||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
config EXAMPLES_UDP
|
config EXAMPLES_UDP
|
||||||
bool "UDP example"
|
bool "UDP example"
|
||||||
default n
|
default n
|
||||||
|
depends on NET_UDP
|
||||||
---help---
|
---help---
|
||||||
Enable the UDP example
|
Enable the UDP example
|
||||||
|
|
||||||
@ -15,6 +16,25 @@ config EXAMPLES_UDP_SERVER
|
|||||||
bool "Target is the server"
|
bool "Target is the server"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "IP Domain"
|
||||||
|
default EXAMPLES_UDP_IPv4 if NET_IPv4
|
||||||
|
default EXAMPLES_UDP_IPv6 if NET_IPv6 && !NET_IPv4
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv4
|
||||||
|
bool "IPv4"
|
||||||
|
depends on NET_IPv4
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6
|
||||||
|
bool "IPv6"
|
||||||
|
depends on NET_IPv6
|
||||||
|
|
||||||
|
endchoice # IP Domain
|
||||||
|
|
||||||
|
if EXAMPLES_UDP_IPv4
|
||||||
|
|
||||||
|
comment "IPv4 addresses"
|
||||||
|
|
||||||
config EXAMPLES_UDP_IPADDR
|
config EXAMPLES_UDP_IPADDR
|
||||||
hex "Target IP address"
|
hex "Target IP address"
|
||||||
default 0x0a000002
|
default 0x0a000002
|
||||||
@ -32,4 +52,387 @@ config EXAMPLES_UDP_SERVERIP
|
|||||||
default 0x0a000001 if !EXAMPLES_UDP_SERVER
|
default 0x0a000001 if !EXAMPLES_UDP_SERVER
|
||||||
default 0x0a000002 if EXAMPLES_UDP_SERVER
|
default 0x0a000002 if EXAMPLES_UDP_SERVER
|
||||||
|
|
||||||
|
|
||||||
|
endif # EXAMPLES_UDP_IPv4
|
||||||
|
|
||||||
|
if EXAMPLES_UDP_IPv6
|
||||||
|
|
||||||
|
comment "Target IPv6 address"
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_1
|
||||||
|
hex "[0]"
|
||||||
|
default 0xfc00
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the first of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_2
|
||||||
|
hex "[1]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the second of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_3
|
||||||
|
hex "[2]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the third of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_4
|
||||||
|
hex "[3]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the fourth of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_5
|
||||||
|
hex "[4]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the fifth of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_6
|
||||||
|
hex "[5]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the sixth of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_7
|
||||||
|
hex "[6]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the seventh of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6ADDR_8
|
||||||
|
hex "[7]"
|
||||||
|
default 0x0002
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||||
|
Each of the eight values forming the full IP address must be
|
||||||
|
specified individually. This is the last of the 8-values. The
|
||||||
|
default for all eight values is fc00::2.
|
||||||
|
|
||||||
|
comment "Router IPv6 address"
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_1
|
||||||
|
hex "[0]"
|
||||||
|
default 0xfc00
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the first of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_2
|
||||||
|
hex "[1]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the second of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_3
|
||||||
|
hex "[2]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the third of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_4
|
||||||
|
hex "[3]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the fourth of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_5
|
||||||
|
hex "[4]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the fifth of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_6
|
||||||
|
hex "[5]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the sixth of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_7
|
||||||
|
hex "[6]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the seventh of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_DRIPv6ADDR_8
|
||||||
|
hex "[7]"
|
||||||
|
default 0x0001
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||||
|
value in host order. Each of the eight values forming the full IP
|
||||||
|
address must be specified individually. This is the last of the
|
||||||
|
8-values. The default for all eight values is fc00::1.
|
||||||
|
|
||||||
|
comment "IPv6 Network mask"
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_1
|
||||||
|
hex "[0]"
|
||||||
|
default 0xfe00
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the first of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_2
|
||||||
|
hex "[1]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the second of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_3
|
||||||
|
hex "[2]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the third of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_4
|
||||||
|
hex "[3]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0x0000
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the fourth of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_5
|
||||||
|
hex "[4]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the fifth of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_6
|
||||||
|
hex "[5]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the sixth of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_7
|
||||||
|
hex "[6]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the seventh of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_IPv6NETMASK_8
|
||||||
|
hex "[7]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
Network mask. This is a 16-bit integer value in host order. Each
|
||||||
|
of the eight values forming the full IP address must be specified
|
||||||
|
individually. This is the eighth of the 8-values. The default for
|
||||||
|
all eight values is fe00::0.
|
||||||
|
|
||||||
|
comment "Client IPv6 address"
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_1
|
||||||
|
hex "[0]"
|
||||||
|
default 0xfc00
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the first of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_2
|
||||||
|
hex "[1]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the second of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_3
|
||||||
|
hex "[2]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the Third of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_4
|
||||||
|
hex "[3]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the fourth of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_5
|
||||||
|
hex "[4]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the fifth of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_6
|
||||||
|
hex "[5]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the sixth of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_7
|
||||||
|
hex "[6]"
|
||||||
|
default 0x0000
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the seventh of the 8-values.
|
||||||
|
|
||||||
|
config EXAMPLES_UDP_SERVERIPv6ADDR_8
|
||||||
|
hex "[7]"
|
||||||
|
default 0x0001 if !EXAMPLES_UDP_SERVER
|
||||||
|
default 0x0002 if EXAMPLES_UDP_SERVER
|
||||||
|
range 0x0 0xffff
|
||||||
|
---help---
|
||||||
|
IP address of the server. If the target is the server, then
|
||||||
|
EXAMPLES_UDP_SERVERIP should be the same as
|
||||||
|
EXAMPLES_UDP_IPADDR (default). If the target is the server,
|
||||||
|
then the default value of EXAMPLES_UDP_SERVERIP is set to the
|
||||||
|
host PC IP address (possibly the gateway address,
|
||||||
|
EXAMPLES_UDP_DRIPADDR?).
|
||||||
|
|
||||||
|
This is a 16-bit integer value in host order. Each of the eight
|
||||||
|
values forming the full IP address must be specified individually.
|
||||||
|
This is the last of the 8-values.
|
||||||
|
|
||||||
|
endif # EXAMPLES_UDP_IPv6
|
||||||
endif # EXAMPLES_UDP
|
endif # EXAMPLES_UDP
|
||||||
|
@ -70,11 +70,7 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HOSTCFLAGS += -DCONFIG_EXAMPLES_UDP_HOST=1
|
HOSTCFLAGS += -DEXAMPLES_UDP_HOST=1
|
||||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER),y)
|
|
||||||
HOSTCFLAGS += -DCONFIG_EXAMPLES_UDP_SERVER=1 \
|
|
||||||
-DCONFIG_EXAMPLES_UDP_SERVERIP="$(CONFIG_EXAMPLES_UDP_SERVERIP)"
|
|
||||||
endif
|
|
||||||
|
|
||||||
HOST_SRCS = host.c
|
HOST_SRCS = host.c
|
||||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER),y)
|
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER),y)
|
||||||
@ -114,13 +110,18 @@ $(TARG_BIN): $(TARG_OBJS) $(HOST_BIN)
|
|||||||
$(call ARCHIVE, $@, $(TARG_OBJS))
|
$(call ARCHIVE, $@, $(TARG_OBJS))
|
||||||
|
|
||||||
$(HOST_OBJS): %.o: %.c
|
$(HOST_OBJS): %.o: %.c
|
||||||
$(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
@echo "CC: $<"
|
||||||
|
$(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
||||||
|
|
||||||
$(HOST_BIN): $(HOST_OBJS)
|
config.h: $(TOPDIR)/include/nuttx/config.h
|
||||||
$(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
@echo "CP: $<"
|
||||||
|
$(Q) cp $< $@
|
||||||
|
|
||||||
.built: $(TARG_BIN) $(HOST_BIN)
|
$(HOST_BIN): config.h $(HOST_OBJS)
|
||||||
@touch .built
|
$(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
||||||
|
|
||||||
|
.built: config.h $(TARG_BIN) $(HOST_BIN)
|
||||||
|
$(Q) touch .built
|
||||||
|
|
||||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
||||||
@ -148,6 +149,7 @@ clean:
|
|||||||
$(call DELFILE, $(TARG_BIN))
|
$(call DELFILE, $(TARG_BIN))
|
||||||
$(call DELFILE, $(HOST_BIN))
|
$(call DELFILE, $(HOST_BIN))
|
||||||
$(call DELFILE, *.dSYM)
|
$(call DELFILE, *.dSYM)
|
||||||
|
$(call DELFILE, config.h)
|
||||||
$(call CLEAN)
|
$(call CLEAN)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "udp-internal.h"
|
#include "udp-internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* examples/udp/target.c
|
* examples/udp/target.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2011, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -37,7 +37,8 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
@ -56,6 +57,50 @@
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
/* Our host IPv6 address */
|
||||||
|
|
||||||
|
static const uint16_t g_ipv6_hostaddr[8] =
|
||||||
|
{
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_1),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_2),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_3),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_4),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_5),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_6),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_7),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_8),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Default routine IPv6 address */
|
||||||
|
|
||||||
|
static const uint16_t g_ipv6_draddr[8] =
|
||||||
|
{
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_1),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_2),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_3),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_4),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_5),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_6),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_7),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_8),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* IPv6 netmask */
|
||||||
|
|
||||||
|
static const uint16_t g_ipv6_netmask[8] =
|
||||||
|
{
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_1),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_2),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_3),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_4),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_5),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_6),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_7),
|
||||||
|
HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_8),
|
||||||
|
};
|
||||||
|
#endif /* CONFIG_EXAMPLES_UDP_IPv6 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -70,6 +115,22 @@ int main(int argc, FAR char *argv[])
|
|||||||
int udp_main(int argc, char *argv[])
|
int udp_main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
/* Set up our host address */
|
||||||
|
|
||||||
|
netlib_set_ipv6addr("eth0",
|
||||||
|
(FAR const struct in6_addr *)g_ipv6_hostaddr);
|
||||||
|
|
||||||
|
/* Set up the default router address */
|
||||||
|
|
||||||
|
netlib_set_dripv6addr("eth0",
|
||||||
|
(FAR const struct in6_addr *)g_ipv6_draddr);
|
||||||
|
|
||||||
|
/* Setup the subnet mask */
|
||||||
|
|
||||||
|
netlib_set_ipv6netmask("eth0",
|
||||||
|
(FAR const struct in6_addr *)g_ipv6_netmask);
|
||||||
|
#else
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
/* Set up our host address */
|
/* Set up our host address */
|
||||||
@ -86,6 +147,7 @@ int udp_main(int argc, char *argv[])
|
|||||||
|
|
||||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK);
|
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK);
|
||||||
netlib_set_ipv4netmask("eth0", &addr);
|
netlib_set_ipv4netmask("eth0", &addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER
|
#ifdef CONFIG_EXAMPLES_UDP_SERVER
|
||||||
recv_server();
|
recv_server();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* examples/udp/udp-client.c
|
* examples/udp/udp-client.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -37,6 +37,8 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
@ -77,15 +79,20 @@ static inline void fill_buffer(unsigned char *buf, int offset)
|
|||||||
|
|
||||||
void send_client(void)
|
void send_client(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
struct sockaddr_in6 server;
|
||||||
|
#else
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
|
#endif
|
||||||
unsigned char outbuf[SENDSIZE];
|
unsigned char outbuf[SENDSIZE];
|
||||||
|
socklen_t addrlen;
|
||||||
int sockfd;
|
int sockfd;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
/* Create a new UDP socket */
|
/* Create a new UDP socket */
|
||||||
|
|
||||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
sockfd = socket(PF_INETX, SOCK_DGRAM, 0);
|
||||||
if (sockfd < 0)
|
if (sockfd < 0)
|
||||||
{
|
{
|
||||||
printf("client socket failure %d\n", errno);
|
printf("client socket failure %d\n", errno);
|
||||||
@ -100,15 +107,35 @@ void send_client(void)
|
|||||||
|
|
||||||
fill_buffer(outbuf, offset);
|
fill_buffer(outbuf, offset);
|
||||||
|
|
||||||
/* Send the message */
|
/* Set up the server address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
server.sin6_family = AF_INET6;
|
||||||
|
server.sin6_port = HTONS(PORTNO);
|
||||||
|
|
||||||
|
server.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_1);
|
||||||
|
server.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_2);
|
||||||
|
server.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_3);
|
||||||
|
server.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_4);
|
||||||
|
server.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_5);
|
||||||
|
server.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_6);
|
||||||
|
server.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_7);
|
||||||
|
server.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_8);
|
||||||
|
|
||||||
|
addrlen = sizeof(struct sockaddr_in6);
|
||||||
|
#else
|
||||||
server.sin_family = AF_INET;
|
server.sin_family = AF_INET;
|
||||||
server.sin_port = HTONS(PORTNO);
|
server.sin_port = HTONS(PORTNO);
|
||||||
server.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP);
|
server.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP);
|
||||||
|
|
||||||
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Send the message */
|
||||||
|
|
||||||
printf("client: %d. Sending %d bytes\n", offset, SENDSIZE);
|
printf("client: %d. Sending %d bytes\n", offset, SENDSIZE);
|
||||||
nbytes = sendto(sockfd, outbuf, SENDSIZE, 0,
|
nbytes = sendto(sockfd, outbuf, SENDSIZE, 0,
|
||||||
(struct sockaddr*)&server, sizeof(struct sockaddr_in));
|
(struct sockaddr*)&server, addrlen);
|
||||||
printf("client: %d. Sent %d bytes\n", offset, nbytes);
|
printf("client: %d. Sent %d bytes\n", offset, nbytes);
|
||||||
|
|
||||||
if (nbytes < 0)
|
if (nbytes < 0)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* examples/udp/udp-internal.h
|
* examples/udp/udp-internal.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2008, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -40,7 +40,7 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_UDP_HOST
|
#ifdef EXAMPLES_UDP_HOST
|
||||||
#else
|
#else
|
||||||
# include <debug.h>
|
# include <debug.h>
|
||||||
#endif
|
#endif
|
||||||
@ -51,13 +51,21 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_UDP_HOST
|
#ifdef EXAMPLES_UDP_HOST
|
||||||
/* HTONS/L macros are unique to uIP */
|
/* HTONS/L macros are unique to uIP */
|
||||||
|
|
||||||
# define HTONS(a) htons(a)
|
# define HTONS(a) htons(a)
|
||||||
# define HTONL(a) htonl(a)
|
# define HTONL(a) htonl(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
# define AF_INETX AF_INET6
|
||||||
|
# define PF_INETX PF_INET6
|
||||||
|
#else
|
||||||
|
# define AF_INETX AF_INET
|
||||||
|
# define PF_INETX PF_INET
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PORTNO 5471
|
#define PORTNO 5471
|
||||||
|
|
||||||
#define ASCIISIZE (0x7f - 0x20)
|
#define ASCIISIZE (0x7f - 0x20)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* examples/udp/udp-server.c
|
* examples/udp/udp-server.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2009, 2012, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -37,12 +37,15 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -73,6 +76,7 @@ static inline int check_buffer(unsigned char *buf)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,19 +86,25 @@ static inline int check_buffer(unsigned char *buf)
|
|||||||
|
|
||||||
void recv_server(void)
|
void recv_server(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
struct sockaddr_in6 server;
|
||||||
|
struct sockaddr_in6 client;
|
||||||
|
#else
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
struct sockaddr_in client;
|
struct sockaddr_in client;
|
||||||
in_addr_t tmpaddr;
|
in_addr_t tmpaddr;
|
||||||
|
#endif
|
||||||
unsigned char inbuf[1024];
|
unsigned char inbuf[1024];
|
||||||
|
socklen_t addrlen;
|
||||||
|
socklen_t recvlen;
|
||||||
int sockfd;
|
int sockfd;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int optval;
|
int optval;
|
||||||
int offset;
|
int offset;
|
||||||
socklen_t addrlen;
|
|
||||||
|
|
||||||
/* Create a new UDP socket */
|
/* Create a new UDP socket */
|
||||||
|
|
||||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
sockfd = socket(PF_INETX, SOCK_DGRAM, 0);
|
||||||
if (sockfd < 0)
|
if (sockfd < 0)
|
||||||
{
|
{
|
||||||
printf("server: socket failure: %d\n", errno);
|
printf("server: socket failure: %d\n", errno);
|
||||||
@ -112,11 +122,21 @@ void recv_server(void)
|
|||||||
|
|
||||||
/* Bind the socket to a local address */
|
/* Bind the socket to a local address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
server.sin6_family = AF_INET6;
|
||||||
|
server.sin6_port = HTONS(PORTNO);
|
||||||
|
memset(&server.sin6_addr, 0, sizeof(struct in6_addr));
|
||||||
|
|
||||||
|
addrlen = sizeof(struct sockaddr_in6);
|
||||||
|
#else
|
||||||
server.sin_family = AF_INET;
|
server.sin_family = AF_INET;
|
||||||
server.sin_port = HTONS(PORTNO);
|
server.sin_port = HTONS(PORTNO);
|
||||||
server.sin_addr.s_addr = HTONL(INADDR_ANY);
|
server.sin_addr.s_addr = HTONL(INADDR_ANY);;
|
||||||
|
|
||||||
if (bind(sockfd, (struct sockaddr*)&server, sizeof(struct sockaddr_in)) < 0)
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (bind(sockfd, (struct sockaddr*)&server, addrlen) < 0)
|
||||||
{
|
{
|
||||||
printf("server: bind failure: %d\n", errno);
|
printf("server: bind failure: %d\n", errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -127,17 +147,26 @@ void recv_server(void)
|
|||||||
for (offset = 0; offset < 256; offset++)
|
for (offset = 0; offset < 256; offset++)
|
||||||
{
|
{
|
||||||
printf("server: %d. Receiving up 1024 bytes\n", offset);
|
printf("server: %d. Receiving up 1024 bytes\n", offset);
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
recvlen = addrlen;
|
||||||
nbytes = recvfrom(sockfd, inbuf, 1024, 0,
|
nbytes = recvfrom(sockfd, inbuf, 1024, 0,
|
||||||
(struct sockaddr*)&client, &addrlen);
|
(struct sockaddr*)&client, &recvlen);
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||||
|
printf("server: %d. Received %d bytes from %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x port %d\n",
|
||||||
|
offset, nbytes,
|
||||||
|
client.sin6_addr.s6_addr16[0], client.sin6_addr.s6_addr16[1],
|
||||||
|
client.sin6_addr.s6_addr16[2], client.sin6_addr.s6_addr16[3],
|
||||||
|
client.sin6_addr.s6_addr16[4], client.sin6_addr.s6_addr16[5],
|
||||||
|
client.sin6_addr.s6_addr16[6], client.sin6_addr.s6_addr16[7],
|
||||||
|
ntohs(client.sin6_port));
|
||||||
|
#else
|
||||||
tmpaddr = ntohl(client.sin_addr.s_addr);
|
tmpaddr = ntohl(client.sin_addr.s_addr);
|
||||||
printf("server: %d. Received %d bytes from %d.%d.%d.%d:%d\n",
|
printf("server: %d. Received %d bytes from %d.%d.%d.%d:%d\n",
|
||||||
offset, nbytes,
|
offset, nbytes,
|
||||||
tmpaddr >> 24, (tmpaddr >> 16) & 0xff,
|
tmpaddr >> 24, (tmpaddr >> 16) & 0xff,
|
||||||
(tmpaddr >> 8) & 0xff, tmpaddr & 0xff,
|
(tmpaddr >> 8) & 0xff, tmpaddr & 0xff,
|
||||||
ntohs(client.sin_port));
|
ntohs(client.sin_port));
|
||||||
|
#endif
|
||||||
if (nbytes < 0)
|
if (nbytes < 0)
|
||||||
{
|
{
|
||||||
printf("server: %d. recv failed: %d\n", offset, errno);
|
printf("server: %d. recv failed: %d\n", offset, errno);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user