minor sniff update
send beacons using the addrstore routine.
This commit is contained in:
parent
0d00a82c88
commit
cf097c84b8
@ -226,7 +226,7 @@ static int status(int fd)
|
|||||||
* Display a single packet
|
* Display a single packet
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int display(FAR struct ieee802154_packet_s *pack)
|
static int display(FAR struct ieee802154_packet_s *pack, bool verbose)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int hlen=0, dhlen=0;
|
int hlen=0, dhlen=0;
|
||||||
@ -238,7 +238,7 @@ static int display(FAR struct ieee802154_packet_s *pack)
|
|||||||
dhlen = hlen;
|
dhlen = hlen;
|
||||||
if(hlen>pack->len) dhlen = 0;
|
if(hlen>pack->len) dhlen = 0;
|
||||||
|
|
||||||
printf("chan=%2d rssi=%3u lqi=%3u len=%d ", gChan, pack->rssi, pack->lqi, pack->len - dhlen);
|
printf("chan=%2d rssi=%3u lqi=%3u len=%3u ", gChan, pack->rssi, pack->lqi, pack->len - dhlen);
|
||||||
|
|
||||||
if(hlen<0)
|
if(hlen<0)
|
||||||
{
|
{
|
||||||
@ -270,6 +270,7 @@ static int display(FAR struct ieee802154_packet_s *pack)
|
|||||||
struct sniffargs
|
struct sniffargs
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
int verbose;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void* sniff(void *arg)
|
static void* sniff(void *arg)
|
||||||
@ -301,7 +302,7 @@ static void* sniff(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Display packet */
|
/* Display packet */
|
||||||
display(&gRxPacket);
|
display(&gRxPacket, sa->verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -459,22 +460,13 @@ int i8_main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct sniffargs args;
|
struct sniffargs args;
|
||||||
|
|
||||||
ret = ioctl(fd, MAC854IOCSPROMISC, TRUE);
|
ret = ieee802154_setpromisc(fd, TRUE);
|
||||||
if (ret<0)
|
|
||||||
{
|
|
||||||
printf("Device is not an IEEE 802.15.4 interface!\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
args.fd = fd;
|
args.fd = fd;
|
||||||
|
args.verbose = FALSE;
|
||||||
ret = (int)sniff(&args);
|
ret = (int)sniff(&args);
|
||||||
|
|
||||||
ret = ioctl(fd, MAC854IOCSPROMISC, FALSE);
|
ret = ieee802154_setpromisc(fd, FALSE);
|
||||||
if (ret<0)
|
|
||||||
{
|
|
||||||
printf("Device is not an IEEE 802.15.4 interface!\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[2], "tx"))
|
else if (!strcmp(argv[2], "tx"))
|
||||||
@ -513,41 +505,46 @@ data_error:
|
|||||||
}
|
}
|
||||||
else if (!strcmp(argv[2], "beacons"))
|
else if (!strcmp(argv[2], "beacons"))
|
||||||
{
|
{
|
||||||
struct sniffargs args;
|
struct sniffargs args;
|
||||||
pthread_t pth;
|
struct ieee802154_addr_s dest;
|
||||||
int i;
|
pthread_t pth;
|
||||||
|
int i;
|
||||||
|
|
||||||
args.fd = fd;
|
args.fd = fd;
|
||||||
|
args.verbose = FALSE;
|
||||||
|
|
||||||
pthread_create(&pth, NULL, sniff, &args);
|
pthread_create(&pth, NULL, sniff, &args);
|
||||||
|
|
||||||
//beacon request
|
//beacon request
|
||||||
gTxPacket.len = 0;
|
gTxPacket.len = 0;
|
||||||
gTxPacket.data[gTxPacket.len++] = 0x03; //mac command, no ack, no panid compression
|
gTxPacket.data[gTxPacket.len++] = 0x03; //mac command, no ack, no panid compression
|
||||||
gTxPacket.data[gTxPacket.len++] = 0x08; //short destination address, no source address
|
gTxPacket.data[gTxPacket.len++] = 0x00; //short destination address, no source address
|
||||||
gTxPacket.data[gTxPacket.len++] = 0; //seq
|
gTxPacket.data[gTxPacket.len++] = 0; //seq
|
||||||
gTxPacket.data[gTxPacket.len++] = 0xFF; //panid
|
dest.ia_len = 2;
|
||||||
gTxPacket.data[gTxPacket.len++] = 0xFF;
|
dest.ia_panid = 0xFFFF;
|
||||||
gTxPacket.data[gTxPacket.len++] = 0xFF; //saddr
|
dest.ia_saddr = 0xFFFF;
|
||||||
gTxPacket.data[gTxPacket.len++] = 0xFF;
|
ieee802154_addrstore(&gTxPacket, &dest, NULL);
|
||||||
gTxPacket.data[gTxPacket.len++] = IEEE802154_CMD_BEACON_REQ;
|
gTxPacket.data[gTxPacket.len++] = 0xFF; //panid
|
||||||
|
gTxPacket.data[gTxPacket.len++] = 0xFF;
|
||||||
|
gTxPacket.data[gTxPacket.len++] = 0xFF; //saddr
|
||||||
|
gTxPacket.data[gTxPacket.len++] = 0xFF;
|
||||||
|
gTxPacket.data[gTxPacket.len++] = IEEE802154_CMD_BEACON_REQ;
|
||||||
// for(i=1;i<3;i++)
|
// for(i=1;i<3;i++)
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
for(ch=11; ch<27; ch++)
|
for(ch=11; ch<27; ch++)
|
||||||
{
|
{
|
||||||
printf("chan=%2d...\r", ch); fflush(stdout);
|
printf("chan=%2d...\r", ch); fflush(stdout);
|
||||||
ieee802154_setchan(fd, ch);
|
ieee802154_setchan(fd, ch);
|
||||||
gChan = ch;
|
gChan = ch;
|
||||||
gTxPacket.data[2] = i; //seq
|
gTxPacket.data[2] = i; //seq
|
||||||
tx(fd, &gTxPacket, FALSE);
|
tx(fd, &gTxPacket, FALSE);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
i++; if(i==256) i=0;
|
i++; if(i==256) i=0;
|
||||||
}
|
}
|
||||||
pthread_kill(pth, SIGUSR1);
|
pthread_kill(pth, SIGUSR1);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user