Hello,
So i read code, userland part is feasible, even for a noob like me -with
time-.
In fact, other OS mainly add the field bssid and mode in the interface
parameters structure.
The cloning for wlan is specific on freebsd, i saw they add a second
parameter that does not exist in openBSD.
This parameter mainly hold enough space for a bssid (set to zero when
cloned) , the card mode, a mac address and some stuff (see below)
In openBSD, all ioctl for 802.11 are placed elsewhere, (sys/net80211), so if
i call
int
ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
inside
int
ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
then:
* i may be able to set some ssid to my vlan (if it is attached to a 80211
if).
* i certainly break everything , because 'driver' do not handle 'vap'
(afaik)
# find /usr/src/sys | xargs grep ieee80211_vap
/usr/src/sys/net80211/ieee80211_var.h: LIST_HEAD(, ieee80211_vap) ic_vaps;
# find /usr/src/sys | xargs grep ic_vaps
/usr/src/sys/net80211/ieee80211_var.h: LIST_HEAD(, ieee80211_vap) ic_vaps;
#
So i need code from net80211/ieee80211.c bsd, all the vap related code.
Given the header the code could be the same. So it's just a nice merge of
newer freebsd file and the openBSD one ? (as they come from the same
source)
I never do such thing, any advice for testing, and doing it right ?
Best regards.
PS:
Here's the FreeBSD code, that create the device, if someone is interested
(for vap card control :
http://svnweb.freebsd.org/base/head/sys/net80211/ieee80211.c?view=markup):
/*
* Virtual AP cloning parameters. The parent device must
* be a vap-capable device. All parameters specified with
* the clone request are fixed for the lifetime of the vap.
*
* There are two flavors of WDS vaps: legacy and dynamic.
* Legacy WDS operation implements a static binding between
* two stations encapsulating traffic in 4-address frames.
* Dynamic WDS vaps are created when a station associates to
* an AP and sends a 4-address frame. If the AP vap is
* configured to support WDS then this will generate an
* event to user programs listening on the routing socket
* and a Dynamic WDS vap will be created to handle traffic
* to/from that station. In both cases the bssid of the
* peer must be specified when creating the vap.
*
* By default a vap will inherit the mac address/bssid of
* the underlying device. To request a unique address the
* IEEE80211_CLONE_BSSID flag should be supplied. This is
* meaningless for WDS vaps as they share the bssid of an
* AP vap that must otherwise exist. Note that some devices
* may not be able to support multiple addresses.
*
* Station mode vap's normally depend on the device to notice
* when the AP stops sending beacon frames. If IEEE80211_CLONE_NOBEACONS
* is specified the net80211 layer will do this in s/w. This
* is mostly useful when setting up a WDS repeater/extender where
* an AP vap is combined with a sta vap and the device isn't able
* to track beacon frames in hardware.
*/
struct ieee80211_clone_params {
char icp_parent[IFNAMSIZ]; /* parent device */
uint16_t icp_opmode; /* operating mode */
uint16_t icp_flags; /* see below */
uint8_t icp_bssid[IEEE80211_ADDR_LEN]; /* for WDS links */
uint8_t icp_macaddr[IEEE80211_ADDR_LEN];/* local address */
};
#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid
*/
#define IEEE80211_CLONE_NOBEACONS 0x0002 /* don't setup beacon timers
*/
#define IEEE80211_CLONE_WDSLEGACY 0x0004 /* legacy WDS processing */
#define IEEE80211_CLONE_MACADDR 0x0008 /* use specified mac addr */
#define IEEE80211_CLONE_TDMA 0x0010 /* operate in TDMA mode */
/***********************************************************************************************/
/****************new ioctl in sys/net/if.c
*************************************/
/****************new ioctl in sys/net/if.c
*************************************/
/***********************************************************************************************/
case SIOCIFCREATE:
case SIOCIFCREATE2:
error = priv_check(td, PRIV_NET_IFCREATE);
if (error == 0)
error = if_clone_create(ifr->ifr_name,
sizeof(ifr->ifr_name),
cmd == SIOCIFCREATE2 ? ifr->ifr_data : NULL);
CURVNET_RESTORE();
return (error);
/***********************************************************************************************/
/* ifconfig part from freebsd
* Virtual AP cloning support.
*/
static struct ieee80211_clone_params params = {
.icp_opmode = IEEE80211_M_STA, /* default to station mode
*/
};
static void
wlan_create(int s, struct ifreq *ifr)
{
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
if (params.icp_parent[0] == '\0')
errx(1, "must specify a parent device (wlandev) when
creating "
"a wlan device");
if (params.icp_opmode == IEEE80211_M_WDS &&
memcmp(params.icp_bssid, zerobssid, sizeof(zerobssid)) == 0)
errx(1, "no bssid specified for WDS (use wlanbssid)");
ifr->ifr_data = (caddr_t) ¶ms;
if (ioctl(s, SIOCIFCREATE2, ifr) < 0)
err(1, "SIOCIFCREATE2");
}
static
DECL_CMD_FUNC(set80211clone_wlandev, arg, d)
{
strlcpy(params.icp_parent, arg, IFNAMSIZ);
}
static
DECL_CMD_FUNC(set80211clone_wlanbssid, arg, d)
{
const struct ether_addr *ea;
ea = ether_aton(arg);
if (ea == NULL)
errx(1, "%s: cannot parse bssid", arg);
memcpy(params.icp_bssid, ea->octet, IEEE80211_ADDR_LEN);
}
static
DECL_CMD_FUNC(set80211clone_wlanaddr, arg, d)
{
const struct ether_addr *ea;
ea = ether_aton(arg);
if (ea == NULL)
errx(1, "%s: cannot parse address", arg);
memcpy(params.icp_macaddr, ea->octet, IEEE80211_ADDR_LEN);
params.icp_flags |= IEEE80211_CLONE_MACADDR;
}
static
DECL_CMD_FUNC(set80211clone_wlanmode, arg, d)
{
#define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0)
if (iseq(arg, "sta"))
params.icp_opmode = IEEE80211_M_STA;
else if (iseq(arg, "ahdemo") || iseq(arg, "adhoc-demo"))
params.icp_opmode = IEEE80211_M_AHDEMO;
else if (iseq(arg, "ibss") || iseq(arg, "adhoc"))
params.icp_opmode = IEEE80211_M_IBSS;
else if (iseq(arg, "ap") || iseq(arg, "host"))
params.icp_opmode = IEEE80211_M_HOSTAP;
else if (iseq(arg, "wds"))
params.icp_opmode = IEEE80211_M_WDS;
else if (iseq(arg, "monitor"))
params.icp_opmode = IEEE80211_M_MONITOR;
else if (iseq(arg, "tdma")) {
params.icp_opmode = IEEE80211_M_AHDEMO;
params.icp_flags |= IEEE80211_CLONE_TDMA;
} else if (iseq(arg, "mesh") || iseq(arg, "mp")) /* mesh point */
params.icp_opmode = IEEE80211_M_MBSS;
else
errx(1, "Don't know to create %s for %s", arg, name);
#undef iseq
}
static void
set80211clone_beacons(const char *val, int d, int s, const struct afswtch
*rafp)
{
/* NB: inverted sense */
if (d)
params.icp_flags &= ~IEEE80211_CLONE_NOBEACONS;
else
params.icp_flags |= IEEE80211_CLONE_NOBEACONS;
}
static void
set80211clone_bssid(const char *val, int d, int s, const struct afswtch
*rafp)
{
if (d)
params.icp_flags |= IEEE80211_CLONE_BSSID;
else
params.icp_flags &= ~IEEE80211_CLONE_BSSID;
}
static void
set80211clone_wdslegacy(const char *val, int d, int s, const struct afswtch
*rafp)
{
if (d)
params.icp_flags |= IEEE80211_CLONE_WDSLEGACY;
else
params.icp_flags &= ~IEEE80211_CLONE_WDSLEGACY;
}
2011/7/2 Nick Holland <[email protected]>
> On 07/02/11 12:05, sven falempin wrote:
> ...
> > What misc at openBSD think about multiple SSID ?
>
> send code.
> Developers don't care about what people "think" (which usually equates
> more to "talk" than true "think") about something, they care about code.
>
> Nick.
>
>
--
---------------------------------------------------------------------------------------------------------------------
() ascii ribbon campaign - against html e-mail
/\