mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
mac length: switch to ETHER_ADDR_LEN
Long story, there's also minimal example to take care of. This change should take care of anything with ETHER_ADDR_LEN in net/ethernet.h plus windows, for both the lib and example.
This commit is contained in:
parent
b391e1141a
commit
dab8e1c4f8
6 changed files with 19 additions and 12 deletions
|
@ -660,6 +660,8 @@ CHECK_C_SOURCE_COMPILES("#include <pthread.h>\nvoid main(void) { while(1) ; } vo
|
|||
CHECK_C_SOURCE_COMPILES("#include <inttypes.h>\nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_INTTYPES_H)
|
||||
CHECK_C_SOURCE_COMPILES("#include <sys/resource.h>\nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_RESOURCE_H)
|
||||
CHECK_C_SOURCE_COMPILES("#include <linux/ipv6.h>\nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_LINUX_IPV6_H)
|
||||
CHECK_C_SOURCE_COMPILES("#include <net/ethernet.h>\nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_NET_ETHERNET_H)
|
||||
|
||||
|
||||
if (LWS_EXT_PTHREAD_INCLUDE_DIR)
|
||||
set(LWS_HAVE_PTHREAD_H 1)
|
||||
|
|
|
@ -165,6 +165,7 @@
|
|||
#cmakedefine LWS_WITH_DLO
|
||||
#cmakedefine LWS_WITH_DRIVERS
|
||||
#cmakedefine LWS_WITH_ESP32
|
||||
#cmakedefine LWS_HAVE_NET_ETHERNET_H
|
||||
#cmakedefine LWS_HAVE_EVBACKEND_LINUXAIO
|
||||
#cmakedefine LWS_HAVE_EVBACKEND_IOURING
|
||||
#cmakedefine LWS_WITH_EXTERNAL_POLL
|
||||
|
|
|
@ -109,3 +109,4 @@
|
|||
|
||||
/* Defined if you have the <inttypes.h> header file. */
|
||||
#cmakedefine LWS_HAVE_INTTYPES_H
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ extern "C" {
|
|||
#if defined(LWS_HAVE_SYS_TYPES_H) && !defined(LWS_PLAT_BAREMETAL)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#if defined(LWS_HAVE_NET_ETHERNET_H)
|
||||
#include <net/ethernet.h>
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(ETHER_ADDR_LEN)
|
||||
#define ETHER_ADDR_LEN 6
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
@ -288,6 +294,7 @@ typedef int suseconds_t;
|
|||
#define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_TLS)
|
||||
#include <mbedtls/ssl.h>
|
||||
#include <mbedtls/entropy.h>
|
||||
|
|
|
@ -24,15 +24,11 @@
|
|||
|
||||
#include "private-lib-core.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(IFHWADDRLEN)
|
||||
#define IFHWADDRLEN 6
|
||||
#endif
|
||||
|
||||
int
|
||||
lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)
|
||||
{
|
||||
int n, m, ofs = 0, fd, optval = 1, ret = 1;
|
||||
uint8_t pkt[17 * IFHWADDRLEN];
|
||||
uint8_t pkt[17 * ETHER_ADDR_LEN];
|
||||
struct sockaddr_in addr;
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
@ -51,10 +47,10 @@ lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)
|
|||
* Lay out the magic packet
|
||||
*/
|
||||
|
||||
for (n = 0; n < IFHWADDRLEN; n++)
|
||||
for (n = 0; n < ETHER_ADDR_LEN; n++)
|
||||
pkt[ofs++] = 0xff;
|
||||
for (m = 0; m < 16; m++)
|
||||
for (n = 0; n < IFHWADDRLEN; n++)
|
||||
for (n = 0; n < ETHER_ADDR_LEN; n++)
|
||||
pkt[ofs++] = mac_6_bytes[n];
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
struct lws_context_creation_info info;
|
||||
struct lws_context *ctx;
|
||||
const char *p, *ip = NULL;
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
int ret = 1;
|
||||
struct lws_context_creation_info info;
|
||||
struct lws_context *ctx;
|
||||
const char *p, *ip = NULL;
|
||||
uint8_t mac[ETHER_ADDR_LEN];
|
||||
int ret = 1;
|
||||
|
||||
memset(&info, 0, sizeof info);
|
||||
lws_cmdline_option_handle_builtin(argc, argv, &info);
|
||||
|
|
Loading…
Add table
Reference in a new issue