eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

vendor_quirks.c (2105B)


      1 /*
      2  *
      3  *  Wireless daemon for Linux
      4  *
      5  *  Copyright (C) 2025  Locus Robotics Corporation. All rights reserved.
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  *
     21  */
     22 
     23 #ifdef HAVE_CONFIG_H
     24 #include <config.h>
     25 #endif
     26 
     27 #include <string.h>
     28 #include <stdio.h>
     29 
     30 #include <ell/ell.h>
     31 
     32 #include "src/vendor_quirks.h"
     33 
     34 static const struct {
     35 	uint8_t oui[3];
     36 	struct vendor_quirk quirks;
     37 } oui_quirk_db[] = {
     38 	{
     39 		/* Cisco Meraki */
     40 		{ 0x00, 0x18, 0x0a },
     41 		{ .ignore_bss_tm_candidates = true },
     42 	},
     43 	{
     44 		/* Hewlett Packard, owns Aruba */
     45 		{ 0x00, 0x0b, 0x86 },
     46 		{ .replay_counter_mismatch = true },
     47 	},
     48 };
     49 
     50 void vendor_quirks_append_for_oui(const uint8_t *oui,
     51 					struct vendor_quirk *quirks)
     52 {
     53 	size_t i;
     54 
     55 	for (i = 0; i < L_ARRAY_SIZE(oui_quirk_db); i++) {
     56 		const struct vendor_quirk *quirk = &oui_quirk_db[i].quirks;
     57 
     58 		if (memcmp(oui_quirk_db[i].oui, oui, 3))
     59 			continue;
     60 
     61 		quirks->ignore_bss_tm_candidates |=
     62 				quirk->ignore_bss_tm_candidates;
     63 		quirks->replay_counter_mismatch |=
     64 				quirk->replay_counter_mismatch;
     65 	}
     66 }
     67 
     68 const char *vendor_quirks_to_string(struct vendor_quirk quirks)
     69 {
     70 	static char out[1024];
     71 	char *pos = out;
     72 	size_t s = 0;
     73 
     74 	if (quirks.ignore_bss_tm_candidates)
     75 		s += snprintf(pos, sizeof(out) - s, "IgnoreBssTmCandidateList");
     76 
     77 	if (quirks.replay_counter_mismatch)
     78 		s += snprintf(pos, sizeof(out) - s, "ReplayCounterMismatch");
     79 
     80 	if (!s)
     81 		return NULL;
     82 
     83 	return out;
     84 }