mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Added support for encryption and decryption of the packetbuf if macros
NETSTACK_ENCRYPT and NETSTACK_DECRYPT are defined. Those are intended to be called as functions NETSTACK_ENCRYPT() and NETSTACK_DECRYPT() to encrypt and decrypt the packetbuf, respectively. If needed, an initialization function by the name NETSTACK_ENCRYPTION_INIT() can also be defined.
This commit is contained in:
parent
63d205e4a2
commit
cb7842bd16
@ -626,6 +626,12 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
|||||||
|
|
||||||
packetbuf_compact();
|
packetbuf_compact();
|
||||||
|
|
||||||
|
#ifdef NETSTACK_ENCRYPT
|
||||||
|
NETSTACK_ENCRYPT();
|
||||||
|
#endif /* NETSTACK_ENCRYPT */
|
||||||
|
|
||||||
|
transmit_len = packetbuf_totlen();
|
||||||
|
|
||||||
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), transmit_len);
|
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), transmit_len);
|
||||||
|
|
||||||
/* Remove the MAC-layer header since it will be recreated next time around. */
|
/* Remove the MAC-layer header since it will be recreated next time around. */
|
||||||
@ -915,7 +921,11 @@ input_packet(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* printf("cycle_start 0x%02x 0x%02x\n", cycle_start, cycle_start % CYCLE_TIME);*/
|
/* printf("cycle_start 0x%02x 0x%02x\n", cycle_start, cycle_start % CYCLE_TIME);*/
|
||||||
|
|
||||||
|
#ifdef NETSTACK_DECRYPT
|
||||||
|
NETSTACK_DECRYPT();
|
||||||
|
#endif /* NETSTACK_DECRYPT */
|
||||||
|
|
||||||
if(packetbuf_totlen() > 0 && NETSTACK_FRAMER.parse() >= 0) {
|
if(packetbuf_totlen() > 0 && NETSTACK_FRAMER.parse() >= 0) {
|
||||||
|
|
||||||
#if WITH_CONTIKIMAC_HEADER
|
#if WITH_CONTIKIMAC_HEADER
|
||||||
|
@ -114,6 +114,10 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||||||
ret = MAC_TX_ERR_FATAL;
|
ret = MAC_TX_ERR_FATAL;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
#ifdef NETSTACK_ENCRYPT
|
||||||
|
NETSTACK_ENCRYPT();
|
||||||
|
#endif /* NETSTACK_ENCRYPT */
|
||||||
|
|
||||||
#if NULLRDC_802154_AUTOACK
|
#if NULLRDC_802154_AUTOACK
|
||||||
int is_broadcast;
|
int is_broadcast;
|
||||||
uint8_t dsn;
|
uint8_t dsn;
|
||||||
@ -213,6 +217,10 @@ send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
|||||||
static void
|
static void
|
||||||
packet_input(void)
|
packet_input(void)
|
||||||
{
|
{
|
||||||
|
#ifdef NETSTACK_DECRYPT
|
||||||
|
NETSTACK_DECRYPT();
|
||||||
|
#endif /* NETSTACK_DECRYPT */
|
||||||
|
|
||||||
#if NULLRDC_802154_AUTOACK
|
#if NULLRDC_802154_AUTOACK
|
||||||
if(packetbuf_datalen() == ACK_LEN) {
|
if(packetbuf_datalen() == ACK_LEN) {
|
||||||
/* Ignore ack packets */
|
/* Ignore ack packets */
|
||||||
|
@ -46,5 +46,9 @@ netstack_init(void)
|
|||||||
NETSTACK_RDC.init();
|
NETSTACK_RDC.init();
|
||||||
NETSTACK_MAC.init();
|
NETSTACK_MAC.init();
|
||||||
NETSTACK_NETWORK.init();
|
NETSTACK_NETWORK.init();
|
||||||
|
|
||||||
|
#ifdef NETSTACK_ENCRYPTION_INIT
|
||||||
|
NETSTACK_ENCRYPTION_INIT();
|
||||||
|
#endif /* NETSTACK_ENCRYPTION_INIT */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user