2020-10-04 07:28:41 +01:00
|
|
|
/*
|
|
|
|
* libwebsockets - small server side websockets and web server implementation
|
|
|
|
*
|
2021-02-05 13:08:41 +00:00
|
|
|
* Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com>
|
2020-10-04 07:28:41 +01:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* We mainly focus on the routing table / gateways because those are the
|
|
|
|
* elements that decide if we can get on to the internet or not.
|
|
|
|
*
|
|
|
|
* We also need to understand the source addresses of possible outgoing routes,
|
|
|
|
* and follow LINK down (ifconfig down) to clean up routes on the interface idx
|
|
|
|
* going down that are not otherwise cleaned.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <private-lib-core.h>
|
|
|
|
|
|
|
|
#include <asm/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <linux/netlink.h>
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
|
2021-02-05 13:08:41 +00:00
|
|
|
//#define lwsl_netlink lwsl_notice
|
2023-09-23 06:35:07 +00:00
|
|
|
#define lwsl_cx_netlink lwsl_cx_info
|
|
|
|
#define lwsl_cx_netlink_debug lwsl_cx_debug
|
2021-02-05 13:08:41 +00:00
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
static void
|
|
|
|
lws_netlink_coldplug_done_cb(lws_sorted_usec_list_t *sul)
|
|
|
|
{
|
|
|
|
struct lws_context *ctx = lws_container_of(sul, struct lws_context,
|
|
|
|
sul_nl_coldplug);
|
|
|
|
ctx->nl_initial_done = 1;
|
2021-09-27 06:29:34 +01:00
|
|
|
#if defined(LWS_WITH_SYS_STATE)
|
2020-10-04 07:28:41 +01:00
|
|
|
/* if nothing is there to intercept anything, go all the way */
|
|
|
|
lws_state_transition_steps(&ctx->mgr_system, LWS_SYSTATE_OPERATIONAL);
|
2021-09-27 06:29:34 +01:00
|
|
|
#endif
|
2020-10-04 07:28:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rops_handle_POLLIN_netlink(struct lws_context_per_thread *pt, struct lws *wsi,
|
|
|
|
struct lws_pollfd *pollfd)
|
|
|
|
{
|
2021-03-07 09:44:29 +00:00
|
|
|
struct lws_context *cx = pt->context;
|
2021-02-05 13:08:41 +00:00
|
|
|
uint8_t s[4096]
|
2020-10-04 07:28:41 +01:00
|
|
|
#if defined(_DEBUG)
|
|
|
|
, route_change = 0
|
|
|
|
#endif
|
|
|
|
#if defined(LWS_WITH_SYS_SMD)
|
|
|
|
, gateway_change = 0
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
struct sockaddr_nl nladdr;
|
2023-09-23 06:35:07 +00:00
|
|
|
lws_route_t robj, *rou;
|
2020-10-04 07:28:41 +01:00
|
|
|
struct nlmsghdr *h;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct iovec iov;
|
2023-09-23 06:35:07 +00:00
|
|
|
unsigned int n, removed;
|
2021-02-05 13:08:41 +00:00
|
|
|
char buf[72];
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
if (!(pollfd->revents & LWS_POLLIN))
|
|
|
|
return LWS_HPI_RET_HANDLED;
|
|
|
|
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
|
|
|
|
iov.iov_base = (void *)s;
|
|
|
|
iov.iov_len = sizeof(s);
|
2021-02-05 13:08:41 +00:00
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
msg.msg_name = (void *)&(nladdr);
|
|
|
|
msg.msg_namelen = sizeof(nladdr);
|
|
|
|
|
|
|
|
msg.msg_iov = &iov;
|
|
|
|
msg.msg_iovlen = 1;
|
|
|
|
|
2020-12-12 06:21:40 +00:00
|
|
|
n = (unsigned int)recvmsg(wsi->desc.sockfd, &msg, 0);
|
2021-02-05 13:08:41 +00:00
|
|
|
if ((int)n < 0) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_notice(cx, "recvmsg failed");
|
2020-10-04 07:28:41 +01:00
|
|
|
return LWS_HPI_RET_PLEASE_CLOSE_ME;
|
2021-02-05 13:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// lwsl_hexdump_notice(s, (size_t)n);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
h = (struct nlmsghdr *)s;
|
|
|
|
|
2021-02-05 13:08:41 +00:00
|
|
|
/* we can get a bunch of messages coalesced in one read*/
|
|
|
|
|
2020-12-12 06:21:40 +00:00
|
|
|
for ( ; NLMSG_OK(h, n); h = NLMSG_NEXT(h, n)) {
|
2020-10-04 07:28:41 +01:00
|
|
|
struct ifaddrmsg *ifam;
|
|
|
|
struct rtattr *ra;
|
|
|
|
struct rtmsg *rm;
|
2021-02-05 13:08:41 +00:00
|
|
|
#if !defined(LWS_WITH_NO_LOGS) && defined(_DEBUG)
|
|
|
|
struct ndmsg *nd;
|
|
|
|
#endif
|
2020-12-12 06:21:40 +00:00
|
|
|
unsigned int ra_len;
|
2020-10-04 07:28:41 +01:00
|
|
|
uint8_t *p;
|
|
|
|
|
2021-02-05 13:08:41 +00:00
|
|
|
struct ifinfomsg *ifi;
|
|
|
|
struct rtattr *attribute;
|
|
|
|
unsigned int len;
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "RTM %d", h->nlmsg_type);
|
2021-02-05 13:08:41 +00:00
|
|
|
|
|
|
|
memset(&robj, 0, sizeof(robj));
|
|
|
|
robj.if_idx = -1;
|
|
|
|
robj.priority = -1;
|
|
|
|
rm = (struct rtmsg *)NLMSG_DATA(h);
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
/*
|
|
|
|
* We have to care about NEWLINK so we can understand when a
|
|
|
|
* network interface went down, and clear the related routes.
|
|
|
|
*
|
|
|
|
* We don't get individual DELROUTEs for these.
|
|
|
|
*/
|
|
|
|
|
2021-02-05 13:08:41 +00:00
|
|
|
switch (h->nlmsg_type) {
|
|
|
|
case RTM_NEWLINK:
|
|
|
|
|
|
|
|
ifi = NLMSG_DATA(h);
|
|
|
|
len = (unsigned int)(h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi)));
|
|
|
|
|
|
|
|
/* loop over all attributes for the NEWLINK message */
|
|
|
|
for (attribute = IFLA_RTA(ifi); RTA_OK(attribute, len);
|
|
|
|
attribute = RTA_NEXT(attribute, len)) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "if attr %d",
|
2021-02-05 13:08:41 +00:00
|
|
|
(int)attribute->rta_type);
|
|
|
|
switch(attribute->rta_type) {
|
|
|
|
case IFLA_IFNAME:
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "NETLINK ifidx %d : %s",
|
2021-02-05 13:08:41 +00:00
|
|
|
ifi->ifi_index,
|
|
|
|
(char *)RTA_DATA(attribute));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* switch */
|
|
|
|
} /* for loop */
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "NEWLINK ifi_index %d, flags 0x%x",
|
|
|
|
ifi->ifi_index, ifi->ifi_flags);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Despite "New"link this is actually telling us there
|
|
|
|
* is some change on the network interface IFF_ state
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(ifi->ifi_flags & IFF_UP)) {
|
|
|
|
/*
|
|
|
|
* Interface is down, so scrub all routes that
|
|
|
|
* applied to it
|
|
|
|
*/
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "NEWLINK: ifdown %d",
|
|
|
|
ifi->ifi_index);
|
2020-10-04 07:28:41 +01:00
|
|
|
lws_pt_lock(pt, __func__);
|
|
|
|
_lws_route_table_ifdown(pt, ifi->ifi_index);
|
|
|
|
lws_pt_unlock(pt);
|
|
|
|
}
|
2021-02-05 13:08:41 +00:00
|
|
|
continue; /* ie, not break, no second half */
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2021-02-05 13:08:41 +00:00
|
|
|
case RTM_NEWADDR:
|
|
|
|
case RTM_DELADDR:
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
ifam = (struct ifaddrmsg *)NLMSG_DATA(h);
|
|
|
|
|
|
|
|
robj.source_ads = 1;
|
|
|
|
robj.dest_len = ifam->ifa_prefixlen;
|
2020-12-12 06:21:40 +00:00
|
|
|
robj.if_idx = (int)ifam->ifa_index;
|
2020-10-04 07:28:41 +01:00
|
|
|
robj.scope = ifam->ifa_scope;
|
|
|
|
robj.ifa_flags = ifam->ifa_flags;
|
|
|
|
robj.dest.sa4.sin_family = ifam->ifa_family;
|
|
|
|
|
|
|
|
/* address attributes */
|
|
|
|
ra = (struct rtattr *)IFA_RTA(ifam);
|
2020-12-12 06:21:40 +00:00
|
|
|
ra_len = (unsigned int)IFA_PAYLOAD(h);
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "%s",
|
2023-09-23 06:35:07 +00:00
|
|
|
h->nlmsg_type == RTM_NEWADDR ? "NEWADDR" : "DELADDR");
|
|
|
|
|
|
|
|
// Parse attributes.
|
|
|
|
for ( ; RTA_OK(ra, ra_len); ra = RTA_NEXT(ra, ra_len)) {
|
|
|
|
//lwsl_cx_netlink_debug(cx, "%s: IFA %d\n", __func__, ra->rta_type);
|
|
|
|
switch (ra->rta_type) {
|
|
|
|
case IFA_LOCAL:
|
|
|
|
// Local address
|
|
|
|
lws_sa46_copy_address(&robj.src, RTA_DATA(ra), rm->rtm_family);
|
|
|
|
robj.src_len = rm->rtm_src_len;
|
|
|
|
lws_sa46_write_numeric_address(&robj.src, buf, sizeof(buf));
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_LOCAL: %s/%d", buf, robj.src_len);
|
|
|
|
break;
|
|
|
|
case IFA_ADDRESS:
|
|
|
|
// Prefix address, not local interface.
|
|
|
|
lws_sa46_copy_address(&robj.dest, RTA_DATA(ra), rm->rtm_family);
|
|
|
|
robj.dest_len = rm->rtm_dst_len;
|
|
|
|
lws_sa46_write_numeric_address(&robj.dest, buf, sizeof(buf));
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_ADDRESS: %s/%d", buf, robj.dest_len);
|
|
|
|
break;
|
|
|
|
case IFA_FLAGS:
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_FLAGS: 0x%x (not handled)",
|
|
|
|
*(unsigned int*)RTA_DATA(ra));
|
|
|
|
break;
|
|
|
|
case IFA_BROADCAST:
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_BROADCAST (not handled)");
|
|
|
|
break;
|
|
|
|
case IFA_ANYCAST:
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_ANYCAST (not handled)");
|
|
|
|
break;
|
|
|
|
case IFA_CACHEINFO:
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_CACHEINFO (not handled)");
|
|
|
|
break;
|
|
|
|
case IFA_LABEL:
|
|
|
|
strncpy(buf, RTA_DATA(ra), sizeof(buf));
|
|
|
|
buf[sizeof(buf)-1] = '\0';
|
|
|
|
lwsl_cx_netlink_debug(cx, "IFA_LABEL: %s (not used)", buf);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lwsl_cx_netlink_debug(cx, "unknown IFA attr type %d", ra->rta_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//lwsl_cx_debug(cx, "rta payload length: %ld", RTA_PAYLOAD(ra));
|
|
|
|
} /* for */
|
2021-05-26 12:45:36 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* almost nothing interesting within IFA_* attributes:
|
|
|
|
* so skip it and goto to the second half
|
|
|
|
*/
|
|
|
|
goto second_half;
|
2021-02-05 13:08:41 +00:00
|
|
|
|
|
|
|
case RTM_NEWROUTE:
|
|
|
|
case RTM_DELROUTE:
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "%s",
|
2021-02-05 13:08:41 +00:00
|
|
|
h->nlmsg_type == RTM_NEWROUTE ?
|
|
|
|
"NEWROUTE" : "DELROUTE");
|
2020-12-12 06:21:40 +00:00
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
/* route attributes */
|
|
|
|
ra = (struct rtattr *)RTM_RTA(rm);
|
2020-12-12 06:21:40 +00:00
|
|
|
ra_len = (unsigned int)RTM_PAYLOAD(h);
|
2021-02-05 13:08:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RTM_DELNEIGH:
|
|
|
|
case RTM_NEWNEIGH:
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "%s", h->nlmsg_type ==
|
|
|
|
RTM_NEWNEIGH ? "NEWNEIGH" :
|
|
|
|
"DELNEIGH");
|
2021-02-05 13:08:41 +00:00
|
|
|
#if !defined(LWS_WITH_NO_LOGS) && defined(_DEBUG)
|
|
|
|
nd = (struct ndmsg *)rm;
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "fam %u, ifidx %u, flags 0x%x",
|
|
|
|
nd->ndm_family, nd->ndm_ifindex,
|
2021-02-05 13:08:41 +00:00
|
|
|
nd->ndm_flags);
|
|
|
|
#endif
|
|
|
|
ra = (struct rtattr *)RTM_RTA(rm);
|
|
|
|
ra_len = (unsigned int)RTM_PAYLOAD(h);
|
|
|
|
for ( ; RTA_OK(ra, ra_len); ra = RTA_NEXT(ra, ra_len)) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "atr %d", ra->rta_type);
|
2021-02-05 13:08:41 +00:00
|
|
|
switch (ra->rta_type) {
|
|
|
|
case NDA_DST:
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "dst len %d",
|
|
|
|
ra->rta_len);
|
2021-02-05 13:08:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lws_pt_lock(pt, __func__);
|
|
|
|
_lws_route_pt_close_unroutable(pt);
|
|
|
|
lws_pt_unlock(pt);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default:
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "*** Unknown RTM_%d",
|
2021-02-05 13:08:41 +00:00
|
|
|
h->nlmsg_type);
|
|
|
|
continue;
|
|
|
|
} /* switch */
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
robj.proto = rm->rtm_protocol;
|
|
|
|
|
2021-05-26 12:45:36 +03:00
|
|
|
// iterate over route attributes
|
2020-10-04 07:28:41 +01:00
|
|
|
for ( ; RTA_OK(ra, ra_len); ra = RTA_NEXT(ra, ra_len)) {
|
2021-02-05 13:08:41 +00:00
|
|
|
// lwsl_netlink("%s: atr %d\n", __func__, ra->rta_type);
|
2020-10-04 07:28:41 +01:00
|
|
|
switch (ra->rta_type) {
|
2021-02-05 13:08:41 +00:00
|
|
|
case RTA_PREFSRC: /* protocol ads: preferred src ads */
|
|
|
|
case RTA_SRC:
|
|
|
|
lws_sa46_copy_address(&robj.src, RTA_DATA(ra),
|
|
|
|
rm->rtm_family);
|
|
|
|
robj.src_len = rm->rtm_src_len;
|
|
|
|
lws_sa46_write_numeric_address(&robj.src, buf, sizeof(buf));
|
2023-09-23 06:35:07 +00:00
|
|
|
if (ra->rta_type == RTA_SRC)
|
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_SRC: %s/%d", buf, robj.src_len);
|
|
|
|
else
|
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_PREFSRC: %s/%d", buf, robj.src_len);
|
2021-02-05 13:08:41 +00:00
|
|
|
break;
|
2020-10-04 07:28:41 +01:00
|
|
|
case RTA_DST:
|
2022-02-02 14:28:24 +00:00
|
|
|
/* check if is local addr -> considering it as src addr too */
|
|
|
|
if (rm->rtm_type == RTN_LOCAL &&
|
|
|
|
((rm->rtm_family == AF_INET && rm->rtm_dst_len == 32) ||
|
|
|
|
(rm->rtm_family == AF_INET6 && rm->rtm_dst_len == 128))) {
|
|
|
|
lws_sa46_copy_address(&robj.src, RTA_DATA(ra),
|
|
|
|
rm->rtm_family);
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "Local addr: RTA_DST -> added to RTA_SRC");
|
2022-02-02 14:28:24 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
lws_sa46_copy_address(&robj.dest, RTA_DATA(ra),
|
2023-09-23 06:35:07 +00:00
|
|
|
rm->rtm_family);
|
2020-10-04 07:28:41 +01:00
|
|
|
robj.dest_len = rm->rtm_dst_len;
|
2021-02-05 13:08:41 +00:00
|
|
|
lws_sa46_write_numeric_address(&robj.dest, buf, sizeof(buf));
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_DST: %s/%d", buf, robj.dest_len);
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
case RTA_GATEWAY:
|
2023-09-23 06:35:07 +00:00
|
|
|
lws_sa46_copy_address(&robj.gateway, RTA_DATA(ra),
|
2020-10-04 07:28:41 +01:00
|
|
|
rm->rtm_family);
|
2023-09-23 06:35:07 +00:00
|
|
|
|
|
|
|
lws_sa46_write_numeric_address(&robj.gateway, buf, sizeof(buf));
|
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_GATEWAY: %s", buf);
|
2020-10-04 07:28:41 +01:00
|
|
|
#if defined(LWS_WITH_SYS_SMD)
|
|
|
|
gateway_change = 1;
|
|
|
|
#endif
|
|
|
|
break;
|
2021-02-05 13:08:41 +00:00
|
|
|
case RTA_IIF: /* int: input interface index */
|
2020-10-04 07:28:41 +01:00
|
|
|
case RTA_OIF: /* int: output interface index */
|
2021-05-26 12:45:36 +03:00
|
|
|
robj.if_idx = *(int *)RTA_DATA(ra);
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_IIF/RTA_OIF: %d", robj.if_idx);
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
case RTA_PRIORITY: /* int: priority of route */
|
|
|
|
p = RTA_DATA(ra);
|
|
|
|
robj.priority = p[3] << 24 | p[2] << 16 |
|
|
|
|
p[1] << 8 | p[0];
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_PRIORITY: %d", robj.priority);
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
case RTA_CACHEINFO: /* struct rta_cacheinfo */
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_CACHEINFO (not handled)");
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
#if defined(LWS_HAVE_RTA_PREF)
|
|
|
|
case RTA_PREF: /* char: RFC4191 v6 router preference */
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_PREF (not handled)");
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case RTA_TABLE: /* int */
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "RTA_TABLE (not handled)");
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "unknown attr type %d", ra->rta_type);
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
|
|
|
}
|
2023-09-23 06:35:07 +00:00
|
|
|
//lwsl_cx_debug(cx, "rta payload length: %ld", RTA_PAYLOAD(ra));
|
2021-02-05 13:08:41 +00:00
|
|
|
} /* for */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the second half, once all the attributes were collected
|
|
|
|
*/
|
2021-05-26 12:45:36 +03:00
|
|
|
second_half:
|
2020-10-04 07:28:41 +01:00
|
|
|
switch (h->nlmsg_type) {
|
|
|
|
|
|
|
|
case RTM_DELROUTE:
|
|
|
|
/*
|
|
|
|
* This will also take down wsi marked as using it
|
|
|
|
*/
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_netlink(cx, "DELROUTE: if_idx %d",
|
2021-02-05 13:08:41 +00:00
|
|
|
robj.if_idx);
|
2020-10-04 07:28:41 +01:00
|
|
|
lws_pt_lock(pt, __func__);
|
2021-02-05 13:08:41 +00:00
|
|
|
_lws_route_remove(pt, &robj, 0);
|
2020-10-04 07:28:41 +01:00
|
|
|
lws_pt_unlock(pt);
|
|
|
|
goto inform;
|
|
|
|
|
|
|
|
case RTM_NEWROUTE:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't want any routing debris like /32 or broadcast
|
|
|
|
* in our routing table... we will collect source addresses
|
|
|
|
* bound to interfaces via NEWADDR
|
|
|
|
*/
|
2023-09-23 06:35:07 +00:00
|
|
|
if (rm->rtm_type != RTN_UNICAST
|
|
|
|
&& rm->rtm_type != RTN_LOCAL) {
|
|
|
|
lwsl_cx_netlink(cx, "NEWROUTE: IGNORED (%s)",
|
|
|
|
rm->rtm_type == RTN_BROADCAST ? "broadcast" :
|
|
|
|
rm->rtm_type == RTN_ANYCAST ? "anycast" :
|
|
|
|
rm->rtm_type == RTN_MULTICAST ? "multicast" :
|
|
|
|
rm->rtm_type == RTN_UNREACHABLE ? "unreachable" :
|
|
|
|
rm->rtm_type == RTN_NAT ? "nat" :
|
|
|
|
rm->rtm_type == RTN_UNSPEC ? "unspecified" :
|
|
|
|
"other");
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
2023-09-23 06:35:07 +00:00
|
|
|
}
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
if (rm->rtm_flags & RTM_F_CLONED) {
|
|
|
|
lwsl_cx_netlink(cx, "NEWROUTE: IGNORED (cloned)");
|
2020-10-04 07:28:41 +01:00
|
|
|
break;
|
2023-09-23 06:35:07 +00:00
|
|
|
}
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink(cx, "NEWROUTE: ACCEPTED (if_idx %d)",
|
|
|
|
robj.if_idx);
|
2021-02-05 13:08:41 +00:00
|
|
|
|
|
|
|
#if defined(_DEBUG)
|
2021-06-26 17:24:19 +01:00
|
|
|
_lws_routing_entry_dump(cx, &robj);
|
2021-02-05 13:08:41 +00:00
|
|
|
#endif
|
2021-03-29 06:42:50 +01:00
|
|
|
|
|
|
|
/*
|
2023-09-23 06:35:07 +00:00
|
|
|
* 1. Allocate new route for linked-list.
|
|
|
|
* (robj is on stack, do NOT use)
|
|
|
|
*/
|
2020-10-04 07:28:41 +01:00
|
|
|
rou = lws_malloc(sizeof(*rou), __func__);
|
|
|
|
if (!rou) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_err(cx, "oom");
|
2020-10-04 07:28:41 +01:00
|
|
|
return LWS_HPI_RET_HANDLED;
|
|
|
|
}
|
|
|
|
*rou = robj;
|
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
// 2. Remove duplicates and add route (both under a lock).
|
2020-10-04 07:28:41 +01:00
|
|
|
lws_pt_lock(pt, __func__);
|
|
|
|
|
|
|
|
/*
|
2023-09-23 06:35:07 +00:00
|
|
|
* Is robj a dupe in the routing table already?
|
|
|
|
*
|
|
|
|
* match on pri ignore == set pri and skip
|
|
|
|
* no match == add
|
|
|
|
*
|
|
|
|
* returns zero ALWAYS
|
|
|
|
*
|
|
|
|
* We could be adding a route to the same destination with
|
|
|
|
* a higher or lower priority from a different source, so why
|
|
|
|
* all existing routes? Only remove if its the same source and
|
|
|
|
* destination, effectively a change in priority.
|
2020-10-04 07:28:41 +01:00
|
|
|
*/
|
2023-09-23 06:35:07 +00:00
|
|
|
_lws_route_remove(pt, &robj,
|
|
|
|
LRR_MATCH_DST | LRR_MATCH_SRC | LRR_IGNORE_PRI);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
/* add route to linked-list */
|
2021-03-07 09:44:29 +00:00
|
|
|
rou->uidx = _lws_route_get_uidx(cx);
|
|
|
|
lws_dll2_add_tail(&rou->list, &cx->routing_table);
|
2023-09-23 06:35:07 +00:00
|
|
|
lws_pt_unlock(pt);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
lwsl_cx_netlink_debug(cx, "route list size %u",
|
|
|
|
cx->routing_table.count);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
/*
|
|
|
|
* 3. Close anyything we cant reach anymore due to the removal.
|
|
|
|
* (don't need to or want to do this under lock)
|
|
|
|
*/
|
|
|
|
_lws_route_pt_close_unroutable(pt);
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
inform:
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
route_change = 1;
|
|
|
|
#endif
|
|
|
|
#if defined(LWS_WITH_SYS_SMD)
|
|
|
|
/*
|
|
|
|
* Reflect the route add / del event using SMD.
|
|
|
|
* Participants interested can refer to the pt
|
|
|
|
* routing table
|
|
|
|
*/
|
2021-03-07 09:44:29 +00:00
|
|
|
(void)lws_smd_msg_printf(cx, LWSSMDCL_NETWORK,
|
2020-10-04 07:28:41 +01:00
|
|
|
"{\"rt\":\"%s\"}\n",
|
2023-09-23 06:35:07 +00:00
|
|
|
(h->nlmsg_type == RTM_NEWROUTE) ?
|
|
|
|
"add" : "del");
|
2020-10-04 07:28:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-09-23 06:35:07 +00:00
|
|
|
case RTM_DELADDR:
|
|
|
|
lwsl_cx_notice(cx, "DELADDR");
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
_lws_routing_entry_dump(cx, &robj);
|
|
|
|
#endif
|
|
|
|
lws_pt_lock(pt, __func__);
|
|
|
|
removed = cx->routing_table.count;
|
|
|
|
_lws_route_remove(pt, &robj, LRR_MATCH_SRC | LRR_IGNORE_PRI);
|
|
|
|
removed -= cx->routing_table.count;
|
|
|
|
lws_pt_unlock(pt);
|
|
|
|
_lws_route_pt_close_unroutable(pt);
|
|
|
|
if (removed > 0)
|
|
|
|
goto inform;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTM_NEWADDR:
|
|
|
|
lwsl_cx_netlink(cx, "NEWADDR (nothing to do)");
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
_lws_routing_entry_dump(cx, &robj);
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* An address alone does not provide new routes.
|
|
|
|
* NEWADDR will happen when the DHCP lease is being
|
|
|
|
* renewed, and will likely not change any routes.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
default:
|
|
|
|
// lwsl_info("%s: unknown msg type %d\n", __func__,
|
|
|
|
// h->nlmsg_type);
|
|
|
|
break;
|
|
|
|
}
|
2021-02-05 13:08:41 +00:00
|
|
|
} /* message iterator */
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
#if defined(LWS_WITH_SYS_SMD)
|
|
|
|
if (gateway_change)
|
|
|
|
/*
|
|
|
|
* If a route with a gw was added or deleted, retrigger captive
|
|
|
|
* portal detection if we have that
|
|
|
|
*/
|
2021-03-07 09:44:29 +00:00
|
|
|
(void)lws_smd_msg_printf(cx, LWSSMDCL_NETWORK,
|
2020-10-04 07:28:41 +01:00
|
|
|
"{\"trigger\": \"cpdcheck\", "
|
|
|
|
"\"src\":\"gw-change\"}");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
if (route_change) {
|
2021-03-07 09:44:29 +00:00
|
|
|
lws_context_lock(cx, __func__);
|
|
|
|
_lws_routing_table_dump(cx);
|
|
|
|
lws_context_unlock(cx);
|
2020-10-04 07:28:41 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-06-27 08:00:35 +01:00
|
|
|
if (!cx->nl_initial_done &&
|
|
|
|
pt == &cx->pt[0] &&
|
|
|
|
cx->routing_table.count) {
|
|
|
|
/*
|
|
|
|
* While netlink info still coming, keep moving the timer for
|
|
|
|
* calling it "done" to +100ms until after it stops coming
|
|
|
|
*/
|
|
|
|
lws_context_lock(cx, __func__);
|
|
|
|
lws_sul_schedule(cx, 0, &cx->sul_nl_coldplug,
|
|
|
|
lws_netlink_coldplug_done_cb,
|
|
|
|
100 * LWS_US_PER_MS);
|
|
|
|
lws_context_unlock(cx);
|
|
|
|
}
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
return LWS_HPI_RET_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nl_req_s {
|
|
|
|
struct nlmsghdr hdr;
|
|
|
|
struct rtmsg gen;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
rops_pt_init_destroy_netlink(struct lws_context *context,
|
|
|
|
const struct lws_context_creation_info *info,
|
|
|
|
struct lws_context_per_thread *pt, int destroy)
|
|
|
|
{
|
|
|
|
struct sockaddr_nl sanl;
|
|
|
|
struct nl_req_s req;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct iovec iov;
|
|
|
|
struct lws *wsi;
|
2021-04-20 15:51:08 +01:00
|
|
|
int n, ret = 1;
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
if (destroy) {
|
2020-11-16 19:32:58 +00:00
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
/*
|
|
|
|
* pt netlink wsi closed + freed as part of pt's destroy
|
|
|
|
* wsi mass close, just need to take down the routing table
|
|
|
|
*/
|
|
|
|
_lws_route_table_empty(pt);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-07 09:44:29 +00:00
|
|
|
if (context->netlink)
|
2020-10-04 07:28:41 +01:00
|
|
|
return 0;
|
|
|
|
|
2020-11-16 19:32:58 +00:00
|
|
|
if (pt > &context->pt[0])
|
|
|
|
/* we can only have one netlink socket */
|
|
|
|
return 0;
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_info(context, "creating netlink skt");
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want a netlink socket per pt as well
|
|
|
|
*/
|
2020-12-24 16:06:50 +00:00
|
|
|
|
|
|
|
lws_context_lock(context, __func__);
|
|
|
|
wsi = __lws_wsi_create_with_role(context, (int)(pt - &context->pt[0]),
|
2021-06-26 17:24:19 +01:00
|
|
|
&role_ops_netlink, NULL);
|
2020-12-24 16:06:50 +00:00
|
|
|
lws_context_unlock(context);
|
2020-10-04 07:28:41 +01:00
|
|
|
if (!wsi)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
wsi->desc.sockfd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
|
|
|
if (wsi->desc.sockfd == LWS_SOCK_INVALID) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_err(context, "unable to open netlink");
|
2020-10-04 07:28:41 +01:00
|
|
|
goto bail1;
|
|
|
|
}
|
|
|
|
|
2021-07-11 10:53:16 +01:00
|
|
|
lws_plat_set_nonblocking(wsi->desc.sockfd);
|
|
|
|
|
2021-06-26 17:24:19 +01:00
|
|
|
__lws_lc_tag(context, &context->lcg[LWSLCG_VHOST], &wsi->lc,
|
|
|
|
"netlink");
|
2020-12-25 05:54:19 +00:00
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
memset(&sanl, 0, sizeof(sanl));
|
|
|
|
sanl.nl_family = AF_NETLINK;
|
2022-02-02 14:28:24 +00:00
|
|
|
sanl.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_IFADDR
|
2020-10-04 07:28:41 +01:00
|
|
|
#if defined(LWS_WITH_IPV6)
|
2022-02-02 14:28:24 +00:00
|
|
|
| RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFADDR
|
2020-10-04 07:28:41 +01:00
|
|
|
#endif
|
2021-02-05 13:08:41 +00:00
|
|
|
;
|
2020-10-04 07:28:41 +01:00
|
|
|
|
2021-04-20 15:51:08 +01:00
|
|
|
if (lws_fi(&context->fic, "netlink_bind") ||
|
|
|
|
bind(wsi->desc.sockfd, (struct sockaddr*)&sanl, sizeof(sanl)) < 0) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_warn(context, "netlink bind failed");
|
2021-04-20 15:51:08 +01:00
|
|
|
ret = 0; /* some systems deny access, just ignore */
|
2020-10-04 07:28:41 +01:00
|
|
|
goto bail2;
|
|
|
|
}
|
|
|
|
|
2021-03-07 09:44:29 +00:00
|
|
|
context->netlink = wsi;
|
2020-10-04 07:28:41 +01:00
|
|
|
if (lws_wsi_inject_to_loop(pt, wsi))
|
|
|
|
goto bail2;
|
|
|
|
|
2020-11-16 19:32:58 +00:00
|
|
|
/* if (lws_change_pollfd(wsi, 0, LWS_POLLIN)) {
|
2020-10-04 07:28:41 +01:00
|
|
|
lwsl_err("%s: pollfd in fail\n", __func__);
|
|
|
|
goto bail2;
|
|
|
|
}
|
2020-11-16 19:32:58 +00:00
|
|
|
*/
|
2020-10-04 07:28:41 +01:00
|
|
|
/*
|
|
|
|
* Since we're starting the PT, ask to be sent all the existing routes.
|
|
|
|
*
|
|
|
|
* This requires CAP_ADMIN, or root... we do this early before dropping
|
|
|
|
* privs
|
|
|
|
*/
|
|
|
|
|
|
|
|
memset(&sanl, 0, sizeof(sanl));
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
memset(&req, 0, sizeof(req));
|
|
|
|
|
|
|
|
sanl.nl_family = AF_NETLINK;
|
|
|
|
|
|
|
|
req.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(req.gen));
|
|
|
|
req.hdr.nlmsg_type = RTM_GETROUTE;
|
|
|
|
req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
|
|
|
|
req.hdr.nlmsg_seq = 1;
|
2020-12-12 06:21:40 +00:00
|
|
|
req.hdr.nlmsg_pid = (uint32_t)getpid();
|
2020-10-04 07:28:41 +01:00
|
|
|
req.gen.rtm_family = AF_PACKET;
|
|
|
|
req.gen.rtm_table = RT_TABLE_DEFAULT;
|
|
|
|
|
|
|
|
iov.iov_base = &req;
|
|
|
|
iov.iov_len = req.hdr.nlmsg_len;
|
|
|
|
msg.msg_iov = &iov;
|
|
|
|
msg.msg_iovlen = 1;
|
|
|
|
msg.msg_name = &sanl;
|
|
|
|
msg.msg_namelen = sizeof(sanl);
|
|
|
|
|
2020-12-12 06:21:40 +00:00
|
|
|
n = (int)sendmsg(wsi->desc.sockfd, (struct msghdr *)&msg, 0);
|
2020-10-04 07:28:41 +01:00
|
|
|
if (n < 0) {
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_notice(context, "rt dump req failed... permissions? errno %d",
|
|
|
|
LWS_ERRNO);
|
2020-10-04 07:28:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-06-27 08:00:35 +01:00
|
|
|
* Responses are going to come asynchronously, let's block moving
|
|
|
|
* off state IFACE_COLDPLUG until we have had them. This is important
|
|
|
|
* since if we don't hold there, when we do get the responses we may
|
|
|
|
* cull any ongoing connections as unroutable otherwise
|
2020-10-04 07:28:41 +01:00
|
|
|
*/
|
|
|
|
|
2021-06-18 07:28:23 +01:00
|
|
|
lwsl_cx_debug(context, "starting netlink coldplug wait");
|
2020-10-04 07:28:41 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bail2:
|
2021-06-26 17:24:19 +01:00
|
|
|
__lws_lc_untag(wsi->a.context, &wsi->lc);
|
2020-10-04 07:28:41 +01:00
|
|
|
compatible_close(wsi->desc.sockfd);
|
|
|
|
bail1:
|
|
|
|
lws_free(wsi);
|
|
|
|
bail:
|
2021-04-20 15:51:08 +01:00
|
|
|
return ret;
|
2020-10-04 07:28:41 +01:00
|
|
|
}
|
|
|
|
|
roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two. No single
role has more than 14 of the ops. On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.
First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.
Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is
2 + (4 x ops_used)
and for 64-bit
6 + (8 x ops_used)
for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160
For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)
This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions
For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata
before patch: 553282
accessor macro: 552714 (568 byte saving)
accessor functions: 553674 (392 bytes worse than without patch)
therefore we went with the macros
2020-10-19 13:55:21 +01:00
|
|
|
static const lws_rops_t rops_table_netlink[] = {
|
|
|
|
/* 1 */ { .pt_init_destroy = rops_pt_init_destroy_netlink },
|
|
|
|
/* 2 */ { .handle_POLLIN = rops_handle_POLLIN_netlink },
|
|
|
|
};
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
const struct lws_role_ops role_ops_netlink = {
|
|
|
|
/* role name */ "netlink",
|
|
|
|
/* alpn id */ NULL,
|
roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two. No single
role has more than 14 of the ops. On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.
First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.
Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is
2 + (4 x ops_used)
and for 64-bit
6 + (8 x ops_used)
for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160
For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)
This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions
For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata
before patch: 553282
accessor macro: 552714 (568 byte saving)
accessor functions: 553674 (392 bytes worse than without patch)
therefore we went with the macros
2020-10-19 13:55:21 +01:00
|
|
|
|
|
|
|
/* rops_table */ rops_table_netlink,
|
|
|
|
/* rops_idx */ {
|
|
|
|
/* LWS_ROPS_check_upgrades */
|
|
|
|
/* LWS_ROPS_pt_init_destroy */ 0x01,
|
|
|
|
/* LWS_ROPS_init_vhost */
|
|
|
|
/* LWS_ROPS_destroy_vhost */ 0x00,
|
|
|
|
/* LWS_ROPS_service_flag_pending */
|
|
|
|
/* LWS_ROPS_handle_POLLIN */ 0x02,
|
|
|
|
/* LWS_ROPS_handle_POLLOUT */
|
|
|
|
/* LWS_ROPS_perform_user_POLLOUT */ 0x00,
|
|
|
|
/* LWS_ROPS_callback_on_writable */
|
|
|
|
/* LWS_ROPS_tx_credit */ 0x00,
|
|
|
|
/* LWS_ROPS_write_role_protocol */
|
|
|
|
/* LWS_ROPS_encapsulation_parent */ 0x00,
|
|
|
|
/* LWS_ROPS_alpn_negotiated */
|
|
|
|
/* LWS_ROPS_close_via_role_protocol */ 0x00,
|
|
|
|
/* LWS_ROPS_close_role */
|
|
|
|
/* LWS_ROPS_close_kill_connection */ 0x00,
|
|
|
|
/* LWS_ROPS_destroy_role */
|
|
|
|
/* LWS_ROPS_adoption_bind */ 0x00,
|
|
|
|
/* LWS_ROPS_client_bind */
|
|
|
|
/* LWS_ROPS_issue_keepalive */ 0x00,
|
|
|
|
},
|
|
|
|
|
2020-10-04 07:28:41 +01:00
|
|
|
/* adoption_cb clnt, srv */ { 0, 0 },
|
|
|
|
/* rx_cb clnt, srv */ { 0, 0 },
|
|
|
|
/* writeable cb clnt, srv */ { 0, 0 },
|
|
|
|
/* close cb clnt, srv */ { 0, 0 },
|
|
|
|
/* protocol_bind_cb c,s */ { 0, 0 },
|
|
|
|
/* protocol_unbind_cb c,s */ { 0, 0 },
|
|
|
|
/* file_handle */ 0,
|
|
|
|
};
|