mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
socket_zep: send dummy HELLO packet on connect
This commit is contained in:
parent
54eedd94ba
commit
90f3c15084
@ -13,6 +13,39 @@
|
||||
*
|
||||
* @see @ref net_zep for protocol definitions
|
||||
*
|
||||
* This ZEP implementation can send a dummy HELLO packet on startup.
|
||||
* This is used to make dispatchers aware of the node.
|
||||
* To enable this behavior, add
|
||||
*
|
||||
* ```
|
||||
* USEMODULE += socket_zep_hello
|
||||
* ```
|
||||
*
|
||||
* to your Makefile.
|
||||
*
|
||||
* A ZEP dispatcher can just drop those packets (ZEP type 0xFF) if it
|
||||
* chooses to parse the ZEP header.
|
||||
*
|
||||
* The header of the HELLO packet will look like this:
|
||||
*
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Preamble (EX) | Version (2) | Type (255) |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* + Reserved (0) +
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | | 'H' | 'E' | 'L' |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 'L' | 'O' | 0 | 0 |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 0 | 0 | 0 | 0 |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
|
@ -40,6 +40,9 @@
|
||||
* (https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/basedefs/time.h.html) */
|
||||
#define TV_USEC_PER_SEC (1000000L)
|
||||
|
||||
/* dummy packet to register with ZEP dispatcher */
|
||||
#define SOCKET_ZEP_V2_TYPE_HELLO (255)
|
||||
|
||||
static size_t _zep_hdr_fill_v2_data(socket_zep_t *dev, zep_v2_data_hdr_t *hdr,
|
||||
size_t payload_len)
|
||||
{
|
||||
@ -390,6 +393,21 @@ static int _connect_remote(socket_zep_t *dev, const socket_zep_params_t *params)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void _send_zep_hello(socket_zep_t *dev)
|
||||
{
|
||||
if (IS_USED(MODULE_SOCKET_ZEP_HELLO)) {
|
||||
/* dummy packet */
|
||||
zep_v2_data_hdr_t hdr = {
|
||||
.hdr.preamble = "EX",
|
||||
.hdr.version = 2,
|
||||
.type = SOCKET_ZEP_V2_TYPE_HELLO,
|
||||
.resv = "HELLO",
|
||||
};
|
||||
|
||||
real_write(dev->sock_fd, &hdr, sizeof(hdr));
|
||||
}
|
||||
}
|
||||
|
||||
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params)
|
||||
{
|
||||
int res;
|
||||
@ -408,7 +426,10 @@ void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params)
|
||||
dev->sock_fd = res;
|
||||
}
|
||||
|
||||
_connect_remote(dev, params);
|
||||
if (_connect_remote(dev, params) == 0) {
|
||||
/* send dummy data to connect to dispatcher */
|
||||
_send_zep_hello(dev);
|
||||
}
|
||||
|
||||
/* generate hardware address from local address */
|
||||
uint8_t ss_array[sizeof(struct sockaddr_storage)] = { 0 };
|
||||
|
@ -116,6 +116,7 @@ PSEUDOMODULES += sock_dtls
|
||||
PSEUDOMODULES += sock_ip
|
||||
PSEUDOMODULES += sock_tcp
|
||||
PSEUDOMODULES += sock_udp
|
||||
PSEUDOMODULES += socket_zep_hello
|
||||
PSEUDOMODULES += soft_uart_modecfg
|
||||
PSEUDOMODULES += stdin
|
||||
PSEUDOMODULES += stdio_cdc_acm
|
||||
|
Loading…
Reference in New Issue
Block a user