lwIP 2.1.0 Lightweight IP stack

Functions
6LoWPAN over BLE (RFC7668)
NETIFs

## Functions
void | ble_addr_to_eui64 (uint8_t *dst, const uint8_t *src, int public_addr)
void | eui64_to_ble_addr (uint8_t *dst, const uint8_t *src)
err_t | rfc7668_set_context (u8_t idx, const ip6_addr_t *context)
err_t | rfc7668_output (struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
err_t | rfc7668_input (struct pbuf *p, struct netif *netif)
err_t | rfc7668_if_init (struct netif *netif)

## Detailed Description

This file implements a RFC7668 implementation for 6LoWPAN over Bluetooth Low Energy. The specification is very similar to 6LoWPAN, so most of the code is re-used. Compared to 6LoWPAN, much functionality is already implemented in lower BLE layers (fragmenting, session management,...).

Usage:

- add this netif
  - don't add IPv4 addresses (no IPv4 support in RFC7668), pass 'NULL','NULL','NULL'
  - use the BLE to EUI64 conversation util to create an IPv6 link-local address from the BLE MAC (ble_addr_to_eui64)
  - input function: rfc7668_input
- set the link output function, which transmits output data to an established L2CAP channel
- If data arrives (HCI event "L2CAP_DATA_PACKET"):
  - allocate a PBUF_RAW buffer
  - let the pbuf struct point to the incoming data or copy it to the buffer
  - call netif->input

## Function Documentation

## ◆ ble_addr_to_eui64()

void ble_addr_to_eui64 | ( | uint8_t * | dst,
|  | const uint8_t * | src,
|  | int | public_addr
| ) |  |

convert BT address to EUI64 addr

This method converts a Bluetooth MAC address to an EUI64 address, which is used within IPv6 communication

Parameters

  dst | IPv6 destination space
  src | BLE MAC address source
  public_addr | If the LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS option is set, bit 0x02 will be set if param=0 (no public addr); cleared otherwise

See also
  LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS

## ◆ eui64_to_ble_addr()

void eui64_to_ble_addr | ( | uint8_t * | dst,
|  | const uint8_t * | src
| ) |  |

convert EUI64 address to Bluetooth MAC addr

This method converts an EUI64 address to a Bluetooth MAC address,

Parameters

  dst | BLE MAC address destination
  src | IPv6 source

## ◆ rfc7668_if_init()

err_t rfc7668_if_init | ( | struct netif * | netif | ) |

Initialize the netif

No flags are used (broadcast not possible, not ethernet, ...) The shortname for this netif is "BT"

Parameters

  netif | the network interface to be initialized as RFC7668 netif

Returns
  ERR_OK if everything went fine

## ◆ rfc7668_input()

err_t rfc7668_input | ( | struct pbuf * | p,
|  | struct netif * | netif
| ) |  |

Process a received raw payload from an L2CAP channel

Parameters

  p | the received packet, p->payload pointing to the IPv6 header (maybe compressed)
  netif | the network interface on which the packet was received

Returns
  ERR_OK if everything was fine

## ◆ rfc7668_output()

err_t rfc7668_output | ( | struct netif * | netif,
|  | struct pbuf * | q,
|  | const ip6_addr_t * | ip6addr
| ) |  |

Compress outgoing IPv6 packet and pass it on to netif->linkoutput

Parameters

  netif | The lwIP network interface which the IP packet will be sent on.
  q | The pbuf(s) containing the IP packet to be sent.
  ip6addr | The IP address of the packet destination.

Returns
  See rfc7668_compress

## ◆ rfc7668_set_context()

err_t rfc7668_set_context | ( | u8_t | idx,
|  | const ip6_addr_t * | context
| ) |  |

Set context id IPv6 address

Store one IPv6 address to a given context id.

Parameters

  idx | Context id
  context | IPv6 addr for this context

Returns
  ERR_OK (if everything is fine), ERR_ARG (if the context id is out of range), ERR_VAL (if contexts disabled)