Browse Source

sys: adapted to renamed netopt header

dev/timer
Hauke Petersen 8 years ago
parent
commit
38956457a1
  1. 8
      sys/include/net/netopt.h
  2. 8
      sys/include/net/ng_netapi.h
  3. 2
      sys/include/net/ng_netbase.h
  4. 6
      sys/include/net/ng_netdev.h
  5. 10
      sys/include/net/ng_nettest.h
  6. 52
      sys/net/application_layer/ng_zep/ng_zep.c
  7. 6
      sys/net/crosslayer/ng_netapi/ng_netapi.c
  8. 14
      sys/net/crosslayer/ng_nettest/ng_nettest.c
  9. 34
      sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c
  10. 8
      sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c
  11. 6
      sys/net/network_layer/ng_ndp/ng_ndp.c
  12. 2
      sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c
  13. 114
      sys/shell/commands/sc_netif.c

8
sys/include/net/netopt.h

@ -93,7 +93,7 @@ typedef enum {
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 ng_netopt_state_t */
* type netopt_state_t */
NETOPT_RAWMODE, /**< en/disable the pre-processing of data
* in a network device driver as type
* ng_nettype_t */
@ -145,7 +145,7 @@ typedef enum {
* @note Interfaces are not meant to respond to that.
*/
NETOPT_NUMOF,
} ng_netopt_t;
} netopt_t;
/**
* @brief Binary parameter for enabling and disabling options
@ -153,7 +153,7 @@ typedef enum {
typedef enum {
NETOPT_DISABLE = 0, /**< disable a given option */
NETOPT_ENABLE = 1, /**< enable a given option */
} ng_netopt_enable_t;
} netopt_enable_t;
/**
* @brief Option parameter to be used with @ref NETOPT_STATE to set or get
@ -175,7 +175,7 @@ typedef enum {
NETOPT_STATE_RESET, /**< triggers a hardware reset. The resulting
* state of the network device is @ref NETOPT_STATE_IDLE */
/* add other states if needed */
} ng_netopt_state_t;
} netopt_state_t;
#ifdef __cplusplus
}

8
sys/include/net/ng_netapi.h

@ -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

2
sys/include/net/ng_netbase.h

@ -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"

6
sys/include/net/ng_netdev.h

@ -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

10
sys/include/net/ng_nettest.h

@ -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);

52
sys/net/application_layer/ng_zep/ng_zep.c

@ -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;
}

6
sys/net/crosslayer/ng_netapi/ng_netapi.c

@ -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,

14
sys/net/crosslayer/ng_nettest/ng_nettest.c

@ -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;
}

34
sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c

@ -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);

8
sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c

@ -471,7 +471,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;
@ -481,10 +481,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 %"
@ -495,7 +495,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;

6
sys/net/network_layer/ng_ndp/ng_ndp.c

@ -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;
}

2
sys/net/network_layer/ng_sixlowpan/iphc/ng_sixlowpan_iphc.c

@ -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));
}

114
sys/shell/commands/sc_netif.c

@ -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

Loading…
Cancel
Save