*** empty log message ***
This commit is contained in:
parent
e1463c25a0
commit
f13ec95efa
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: sicslowmac.c,v 1.4 2008/10/27 18:03:26 c_oflynn Exp $
|
||||
* $Id: sicslowmac.c,v 1.5 2008/11/08 03:29:15 c_oflynn Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -104,6 +104,11 @@ static struct {
|
|||
/* Prototypes */
|
||||
static void setinput(void (*r)(const struct mac_driver *d));
|
||||
void (*pinput)(const struct mac_driver *r);
|
||||
void sicslowmac_unknownIndication(void);
|
||||
|
||||
|
||||
void (*sicslowmac_snifferhook)(const struct mac_driver *r) = NULL;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -194,12 +199,18 @@ mac_task(process_event_t ev, process_data_t data)
|
|||
|
||||
/* Handle events from radio */
|
||||
if (event){
|
||||
|
||||
if (event->event == MAC_EVENT_RX){
|
||||
/* got a frame, find out with kind of frame */
|
||||
parsed_frame = (parsed_frame_t *)event->data;
|
||||
if (parsed_frame->fcf->frameType == DATAFRAME){
|
||||
sicslowmac_dataIndication();
|
||||
}
|
||||
} else {
|
||||
|
||||
/* Hook to cath unknown frames */
|
||||
sicslowmac_unknownIndication();
|
||||
}
|
||||
|
||||
|
||||
/* Frame no longer in use */
|
||||
parsed_frame->in_use = false;
|
||||
|
@ -207,7 +218,7 @@ mac_task(process_event_t ev, process_data_t data)
|
|||
|
||||
if (event->event == MAC_EVENT_DROPPED){
|
||||
/* Frame was dropped */
|
||||
printf("sicslowmac: Frame Dropped!\n");
|
||||
PRINTF("sicslowmac: Frame Dropped!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +255,35 @@ sicslowmac_dataIndication(void)
|
|||
PRINTF("sicslowmac: hand off frame to sicslowpan \n");
|
||||
pinput(pmac_driver);
|
||||
}
|
||||
|
||||
void
|
||||
sicslowmac_unknownIndication(void)
|
||||
{
|
||||
if (sicslowmac_snifferhook) {
|
||||
|
||||
rimebuf_clear();
|
||||
|
||||
/* Finally, get the stuff into the rime buffer.... */
|
||||
rimebuf_copyfrom(parsed_frame->payload, parsed_frame->payload_length);
|
||||
rimebuf_set_datalen(parsed_frame->payload_length);
|
||||
|
||||
memcpy(dest_reversed, (uint8_t *)parsed_frame->dest_addr, 8);
|
||||
memcpy(src_reversed, (uint8_t *)parsed_frame->src_addr, 8);
|
||||
|
||||
/* Change addresses to expected byte order */
|
||||
byte_reverse((uint8_t *)dest_reversed, 8);
|
||||
byte_reverse((uint8_t *)src_reversed, 8);
|
||||
|
||||
rimebuf_set_addr(RIMEBUF_ADDR_RECEIVER, (const rimeaddr_t *)dest_reversed);
|
||||
rimebuf_set_addr(RIMEBUF_ADDR_SENDER, (const rimeaddr_t *)src_reversed);
|
||||
|
||||
PRINTF("sicslowmac: hand off frame to sniffer \n");
|
||||
|
||||
sicslowmac_snifferhook(pmac_driver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief This is the implementation of the 15.4 MAC Data Request
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: frame.c,v 1.2 2008/10/14 18:37:28 c_oflynn Exp $
|
||||
* $Id: frame.c,v 1.3 2008/11/08 03:29:15 c_oflynn Exp $
|
||||
*/
|
||||
/*
|
||||
* \brief This file is where the main functions that relate to frame
|
||||
|
@ -276,50 +276,55 @@ void rx_frame_parse(hal_rx_frame_t *rx_frame, parsed_frame_t *pf)
|
|||
}
|
||||
|
||||
|
||||
if (fcf->frameType == ACKFRAME)
|
||||
return; /* Don't bother with ACK frames */
|
||||
|
||||
pf->fcf = (fcf_t *)p;
|
||||
pf->seqNum = p+2;
|
||||
p += 3; /* Skip first three bytes */
|
||||
/* Destination PID, if any */
|
||||
if (fcf->frameType != BEACONFRAME){ /* No destination addresses in Beacon frame */
|
||||
pf->dest_pid = (uint16_t *)p;
|
||||
p += 2;
|
||||
/* Destination address */
|
||||
pf->dest_addr = 0;
|
||||
if (fcf->destAddrMode == SHORTADDRMODE ||
|
||||
fcf->destAddrMode == LONGADDRMODE){
|
||||
pf->dest_addr = (addr_t *)p;
|
||||
/* Update pointer to account for possible missing addr field */
|
||||
if (fcf->destAddrMode == SHORTADDRMODE){
|
||||
p += 2;
|
||||
}
|
||||
if (fcf->destAddrMode == LONGADDRMODE){
|
||||
p += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Source PANID */
|
||||
pf->src_pid = 0;
|
||||
if (!fcf->panIdCompression){
|
||||
pf->src_pid = (uint16_t *)p;
|
||||
p += 2;
|
||||
}
|
||||
/* Source address */
|
||||
pf->src_addr = (addr_t *)p;
|
||||
if (fcf->srcAddrMode == SHORTADDRMODE){
|
||||
p += 2;
|
||||
}
|
||||
if (fcf->srcAddrMode == LONGADDRMODE){
|
||||
p += 8;
|
||||
}
|
||||
/* aux security header, not yet implemented */
|
||||
pf->aux_sec_hdr = 0;
|
||||
/* payload length */
|
||||
pf->payload_length = rx_frame->length - (p - (uint8_t*)&rx_frame->data) - 2;
|
||||
/* payload */
|
||||
pf->payload = p;
|
||||
|
||||
if (fcf->frameType == ACKFRAME) {
|
||||
//ACK frames have no addresses and no payload!
|
||||
pf->payload_length = 0;
|
||||
|
||||
} else {
|
||||
|
||||
/* Destination PID, if any */
|
||||
if (fcf->frameType != BEACONFRAME){ /* No destination addresses in Beacon frame */
|
||||
pf->dest_pid = (uint16_t *)p;
|
||||
p += 2;
|
||||
/* Destination address */
|
||||
pf->dest_addr = 0;
|
||||
if (fcf->destAddrMode == SHORTADDRMODE ||
|
||||
fcf->destAddrMode == LONGADDRMODE){
|
||||
pf->dest_addr = (addr_t *)p;
|
||||
/* Update pointer to account for possible missing addr field */
|
||||
if (fcf->destAddrMode == SHORTADDRMODE){
|
||||
p += 2;
|
||||
}
|
||||
if (fcf->destAddrMode == LONGADDRMODE){
|
||||
p += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Source PANID */
|
||||
pf->src_pid = 0;
|
||||
if (!fcf->panIdCompression){
|
||||
pf->src_pid = (uint16_t *)p;
|
||||
p += 2;
|
||||
}
|
||||
/* Source address */
|
||||
pf->src_addr = (addr_t *)p;
|
||||
if (fcf->srcAddrMode == SHORTADDRMODE){
|
||||
p += 2;
|
||||
}
|
||||
if (fcf->srcAddrMode == LONGADDRMODE){
|
||||
p += 8;
|
||||
}
|
||||
/* aux security header, not yet implemented */
|
||||
pf->aux_sec_hdr = 0;
|
||||
/* payload length */
|
||||
pf->payload_length = rx_frame->length - (p - (uint8_t*)&rx_frame->data) - 2;
|
||||
/* payload */
|
||||
pf->payload = p;
|
||||
}
|
||||
|
||||
pf->lqi = rx_frame->lqi;
|
||||
pf->fcs = rx_frame->crc;
|
||||
|
|
|
@ -179,8 +179,11 @@ usbstick_mode_t usbstick_mode;
|
|||
uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan);
|
||||
uint8_t mac_createEthernetAddr(uint8_t * ethernet, uip_lladdr_t * lowpan);
|
||||
uint8_t memcmp_reverse(uint8_t * a, uint8_t * b, uint8_t num);
|
||||
void mac_ethhijack_nondata(const struct mac_driver *r);
|
||||
void mac_ethhijack(const struct mac_driver *r);
|
||||
|
||||
extern void (*sicslowmac_snifferhook)(const struct mac_driver *r);
|
||||
|
||||
|
||||
//! Location of TRANSLATE (TR) bit in Ethernet address
|
||||
#define TRANSLATE_BIT_MASK (1<<2)
|
||||
|
@ -219,6 +222,7 @@ void mac_ethernetSetup(void)
|
|||
|
||||
pmac = sicslowmac_get_driver();
|
||||
pmac->set_receive_function(mac_ethhijack);
|
||||
sicslowmac_snifferhook = mac_ethhijack_nondata;
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,9 +236,11 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
uip_lladdr_t destAddr;
|
||||
uip_lladdr_t *destAddrPtr = NULL;
|
||||
|
||||
PRINTF("Packet type: %x\n", ((struct uip_eth_hdr *) ethHeader)->type);
|
||||
|
||||
//If not IPv6 we don't do anything
|
||||
if (((struct uip_eth_hdr *) ethHeader)->type != HTONS(UIP_ETHTYPE_IPV6)) {
|
||||
PRINTF("eth2low: Packet is not IPv6, dropping\n");
|
||||
printf("eth2low: Packet is not IPv6, dropping\n");
|
||||
rndis_stat.txbad++;
|
||||
uip_len = 0;
|
||||
return;
|
||||
|
@ -709,6 +715,13 @@ void mac_ethhijack(const struct mac_driver *r)
|
|||
|
||||
}
|
||||
|
||||
void mac_ethhijack_nondata(const struct mac_driver *r)
|
||||
{
|
||||
if (usbstick_mode.raw)
|
||||
mac_802154raw(r);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \brief Logs a sent 6lowpan frame
|
||||
|
|
Loading…
Reference in a new issue