Reformat netif subdir using astylerc

This commit is contained in:
Dirk Ziegelmeier 2017-10-03 21:22:04 +02:00
parent 47138f92d0
commit de5b693e7d
5 changed files with 152 additions and 153 deletions

View File

@ -171,7 +171,7 @@ static void
bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx)
{
int i;
bridgeif_dfdb_t *fdb = (bridgeif_dfdb_t*)fdb_ptr;
bridgeif_dfdb_t *fdb = (bridgeif_dfdb_t *)fdb_ptr;
BRIDGEIF_DECL_PROTECT(lev);
BRIDGEIF_READ_PROTECT(lev);
for (i = 0; i < fdb->max_fdb_entries; i++) {
@ -179,8 +179,8 @@ bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx)
if (e->used && e->ts) {
if (!memcmp(&e->addr, src_addr, sizeof(struct eth_addr))) {
LWIP_DEBUGF(BRIDGEIF_FDB_DEBUG, ("br: update src %02x:%02x:%02x:%02x:%02x:%02x (from %d) @ idx %d\n",
src_addr->addr[0], src_addr->addr[1], src_addr->addr[2], src_addr->addr[3], src_addr->addr[4], src_addr->addr[5],
port_idx, i));
src_addr->addr[0], src_addr->addr[1], src_addr->addr[2], src_addr->addr[3], src_addr->addr[4], src_addr->addr[5],
port_idx, i));
BRIDGEIF_WRITE_PROTECT(lev);
e->ts = BR_FDB_TIMEOUT_SEC;
e->port = port_idx;
@ -198,8 +198,8 @@ bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx)
/* check again when protected */
if (!e->used || !e->ts) {
LWIP_DEBUGF(BRIDGEIF_FDB_DEBUG, ("br: create src %02x:%02x:%02x:%02x:%02x:%02x (from %d) @ idx %d\n",
src_addr->addr[0], src_addr->addr[1], src_addr->addr[2], src_addr->addr[3], src_addr->addr[4], src_addr->addr[5],
port_idx, i));
src_addr->addr[0], src_addr->addr[1], src_addr->addr[2], src_addr->addr[3], src_addr->addr[4], src_addr->addr[5],
port_idx, i));
memcpy(&e->addr, src_addr, sizeof(struct eth_addr));
e->ts = BR_FDB_TIMEOUT_SEC;
e->port = port_idx;
@ -220,7 +220,7 @@ static bridgeif_portmask_t
bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr)
{
int i;
bridgeif_dfdb_t *fdb = (bridgeif_dfdb_t*)fdb_ptr;
bridgeif_dfdb_t *fdb = (bridgeif_dfdb_t *)fdb_ptr;
BRIDGEIF_DECL_PROTECT(lev);
BRIDGEIF_READ_PROTECT(lev);
for (i = 0; i < fdb->max_fdb_entries; i++) {
@ -238,15 +238,15 @@ bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr)
}
/** Init our simple fdb list */
static void*
static void *
bridgeif_fdb_init(u16_t max_fdb_entries)
{
bridgeif_dfdb_t *fdb;
size_t alloc_len_sizet = sizeof(bridgeif_dfdb_t) + (max_fdb_entries*sizeof(bridgeif_dfdb_entry_t));
size_t alloc_len_sizet = sizeof(bridgeif_dfdb_t) + (max_fdb_entries * sizeof(bridgeif_dfdb_entry_t));
mem_size_t alloc_len = (mem_size_t)alloc_len_sizet;
LWIP_ASSERT("alloc_len == alloc_len_sizet", alloc_len == alloc_len_sizet);
LWIP_DEBUGF(BRIDGEIF_DEBUG, ("bridgeif_fdb_init: allocating %d bytes for private FDB data\n", (int)alloc_len));
fdb = (bridgeif_dfdb_t*)mem_calloc(1, alloc_len);
fdb = (bridgeif_dfdb_t *)mem_calloc(1, alloc_len);
if (fdb == NULL) {
return NULL;
}
@ -315,7 +315,7 @@ bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_p
bridgeif_private_t *br;
BRIDGEIF_DECL_PROTECT(lev);
LWIP_ASSERT("invalid netif", bridgeif != NULL);
br = (bridgeif_private_t*)bridgeif->state;
br = (bridgeif_private_t *)bridgeif->state;
LWIP_ASSERT("invalid state", br != NULL);
BRIDGEIF_READ_PROTECT(lev);
@ -348,7 +348,7 @@ bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr)
bridgeif_private_t *br;
BRIDGEIF_DECL_PROTECT(lev);
LWIP_ASSERT("invalid netif", bridgeif != NULL);
br = (bridgeif_private_t*)bridgeif->state;
br = (bridgeif_private_t *)bridgeif->state;
LWIP_ASSERT("invalid state", br != NULL);
BRIDGEIF_READ_PROTECT(lev);
@ -434,7 +434,7 @@ bridgeif_send_to_port(bridgeif_private_t *br, struct pbuf *p, u8_t dstport_idx)
/* prevent sending out to rx port */
if (netif_get_index(portif) != p->if_idx) {
if (netif_is_link_up(portif)) {
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> flood(%p:%d) -> %d\n", (void*)p, p->if_idx, netif_get_index(portif)));
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> flood(%p:%d) -> %d\n", (void *)p, p->if_idx, netif_get_index(portif)));
return portif->linkoutput(portif, p);
}
}
@ -477,14 +477,14 @@ static err_t
bridgeif_output(struct netif *netif, struct pbuf *p)
{
err_t err;
bridgeif_private_t *br = (bridgeif_private_t*)netif->state;
bridgeif_private_t *br = (bridgeif_private_t *)netif->state;
struct eth_addr *dst = (struct eth_addr *)(p->payload);
bridgeif_portmask_t dstports = bridgeif_find_dst_ports(br, dst);
err = bridgeif_send_to_ports(br, p, dstports);
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
if (((u8_t*)p->payload)[0] & 1) {
if (((u8_t *)p->payload)[0] & 1) {
/* broadcast or multicast packet*/
MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
} else {
@ -522,8 +522,8 @@ bridgeif_input(struct pbuf *p, struct netif *netif)
/* store receive index in pbuf */
p->if_idx = rx_idx;
dst = (struct eth_addr*)p->payload;
src = (struct eth_addr*)(((u8_t*)p->payload) + sizeof(struct eth_addr));
dst = (struct eth_addr *)p->payload;
src = (struct eth_addr *)(((u8_t *)p->payload) + sizeof(struct eth_addr));
if ((src->addr[0] & 1) == 0) {
/* update src for all non-group addresses */
@ -536,7 +536,7 @@ bridgeif_input(struct pbuf *p, struct netif *netif)
bridgeif_send_to_ports(br, p, dstports);
if (dstports & (1 << BRIDGEIF_MAX_PORTS)) {
/* we pass the reference to ->input or have to free it */
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> input(%p)\n", (void*)p));
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> input(%p)\n", (void *)p));
if (br->netif->input(p, br->netif) != ERR_OK) {
pbuf_free(p);
}
@ -550,7 +550,7 @@ bridgeif_input(struct pbuf *p, struct netif *netif)
/* is this for one of the local ports? */
if (bridgeif_is_local_mac(br, dst)) {
/* yes, send to cpu port only */
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> input(%p)\n", (void*)p));
LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> input(%p)\n", (void *)p));
return br->netif->input(p, br->netif);
}
@ -599,7 +599,7 @@ bridgeif_init(struct netif *netif)
LWIP_ASSERT("netif != NULL", (netif != NULL));
#if !BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT
if (netif->input == tcpip_input) {
LWIP_DEBUGF(BRIDGEIF_DEBUG|LWIP_DBG_ON, ("bridgeif does not need tcpip_input, use netif_input/ethernet_input instead"));
LWIP_DEBUGF(BRIDGEIF_DEBUG | LWIP_DBG_ON, ("bridgeif does not need tcpip_input, use netif_input/ethernet_input instead"));
}
#endif
@ -610,13 +610,13 @@ bridgeif_init(struct netif *netif)
init_data = (bridgeif_initdata_t *)netif->state;
LWIP_ASSERT("init_data != NULL", (init_data != NULL));
LWIP_ASSERT("init_data->max_ports <= BRIDGEIF_MAX_PORTS",
init_data->max_ports <= BRIDGEIF_MAX_PORTS);
init_data->max_ports <= BRIDGEIF_MAX_PORTS);
alloc_len_sizet = sizeof(bridgeif_private_t) + (init_data->max_ports*sizeof(bridgeif_port_t) + (init_data->max_fdb_static_entries*sizeof(bridgeif_fdb_static_entry_t)));
alloc_len_sizet = sizeof(bridgeif_private_t) + (init_data->max_ports * sizeof(bridgeif_port_t) + (init_data->max_fdb_static_entries * sizeof(bridgeif_fdb_static_entry_t)));
alloc_len = (mem_size_t)alloc_len_sizet;
LWIP_ASSERT("alloc_len == alloc_len_sizet", alloc_len == alloc_len_sizet);
LWIP_DEBUGF(BRIDGEIF_DEBUG, ("bridgeif_init: allocating %d bytes for private data\n", (int)alloc_len));
br = (bridgeif_private_t*)mem_calloc(1, alloc_len);
br = (bridgeif_private_t *)mem_calloc(1, alloc_len);
if (br == NULL) {
LWIP_DEBUGF(NETIF_DEBUG, ("bridgeif_init: out of memory\n"));
return ERR_MEM;
@ -625,10 +625,10 @@ bridgeif_init(struct netif *netif)
br->netif = netif;
br->max_ports = init_data->max_ports;
br->ports = (bridgeif_port_t*)(br + 1);
br->ports = (bridgeif_port_t *)(br + 1);
br->max_fdbs_entries = init_data->max_fdb_static_entries;
br->fdbs = (bridgeif_fdb_static_entry_t*)(((u8_t*)(br + 1)) + (init_data->max_ports*sizeof(bridgeif_port_t)));
br->fdbs = (bridgeif_fdb_static_entry_t *)(((u8_t *)(br + 1)) + (init_data->max_ports * sizeof(bridgeif_port_t)));
br->max_fdbd_entries = init_data->max_fdb_dynamic_entries;
br->fdbd = bridgeif_fdb_init(init_data->max_fdb_dynamic_entries);
@ -676,7 +676,7 @@ bridgeif_init(struct netif *netif)
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP | NETIF_FLAG_MLD6 |NETIF_FLAG_LINK_UP;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP | NETIF_FLAG_MLD6 | NETIF_FLAG_LINK_UP;
#if LWIP_IPV6 && LWIP_IPV6_MLD
/*

View File

@ -1,7 +1,7 @@
/**
* @file
* Ethernet common functions
*
*
* @defgroup ethernet Ethernet
* @ingroup callbackstyle_api
*/
@ -60,8 +60,8 @@
#include LWIP_HOOK_FILENAME
#endif
const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
const struct eth_addr ethzero = {{0,0,0,0,0,0}};
const struct eth_addr ethbroadcast = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
const struct eth_addr ethzero = {{0, 0, 0, 0, 0, 0}};
/**
* @ingroup lwip_nosys
@ -72,7 +72,7 @@ const struct eth_addr ethzero = {{0,0,0,0,0,0}};
*
* @param p the received packet, p->payload pointing to the ethernet header
* @param netif the network interface on which the packet was received
*
*
* @see LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
* @see ETHARP_SUPPORT_VLAN
* @see LWIP_HOOK_VLAN_CHECK
@ -80,7 +80,7 @@ const struct eth_addr ethzero = {{0,0,0,0,0,0}};
err_t
ethernet_input(struct pbuf *p, struct netif *netif)
{
struct eth_hdr* ethhdr;
struct eth_hdr *ethhdr;
u16_t type;
#if LWIP_ARP || ETHARP_SUPPORT_VLAN || LWIP_IPV6
u16_t next_hdr_offset = SIZEOF_ETH_HDR;
@ -101,17 +101,17 @@ ethernet_input(struct pbuf *p, struct netif *netif)
/* points to packet payload, which starts with an Ethernet header */
ethhdr = (struct eth_hdr *)p->payload;
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE,
("ethernet_input: dest:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", src:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", type:%"X16_F"\n",
(unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2],
(unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5],
(unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2],
(unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5],
lwip_htons(ethhdr->type)));
("ethernet_input: dest:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", src:%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F", type:%"X16_F"\n",
(unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2],
(unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5],
(unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2],
(unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5],
lwip_htons(ethhdr->type)));
type = ethhdr->type;
#if ETHARP_SUPPORT_VLAN
if (type == PP_HTONS(ETHTYPE_VLAN)) {
struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR);
struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr *)(((char *)ethhdr) + SIZEOF_ETH_HDR);
if (p->len <= SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) {
/* a packet with only an ethernet/vlan header (or less) is not valid for us */
ETHARP_STATS_INC(etharp.proterr);
@ -155,8 +155,8 @@ ethernet_input(struct pbuf *p, struct netif *netif)
#if LWIP_IPV6
else if ((ethhdr->dest.addr[0] == LL_IP6_MULTICAST_ADDR_0) &&
(ethhdr->dest.addr[1] == LL_IP6_MULTICAST_ADDR_1)) {
/* mark the pbuf as link-layer multicast */
p->flags |= PBUF_FLAG_LLMCAST;
/* mark the pbuf as link-layer multicast */
p->flags |= PBUF_FLAG_LLMCAST;
}
#endif /* LWIP_IPV6 */
else if (eth_addr_cmp(&ethhdr->dest, &ethbroadcast)) {
@ -175,8 +175,8 @@ ethernet_input(struct pbuf *p, struct netif *netif)
/* skip Ethernet header */
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: IPv4 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
("ethernet_input: IPv4 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("Can't move over header in packet"));
goto free_and_return;
} else {
@ -192,8 +192,8 @@ ethernet_input(struct pbuf *p, struct netif *netif)
/* skip Ethernet header */
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: ARP response packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
("ethernet_input: ARP response packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("Can't move over header in packet"));
ETHARP_STATS_INC(etharp.lenerr);
ETHARP_STATS_INC(etharp.drop);
@ -219,8 +219,8 @@ ethernet_input(struct pbuf *p, struct netif *netif)
/* skip Ethernet header */
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: IPv6 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
("ethernet_input: IPv6 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
goto free_and_return;
} else {
/* pass to IPv6 layer */
@ -231,7 +231,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
default:
#ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
if(LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) == ERR_OK) {
if (LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) == ERR_OK) {
break;
}
#endif
@ -265,24 +265,23 @@ free_and_return:
* @return ERR_OK if the packet was sent, any other err_t on failure
*/
err_t
ethernet_output(struct netif* netif, struct pbuf* p,
const struct eth_addr* src, const struct eth_addr* dst,
u16_t eth_type)
{
struct eth_hdr* ethhdr;
ethernet_output(struct netif * netif, struct pbuf * p,
const struct eth_addr * src, const struct eth_addr * dst,
u16_t eth_type) {
struct eth_hdr *ethhdr;
u16_t eth_type_be = lwip_htons(eth_type);
#if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET)
s32_t vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type);
if (vlan_prio_vid >= 0) {
struct eth_vlan_hdr* vlanhdr;
struct eth_vlan_hdr *vlanhdr;
LWIP_ASSERT("prio_vid must be <= 0xFFFF", vlan_prio_vid <= 0xFFFF);
if (pbuf_add_header(p, SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) != 0) {
goto pbuf_header_failed;
}
vlanhdr = (struct eth_vlan_hdr*)(((u8_t*)p->payload) + SIZEOF_ETH_HDR);
vlanhdr = (struct eth_vlan_hdr *)(((u8_t *)p->payload) + SIZEOF_ETH_HDR);
vlanhdr->tpid = eth_type_be;
vlanhdr->prio_vid = lwip_htons((u16_t)vlan_prio_vid);
@ -295,22 +294,22 @@ ethernet_output(struct netif* netif, struct pbuf* p,
}
}
ethhdr = (struct eth_hdr*)p->payload;
ethhdr = (struct eth_hdr *)p->payload;
ethhdr->type = eth_type_be;
SMEMCPY(&ethhdr->dest, dst, ETH_HWADDR_LEN);
SMEMCPY(&ethhdr->src, src, ETH_HWADDR_LEN);
LWIP_ASSERT("netif->hwaddr_len must be 6 for ethernet_output!",
(netif->hwaddr_len == ETH_HWADDR_LEN));
(netif->hwaddr_len == ETH_HWADDR_LEN));
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE,
("ethernet_output: sending packet %p\n", (void *)p));
("ethernet_output: sending packet %p\n", (void *)p));
/* send the packet */
return netif->linkoutput(netif, p);
pbuf_header_failed:
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
("ethernet_output: could not allocate room for header.\n"));
("ethernet_output: could not allocate room for header.\n"));
LINK_STATS_INC(link.lenerr);
return ERR_BUF;
}

View File

@ -155,7 +155,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
signal that packet should be sent();
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
if (((u8_t*)p->payload)[0] & 1) {
if (((u8_t *)p->payload)[0] & 1) {
/* broadcast or multicast packet*/
MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
} else {
@ -221,7 +221,7 @@ low_level_input(struct netif *netif)
acknowledge that packet has been read();
MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
if (((u8_t*)p->payload)[0] & 1) {
if (((u8_t *)p->payload)[0] & 1) {
/* broadcast or multicast packet*/
MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
} else {
@ -326,7 +326,7 @@ ethernetif_init(struct netif *netif)
#endif /* LWIP_IPV6 */
netif->linkoutput = low_level_output;
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
ethernetif->ethaddr = (struct eth_addr *) & (netif->hwaddr[0]);
/* initialize the hardware */
low_level_init(netif);

View File

@ -77,7 +77,7 @@ struct lowpan6_reass_helper {
u16_t datagram_tag;
};
static struct lowpan6_reass_helper * reass_list;
static struct lowpan6_reass_helper *reass_list;
#if LWIP_6LOWPAN_NUM_CONTEXTS > 0
static ip6_addr_t lowpan6_context[LWIP_6LOWPAN_NUM_CONTEXTS];
@ -88,7 +88,7 @@ static u16_t ieee_802154_pan_id;
static const struct ieee_802154_addr ieee_802154_broadcast = {2, {0xff, 0xff}};
#if LWIP_6LOWPAN_INFER_SHORT_ADDRESS
static struct ieee_802154_addr short_mac_addr = {2, {0,0}};
static struct ieee_802154_addr short_mac_addr = {2, {0, 0}};
#endif /* LWIP_6LOWPAN_INFER_SHORT_ADDRESS */
static err_t dequeue_datagram(struct lowpan6_reass_helper *lrh);
@ -159,20 +159,20 @@ lowpan6_get_address_mode(const ip6_addr_t *ip6addr, const struct ieee_802154_add
{
if (mac_addr->addr_len == 2) {
if ((ip6addr->addr[2] == (u32_t)PP_HTONL(0x000000ff)) &&
((ip6addr->addr[3] & PP_HTONL(0xffff0000)) == PP_NTOHL(0xfe000000))) {
((ip6addr->addr[3] & PP_HTONL(0xffff0000)) == PP_NTOHL(0xfe000000))) {
if ((ip6addr->addr[3] & PP_HTONL(0x0000ffff)) == lwip_ntohl((mac_addr->addr[0] << 8) | mac_addr->addr[1])) {
return 3;
}
}
} else if (mac_addr->addr_len == 8) {
if ((ip6addr->addr[2] == lwip_ntohl(((mac_addr->addr[0] ^ 2) << 24) | (mac_addr->addr[1] << 16) | mac_addr->addr[2] << 8 | mac_addr->addr[3])) &&
(ip6addr->addr[3] == lwip_ntohl((mac_addr->addr[4] << 24) | (mac_addr->addr[5] << 16) | mac_addr->addr[6] << 8 | mac_addr->addr[7]))) {
(ip6addr->addr[3] == lwip_ntohl((mac_addr->addr[4] << 24) | (mac_addr->addr[5] << 16) | mac_addr->addr[6] << 8 | mac_addr->addr[7]))) {
return 3;
}
}
if ((ip6addr->addr[2] == PP_HTONL(0x000000ffUL)) &&
((ip6addr->addr[3] & PP_HTONL(0xffff0000)) == PP_NTOHL(0xfe000000UL))) {
((ip6addr->addr[3] & PP_HTONL(0xffff0000)) == PP_NTOHL(0xfe000000UL))) {
return 2;
}
@ -189,7 +189,7 @@ lowpan6_get_address_mode_mc(const ip6_addr_t *ip6addr)
((ip6addr->addr[3] & PP_HTONL(0xffffff00)) == 0)) {
return 3;
} else if (((ip6addr->addr[0] & PP_HTONL(0xff00ffff)) == PP_HTONL(0xff000000)) &&
(ip6addr->addr[1] == 0)) {
(ip6addr->addr[1] == 0)) {
if ((ip6addr->addr[2] == 0) &&
((ip6addr->addr[3] & PP_HTONL(0xff000000)) == 0)) {
return 2;
@ -209,9 +209,9 @@ lowpan6_get_address_mode_mc(const ip6_addr_t *ip6addr)
static err_t
lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr *src, const struct ieee_802154_addr *dst)
{
struct pbuf * p_frag;
struct pbuf *p_frag;
u16_t frag_len, remaining_len;
u8_t * buffer;
u8_t *buffer;
u8_t ieee_header_len;
u8_t lowpan6_header_len;
s8_t i;
@ -228,7 +228,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
}
/* Write IEEE 802.15.4 header. */
buffer = (u8_t*)p_frag->payload;
buffer = (u8_t *)p_frag->payload;
ieee_header_len = 0;
if (dst == &ieee_802154_broadcast) {
buffer[ieee_header_len++] = 0x01; /* data packet, no ack required. */
@ -355,10 +355,10 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
i = lowpan6_get_address_mode(ip_2_ip6(&ip_data.current_iphdr_src), src);
buffer[ieee_header_len + 1] |= (i & 0x03) << 4;
if (i == 1) {
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 16, 8);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 16, 8);
lowpan6_header_len += 8;
} else if (i == 2) {
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 22, 2);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 22, 2);
lowpan6_header_len += 2;
}
} else if (ip6_addr_isany(ip_2_ip6(&ip_data.current_iphdr_src))) {
@ -366,7 +366,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
buffer[ieee_header_len + 1] |= 0x40;
} else {
/* Append full address. */
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 8, 16);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 8, 16);
lowpan6_header_len += 16;
}
@ -379,15 +379,15 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
i = lowpan6_get_address_mode_mc(ip_2_ip6(&ip_data.current_iphdr_dest));
buffer[ieee_header_len + 1] |= i & 0x03;
if (i == 0) {
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 24, 16);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 24, 16);
lowpan6_header_len += 16;
} else if (i == 1) {
buffer[ieee_header_len + lowpan6_header_len++] = ((u8_t *)p->payload)[25];
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 35, 5);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 35, 5);
lowpan6_header_len += 5;
} else if (i == 2) {
buffer[ieee_header_len + lowpan6_header_len++] = ((u8_t *)p->payload)[25];
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 37, 3);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 37, 3);
lowpan6_header_len += 3;
} else if (i == 3) {
buffer[ieee_header_len + lowpan6_header_len++] = ((u8_t *)p->payload)[39];
@ -398,15 +398,15 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
i = lowpan6_get_address_mode(ip_2_ip6(&ip_data.current_iphdr_dest), dst);
buffer[ieee_header_len + 1] |= i & 0x03;
if (i == 1) {
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 32, 8);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 32, 8);
lowpan6_header_len += 8;
} else if (i == 2) {
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 38, 2);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 38, 2);
lowpan6_header_len += 2;
}
} else {
/* Append full address. */
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t*)p->payload + 24, 16);
MEMCPY(buffer + ieee_header_len + lowpan6_header_len, (u8_t *)p->payload + 24, 16);
lowpan6_header_len += 16;
}
@ -572,7 +572,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
}
err_t
lowpan6_set_context(u8_t idx, const ip6_addr_t * context)
lowpan6_set_context(u8_t idx, const ip6_addr_t *context)
{
if (idx >= LWIP_6LOWPAN_NUM_CONTEXTS) {
return ERR_ARG;
@ -627,7 +627,7 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
struct ieee_802154_addr src, dest;
#if LWIP_6LOWPAN_INFER_SHORT_ADDRESS
ip6_addr_t ip6_src;
struct ip6_hdr * ip6_hdr;
struct ip6_hdr *ip6_hdr;
#endif /* LWIP_6LOWPAN_INFER_SHORT_ADDRESS */
#if LWIP_6LOWPAN_INFER_SHORT_ADDRESS
@ -691,10 +691,10 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
}
static struct pbuf *
lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_802154_addr * dest)
lowpan6_decompress(struct pbuf *p, struct ieee_802154_addr *src, struct ieee_802154_addr *dest)
{
struct pbuf * q;
u8_t * lowpan6_buffer;
struct pbuf *q;
u8_t *lowpan6_buffer;
u16_t lowpan6_offset;
struct ip6_hdr *ip6hdr;
s8_t i;
@ -722,13 +722,13 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
/* Set IPv6 version, traffic class and flow label. */
if ((lowpan6_buffer[0] & 0x18) == 0x00) {
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset], ((lowpan6_buffer[lowpan6_offset+1] & 0x0f) << 16) | (lowpan6_buffer[lowpan6_offset + 2] << 8) | lowpan6_buffer[lowpan6_offset+3]);
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset], ((lowpan6_buffer[lowpan6_offset + 1] & 0x0f) << 16) | (lowpan6_buffer[lowpan6_offset + 2] << 8) | lowpan6_buffer[lowpan6_offset + 3]);
lowpan6_offset += 4;
} else if ((lowpan6_buffer[0] & 0x18) == 0x08) {
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset] & 0xc0, ((lowpan6_buffer[lowpan6_offset] & 0x0f) << 16) | (lowpan6_buffer[lowpan6_offset + 1] << 8) | lowpan6_buffer[lowpan6_offset+2]);
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset] & 0xc0, ((lowpan6_buffer[lowpan6_offset] & 0x0f) << 16) | (lowpan6_buffer[lowpan6_offset + 1] << 8) | lowpan6_buffer[lowpan6_offset + 2]);
lowpan6_offset += 3;
} else if ((lowpan6_buffer[0] & 0x18) == 0x10) {
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset],0);
IP6H_VTCFL_SET(ip6hdr, 6, lowpan6_buffer[lowpan6_offset], 0);
lowpan6_offset += 1;
} else if ((lowpan6_buffer[0] & 0x18) == 0x18) {
IP6H_VTCFL_SET(ip6hdr, 6, 0, 0);
@ -770,7 +770,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
ip6hdr->src.addr[1] = 0;
ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL);
ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) |
lowpan6_buffer[lowpan6_offset+1]);
lowpan6_buffer[lowpan6_offset + 1]);
lowpan6_offset += 2;
} else if ((lowpan6_buffer[1] & 0x30) == 0x30) {
ip6hdr->src.addr[0] = PP_HTONL(0xfe800000UL);
@ -780,9 +780,9 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (src->addr[0] << 8) | src->addr[1]);
} else {
ip6hdr->src.addr[2] = lwip_htonl(((src->addr[0] ^ 2) << 24) | (src->addr[1] << 16) |
(src->addr[2] << 8) | src->addr[3]);
(src->addr[2] << 8) | src->addr[3]);
ip6hdr->src.addr[3] = lwip_htonl((src->addr[4] << 24) | (src->addr[5] << 16) |
(src->addr[6] << 8) | src->addr[7]);
(src->addr[6] << 8) | src->addr[7]);
}
}
} else {
@ -816,7 +816,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
lowpan6_offset += 8;
} else if ((lowpan6_buffer[1] & 0x30) == 0x20) {
ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL);
ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset+1]);
ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset + 1]);
lowpan6_offset += 2;
} else if ((lowpan6_buffer[1] & 0x30) == 0x30) {
if (src->addr_len == 2) {
@ -850,7 +850,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
ip6hdr->dest.addr[3] = lwip_htonl((lowpan6_buffer[lowpan6_offset] << 24) | (lowpan6_buffer[lowpan6_offset + 1] << 16) | (lowpan6_buffer[lowpan6_offset + 2] << 8) | lowpan6_buffer[lowpan6_offset + 3]);
lowpan6_offset += 4;
} else if ((lowpan6_buffer[1] & 0x03) == 0x02) {
ip6hdr->dest.addr[0] = lwip_htonl(0xff000000UL | (lowpan6_buffer[lowpan6_offset++] << 16));
ip6hdr->dest.addr[0] = lwip_htonl(0xff000000UL | (lowpan6_buffer[lowpan6_offset++] << 16));
ip6hdr->dest.addr[1] = 0;
ip6hdr->dest.addr[2] = 0;
ip6hdr->dest.addr[3] = lwip_htonl((lowpan6_buffer[lowpan6_offset] << 16) | (lowpan6_buffer[lowpan6_offset + 1] << 8) | lowpan6_buffer[lowpan6_offset + 2]);
@ -964,7 +964,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
/* Now we copy leftover contents from p to q, so we have all L2 and L3 headers (and L4?) in a single PBUF.
* Replace p with q, and free p */
pbuf_remove_header(p, lowpan6_offset);
MEMCPY((u8_t*)q->payload + ip6_offset, p->payload, p->len);
MEMCPY((u8_t *)q->payload + ip6_offset, p->payload, p->len);
q->len = q->tot_len = ip6_offset + p->len;
if (p->next != NULL) {
pbuf_cat(q, p->next);
@ -980,9 +980,9 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
}
err_t
lowpan6_input(struct pbuf * p, struct netif *netif)
lowpan6_input(struct pbuf *p, struct netif *netif)
{
u8_t * puc;
u8_t *puc;
s8_t i;
struct ieee_802154_addr src, dest;
u16_t datagram_size, datagram_offset, datagram_tag;
@ -991,7 +991,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
/* Analyze header. @todo validate. */
puc = (u8_t*)p->payload;
puc = (u8_t *)p->payload;
datagram_offset = 5;
if ((puc[1] & 0x0c) == 0x0c) {
dest.addr_len = 8;
@ -1024,7 +1024,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
pbuf_remove_header(p, datagram_offset); /* hide IEEE802.15.4 header. */
/* Check dispatch. */
puc = (u8_t*)p->payload;
puc = (u8_t *)p->payload;
if ((*puc & 0xf8) == 0xc0) {
/* FRAG1 dispatch. add this packet to reassembly list. */
@ -1137,12 +1137,12 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
}
/* We have a complete packet, check dispatch for headers. */
puc = (u8_t*)p->payload;
puc = (u8_t *)p->payload;
if (*puc == 0x41) {
/* This is a complete IPv6 packet, just skip dispatch byte. */
pbuf_remove_header(p, 1); /* hide dispatch byte. */
} else if ((*puc & 0xe0 )== 0x60) {
} else if ((*puc & 0xe0 ) == 0x60) {
/* IPv6 headers are compressed using IPHC. */
p = lowpan6_decompress(p, &src, &dest);
if (p == NULL) {

View File

@ -88,8 +88,8 @@
#endif
enum slipif_recv_state {
SLIP_RECV_NORMAL,
SLIP_RECV_ESCAPE
SLIP_RECV_NORMAL,
SLIP_RECV_ESCAPE
};
struct slipif_priv {
@ -135,20 +135,20 @@ slipif_output(struct netif *netif, struct pbuf *p)
for (i = 0; i < q->len; i++) {
c = ((u8_t *)q->payload)[i];
switch (c) {
case SLIP_END:
/* need to escape this byte (0xC0 -> 0xDB, 0xDC) */
sio_send(SLIP_ESC, priv->sd);
sio_send(SLIP_ESC_END, priv->sd);
break;
case SLIP_ESC:
/* need to escape this byte (0xDB -> 0xDB, 0xDD) */
sio_send(SLIP_ESC, priv->sd);
sio_send(SLIP_ESC_ESC, priv->sd);
break;
default:
/* normal byte - no need for escaping */
sio_send(c, priv->sd);
break;
case SLIP_END:
/* need to escape this byte (0xC0 -> 0xDB, 0xDC) */
sio_send(SLIP_ESC, priv->sd);
sio_send(SLIP_ESC_END, priv->sd);
break;
case SLIP_ESC:
/* need to escape this byte (0xDB -> 0xDB, 0xDD) */
sio_send(SLIP_ESC, priv->sd);
sio_send(SLIP_ESC_ESC, priv->sd);
break;
default:
/* normal byte - no need for escaping */
sio_send(c, priv->sd);
break;
}
}
}
@ -203,7 +203,7 @@ slipif_output_v6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr)
* return a complete packet, NULL is returned before - used for polling)
* @return The IP packet when SLIP_END is received
*/
static struct pbuf*
static struct pbuf *
slipif_rxbyte(struct netif *netif, u8_t c)
{
struct slipif_priv *priv;
@ -215,47 +215,47 @@ slipif_rxbyte(struct netif *netif, u8_t c)
priv = (struct slipif_priv *)netif->state;
switch (priv->state) {
case SLIP_RECV_NORMAL:
switch (c) {
case SLIP_END:
if (priv->recved > 0) {
/* Received whole packet. */
/* Trim the pbuf to the size of the received packet. */
pbuf_realloc(priv->q, priv->recved);
case SLIP_RECV_NORMAL:
switch (c) {
case SLIP_END:
if (priv->recved > 0) {
/* Received whole packet. */
/* Trim the pbuf to the size of the received packet. */
pbuf_realloc(priv->q, priv->recved);
LINK_STATS_INC(link.recv);
LINK_STATS_INC(link.recv);
LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet (%"U16_F" bytes)\n", priv->recved));
t = priv->q;
priv->p = priv->q = NULL;
priv->i = priv->recved = 0;
return t;
LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet (%"U16_F" bytes)\n", priv->recved));
t = priv->q;
priv->p = priv->q = NULL;
priv->i = priv->recved = 0;
return t;
}
return NULL;
case SLIP_ESC:
priv->state = SLIP_RECV_ESCAPE;
return NULL;
default:
break;
} /* end switch (c) */
break;
case SLIP_RECV_ESCAPE:
/* un-escape END or ESC bytes, leave other bytes
(although that would be a protocol error) */
switch (c) {
case SLIP_ESC_END:
c = SLIP_END;
break;
case SLIP_ESC_ESC:
c = SLIP_ESC;
break;
default:
break;
}
return NULL;
case SLIP_ESC:
priv->state = SLIP_RECV_ESCAPE;
return NULL;
default:
break;
} /* end switch (c) */
break;
case SLIP_RECV_ESCAPE:
/* un-escape END or ESC bytes, leave other bytes
(although that would be a protocol error) */
switch (c) {
case SLIP_ESC_END:
c = SLIP_END;
break;
case SLIP_ESC_ESC:
c = SLIP_ESC;
priv->state = SLIP_RECV_NORMAL;
break;
default:
break;
}
priv->state = SLIP_RECV_NORMAL;
break;
default:
break;
} /* end switch (priv->state) */
/* byte received, packet not yet completely received */
@ -290,11 +290,11 @@ slipif_rxbyte(struct netif *netif, u8_t c)
priv->i = 0;
if (priv->p->next != NULL && priv->p->next->len > 0) {
/* p is a chain, on to the next in the chain */
priv->p = priv->p->next;
priv->p = priv->p->next;
} else {
/* p is a single pbuf, set it to NULL so next time a new
* pbuf is allocated */
priv->p = NULL;
priv->p = NULL;
}
}
}
@ -408,7 +408,7 @@ slipif_init(struct netif *netif)
#if SLIP_USE_RX_THREAD
/* Create a thread to poll the serial line. */
sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif,
SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO);
SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO);
#endif /* SLIP_USE_RX_THREAD */
return ERR_OK;
}