2017-06-14 08:49:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* wireless/ieee802154/mac802154_ioctl.c
|
|
|
|
*
|
2024-09-11 09:04:25 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-09-06 13:39:36 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2017-06-14 08:49:27 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "mac802154.h"
|
|
|
|
|
|
|
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
2020-04-23 11:51:21 +02:00
|
|
|
* Public Functions
|
2017-06-14 08:49:27 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mac802154_ioctl
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle MAC and radio IOCTL commands directed to the MAC.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-06-14 08:49:27 +02:00
|
|
|
* mac - Reference to the MAC driver state structure
|
|
|
|
* cmd - The IOCTL command
|
|
|
|
* arg - The argument for the IOCTL command
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* OK on success; Negated errno on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
|
|
|
|
{
|
|
|
|
int ret = -EINVAL;
|
|
|
|
|
|
|
|
FAR union ieee802154_macarg_u *macarg =
|
|
|
|
(FAR union ieee802154_macarg_u *)((uintptr_t)arg);
|
|
|
|
|
2017-07-11 01:45:29 +02:00
|
|
|
DEBUGASSERT(mac != NULL);
|
2017-06-14 08:49:27 +02:00
|
|
|
|
|
|
|
/* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */
|
|
|
|
|
|
|
|
if (_MAC802154IOCVALID(cmd))
|
|
|
|
{
|
|
|
|
/* Handle the MAC IOCTL command */
|
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
case MAC802154IOC_MLME_ASSOC_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_associate(mac, &macarg->assocreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_ASSOC_RESPONSE:
|
|
|
|
{
|
|
|
|
ret = mac802154_resp_associate(mac, &macarg->assocresp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_DISASSOC_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_disassociate(mac, &macarg->disassocreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_GET_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_get(mac, macarg->getreq.attr,
|
|
|
|
&macarg->getreq.attrval);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_GTS_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_gts(mac, &macarg->gtsreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_ORPHAN_RESPONSE:
|
|
|
|
{
|
|
|
|
ret = mac802154_resp_orphan(mac, &macarg->orphanresp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_RESET_REQUEST:
|
|
|
|
{
|
2017-07-01 23:02:40 +02:00
|
|
|
ret = mac802154_req_reset(mac, macarg->resetreq.resetattr);
|
2017-06-14 08:49:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_RXENABLE_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_rxenable(mac, &macarg->rxenabreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_SCAN_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_scan(mac, &macarg->scanreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_SET_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_set(mac, macarg->setreq.attr,
|
|
|
|
&macarg->setreq.attrval);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_START_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_start(mac, &macarg->startreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_SYNC_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_sync(mac, &macarg->syncreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MAC802154IOC_MLME_POLL_REQUEST:
|
|
|
|
{
|
|
|
|
ret = mac802154_req_poll(mac, &macarg->pollreq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wlerr("ERROR: Unrecognized cmd: %d\n", cmd);
|
|
|
|
ret = -ENOTTY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-23 11:51:21 +02:00
|
|
|
|
2017-06-14 08:49:27 +02:00
|
|
|
return ret;
|
|
|
|
}
|