forked from eclipse-zenoh/zenoh-pico
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
289a0ee
commit 820eb2c
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include "zenoh-pico/system/link/raweth.h" | ||
|
||
#include <arpa/inet.h> | ||
#include <errno.h> | ||
#include <ifaddrs.h> | ||
|
@@ -31,7 +33,6 @@ | |
#include "zenoh-pico/collections/string.h" | ||
#include "zenoh-pico/config.h" | ||
#include "zenoh-pico/system/platform/unix.h" | ||
#include "zenoh-pico/system/link/raweth.h" | ||
#include "zenoh-pico/utils/logging.h" | ||
#include "zenoh-pico/utils/pointers.h" | ||
|
||
|
@@ -105,4 +106,18 @@ size_t _z_send_raweth(const _z_sys_net_socket_t *sock, const void *buff, size_t | |
return (size_t)wb; | ||
} | ||
|
||
size_t _z_receive_raweth(const _z_sys_net_socket_t *sock, void *buff, size_t buff_len, _z_bytes_t *addr) { | ||
size_t bytesRead = recvfrom(sock->_fd, buff, buff_len, 0, NULL, NULL); | ||
if (bytesRead < 0) { | ||
return SIZE_MAX; | ||
} | ||
// Soft Filtering ? | ||
// Copy sender mac if needed | ||
if ((addr != NULL) && (bytesRead > 2 * ETH_ALEN)) { | ||
*addr = _z_bytes_make(sizeof(ETH_ALEN)); | ||
(void)memcpy((uint8_t *)addr->start, &(buff + ETH_ALEN), sizeof(ETH_ALEN)); | ||
} | ||
return bytesRead; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters