Fix nxstyle warning

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-10-19 11:43:29 +08:00 committed by Brennan Ashton
parent 8a63e58936
commit 8375a2177e
11 changed files with 139 additions and 73 deletions

View File

@ -117,7 +117,7 @@ static uint8_t netlib_msbits8(uint8_t byval)
static inline uint8_t netlib_msbits16(uint16_t hword) static inline uint8_t netlib_msbits16(uint16_t hword)
{ {
uint8_t ones; uint8_t ones;
/* Look at the MS byte of the 16-bit value */ /* Look at the MS byte of the 16-bit value */

View File

@ -58,6 +58,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
#if !defined(CONFIG_IEEE802154_I8SAK_DEFAULT_EP_EADDR) #if !defined(CONFIG_IEEE802154_I8SAK_DEFAULT_EP_EADDR)
@ -142,7 +143,8 @@ struct i8sak_s
sem_t eventsem; /* For synchronizing access to the event receiver list */ sem_t eventsem; /* For synchronizing access to the event receiver list */
sq_queue_t eventreceivers; sq_queue_t eventreceivers;
sq_queue_t eventreceivers_free; sq_queue_t eventreceivers_free;
struct i8sak_eventreceiver_s eventreceiver_pool[CONFIG_I8SAK_NEVENTRECEIVERS]; struct i8sak_eventreceiver_s
eventreceiver_pool[CONFIG_I8SAK_NEVENTRECEIVERS];
/* MAC related fields */ /* MAC related fields */
@ -165,10 +167,10 @@ struct i8sak_s
struct sockaddr_in6 ep_in6addr; struct sockaddr_in6 ep_in6addr;
#endif #endif
/* For the Coordinator, we keep a Short Address that will be handed out next. /* For the Coordinator, we keep a Short Address that will be handed out
* After assigning the address to a device requesting association, this field * next. After assigning the address to a device requesting association,
* is simply incremented. This means short addresses will be assigned to * this field is simply incremented. This means short addresses will be
* associating devices in order. * assigned to associating devices in order.
*/ */
uint8_t next_saddr[IEEE802154_SADDRSIZE]; uint8_t next_saddr[IEEE802154_SADDRSIZE];
@ -220,18 +222,30 @@ void i8sak_str2panid (FAR const char *str, FAR uint8_t *panid);
/* Command Functions. Alphabetical Order */ /* Command Functions. Alphabetical Order */
void i8sak_acceptassoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_acceptassoc_cmd (FAR struct i8sak_s *i8sak,
void i8sak_assoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_blaster_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_assoc_cmd (FAR struct i8sak_s *i8sak,
void i8sak_get_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_poll_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_blaster_cmd (FAR struct i8sak_s *i8sak,
void i8sak_regdump_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_reset_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_get_cmd (FAR struct i8sak_s *i8sak,
void i8sak_scan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_set_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_poll_cmd (FAR struct i8sak_s *i8sak,
void i8sak_sniffer_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); void i8sak_regdump_cmd (FAR struct i8sak_s *i8sak,
void i8sak_tx_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); int argc, FAR char *argv[]);
void i8sak_reset_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
void i8sak_scan_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
void i8sak_set_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
void i8sak_sniffer_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
void i8sak_tx_cmd (FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[]);
/* Command background threads */ /* Command background threads */
@ -270,13 +284,17 @@ static inline void i8sak_update_ep_ip(FAR struct i8sak_s *i8sak)
if (i8sak->ep_addr.mode == IEEE802154_ADDRMODE_EXTENDED) if (i8sak->ep_addr.mode == IEEE802154_ADDRMODE_EXTENDED)
{ {
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[4] = i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[4] =
HTONS(((uint16_t)i8sak->ep_addr.eaddr[0] << 8 | (uint16_t)i8sak->ep_addr.eaddr[1])); HTONS(((uint16_t)i8sak->ep_addr.eaddr[0] << 8) |
(uint16_t)i8sak->ep_addr.eaddr[1]);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[5] = i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[5] =
HTONS(((uint16_t)i8sak->ep_addr.eaddr[2] << 8 | (uint16_t)i8sak->ep_addr.eaddr[3])); HTONS(((uint16_t)i8sak->ep_addr.eaddr[2] << 8) |
(uint16_t)i8sak->ep_addr.eaddr[3]);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[6] = i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[6] =
HTONS(((uint16_t)i8sak->ep_addr.eaddr[4] << 8 | (uint16_t)i8sak->ep_addr.eaddr[5])); HTONS(((uint16_t)i8sak->ep_addr.eaddr[4] << 8) |
(uint16_t)i8sak->ep_addr.eaddr[5]);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[7] = i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[7] =
HTONS(((uint16_t)i8sak->ep_addr.eaddr[6] << 8 | (uint16_t)i8sak->ep_addr.eaddr[7])); HTONS(((uint16_t)i8sak->ep_addr.eaddr[6] << 8) |
(uint16_t)i8sak->ep_addr.eaddr[7]);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[4] ^= HTONS(0x0200); i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[4] ^= HTONS(0x0200);
} }
@ -286,7 +304,8 @@ static inline void i8sak_update_ep_ip(FAR struct i8sak_s *i8sak)
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[5] = HTONS(0x00ff); i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[5] = HTONS(0x00ff);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[6] = HTONS(0xfe00); i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[6] = HTONS(0xfe00);
i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[7] = i8sak->ep_in6addr.sin6_addr.in6_u.u6_addr16[7] =
((uint16_t)i8sak->ep_addr.saddr[0] << 8 | (uint16_t)i8sak->ep_addr.saddr[1]); ((uint16_t)i8sak->ep_addr.saddr[0] << 8 |
(uint16_t)i8sak->ep_addr.saddr[1]);
} }
} }
#endif #endif

View File

@ -63,7 +63,8 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static void assoc_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg); static void assoc_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg);
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -139,19 +140,22 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
break; break;
case 'p': case 'p':
/* Parse short address and put it into the i8sak instance */ /* Parse short address and put it into the i8sak instance */
i8sak_str2panid(optarg, i8sak->ep_addr.panid); i8sak_str2panid(optarg, i8sak->ep_addr.panid);
break; break;
case 's': case 's':
/* Parse short address and put it into the i8sak instance */ /* Parse short address and put it into the i8sak instance */
i8sak_str2saddr(optarg, i8sak->ep_addr.saddr); i8sak_str2saddr(optarg, i8sak->ep_addr.saddr);
i8sak->ep_addr.mode= IEEE802154_ADDRMODE_SHORT; i8sak->ep_addr.mode = IEEE802154_ADDRMODE_SHORT;
break; break;
case 'e': case 'e':
/* Parse extended address and put it into the i8sak instance */ /* Parse extended address and put it into the i8sak instance */
i8sak_str2eaddr(optarg, i8sak->ep_addr.eaddr); i8sak_str2eaddr(optarg, i8sak->ep_addr.eaddr);
@ -159,12 +163,14 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
break; break;
case 't': case 't':
/* Parse wait time and set the parameter in the request */ /* Parse wait time and set the parameter in the request */
setreq.attrval.mac.resp_waittime = i8sak_str2luint8(optarg); setreq.attrval.mac.resp_waittime = i8sak_str2luint8(optarg);
break; break;
case 'w': case 'w':
/* Wait and retry if we fail to associate */ /* Wait and retry if we fail to associate */
retry = true; retry = true;
@ -194,7 +200,8 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
fd = open(i8sak->ifname, O_RDWR); fd = open(i8sak->ifname, O_RDWR);
if (fd < 0) if (fd < 0)
{ {
fprintf(stderr, "ERROR: cannot open %s, errno=%d\n", i8sak->ifname, errno); fprintf(stderr, "ERROR: cannot open %s, errno=%d\n",
i8sak->ifname, errno);
i8sak_cmd_error(i8sak); i8sak_cmd_error(i8sak);
} }
@ -320,7 +327,8 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
static void assoc_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg) static void assoc_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg)
{ {
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg; FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;

View File

@ -39,7 +39,7 @@
* *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@ -133,7 +133,8 @@ void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
break; break;
case 'f': /* Inline change blaster frame */ case 'f': /* Inline change blaster frame */
i8sak->payload_len = i8sak_str2payload(optarg, &i8sak->payload[0]); i8sak->payload_len = i8sak_str2payload(optarg,
&i8sak->payload[0]);
i8sak_blaster_start(i8sak); i8sak_blaster_start(i8sak);
break; break;
@ -172,7 +173,7 @@ pthread_addr_t i8sak_blaster_thread(pthread_addr_t arg)
#ifdef CONFIG_NET_6LOWPAN #ifdef CONFIG_NET_6LOWPAN
if (i8sak->mode == I8SAK_MODE_NETIF) if (i8sak->mode == I8SAK_MODE_NETIF)
{ {
if (bind(i8sak->fd, (struct sockaddr*)&i8sak->ep_in6addr, if (bind(i8sak->fd, (struct sockaddr *)&i8sak->ep_in6addr,
sizeof(struct sockaddr_in6)) < 0) sizeof(struct sockaddr_in6)) < 0)
{ {
fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno); fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno);
@ -183,7 +184,7 @@ pthread_addr_t i8sak_blaster_thread(pthread_addr_t arg)
while (i8sak->blasterenabled) while (i8sak->blasterenabled)
{ {
usleep(i8sak->blasterperiod*1000); usleep(i8sak->blasterperiod * 1000);
if (i8sak->mode == I8SAK_MODE_CHAR) if (i8sak->mode == I8SAK_MODE_CHAR)
{ {
@ -198,7 +199,8 @@ pthread_addr_t i8sak_blaster_thread(pthread_addr_t arg)
tx.meta.ranging = IEEE802154_NON_RANGING; tx.meta.ranging = IEEE802154_NON_RANGING;
tx.meta.srcmode = i8sak->addrmode; tx.meta.srcmode = i8sak->addrmode;
memcpy(&tx.meta.destaddr, &i8sak->ep_addr, sizeof(struct ieee802154_addr_s)); memcpy(&tx.meta.destaddr, &i8sak->ep_addr,
sizeof(struct ieee802154_addr_s));
/* Each byte is represented by 2 chars */ /* Each byte is represented by 2 chars */
@ -211,7 +213,8 @@ pthread_addr_t i8sak_blaster_thread(pthread_addr_t arg)
else if (i8sak->mode == I8SAK_MODE_NETIF) else if (i8sak->mode == I8SAK_MODE_NETIF)
{ {
sendto(i8sak->fd, i8sak->payload, i8sak->payload_len, 0, sendto(i8sak->fd, i8sak->payload, i8sak->payload_len, 0,
(struct sockaddr*)&i8sak->ep_in6addr, sizeof(struct sockaddr_in6)); (struct sockaddr *)&i8sak->ep_in6addr,
sizeof(struct sockaddr_in6));
} }
#endif #endif
} }

View File

@ -39,7 +39,7 @@
* *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@ -61,7 +61,8 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static void poll_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg); static void poll_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg);
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -91,18 +92,22 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
"Usage: %s [-h]\n" "Usage: %s [-h]\n"
" -h = this help menu\n" " -h = this help menu\n"
, argv[0]); , argv[0]);
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
return; return;
case ':': case ':':
fprintf(stderr, "ERROR: missing argument\n"); fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
i8sak_cmd_error(i8sak); /* This exits for us */ i8sak_cmd_error(i8sak); /* This exits for us */
case '?': case '?':
fprintf(stderr, "ERROR: unknown argument\n"); fprintf(stderr, "ERROR: unknown argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -112,14 +117,15 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
i8sak_requestdaemon(i8sak); i8sak_requestdaemon(i8sak);
/* Register new oneshot callback for receiving the association notifications */ /* Register new callback for receiving the association notifications */
memset(&eventfilter, 0, sizeof(struct i8sak_eventfilter_s)); memset(&eventfilter, 0, sizeof(struct i8sak_eventfilter_s));
eventfilter.confevents.poll = true; eventfilter.confevents.poll = true;
i8sak_eventlistener_addreceiver(i8sak, poll_eventcb, &eventfilter, true); i8sak_eventlistener_addreceiver(i8sak, poll_eventcb, &eventfilter, true);
memcpy(&pollreq.coordaddr, &i8sak->ep_addr, sizeof(struct ieee802154_addr_s)); memcpy(&pollreq.coordaddr, &i8sak->ep_addr,
sizeof(struct ieee802154_addr_s));
if (pollreq.coordaddr.mode == IEEE802154_ADDRMODE_SHORT) if (pollreq.coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
{ {
@ -135,7 +141,8 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
fd = open(i8sak->ifname, O_RDWR); fd = open(i8sak->ifname, O_RDWR);
if (fd < 0) if (fd < 0)
{ {
fprintf(stderr, "ERROR: cannot open %s, errno=%d\n", i8sak->ifname, errno); fprintf(stderr, "ERROR: cannot open %s, errno=%d\n",
i8sak->ifname, errno);
i8sak_cmd_error(i8sak); i8sak_cmd_error(i8sak);
} }
@ -157,7 +164,9 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
close(fd); close(fd);
/* Wait here, the event listener will notify us if the correct event occurs */ /* Wait here, the event listener will notify us if the correct event
* occurs
*/
ret = sem_wait(&i8sak->sigsem); ret = sem_wait(&i8sak->sigsem);
if (ret != OK) if (ret != OK)
@ -173,7 +182,8 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
* Private Function * Private Function
****************************************************************************/ ****************************************************************************/
static void poll_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg) static void poll_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg)
{ {
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg; FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;

View File

@ -59,7 +59,8 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg); static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg);
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -119,6 +120,7 @@ void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
case ':': case ':':
fprintf(stderr, "ERROR: missing argument\n"); fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -126,6 +128,7 @@ void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
case '?': case '?':
fprintf(stderr, "ERROR: unknown argument\n"); fprintf(stderr, "ERROR: unknown argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -205,7 +208,8 @@ void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg) static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg)
{ {
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg; FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;
FAR struct ieee802154_scan_conf_s *scan = &primitive->u.scanconf; FAR struct ieee802154_scan_conf_s *scan = &primitive->u.scanconf;
@ -234,7 +238,8 @@ static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void
printf("Scan results: \n"); printf("Scan results: \n");
if (scan->type == IEEE802154_SCANTYPE_ACTIVE || scan->type == IEEE802154_SCANTYPE_PASSIVE) if (scan->type == IEEE802154_SCANTYPE_ACTIVE ||
scan->type == IEEE802154_SCANTYPE_PASSIVE)
{ {
/* Copy the results from the notification */ /* Copy the results from the notification */
@ -268,10 +273,11 @@ static void scan_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void
{ {
/* Print the results out */ /* Print the results out */
for (i=0; i < scan->numresults; i++) for (i = 0; i < scan->numresults; i++)
{ {
printf("Result %d\n", i); printf("Result %d\n", i);
printf(" Channel: %u Energy: %d\n", scan->chlist[i], scan->edlist[i]); printf(" Channel: %u Energy: %d\n",
scan->chlist[i], scan->edlist[i]);
} }
} }

View File

@ -39,7 +39,7 @@
* *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@ -90,6 +90,7 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
"Usage: %s [-h|d]\n" "Usage: %s [-h|d]\n"
" -h = this help menu\n" " -h = this help menu\n"
, argv[0]); , argv[0]);
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -103,6 +104,7 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
case ':': case ':':
fprintf(stderr, "ERROR: missing argument\n"); fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -110,6 +112,7 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
case '?': case '?':
fprintf(stderr, "ERROR: unknown argument\n"); fprintf(stderr, "ERROR: unknown argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
@ -138,6 +141,7 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
{ {
printf("i8sak: turning on promiscuous mode.\n"); printf("i8sak: turning on promiscuous mode.\n");
} }
ieee802154_setpromisc(fd, true); ieee802154_setpromisc(fd, true);
/* Make sure receiver is always on while idle */ /* Make sure receiver is always on while idle */
@ -146,6 +150,7 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
{ {
printf("i8sak: setting receiveonidle.\n"); printf("i8sak: setting receiveonidle.\n");
} }
ieee802154_setrxonidle(fd, true); ieee802154_setrxonidle(fd, true);
} }
#ifdef CONFIG_NET_6LOWPAN #ifdef CONFIG_NET_6LOWPAN
@ -218,7 +223,7 @@ pthread_addr_t i8sak_sniffer_thread(pthread_addr_t arg)
memset(&addr.sin6_addr, 0, sizeof(struct in6_addr)); memset(&addr.sin6_addr, 0, sizeof(struct in6_addr));
addrlen = sizeof(struct sockaddr_in6); addrlen = sizeof(struct sockaddr_in6);
if (bind(i8sak->fd, (struct sockaddr*)&addr, addrlen) < 0) if (bind(i8sak->fd, (struct sockaddr *)&addr, addrlen) < 0)
{ {
fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno); fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno);
exit(1); exit(1);
@ -230,7 +235,8 @@ pthread_addr_t i8sak_sniffer_thread(pthread_addr_t arg)
{ {
if (i8sak->mode == I8SAK_MODE_CHAR) if (i8sak->mode == I8SAK_MODE_CHAR)
{ {
ret = read(i8sak->fd, &frame, sizeof(struct mac802154dev_rxframe_s)); ret = read(i8sak->fd, &frame,
sizeof(struct mac802154dev_rxframe_s));
if (ret < 0) if (ret < 0)
{ {
continue; continue;

View File

@ -68,7 +68,8 @@
* Start PAN and accept association requests * Start PAN and accept association requests
****************************************************************************/ ****************************************************************************/
void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak,
int argc, FAR char *argv[])
{ {
struct ieee802154_start_req_s startreq; struct ieee802154_start_req_s startreq;
bool beaconenabled = false; bool beaconenabled = false;
@ -88,21 +89,27 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
" -h = this help menu\n" " -h = this help menu\n"
" -b = start beacon-enabled PAN\n" " -b = start beacon-enabled PAN\n"
, argv[0]); , argv[0]);
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
return; return;
case 'b': case 'b':
beaconenabled = true; beaconenabled = true;
break; break;
case ':': case ':':
fprintf(stderr, "ERROR: missing argument\n"); fprintf(stderr, "ERROR: missing argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;
i8sak_cmd_error(i8sak); /* This exits for us */ i8sak_cmd_error(i8sak); /* This exits for us */
case '?': case '?':
fprintf(stderr, "ERROR: unknown argument\n"); fprintf(stderr, "ERROR: unknown argument\n");
/* Must manually reset optind if we are going to exit early */ /* Must manually reset optind if we are going to exit early */
optind = -1; optind = -1;

View File

@ -39,7 +39,7 @@
* *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
@ -62,7 +62,8 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static void tx_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg); static void tx_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg);
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -186,9 +187,9 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
} }
else else
{ {
/* We cannot send a frame as direct if we are the PAN coordinator. Maybe /* We cannot send a frame as direct if we are the PAN coordinator.
* this should be the hook for sending payload in beacon? But for now, * Maybe this should be the hook for sending payload in beacon? But
* let's just throw an error. * for now, let's just throw an error.
*/ */
if (devmode == IEEE802154_DEVMODE_PANCOORD) if (devmode == IEEE802154_DEVMODE_PANCOORD)
@ -203,7 +204,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
i8sak_requestdaemon(i8sak); i8sak_requestdaemon(i8sak);
/* Register new oneshot callback for receiving the association notifications */ /* Register new callback for receiving the association notifications */
memset(&eventfilter, 0, sizeof(struct i8sak_eventfilter_s)); memset(&eventfilter, 0, sizeof(struct i8sak_eventfilter_s));
eventfilter.confevents.data = true; eventfilter.confevents.data = true;
@ -243,7 +244,8 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
tx.meta.ranging = IEEE802154_NON_RANGING; tx.meta.ranging = IEEE802154_NON_RANGING;
tx.meta.srcmode = i8sak->addrmode; tx.meta.srcmode = i8sak->addrmode;
memcpy(&tx.meta.destaddr, &i8sak->ep_addr, sizeof(struct ieee802154_addr_s)); memcpy(&tx.meta.destaddr, &i8sak->ep_addr,
sizeof(struct ieee802154_addr_s));
/* Each byte is represented by 2 chars */ /* Each byte is represented by 2 chars */
@ -261,15 +263,14 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
addr.sin6_port = HTONS(0); addr.sin6_port = HTONS(0);
memset(addr.sin6_addr.s6_addr, 0, sizeof(struct in6_addr)); memset(addr.sin6_addr.s6_addr, 0, sizeof(struct in6_addr));
if (bind(i8sak->fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in6)) < 0) ret = bind(i8sak->fd, (struct sockaddr *)&addr,
sizeof(struct sockaddr_in6));
if (ret >= 0)
{ {
fprintf(stderr, "ERROR: failure to bind sock: %d\n", errno); ret = sendto(fd, i8sak->payload, i8sak->payload_len, 0,
close(fd); (struct sockaddr *)&i8sak->ep_in6addr,
i8sak_cmd_error(i8sak); sizeof(struct sockaddr_in6));
} }
ret = sendto(fd, i8sak->payload, i8sak->payload_len, 0,
(struct sockaddr*)&i8sak->ep_in6addr, sizeof(struct sockaddr_in6));
} }
#endif #endif
@ -283,7 +284,8 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
close(fd); close(fd);
} }
static void tx_eventcb(FAR struct ieee802154_primitive_s *primitive, FAR void *arg) static void tx_eventcb(FAR struct ieee802154_primitive_s *primitive,
FAR void *arg)
{ {
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg; FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;

View File

@ -10,10 +10,11 @@
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are
* met:
* *
* - Redistributions of source code must retain the above copyright notice, * - Redistributions of source code must retain the above copyright
* this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* - Redistributions in binary form must reproduce the above copyright * - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
@ -177,7 +178,8 @@ int wapi_get_ifup(int sock, FAR const char *ifname, FAR int *is_up)
WAPI_VALIDATE_PTR(is_up); WAPI_VALIDATE_PTR(is_up);
strncpy(ifr.ifr_name, ifname, IFNAMSIZ); strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if ((ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr))) >= 0) ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr));
if (ret >= 0)
{ {
*is_up = (ifr.ifr_flags & IFF_UP) == IFF_UP; *is_up = (ifr.ifr_flags & IFF_UP) == IFF_UP;
} }
@ -205,7 +207,8 @@ int wapi_set_ifup(int sock, FAR const char *ifname)
int ret; int ret;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ); strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if ((ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr))) >= 0) ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr));
if (ret >= 0)
{ {
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING); ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr)); ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));
@ -240,7 +243,8 @@ int wapi_set_ifdown(int sock, FAR const char *ifname)
int ret; int ret;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ); strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if ((ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr))) >= 0) ret = ioctl(sock, SIOCGIFFLAGS, (unsigned long)((uintptr_t)&ifr));
if (ret >= 0)
{ {
ifr.ifr_flags &= ~IFF_UP; ifr.ifr_flags &= ~IFF_UP;
ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr)); ret = ioctl(sock, SIOCSIFFLAGS, (unsigned long)((uintptr_t)&ifr));

View File

@ -10,10 +10,11 @@
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are
* met:
* *
* - Redistributions of source code must retain the above copyright notice, * - Redistributions of source code must retain the above copyright
* this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* - Redistributions in binary form must reproduce the above copyright * - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the