The size of a single route(4) message cannot be derived from
either the size of the AF_INET or AF_INET6 routing tables.
Both could be empty or very large.
As such revert back to a buffer size of 2048 which mirrors
other programs which parse the routing socket.
Signed-off-by: Roy Marples <roy@marples.name>
#include "includes.h"
#include <sys/ioctl.h>
#include "includes.h"
#include <sys/ioctl.h>
#include "common.h"
#include "driver.h"
#include "common.h"
#include "driver.h"
void *ctx;
int sock; /* socket for 802.11 ioctls */
int route; /* routing socket for events */
void *ctx;
int sock; /* socket for 802.11 ioctls */
int route; /* routing socket for events */
- char *event_buf;
- size_t event_buf_len;
struct dl_list ifaces; /* list of interfaces */
};
struct dl_list ifaces; /* list of interfaces */
};
-static size_t
-rtbuf_len(void)
-{
- size_t len;
-
- int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0};
-
- if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
- wpa_printf(MSG_WARNING, "%s failed: %s", __func__,
- strerror(errno));
- len = 2048;
- }
-
- return len;
-}
-
static void
bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
{
static void
bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
{
+ char event_buf[2048]; /* max size of a single route(4) msg */
struct bsd_driver_global *global = sock_ctx;
struct bsd_driver_data *drv;
struct if_announcemsghdr *ifan;
struct bsd_driver_global *global = sock_ctx;
struct bsd_driver_data *drv;
struct if_announcemsghdr *ifan;
struct ieee80211_join_event *join;
int n;
struct ieee80211_join_event *join;
int n;
- n = read(sock, global->event_buf, global->event_buf_len);
+ n = read(sock, event_buf, sizeof(event_buf));
if (n < 0) {
if (errno != EINTR && errno != EAGAIN)
wpa_printf(MSG_ERROR, "%s read() failed: %s",
if (n < 0) {
if (errno != EINTR && errno != EAGAIN)
wpa_printf(MSG_ERROR, "%s read() failed: %s",
- rtm = (struct rt_msghdr *) global->event_buf;
+ rtm = (struct rt_msghdr *) event_buf;
if (rtm->rtm_version != RTM_VERSION) {
wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
rtm->rtm_version);
if (rtm->rtm_version != RTM_VERSION) {
wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
rtm->rtm_version);
- global->event_buf_len = rtbuf_len();
- global->event_buf = os_malloc(global->event_buf_len);
- if (global->event_buf == NULL) {
- wpa_printf(MSG_ERROR, "%s: os_malloc() failed", __func__);
- goto fail;
- }
-
eloop_register_read_sock(global->route, bsd_wireless_event_receive,
NULL, global);
eloop_register_read_sock(global->route, bsd_wireless_event_receive,
NULL, global);