1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #3576 from haukepetersen/mv_netopt

net: remove ng_ from netopt header
This commit is contained in:
Martine Lenders 2015-08-07 07:17:42 +02:00
commit 73a42314a5
19 changed files with 503 additions and 503 deletions

View File

@ -211,52 +211,52 @@ static void _switch_to_rx(void)
*/
int _get_state(uint8_t *val, size_t max_len)
{
ng_netopt_state_t state;
netopt_state_t state;
if (max_len < sizeof(ng_netopt_state_t)) {
if (max_len < sizeof(netopt_state_t)) {
return -EOVERFLOW;
}
switch (_state) {
case STATE_OFF:
state = NG_NETOPT_STATE_OFF;
state = NETOPT_STATE_OFF;
break;
case STATE_IDLE:
state = NG_NETOPT_STATE_SLEEP;
state = NETOPT_STATE_SLEEP;
break;
case STATE_RX:
state = NG_NETOPT_STATE_IDLE;
state = NETOPT_STATE_IDLE;
break;
case STATE_TX:
state = NG_NETOPT_STATE_TX;
state = NETOPT_STATE_TX;
break;
default:
return -ECANCELED;
}
memcpy(val, &state, sizeof(ng_netopt_state_t));
return sizeof(ng_netopt_state_t);
memcpy(val, &state, sizeof(netopt_state_t));
return sizeof(netopt_state_t);
}
int _set_state(uint8_t *val, size_t len)
{
ng_netopt_state_t state;
netopt_state_t state;
if (len != sizeof(ng_netopt_state_t)) {
if (len != sizeof(netopt_state_t)) {
return -EINVAL;
}
/* get target state */
memcpy(&state, val, len);
/* switch to target state */
switch (state) {
case NG_NETOPT_STATE_SLEEP:
case NETOPT_STATE_SLEEP:
_switch_to_idle();
break;
case NG_NETOPT_STATE_IDLE:
case NETOPT_STATE_IDLE:
_switch_to_rx();
break;
default:
return -ENOTSUP;
}
return sizeof(ng_netopt_state_t);
return sizeof(netopt_state_t);
}
int _get_address(uint8_t *val, size_t max_len)
@ -662,40 +662,40 @@ int _rem_event_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
return -ENOENT;
}
int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len)
int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
{
(void)dev;
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
return _get_address(value, max_len);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return _get_channel(value, max_len);
case NG_NETOPT_NID:
case NETOPT_NID:
return _get_pan(value, max_len);
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
return _get_txpower(value, max_len);
case NG_NETOPT_STATE:
case NETOPT_STATE:
return _get_state(value, max_len);
default:
return -ENOTSUP;
}
}
int _set(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len)
int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
{
(void)dev;
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
return _set_address(value, value_len);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return _set_channel(value, value_len);
case NG_NETOPT_NID:
case NETOPT_NID:
return _set_pan(value, value_len);
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
return _set_txpower(value, value_len);
case NG_NETOPT_STATE:
case NETOPT_STATE:
return _set_state(value, value_len);
default:
return -ENOTSUP;

View File

@ -109,7 +109,7 @@ typedef struct {
kernel_pid_t mac_pid; /**< The driver's thread's PID */
/* driver specific fields */
uint8_t buf[KW2XRF_MAX_PKT_LENGTH]; /**< Buffer for incoming or outgoing packets */
ng_netopt_state_t state; /**< Variable to keep radio driver's state */
netopt_state_t state; /**< Variable to keep radio driver's state */
uint8_t seq_nr; /**< Next packets sequence number */
uint16_t radio_pan; /**< The PAN the radio device is using */
uint8_t radio_channel; /**< The channel the radio device is using */

View File

@ -184,32 +184,32 @@ void kw2xrf_set_sequence(kw2xrf_t *dev, kw2xrf_physeq_t seq)
/* Progrmm new sequence */
switch (seq) {
case XCVSEQ_IDLE:
dev->state = NG_NETOPT_STATE_SLEEP;
dev->state = NETOPT_STATE_SLEEP;
break;
case XCVSEQ_RECEIVE:
dev->state = NG_NETOPT_STATE_IDLE;
dev->state = NETOPT_STATE_IDLE;
break;
case XCVSEQ_TRANSMIT:
dev->state = NG_NETOPT_STATE_TX;
dev->state = NETOPT_STATE_TX;
break;
case XCVSEQ_CCA:
dev->state = NG_NETOPT_STATE_TX;
dev->state = NETOPT_STATE_TX;
break;
case XCVSEQ_TX_RX:
dev->state = NG_NETOPT_STATE_TX;
dev->state = NETOPT_STATE_TX;
break;
case XCVSEQ_CONTINUOUS_CCA:
dev->state = NG_NETOPT_STATE_TX;
dev->state = NETOPT_STATE_TX;
break;
default:
DEBUG("kw2xrf: undefined state assigned to phy\n");
dev->state = NG_NETOPT_STATE_IDLE;
dev->state = NETOPT_STATE_IDLE;
}
/* Mapping of TX-sequences depending on AUTOACK flag */
@ -352,7 +352,7 @@ int kw2xrf_on(kw2xrf_t *dev)
/* abort any ongoing sequence */
kw2xrf_set_sequence(dev, XCVSEQ_IDLE);
dev->state = NG_NETOPT_STATE_SLEEP;
dev->state = NETOPT_STATE_SLEEP;
return 0;
}
@ -508,7 +508,7 @@ uint64_t kw2xrf_get_addr_long(kw2xrf_t *dev)
return addr;
}
int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len)
int kw2xrf_get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
{
kw2xrf_t *dev = (kw2xrf_t *)netdev;
@ -517,7 +517,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
}
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -525,7 +525,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*((uint16_t *)value) = ((dev->addr_short[0] << 8) | dev->addr_short[1]);
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (max_len < sizeof(uint64_t)) {
return -EOVERFLOW;
}
@ -533,7 +533,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*((uint64_t *)value) = kw2xrf_get_addr_long(dev);
return sizeof(uint64_t);
case NG_NETOPT_ADDR_LEN:
case NETOPT_ADDR_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -541,7 +541,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*((uint16_t *)value) = 2;
return sizeof(uint16_t);
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -555,7 +555,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -563,21 +563,21 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*((uint16_t *)value) = dev->radio_pan;
return sizeof(uint16_t);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return kw2xrf_get_channel(dev, (uint8_t *)value, max_len);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
return kw2xrf_get_proto(dev, (uint8_t *)value, max_len);
case NG_NETOPT_STATE:
if (max_len < sizeof(ng_netopt_state_t)) {
case NETOPT_STATE:
if (max_len < sizeof(netopt_state_t)) {
return -EOVERFLOW;
}
*(ng_netopt_state_t *)value = *(ng_netopt_state_t *) & (dev->state);
*(netopt_state_t *)value = *(netopt_state_t *) & (dev->state);
return 0;
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
if (max_len < 1) {
return -EOVERFLOW;
}
@ -585,7 +585,7 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*(int16_t *)value = dev->tx_power;
return 0;
case NG_NETOPT_MAX_PACKET_SIZE:
case NETOPT_MAX_PACKET_SIZE:
if (max_len < sizeof(int16_t)) {
return -EOVERFLOW;
}
@ -593,21 +593,21 @@ int kw2xrf_get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len
*((uint16_t *)value) = KW2XRF_MAX_PKT_LENGTH;
return sizeof(uint16_t);
case NG_NETOPT_PRELOADING:
*((ng_netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_PRELOADING);
return sizeof(ng_netopt_enable_t);
case NETOPT_PRELOADING:
*((netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_PRELOADING);
return sizeof(netopt_enable_t);
case NG_NETOPT_AUTOACK:
*((ng_netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_AUTOACK);
return sizeof(ng_netopt_enable_t);
case NETOPT_AUTOACK:
*((netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_AUTOACK);
return sizeof(netopt_enable_t);
case NG_NETOPT_PROMISCUOUSMODE:
*((ng_netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_PROMISCUOUS);
return sizeof(ng_netopt_enable_t);
case NETOPT_PROMISCUOUSMODE:
*((netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_PROMISCUOUS);
return sizeof(netopt_enable_t);
case NG_NETOPT_RAWMODE:
*((ng_netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_RAWDUMP);
return sizeof(ng_netopt_enable_t);
case NETOPT_RAWMODE:
*((netopt_enable_t *)value) = !!(dev->option & KW2XRF_OPT_RAWDUMP);
return sizeof(netopt_enable_t);
default:
return -ENOTSUP;
@ -696,7 +696,7 @@ void kw2xrf_set_option(kw2xrf_t *dev, uint16_t option, bool state)
}
}
int kw2xrf_set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_len)
int kw2xrf_set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
{
kw2xrf_t *dev = (kw2xrf_t *)netdev;
@ -705,24 +705,24 @@ int kw2xrf_set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_l
}
switch (opt) {
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return kw2xrf_set_channel(dev, (uint8_t *)value, value_len);
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (value_len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
return kw2xrf_set_addr(dev, *((uint16_t *)value));
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (value_len > sizeof(uint64_t)) {
return -EOVERFLOW;
}
return kw2xrf_set_addr_long(dev, *((uint64_t *)value));
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (value_len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -741,14 +741,14 @@ int kw2xrf_set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_l
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (value_len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
return kw2xrf_set_pan(dev, *((uint16_t *)value));
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
if (value_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -756,48 +756,48 @@ int kw2xrf_set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_l
kw2xrf_set_tx_power(dev, (int8_t *)value, value_len);
return sizeof(uint16_t);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
return kw2xrf_set_proto(dev, (uint8_t *)value, value_len);
case NG_NETOPT_AUTOACK:
case NETOPT_AUTOACK:
/* Set up HW generated automatic ACK after Receive */
kw2xrf_set_option(dev, KW2XRF_OPT_AUTOACK,
((bool *)value)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_PROMISCUOUSMODE:
case NETOPT_PROMISCUOUSMODE:
kw2xrf_set_option(dev, KW2XRF_OPT_PROMISCUOUS,
((bool *)value)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RAWMODE:
case NETOPT_RAWMODE:
kw2xrf_set_option(dev, KW2XRF_OPT_RAWDUMP,
((bool *)value)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_PRELOADING:
case NETOPT_PRELOADING:
kw2xrf_set_option(dev, KW2XRF_OPT_PRELOADING,
((bool *)value)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_AUTOCCA:
case NETOPT_AUTOCCA:
kw2xrf_set_option(dev, KW2XRF_OPT_CSMA,
((bool *)value)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_STATE:
if (*((ng_netopt_state_t *)value) == NG_NETOPT_STATE_TX) {
case NETOPT_STATE:
if (*((netopt_state_t *)value) == NETOPT_STATE_TX) {
DEBUG("kw2xrf: Sending now.\n");
kw2xrf_set_sequence(dev, XCVSEQ_TRANSMIT);
return sizeof(ng_netopt_state_t);
return sizeof(netopt_state_t);
}
else if (*((ng_netopt_state_t *)value) == NG_NETOPT_STATE_SLEEP) {
else if (*((netopt_state_t *)value) == NETOPT_STATE_SLEEP) {
kw2xrf_set_sequence(dev, XCVSEQ_IDLE);
return sizeof(ng_netopt_state_t);
return sizeof(netopt_state_t);
}
else if (*((ng_netopt_state_t *)value) == NG_NETOPT_STATE_IDLE) {
else if (*((netopt_state_t *)value) == NETOPT_STATE_IDLE) {
kw2xrf_set_sequence(dev, XCVSEQ_RECEIVE);
return sizeof(ng_netopt_state_t);
return sizeof(netopt_state_t);
}
/* TODO: Implement Off state here, when LPM functions are implemented */
@ -1188,7 +1188,7 @@ int kw2xrf_send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
DEBUG("kw2xrf: packet with size %i loaded to tx_buf\n", dev->buf[0]);
kw2xrf_write_fifo(dev->buf, dev->buf[0]);
if ((dev->option & KW2XRF_OPT_PRELOADING) == NG_NETOPT_DISABLE) {
if ((dev->option & KW2XRF_OPT_PRELOADING) == NETOPT_DISABLE) {
DEBUG("kw2xrf: Sending now.\n");
kw2xrf_set_sequence(dev, XCVSEQ_TRANSMIT);
}

View File

@ -318,46 +318,46 @@ static void _receive_data(ng_at86rf2xx_t *dev)
dev->event_cb(NETDEV_EVENT_RX_COMPLETE, payload);
}
static int _set_state(ng_at86rf2xx_t *dev, ng_netopt_state_t state)
static int _set_state(ng_at86rf2xx_t *dev, netopt_state_t state)
{
switch (state) {
case NG_NETOPT_STATE_SLEEP:
case NETOPT_STATE_SLEEP:
ng_at86rf2xx_set_state(dev, NG_AT86RF2XX_STATE_TRX_OFF);
break;
case NG_NETOPT_STATE_IDLE:
case NETOPT_STATE_IDLE:
ng_at86rf2xx_set_state(dev, NG_AT86RF2XX_STATE_RX_AACK_ON);
break;
case NG_NETOPT_STATE_TX:
case NETOPT_STATE_TX:
if (dev->options & NG_AT86RF2XX_OPT_PRELOADING) {
ng_at86rf2xx_tx_exec(dev);
}
break;
case NG_NETOPT_STATE_RESET:
case NETOPT_STATE_RESET:
ng_at86rf2xx_reset(dev);
break;
default:
return -ENOTSUP;
}
return sizeof(ng_netopt_state_t);
return sizeof(netopt_state_t);
}
ng_netopt_state_t _get_state(ng_at86rf2xx_t *dev)
netopt_state_t _get_state(ng_at86rf2xx_t *dev)
{
switch (ng_at86rf2xx_get_status(dev)) {
case NG_AT86RF2XX_STATE_SLEEP:
return NG_NETOPT_STATE_SLEEP;
return NETOPT_STATE_SLEEP;
case NG_AT86RF2XX_STATE_BUSY_RX_AACK:
return NG_NETOPT_STATE_RX;
return NETOPT_STATE_RX;
case NG_AT86RF2XX_STATE_BUSY_TX_ARET:
case NG_AT86RF2XX_STATE_TX_ARET_ON:
return NG_NETOPT_STATE_TX;
return NETOPT_STATE_TX;
case NG_AT86RF2XX_STATE_RX_AACK_ON:
default:
return NG_NETOPT_STATE_IDLE;
return NETOPT_STATE_IDLE;
}
}
static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
static int _get(ng_netdev_t *device, netopt_t opt, void *val, size_t max_len)
{
if (device == NULL) {
return -ENODEV;
@ -366,28 +366,28 @@ static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)val) = ng_at86rf2xx_get_addr_short(dev);
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (max_len < sizeof(uint64_t)) {
return -EOVERFLOW;
}
*((uint64_t *)val) = ng_at86rf2xx_get_addr_long(dev);
return sizeof(uint64_t);
case NG_NETOPT_ADDR_LEN:
case NETOPT_ADDR_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)val) = 2;
return sizeof(uint16_t);
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -399,14 +399,14 @@ static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
}
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)val) = dev->pan;
return sizeof(uint16_t);
case NG_NETOPT_IPV6_IID:
case NETOPT_IPV6_IID:
if (max_len < sizeof(eui64_t)) {
return -EOVERFLOW;
}
@ -420,14 +420,14 @@ static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
}
return sizeof(eui64_t);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
if (max_len < sizeof(ng_nettype_t)) {
return -EOVERFLOW;
}
*((ng_nettype_t *)val) = dev->proto;
return sizeof(ng_nettype_t);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -435,98 +435,98 @@ static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
((uint8_t *)val)[0] = ng_at86rf2xx_get_chan(dev);
return sizeof(uint16_t);
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
if (max_len < sizeof(int16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)val) = ng_at86rf2xx_get_txpower(dev);
return sizeof(uint16_t);
case NG_NETOPT_MAX_PACKET_SIZE:
case NETOPT_MAX_PACKET_SIZE:
if (max_len < sizeof(int16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)val) = NG_AT86RF2XX_MAX_PKT_LENGTH - _MAX_MHR_OVERHEAD;
return sizeof(uint16_t);
case NG_NETOPT_STATE:
if (max_len < sizeof(ng_netopt_state_t)) {
case NETOPT_STATE:
if (max_len < sizeof(netopt_state_t)) {
return -EOVERFLOW;
}
*((ng_netopt_state_t*)val) = _get_state(dev);
*((netopt_state_t*)val) = _get_state(dev);
break;
case NG_NETOPT_PRELOADING:
case NETOPT_PRELOADING:
if (dev->options & NG_AT86RF2XX_OPT_PRELOADING) {
*((ng_netopt_enable_t *)val) = NG_NETOPT_ENABLE;
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
*((ng_netopt_enable_t *)val) = NG_NETOPT_DISABLE;
*((netopt_enable_t *)val) = NETOPT_DISABLE;
}
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_AUTOACK:
case NETOPT_AUTOACK:
if (dev->options & NG_AT86RF2XX_OPT_AUTOACK) {
*((ng_netopt_enable_t *)val) = NG_NETOPT_ENABLE;
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
*((ng_netopt_enable_t *)val) = NG_NETOPT_DISABLE;
*((netopt_enable_t *)val) = NETOPT_DISABLE;
}
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RETRANS:
case NETOPT_RETRANS:
if (max_len < sizeof(uint8_t)) {
return -EOVERFLOW;
}
*((uint8_t *)val) = ng_at86rf2xx_get_max_retries(dev);
return sizeof(uint8_t);
case NG_NETOPT_PROMISCUOUSMODE:
case NETOPT_PROMISCUOUSMODE:
if (dev->options & NG_AT86RF2XX_OPT_PROMISCUOUS) {
*((ng_netopt_enable_t *)val) = NG_NETOPT_ENABLE;
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
*((ng_netopt_enable_t *)val) = NG_NETOPT_DISABLE;
*((netopt_enable_t *)val) = NETOPT_DISABLE;
}
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RAWMODE:
case NETOPT_RAWMODE:
if (dev->options & NG_AT86RF2XX_OPT_RAWDUMP) {
*((ng_netopt_enable_t *)val) = NG_NETOPT_ENABLE;
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
*((ng_netopt_enable_t *)val) = NG_NETOPT_DISABLE;
*((netopt_enable_t *)val) = NETOPT_DISABLE;
}
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_IS_CHANNEL_CLR:
case NETOPT_IS_CHANNEL_CLR:
if (ng_at86rf2xx_cca(dev)) {
*((ng_netopt_enable_t *)val) = NG_NETOPT_ENABLE;
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
*((ng_netopt_enable_t *)val) = NG_NETOPT_DISABLE;
*((netopt_enable_t *)val) = NETOPT_DISABLE;
}
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RX_START_IRQ:
*((ng_netopt_enable_t *)val) =
case NETOPT_RX_START_IRQ:
*((netopt_enable_t *)val) =
!!(dev->options & NG_AT86RF2XX_OPT_TELL_RX_START);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RX_END_IRQ:
*((ng_netopt_enable_t *)val) =
case NETOPT_RX_END_IRQ:
*((netopt_enable_t *)val) =
!!(dev->options & NG_AT86RF2XX_OPT_TELL_RX_END);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_TX_START_IRQ:
*((ng_netopt_enable_t *)val) =
case NETOPT_TX_START_IRQ:
*((netopt_enable_t *)val) =
!!(dev->options & NG_AT86RF2XX_OPT_TELL_TX_START);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_TX_END_IRQ:
*((ng_netopt_enable_t *)val) =
case NETOPT_TX_END_IRQ:
*((netopt_enable_t *)val) =
!!(dev->options & NG_AT86RF2XX_OPT_TELL_TX_END);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
default:
return -ENOTSUP;
@ -535,7 +535,7 @@ static int _get(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t max_len)
return 0;
}
static int _set(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t len)
static int _set(ng_netdev_t *device, netopt_t opt, void *val, size_t len)
{
ng_at86rf2xx_t *dev = (ng_at86rf2xx_t *) device;
@ -544,21 +544,21 @@ static int _set(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t len)
}
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
ng_at86rf2xx_set_addr_short(dev, *((uint16_t*)val));
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (len > sizeof(uint64_t)) {
return -EOVERFLOW;
}
ng_at86rf2xx_set_addr_long(dev, *((uint64_t*)val));
return sizeof(uint64_t);
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -575,14 +575,14 @@ static int _set(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t len)
}
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (len > sizeof(uint16_t)) {
return -EOVERFLOW;
}
ng_at86rf2xx_set_pan(dev, *((uint16_t *)val));
return sizeof(uint16_t);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
if (len != sizeof(uint16_t)) {
return -EINVAL;
}
@ -594,65 +594,65 @@ static int _set(ng_netdev_t *device, ng_netopt_t opt, void *val, size_t len)
ng_at86rf2xx_set_chan(dev, chan);
return sizeof(uint16_t);
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
if (len > sizeof(int16_t)) {
return -EOVERFLOW;
}
ng_at86rf2xx_set_txpower(dev, *((int16_t *)val));
return sizeof(uint16_t);
case NG_NETOPT_STATE:
if (len > sizeof(ng_netopt_state_t)) {
case NETOPT_STATE:
if (len > sizeof(netopt_state_t)) {
return -EOVERFLOW;
}
return _set_state(dev, *((ng_netopt_state_t *)val));
return _set_state(dev, *((netopt_state_t *)val));
case NG_NETOPT_AUTOACK:
case NETOPT_AUTOACK:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_AUTOACK,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RETRANS:
case NETOPT_RETRANS:
if (len > sizeof(uint8_t)) {
return -EOVERFLOW;
}
ng_at86rf2xx_set_max_retries(dev, *((uint8_t *)val));
return sizeof(uint8_t);
case NG_NETOPT_PRELOADING:
case NETOPT_PRELOADING:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_PRELOADING,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_PROMISCUOUSMODE:
case NETOPT_PROMISCUOUSMODE:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_PROMISCUOUS,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RAWMODE:
case NETOPT_RAWMODE:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_RAWDUMP,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RX_START_IRQ:
case NETOPT_RX_START_IRQ:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_RX_START,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_RX_END_IRQ:
case NETOPT_RX_END_IRQ:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_RX_END,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_TX_START_IRQ:
case NETOPT_TX_START_IRQ:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_TX_START,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
case NG_NETOPT_TX_END_IRQ:
case NETOPT_TX_END_IRQ:
ng_at86rf2xx_set_option(dev, NG_AT86RF2XX_OPT_TELL_TX_END,
((bool *)val)[0]);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
default:
return -ENOTSUP;

View File

@ -597,7 +597,7 @@ static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
return 0;
}
static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len)
static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
{
xbee_t *dev = (xbee_t *)netdev;
if (dev == NULL) {
@ -605,12 +605,12 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
}
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
return _get_addr_short(dev, (uint8_t *)value, max_len);
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
return _get_addr_long(dev, (uint8_t *)value, max_len);
case NG_NETOPT_ADDR_LEN:
case NG_NETOPT_SRC_LEN:
case NETOPT_ADDR_LEN:
case NETOPT_SRC_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -621,7 +621,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
*((uint16_t *)value) = 2;
}
return sizeof(uint16_t);
case NG_NETOPT_IPV6_IID:
case NETOPT_IPV6_IID:
if (max_len < sizeof(eui64_t)) {
return -EOVERFLOW;
}
@ -633,24 +633,24 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
}
return sizeof(eui64_t);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return _get_channel(dev, (uint8_t *)value, max_len);
case NG_NETOPT_MAX_PACKET_SIZE:
case NETOPT_MAX_PACKET_SIZE:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
*((uint16_t *)value) = XBEE_MAX_PAYLOAD_LENGTH;
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
return _get_panid(dev, (uint8_t *)value, max_len);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
return _get_proto(dev, (uint8_t *)value, max_len);
default:
return -ENOTSUP;
}
}
static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_len)
static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
{
xbee_t *dev = (xbee_t *)netdev;
if (dev == NULL) {
@ -658,16 +658,16 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
}
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
return _set_addr(dev, (uint8_t *)value, value_len);
case NG_NETOPT_ADDR_LEN:
case NG_NETOPT_SRC_LEN:
case NETOPT_ADDR_LEN:
case NETOPT_SRC_LEN:
return _set_addr_len(dev, value, value_len);
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
return _set_channel(dev, (uint8_t *)value, value_len);
case NG_NETOPT_NID:
case NETOPT_NID:
return _set_panid(dev, (uint8_t *)value, value_len);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
return _set_proto(dev, (uint8_t *)value, value_len);
default:
return -ENOTSUP;

185
sys/include/net/netopt.h Normal file
View File

@ -0,0 +1,185 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_netopt Configuration options for network APIs
* @ingroup net
* @brief List of available configuration options for the
* @ref net_ng_netdev and the @ref net_ng_netapi
* @{
*
* @file
* @brief Definition of global configuration options
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#ifndef NETOPT_H_
#define NETOPT_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Global list of configuration options available throughout the
* network stack, e.g. by netdev and netapi
*/
typedef enum {
NETOPT_CHANNEL, /**< get/set channel as uint16_t in host
* byte order */
NETOPT_IS_CHANNEL_CLR, /**< check if channel is clear */
NETOPT_ADDRESS, /**< get/set address in host byte order */
/**
* @brief get/set long address in host byte order
*
* Examples for this include the EUI-64 in IEEE 802.15.4
*/
NETOPT_ADDRESS_LONG,
NETOPT_ADDR_LEN, /**< get the default address length a
* network device expects as uint16_t in
* host byte order */
NETOPT_SRC_LEN, /**< get/set the address length to choose
* for the network device's source address
* as uint16_t in host byte order */
/**
* @brief get/set the network ID as uint16_t in host byte order
*
* Examples for this include the PAN ID in IEEE 802.15.4
*/
NETOPT_NID,
/**
* @brief get the IPv6 interface identifier of a network interface as
* eui64_t.
*
* @see <a href="https://tools.ietf.org/html/rfc4291#section-2.5.1">
* RFC 4291, section 2.5.1
* </a>
*
* The generation of the interface identifier is dependent on the link-layer.
* Please refer to the appropriate IPv6 over `<link>` specification for
* further implementation details (such as
* <a href="https://tools.ietf.org/html/rfc2464">RFC 2464</a> or
* <a href="https://tools.ietf.org/html/rfc4944">RFC 4944</a>).
*/
NETOPT_IPV6_IID,
NETOPT_TX_POWER, /**< get/set the output power for radio
* devices in dBm as int16_t in host byte
* order */
NETOPT_MAX_PACKET_SIZE, /**< get/set the maximum packet size a
* network module can handle as uint16_t
* in host byte order */
/**
* @brief en/disable preloading or read the current state.
*
* Preload using ng_netdev_driver_t::send_data() or ng_netapi_send()
* respectively, send setting state to @ref NETOPT_STATE_TX
*/
NETOPT_PRELOADING,
NETOPT_PROMISCUOUSMODE, /**< en/disable promiscuous mode or read
* the current state */
NETOPT_AUTOACK, /**< en/disable link layer auto ACKs or read
* the current state */
NETOPT_RETRANS, /**< get/set the maximum number of
* retransmissions. */
NETOPT_PROTO, /**< get/set the protocol for the layer
* as type ng_nettype_t. */
NETOPT_STATE, /**< get/set the state of network devices as
* type netopt_state_t */
NETOPT_RAWMODE, /**< en/disable the pre-processing of data
* in a network device driver as type
* ng_nettype_t */
/**
* @brief en/disable the interrupt at reception start.
*
* It is mostly triggered after the preamble is correctly received
*
* @note not all transceivers may support this interrupt
*/
NETOPT_RX_START_IRQ,
/**
* @brief en/disable the interrupt after packet reception.
*
* This interrupt is triggered after a complete packet is received.
*
* @note in case a transceiver does not support this interrupt, the event
* may be triggered by the driver
*/
NETOPT_RX_END_IRQ,
/**
* @brief en/disable the interrupt right in the beginning of transmission.
*
* This interrupt is triggered when the transceiver starts to send out the
* packet.
*
* @note in case a transceiver does not support this interrupt, the event
* may be triggered by the driver
*/
NETOPT_TX_START_IRQ,
/**
* @brief en/disable the interrupt after packet transmission.
*
* This interrupt is triggered when the full packet is transmitted.
*
* @note not all transceivers may support this interrupt
*/
NETOPT_TX_END_IRQ,
NETOPT_AUTOCCA, /**< en/disable to check automatically
* before sending the channel is clear. */
/* add more options if needed */
/**
* @brief maximum number of options defined here
*
* @note Interfaces are not meant to respond to that.
*/
NETOPT_NUMOF,
} netopt_t;
/**
* @brief Binary parameter for enabling and disabling options
*/
typedef enum {
NETOPT_DISABLE = 0, /**< disable a given option */
NETOPT_ENABLE = 1, /**< enable a given option */
} netopt_enable_t;
/**
* @brief Option parameter to be used with @ref NETOPT_STATE to set or get
* the state of a network device or protocol implementation
*/
typedef enum {
NETOPT_STATE_OFF = 0, /**< powered off */
NETOPT_STATE_SLEEP, /**< sleep mode */
NETOPT_STATE_IDLE, /**< idle mode,
* the device listens to receive packets */
NETOPT_STATE_RX, /**< receive mode,
* the device currently receives a packet */
NETOPT_STATE_TX, /**< transmit mode,
* set: triggers transmission of a preloaded packet
* (see @ref NETOPT_PRELOADING*). The resulting
* state of the network device is @ref NETOPT_STATE_IDLE
* get: the network device is in the process of
* transmitting a packet */
NETOPT_STATE_RESET, /**< triggers a hardware reset. The resulting
* state of the network device is @ref NETOPT_STATE_IDLE */
/* add other states if needed */
} netopt_state_t;
#ifdef __cplusplus
}
#endif
#endif /* NETOPT_H_ */
/** @} */

View File

@ -30,7 +30,7 @@
#include "kernel.h"
#include "thread.h"
#include "net/ng_netopt.h"
#include "net/netopt.h"
#include "net/ng_nettype.h"
#include "net/ng_pkt.h"
@ -67,7 +67,7 @@ extern "C" {
* @brief Data structure to be send for setting and getting options
*/
typedef struct {
ng_netopt_t opt; /**< the option to get/set */
netopt_t opt; /**< the option to get/set */
uint16_t context; /**< (optional) context for that option */
void *data; /**< data to set or buffer to read into */
uint16_t data_len; /**< size of the data / the buffer */
@ -133,7 +133,7 @@ int ng_netapi_dispatch_receive(ng_nettype_t type, uint32_t demux_ctx,
*
* @return value returned by the @ref NG_NETAPI_MSG_TYPE_ACK message
*/
int ng_netapi_get(kernel_pid_t pid, ng_netopt_t opt, uint16_t context,
int ng_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
void *data, size_t max_len);
/**
@ -148,7 +148,7 @@ int ng_netapi_get(kernel_pid_t pid, ng_netopt_t opt, uint16_t context,
*
* @return value returned by the @ref NG_NETAPI_MSG_TYPE_ACK message
*/
int ng_netapi_set(kernel_pid_t pid, ng_netopt_t opt, uint16_t context,
int ng_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
void *data, size_t data_len);
#ifdef __cplusplus

View File

@ -20,9 +20,9 @@
#ifndef NG_NETBASE_H_
#define NG_NETBASE_H_
#include "net/netopt.h"
#include "net/ng_netdev.h"
#include "net/ng_netapi.h"
#include "net/ng_netopt.h"
#include "net/ng_netreg.h"
#include "net/ng_nettype.h"
#include "net/ng_netif.h"

View File

@ -28,7 +28,7 @@
#include "kernel.h"
#include "net/ng_pkt.h"
#include "net/ng_netopt.h"
#include "net/netopt.h"
#ifdef __cplusplus
extern "C" {
@ -127,7 +127,7 @@ typedef struct {
* @p max_len is too small to store the option value
* @return -ECANCELED if internal driver error occurred
*/
int (*get)(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len);
int (*get)(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
/**
* @brief Set an option value for a given network device
@ -143,7 +143,7 @@ typedef struct {
* @return -EINVAL if @p value is invalid
* @return -ECANCELED if internal driver error occurred
*/
int (*set)(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len);
int (*set)(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
/**
* @brief This function is called by a MAC layer when a message of type

View File

@ -1,185 +0,0 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_ng_netopt Configuration options for network APIs
* @ingroup net
* @brief List of available configuration options for the
* @ref net_ng_netdev and the @ref net_ng_netapi
* @{
*
* @file
* @brief Definition of global configuration options
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#ifndef NG_NETOPT_H_
#define NG_NETOPT_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Global list of configuration options available throughout the
* network stack, e.g. by netdev and netapi
*/
typedef enum {
NG_NETOPT_CHANNEL, /**< get/set channel as uint16_t in host
* byte order */
NG_NETOPT_IS_CHANNEL_CLR, /**< check if channel is clear */
NG_NETOPT_ADDRESS, /**< get/set address in host byte order */
/**
* @brief get/set long address in host byte order
*
* Examples for this include the EUI-64 in IEEE 802.15.4
*/
NG_NETOPT_ADDRESS_LONG,
NG_NETOPT_ADDR_LEN, /**< get the default address length a
* network device expects as uint16_t in
* host byte order */
NG_NETOPT_SRC_LEN, /**< get/set the address length to choose
* for the network device's source address
* as uint16_t in host byte order */
/**
* @brief get/set the network ID as uint16_t in host byte order
*
* Examples for this include the PAN ID in IEEE 802.15.4
*/
NG_NETOPT_NID,
/**
* @brief get the IPv6 interface identifier of a network interface as
* eui64_t.
*
* @see <a href="https://tools.ietf.org/html/rfc4291#section-2.5.1">
* RFC 4291, section 2.5.1
* </a>
*
* The generation of the interface identifier is dependent on the link-layer.
* Please refer to the appropriate IPv6 over `<link>` specification for
* further implementation details (such as
* <a href="https://tools.ietf.org/html/rfc2464">RFC 2464</a> or
* <a href="https://tools.ietf.org/html/rfc4944">RFC 4944</a>).
*/
NG_NETOPT_IPV6_IID,
NG_NETOPT_TX_POWER, /**< get/set the output power for radio
* devices in dBm as int16_t in host byte
* order */
NG_NETOPT_MAX_PACKET_SIZE, /**< get/set the maximum packet size a
* network module can handle as uint16_t
* in host byte order */
/**
* @brief en/disable preloading or read the current state.
*
* Preload using ng_netdev_driver_t::send_data() or ng_netapi_send()
* respectively, send setting state to @ref NG_NETOPT_STATE_TX
*/
NG_NETOPT_PRELOADING,
NG_NETOPT_PROMISCUOUSMODE, /**< en/disable promiscuous mode or read
* the current state */
NG_NETOPT_AUTOACK, /**< en/disable link layer auto ACKs or read
* the current state */
NG_NETOPT_RETRANS, /**< get/set the maximum number of
retransmissions. */
NG_NETOPT_PROTO, /**< get/set the protocol for the layer
* as type ng_nettype_t. */
NG_NETOPT_STATE, /**< get/set the state of network devices as
* type ng_netopt_state_t */
NG_NETOPT_RAWMODE, /**< en/disable the pre-processing of data
* in a network device driver as type
* ng_nettype_t */
/**
* @brief en/disable the interrupt at reception start.
*
* It is mostly triggered after the preamble is correctly received
*
* @note not all transceivers may support this interrupt
*/
NG_NETOPT_RX_START_IRQ,
/**
* @brief en/disable the interrupt after packet reception.
*
* This interrupt is triggered after a complete packet is received.
*
* @note in case a transceiver does not support this interrupt, the event
* may be triggered by the driver
*/
NG_NETOPT_RX_END_IRQ,
/**
* @brief en/disable the interrupt right in the beginning of transmission.
*
* This interrupt is triggered when the transceiver starts to send out the
* packet.
*
* @note in case a transceiver does not support this interrupt, the event
* may be triggered by the driver
*/
NG_NETOPT_TX_START_IRQ,
/**
* @brief en/disable the interrupt after packet transmission.
*
* This interrupt is triggered when the full packet is transmitted.
*
* @note not all transceivers may support this interrupt
*/
NG_NETOPT_TX_END_IRQ,
NG_NETOPT_AUTOCCA, /**< en/disable to check automatically
* before sending the channel is clear. */
/* add more options if needed */
/**
* @brief maximum number of options defined here
*
* @note Interfaces are not meant to respond to that.
*/
NG_NETOPT_NUMOF,
} ng_netopt_t;
/**
* @brief Binary parameter for enabling and disabling options
*/
typedef enum {
NG_NETOPT_DISABLE = 0, /**< disable a given option */
NG_NETOPT_ENABLE = 1, /**< enable a given option */
} ng_netopt_enable_t;
/**
* @brief Option parameter to be used with @ref NG_NETOPT_STATE to set or get
* the state of a network device or protocol implementation
*/
typedef enum {
NG_NETOPT_STATE_OFF = 0, /**< powered off */
NG_NETOPT_STATE_SLEEP, /**< sleep mode */
NG_NETOPT_STATE_IDLE, /**< idle mode,
* the device listens to receive packets */
NG_NETOPT_STATE_RX, /**< receive mode,
* the device currently receives a packet */
NG_NETOPT_STATE_TX, /**< transmit mode,
* set: triggers transmission of a preloaded packet
* (see @ref NG_NETOPT_PRELOADING*). The resulting
* state of the network device is @ref NG_NETOPT_STATE_IDLE
* get: the network device is in the process of
* transmitting a packet */
NG_NETOPT_STATE_RESET, /**< triggers a hardware reset. The resulting
* state of the network device is @ref NG_NETOPT_STATE_IDLE */
/* add other states if needed */
} ng_netopt_state_t;
#ifdef __cplusplus
}
#endif
#endif /* NG_NETOPT_H_ */
/** @} */

View File

@ -26,7 +26,7 @@
#include "kernel_types.h"
#include "net/ng_netapi.h"
#include "net/ng_netopt.h"
#include "net/netopt.h"
#include "net/ng_nettype.h"
#include "net/ng_pkt.h"
#include "thread.h"
@ -105,7 +105,7 @@ typedef enum {
* @param[in] opt The option to register the getter for.
* @param[in] cb An option getter. NULL to delete.
*/
void ng_nettest_register_get(ng_netopt_t opt, ng_nettest_opt_cb_t cb);
void ng_nettest_register_get(netopt_t opt, ng_nettest_opt_cb_t cb);
/**
* @brief Registers a setter for an option.
@ -115,7 +115,7 @@ void ng_nettest_register_get(ng_netopt_t opt, ng_nettest_opt_cb_t cb);
* @param[in] opt The option to register the setter for.
* @param[in] cb An option setter. NULL to delete.
*/
void ng_nettest_register_set(ng_netopt_t opt, ng_nettest_opt_cb_t cb);
void ng_nettest_register_set(netopt_t opt, ng_nettest_opt_cb_t cb);
/**
* @brief Test @ref NG_NETAPI_MSG_TYPE_SND command to @p pid.
@ -223,7 +223,7 @@ ng_nettest_res_t ng_nettest_receive(kernel_pid_t pid, ng_pktsnip_t *in,
*
* @return @see ng_nettest_res_t
*/
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, ng_netopt_t opt,
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, netopt_t opt,
uint16_t context, void *data, size_t data_len,
void *exp_data, int exp_res);
@ -242,7 +242,7 @@ ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, ng_netopt_t opt,
*
* @return @see ng_nettest_res_t
*/
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, ng_netopt_t opt,
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, netopt_t opt,
uint16_t context, void *data, size_t data_len,
int exp_res);

View File

@ -56,8 +56,8 @@ static ringbuffer_t _rx_buf = RINGBUFFER_INIT(_rx_buf_array);
static int _send(ng_netdev_t *dev, ng_pktsnip_t *pkt);
static int _add_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
static int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len);
static int _set(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len);
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
static void _isr_event(ng_netdev_t *dev, uint32_t event_type);
static const ng_netdev_driver_t _zep_driver = {
@ -182,14 +182,14 @@ static inline void _set_uint64_ptr(uint64_t *ptr, uint64_t val)
*ptr = val;
}
static inline void _set_flag_ptr(ng_netopt_enable_t *enable,
static inline void _set_flag_ptr(netopt_enable_t *enable,
uint16_t flag_field, uint16_t flag)
{
if (flag_field & flag) {
*enable = NG_NETOPT_ENABLE;
*enable = NETOPT_ENABLE;
}
else {
*enable = NG_NETOPT_DISABLE;
*enable = NETOPT_DISABLE;
}
}
@ -327,7 +327,7 @@ static int _rem_cb(ng_netdev_t *dev, ng_netdev_event_cb_t cb)
return 0;
}
static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_len)
static int _get(ng_netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
{
ng_zep_t *dev = (ng_zep_t *)netdev;
@ -336,7 +336,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
}
switch (opt) {
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -344,7 +344,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
_set_uint16_ptr(value, (uint16_t)dev->chan);
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -352,7 +352,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
_set_uint16_ptr(value, byteorder_ltobs(dev->addr).u16);
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (max_len < sizeof(uint64_t)) {
return -EOVERFLOW;
}
@ -360,7 +360,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
_set_uint64_ptr(value, byteorder_ltobll(dev->eui64).u64);
return sizeof(uint64_t);
case NG_NETOPT_ADDR_LEN:
case NETOPT_ADDR_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -374,7 +374,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
return sizeof(uint16_t);
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -388,7 +388,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
return sizeof(uint16_t);
case NG_NETOPT_PROTO:
case NETOPT_PROTO:
if (max_len < sizeof(ng_nettype_t)) {
return -EOVERFLOW;
}
@ -396,7 +396,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
*((ng_nettype_t *)value) = dev->proto;
return sizeof(ng_nettype_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -404,7 +404,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
_set_uint16_ptr(value, byteorder_ltobs(dev->pan).u16);
return sizeof(uint16_t);
case NG_NETOPT_IPV6_IID:
case NETOPT_IPV6_IID:
if (max_len < sizeof(eui64_t)) {
return -EOVERFLOW;
}
@ -418,7 +418,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
}
return sizeof(eui64_t);
case NG_NETOPT_MAX_PACKET_SIZE:
case NETOPT_MAX_PACKET_SIZE:
if (max_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -426,8 +426,8 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
_set_uint16_ptr(value, NG_ZEP_MAX_PKT_LENGTH);
return sizeof(uint16_t);
case NG_NETOPT_AUTOACK:
if (max_len < sizeof(ng_netopt_enable_t)) {
case NETOPT_AUTOACK:
if (max_len < sizeof(netopt_enable_t)) {
return -EOVERFLOW;
}
@ -439,7 +439,7 @@ static int _get(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t max_le
}
}
static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_len)
static int _set(ng_netdev_t *netdev, netopt_t opt, void *value, size_t value_len)
{
ng_zep_t *dev = (ng_zep_t *)netdev;
@ -448,7 +448,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
}
switch (opt) {
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
if (value_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -461,7 +461,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
dev->chan = *_get_uint16_ptr(value);
return sizeof(uint16_t);
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
if (value_len < sizeof(be_uint16_t)) {
return -EOVERFLOW;
}
@ -472,7 +472,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
return sizeof(be_uint16_t);
}
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
if (value_len < sizeof(be_uint64_t)) {
return -EOVERFLOW;
}
@ -483,7 +483,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
return sizeof(be_uint64_t);
}
case NG_NETOPT_ADDR_LEN:
case NETOPT_ADDR_LEN:
if (value_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -503,7 +503,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
return sizeof(uint16_t);
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
if (value_len < sizeof(uint16_t)) {
return -EOVERFLOW;
}
@ -523,7 +523,7 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
return sizeof(uint16_t);
case NG_NETOPT_NID:
case NETOPT_NID:
if (value_len < sizeof(be_uint16_t)) {
return -EOVERFLOW;
}
@ -534,8 +534,8 @@ static int _set(ng_netdev_t *netdev, ng_netopt_t opt, void *value, size_t value_
return sizeof(be_uint16_t);
}
case NG_NETOPT_AUTOACK:
if (value_len < sizeof(ng_netopt_enable_t)) {
case NETOPT_AUTOACK:
if (value_len < sizeof(netopt_enable_t)) {
return -EOVERFLOW;
}

View File

@ -36,7 +36,7 @@
* @return the value from the received ACK message
*/
static inline int _get_set(kernel_pid_t pid, uint16_t type,
ng_netopt_t opt, uint16_t context,
netopt_t opt, uint16_t context,
void *data, size_t data_len)
{
msg_t cmd;
@ -106,14 +106,14 @@ int ng_netapi_dispatch_receive(ng_nettype_t type, uint32_t demux_ctx,
return _snd_rcv_dispatch(type, demux_ctx, NG_NETAPI_MSG_TYPE_RCV, pkt);
}
int ng_netapi_get(kernel_pid_t pid, ng_netopt_t opt, uint16_t context,
int ng_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
void *data, size_t data_len)
{
return _get_set(pid, NG_NETAPI_MSG_TYPE_GET, opt, context,
data, data_len);
}
int ng_netapi_set(kernel_pid_t pid, ng_netopt_t opt, uint16_t context,
int ng_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
void *data, size_t data_len)
{
return _get_set(pid, NG_NETAPI_MSG_TYPE_SET, opt, context,

View File

@ -19,7 +19,7 @@
#include "mutex.h"
#include "net/ng_netapi.h"
#include "net/ng_netif.h"
#include "net/ng_netopt.h"
#include "net/netopt.h"
#include "net/ng_netreg.h"
#include "net/ng_pktbuf.h"
#include "timex.h"
@ -28,21 +28,21 @@
#include "net/ng_nettest.h"
static ng_nettest_opt_cbs_t _opt_cbs[NG_NETOPT_NUMOF];
static ng_nettest_opt_cbs_t _opt_cbs[NETOPT_NUMOF];
static mutex_t _mutex = MUTEX_INIT;
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
static char _stack[NG_NETTEST_STACK_SIZE];
static void *_event_loop(void *arg);
void ng_nettest_register_get(ng_netopt_t opt, ng_nettest_opt_cb_t cb)
void ng_nettest_register_get(netopt_t opt, ng_nettest_opt_cb_t cb)
{
mutex_lock(&_mutex);
_opt_cbs[opt].get = cb;
mutex_unlock(&_mutex);
}
void ng_nettest_register_set(ng_netopt_t opt, ng_nettest_opt_cb_t cb)
void ng_nettest_register_set(netopt_t opt, ng_nettest_opt_cb_t cb)
{
mutex_lock(&_mutex);
_opt_cbs[opt].set = cb;
@ -163,7 +163,7 @@ ng_nettest_res_t ng_nettest_receive(kernel_pid_t pid, ng_pktsnip_t *in,
return res;
}
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, ng_netopt_t opt,
ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, netopt_t opt,
uint16_t context, void *data, size_t data_len,
void *exp_data, int exp_res)
{
@ -175,7 +175,7 @@ ng_nettest_res_t ng_nettest_get(kernel_pid_t pid, ng_netopt_t opt,
return NG_NETTEST_SUCCESS;
}
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, ng_netopt_t opt,
ng_nettest_res_t ng_nettest_set(kernel_pid_t pid, netopt_t opt,
uint16_t context, void *data, size_t data_len,
int exp_res)
{
@ -198,7 +198,7 @@ int ng_nettest_init(void)
void ng_nettest_reset(void)
{
for (int i = 0; i < NG_NETOPT_NUMOF; i++) {
for (int i = 0; i < NETOPT_NUMOF; i++) {
_opt_cbs[i].get = NULL;
_opt_cbs[i].set = NULL;
}

View File

@ -56,8 +56,8 @@ static uint8_t recv_buffer[NG_ETHERNET_MAX_LEN];
static int _send_data(ng_netdev_t *netdev, ng_pktsnip_t *pkt);
static int _add_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
static int _rem_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb);
static int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len);
static int _set(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len);
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len);
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len);
static void _isr_event(ng_netdev_t *dev, uint32_t event_type);
/* netdev driver struct */
@ -227,22 +227,22 @@ static inline int _get_max_pkt_sz(uint16_t *value, size_t max_len)
return sizeof(uint16_t);
}
static inline int _get_promiscousmode(ng_netdev_eth_t *netdev, ng_netopt_enable_t *value,
static inline int _get_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *value,
size_t max_len)
{
if (max_len != sizeof(ng_netopt_enable_t)) {
if (max_len != sizeof(netopt_enable_t)) {
/* value buffer not big enough */
return -EOVERFLOW;
}
dev_eth_t *dev = netdev->ethdev;
*value = (ng_netopt_enable_t)dev->driver->get_promiscous(dev);
*value = (netopt_enable_t)dev->driver->get_promiscous(dev);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
}
static int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len)
static int _get(ng_netdev_t *dev, netopt_t opt, void *value, size_t max_len)
{
DEBUG("ng_netdev_eth: get ");
@ -252,23 +252,23 @@ static int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len)
}
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
DEBUG("address\n");
return _get_addr((ng_netdev_eth_t *)dev, value, max_len);
case NG_NETOPT_ADDR_LEN:
case NETOPT_ADDR_LEN:
DEBUG("address length\n");
return _get_addr_len(value, max_len);
case NG_NETOPT_IPV6_IID:
case NETOPT_IPV6_IID:
DEBUG("IPv6 IID\n");
return _get_iid((ng_netdev_eth_t *)dev, value, max_len);
case NG_NETOPT_MAX_PACKET_SIZE:
case NETOPT_MAX_PACKET_SIZE:
DEBUG("maximum packet size\n");
return _get_max_pkt_sz(value, max_len);
case NG_NETOPT_PROMISCUOUSMODE:
case NETOPT_PROMISCUOUSMODE:
DEBUG("promiscous mode\n");
return _get_promiscousmode((ng_netdev_eth_t *)dev, value, max_len);
@ -279,10 +279,10 @@ static int _get(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t max_len)
}
/* individual option getters to be called by _get() */
static inline int _set_promiscousmode(ng_netdev_eth_t *netdev, ng_netopt_enable_t *value,
static inline int _set_promiscousmode(ng_netdev_eth_t *netdev, netopt_enable_t *value,
size_t value_len)
{
if (value_len != sizeof(ng_netopt_enable_t)) {
if (value_len != sizeof(netopt_enable_t)) {
/* value buffer not big enough */
return -EOVERFLOW;
}
@ -291,10 +291,10 @@ static inline int _set_promiscousmode(ng_netdev_eth_t *netdev, ng_netopt_enable_
dev->driver->set_promiscous(dev, (uint8_t)*value);
return sizeof(ng_netopt_enable_t);
return sizeof(netopt_enable_t);
}
static int _set(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len)
static int _set(ng_netdev_t *dev, netopt_t opt, void *value, size_t value_len)
{
DEBUG("ng_netdev_eth: set ");
@ -304,7 +304,7 @@ static int _set(ng_netdev_t *dev, ng_netopt_t opt, void *value, size_t value_len
}
switch (opt) {
case NG_NETOPT_PROMISCUOUSMODE:
case NETOPT_PROMISCUOUSMODE:
DEBUG("promiscous mode\n");
return _set_promiscousmode((ng_netdev_eth_t *)dev, value, value_len);

View File

@ -470,7 +470,7 @@ void ng_ipv6_netif_init_by_dev(void)
#ifdef MODULE_NG_SIXLOWPAN
ng_nettype_t if_type = NG_NETTYPE_UNDEF;
if ((ng_netapi_get(ifs[i], NG_NETOPT_PROTO, 0, &if_type,
if ((ng_netapi_get(ifs[i], NETOPT_PROTO, 0, &if_type,
sizeof(if_type)) != -ENOTSUP) &&
(if_type == NG_NETTYPE_SIXLOWPAN)) {
uint16_t src_len = 8;
@ -480,10 +480,10 @@ void ng_ipv6_netif_init_by_dev(void)
ipv6_ifs[i].flags |= NG_IPV6_NETIF_FLAGS_SIXLOWPAN;
/* use EUI-64 (8-byte address) for IID generation and for sending
* packets */
ng_netapi_set(ifs[i], NG_NETOPT_SRC_LEN, 0, &src_len,
ng_netapi_set(ifs[i], NETOPT_SRC_LEN, 0, &src_len,
sizeof(src_len)); /* don't care for result */
if (ng_netapi_get(ifs[i], NG_NETOPT_MAX_PACKET_SIZE,
if (ng_netapi_get(ifs[i], NETOPT_MAX_PACKET_SIZE,
0, &max_frag_size, sizeof(max_frag_size)) < 0) {
/* if error we assume it works */
DEBUG("ipv6 netif: Can not get max packet size from interface %"
@ -494,7 +494,7 @@ void ng_ipv6_netif_init_by_dev(void)
}
#endif
if ((ng_netapi_get(ifs[i], NG_NETOPT_IPV6_IID, 0, &iid,
if ((ng_netapi_get(ifs[i], NETOPT_IPV6_IID, 0, &iid,
sizeof(eui64_t)) < 0)) {
mutex_unlock(&ipv6_if->mutex);
continue;

View File

@ -640,17 +640,17 @@ static uint16_t _get_l2src(uint8_t *l2src, size_t l2src_size, kernel_pid_t iface
const uint16_t max_short_len = 6;
/* try getting source address */
if ((ng_netapi_get(iface, NG_NETOPT_SRC_LEN, 0, &l2src_len,
if ((ng_netapi_get(iface, NETOPT_SRC_LEN, 0, &l2src_len,
sizeof(l2src_len)) >= 0) &&
(l2src_len > max_short_len)) {
try_long = true;
}
if (try_long && ((res = ng_netapi_get(iface, NG_NETOPT_ADDRESS_LONG, 0,
if (try_long && ((res = ng_netapi_get(iface, NETOPT_ADDRESS_LONG, 0,
l2src, l2src_size)) > max_short_len)) {
l2src_len = (uint16_t)res;
}
else if ((res = ng_netapi_get(iface, NG_NETOPT_ADDRESS, 0, l2src,
else if ((res = ng_netapi_get(iface, NETOPT_ADDRESS, 0, l2src,
l2src_size)) >= 0) {
l2src_len = (uint16_t)res;
}

View File

@ -515,7 +515,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
}
else {
/* but take from driver otherwise */
ng_netapi_get(netif_hdr->if_pid, NG_NETOPT_IPV6_IID, 0, &iid,
ng_netapi_get(netif_hdr->if_pid, NETOPT_IPV6_IID, 0, &iid,
sizeof(eui64_t));
}

View File

@ -29,7 +29,7 @@
#include "net/ng_ipv6/netif.h"
#include "net/ng_netif.h"
#include "net/ng_netapi.h"
#include "net/ng_netopt.h"
#include "net/netopt.h"
#include "net/ng_pkt.h"
#include "net/ng_pktbuf.h"
#include "net/ng_netif/hdr.h"
@ -106,30 +106,30 @@ static void _del_usage(char *cmd_name)
cmd_name);
}
static void _print_netopt(ng_netopt_t opt)
static void _print_netopt(netopt_t opt)
{
switch (opt) {
case NG_NETOPT_ADDRESS:
case NETOPT_ADDRESS:
printf("(short) address");
break;
case NG_NETOPT_ADDRESS_LONG:
case NETOPT_ADDRESS_LONG:
printf("long address");
break;
case NG_NETOPT_SRC_LEN:
case NETOPT_SRC_LEN:
printf("source address length");
break;
case NG_NETOPT_CHANNEL:
case NETOPT_CHANNEL:
printf("channel");
break;
case NG_NETOPT_NID:
case NETOPT_NID:
printf("network identifier");
break;
case NG_NETOPT_TX_POWER:
case NETOPT_TX_POWER:
printf("TX power [in dBm]");
break;
@ -139,25 +139,25 @@ static void _print_netopt(ng_netopt_t opt)
}
}
static void _print_netopt_state(ng_netopt_state_t state)
static void _print_netopt_state(netopt_state_t state)
{
switch (state) {
case NG_NETOPT_STATE_OFF:
case NETOPT_STATE_OFF:
printf("OFF");
break;
case NG_NETOPT_STATE_SLEEP:
case NETOPT_STATE_SLEEP:
printf("SLEEP");
break;
case NG_NETOPT_STATE_IDLE:
case NETOPT_STATE_IDLE:
printf("IDLE");
break;
case NG_NETOPT_STATE_RX:
case NETOPT_STATE_RX:
printf("RX");
break;
case NG_NETOPT_STATE_TX:
case NETOPT_STATE_TX:
printf("TX");
break;
case NG_NETOPT_STATE_RESET:
case NETOPT_STATE_RESET:
printf("RESET");
break;
default:
@ -172,8 +172,8 @@ static void _netif_list(kernel_pid_t dev)
uint16_t u16;
int16_t i16;
int res;
ng_netopt_state_t state;
ng_netopt_enable_t enable;
netopt_state_t state;
netopt_enable_t enable;
bool linebreak = false;
#ifdef MODULE_NG_IPV6_NETIF
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(dev);
@ -183,7 +183,7 @@ static void _netif_list(kernel_pid_t dev)
printf("Iface %2d ", dev);
res = ng_netapi_get(dev, NG_NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr));
res = ng_netapi_get(dev, NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr));
if (res >= 0) {
char hwaddr_str[res * 3];
@ -193,25 +193,25 @@ static void _netif_list(kernel_pid_t dev)
printf(" ");
}
res = ng_netapi_get(dev, NG_NETOPT_CHANNEL, 0, &u16, sizeof(u16));
res = ng_netapi_get(dev, NETOPT_CHANNEL, 0, &u16, sizeof(u16));
if (res >= 0) {
printf(" Channel: %" PRIu16 " ", u16);
}
res = ng_netapi_get(dev, NG_NETOPT_NID, 0, &u16, sizeof(u16));
res = ng_netapi_get(dev, NETOPT_NID, 0, &u16, sizeof(u16));
if (res >= 0) {
printf(" NID: 0x%" PRIx16 " ", u16);
}
res = ng_netapi_get(dev, NG_NETOPT_TX_POWER, 0, &i16, sizeof(i16));
res = ng_netapi_get(dev, NETOPT_TX_POWER, 0, &i16, sizeof(i16));
if (res >= 0) {
printf(" TX-Power: %" PRIi16 "dBm ", i16);
}
res = ng_netapi_get(dev, NG_NETOPT_STATE, 0, &state, sizeof(state));
res = ng_netapi_get(dev, NETOPT_STATE, 0, &state, sizeof(state));
if (res >= 0) {
printf(" State: ");
@ -220,7 +220,7 @@ static void _netif_list(kernel_pid_t dev)
printf("\n ");
res = ng_netapi_get(dev, NG_NETOPT_ADDRESS_LONG, 0, hwaddr, sizeof(hwaddr));
res = ng_netapi_get(dev, NETOPT_ADDRESS_LONG, 0, hwaddr, sizeof(hwaddr));
if (res >= 0) {
char hwaddr_str[res * 3];
@ -230,30 +230,30 @@ static void _netif_list(kernel_pid_t dev)
printf("\n ");
}
res = ng_netapi_get(dev, NG_NETOPT_PROMISCUOUSMODE, 0, &enable, sizeof(enable));
res = ng_netapi_get(dev, NETOPT_PROMISCUOUSMODE, 0, &enable, sizeof(enable));
if ((res >= 0) && (enable == NG_NETOPT_ENABLE)) {
if ((res >= 0) && (enable == NETOPT_ENABLE)) {
printf("PROMISC ");
linebreak = true;
}
res = ng_netapi_get(dev, NG_NETOPT_AUTOACK, 0, &enable, sizeof(enable));
res = ng_netapi_get(dev, NETOPT_AUTOACK, 0, &enable, sizeof(enable));
if ((res >= 0) && (enable == NG_NETOPT_ENABLE)) {
if ((res >= 0) && (enable == NETOPT_ENABLE)) {
printf("AUTOACK ");
linebreak = true;
}
res = ng_netapi_get(dev, NG_NETOPT_PRELOADING, 0, &enable, sizeof(enable));
res = ng_netapi_get(dev, NETOPT_PRELOADING, 0, &enable, sizeof(enable));
if ((res >= 0) && (enable == NG_NETOPT_ENABLE)) {
if ((res >= 0) && (enable == NETOPT_ENABLE)) {
printf("PRELOAD ");
linebreak = true;
}
res = ng_netapi_get(dev, NG_NETOPT_RAWMODE, 0, &enable, sizeof(enable));
res = ng_netapi_get(dev, NETOPT_RAWMODE, 0, &enable, sizeof(enable));
if ((res >= 0) && (enable == NG_NETOPT_ENABLE)) {
if ((res >= 0) && (enable == NETOPT_ENABLE)) {
printf("RAWMODE ");
linebreak = true;
}
@ -278,7 +278,7 @@ static void _netif_list(kernel_pid_t dev)
printf("\n ");
}
res = ng_netapi_get(dev, NG_NETOPT_SRC_LEN, 0, &u16, sizeof(u16));
res = ng_netapi_get(dev, NETOPT_SRC_LEN, 0, &u16, sizeof(u16));
if (res >= 0) {
printf("Source address length: %" PRIu16 "\n ", u16);
@ -322,7 +322,7 @@ static void _netif_list(kernel_pid_t dev)
puts("");
}
static int _netif_set_u16(kernel_pid_t dev, ng_netopt_t opt, char *u16_str)
static int _netif_set_u16(kernel_pid_t dev, netopt_t opt, char *u16_str)
{
unsigned int res;
bool hex = false;
@ -371,7 +371,7 @@ static int _netif_set_u16(kernel_pid_t dev, ng_netopt_t opt, char *u16_str)
return 0;
}
static int _netif_set_i16(kernel_pid_t dev, ng_netopt_t opt, char *i16_str)
static int _netif_set_i16(kernel_pid_t dev, netopt_t opt, char *i16_str)
{
int16_t val = (int16_t)atoi(i16_str);
@ -389,10 +389,10 @@ static int _netif_set_i16(kernel_pid_t dev, ng_netopt_t opt, char *i16_str)
return 0;
}
static int _netif_set_flag(kernel_pid_t dev, ng_netopt_t opt,
ng_netopt_enable_t set)
static int _netif_set_flag(kernel_pid_t dev, netopt_t opt,
netopt_enable_t set)
{
if (ng_netapi_set(dev, opt, 0, &set, sizeof(ng_netopt_enable_t)) < 0) {
if (ng_netapi_set(dev, opt, 0, &set, sizeof(netopt_enable_t)) < 0) {
puts("error: unable to set option");
return 1;
}
@ -400,7 +400,7 @@ static int _netif_set_flag(kernel_pid_t dev, ng_netopt_t opt,
return 0;
}
static int _netif_set_addr(kernel_pid_t dev, ng_netopt_t opt, char *addr_str)
static int _netif_set_addr(kernel_pid_t dev, netopt_t opt, char *addr_str)
{
uint8_t addr[MAX_ADDR_LEN];
size_t addr_len = ng_netif_addr_from_str(addr, sizeof(addr), addr_str);
@ -428,28 +428,28 @@ static int _netif_set_addr(kernel_pid_t dev, ng_netopt_t opt, char *addr_str)
static int _netif_set_state(kernel_pid_t dev, char *state_str)
{
ng_netopt_state_t state;
netopt_state_t state;
if ((strcmp("off", state_str) == 0) || (strcmp("OFF", state_str) == 0)) {
state = NG_NETOPT_STATE_OFF;
state = NETOPT_STATE_OFF;
}
else if ((strcmp("sleep", state_str) == 0) ||
(strcmp("SLEEP", state_str) == 0)) {
state = NG_NETOPT_STATE_SLEEP;
state = NETOPT_STATE_SLEEP;
}
else if ((strcmp("idle", state_str) == 0) ||
(strcmp("IDLE", state_str) == 0)) {
state = NG_NETOPT_STATE_IDLE;
state = NETOPT_STATE_IDLE;
}
else if ((strcmp("reset", state_str) == 0) ||
(strcmp("RESET", state_str) == 0)) {
state = NG_NETOPT_STATE_RESET;
state = NETOPT_STATE_RESET;
}
else {
puts("usage: ifconfig <if_id> set state [off|sleep|idle|reset]");
return 1;
}
if (ng_netapi_set(dev, NG_NETOPT_STATE, 0,
&state, sizeof(ng_netopt_state_t)) < 0) {
if (ng_netapi_set(dev, NETOPT_STATE, 0,
&state, sizeof(netopt_state_t)) < 0) {
printf("error: unable to set state to ");
_print_netopt_state(state);
puts("");
@ -465,23 +465,23 @@ static int _netif_set_state(kernel_pid_t dev, char *state_str)
static int _netif_set(char *cmd_name, kernel_pid_t dev, char *key, char *value)
{
if ((strcmp("addr", key) == 0) || (strcmp("addr_short", key) == 0)) {
return _netif_set_addr(dev, NG_NETOPT_ADDRESS, value);
return _netif_set_addr(dev, NETOPT_ADDRESS, value);
}
else if (strcmp("addr_long", key) == 0) {
return _netif_set_addr(dev, NG_NETOPT_ADDRESS_LONG, value);
return _netif_set_addr(dev, NETOPT_ADDRESS_LONG, value);
}
else if ((strcmp("channel", key) == 0) || (strcmp("chan", key) == 0)) {
return _netif_set_u16(dev, NG_NETOPT_CHANNEL, value);
return _netif_set_u16(dev, NETOPT_CHANNEL, value);
}
else if ((strcmp("nid", key) == 0) || (strcmp("pan", key) == 0) ||
(strcmp("pan_id", key) == 0)) {
return _netif_set_u16(dev, NG_NETOPT_NID, value);
return _netif_set_u16(dev, NETOPT_NID, value);
}
else if (strcmp("power", key) == 0) {
return _netif_set_i16(dev, NG_NETOPT_TX_POWER, value);
return _netif_set_i16(dev, NETOPT_TX_POWER, value);
}
else if (strcmp("src_len", key) == 0) {
return _netif_set_u16(dev, NG_NETOPT_SRC_LEN, value);
return _netif_set_u16(dev, NETOPT_SRC_LEN, value);
}
else if (strcmp("state", key) == 0) {
return _netif_set_state(dev, value);
@ -493,24 +493,24 @@ static int _netif_set(char *cmd_name, kernel_pid_t dev, char *key, char *value)
static int _netif_flag(char *cmd, kernel_pid_t dev, char *flag)
{
ng_netopt_enable_t set = NG_NETOPT_ENABLE;
netopt_enable_t set = NETOPT_ENABLE;
if (flag[0] == '-') {
set = NG_NETOPT_DISABLE;
set = NETOPT_DISABLE;
flag++;
}
if (strcmp(flag, "promisc") == 0) {
return _netif_set_flag(dev, NG_NETOPT_PROMISCUOUSMODE, set);
return _netif_set_flag(dev, NETOPT_PROMISCUOUSMODE, set);
}
else if (strcmp(flag, "preload") == 0) {
return _netif_set_flag(dev, NG_NETOPT_PRELOADING, set);
return _netif_set_flag(dev, NETOPT_PRELOADING, set);
}
else if (strcmp(flag, "autoack") == 0) {
return _netif_set_flag(dev, NG_NETOPT_AUTOACK, set);
return _netif_set_flag(dev, NETOPT_AUTOACK, set);
}
else if (strcmp(flag, "raw") == 0) {
return _netif_set_flag(dev, NG_NETOPT_RAWMODE, set);
return _netif_set_flag(dev, NETOPT_RAWMODE, set);
}
else if (strcmp(flag, "6lo") == 0) {
#ifdef MODULE_NG_IPV6_NETIF