1195972f6Sopenharmony_ci/**
2195972f6Sopenharmony_ci * @file
3195972f6Sopenharmony_ci *
4195972f6Sopenharmony_ci * A netif implementing the ZigBee Eencapsulation Protocol (ZEP).
5195972f6Sopenharmony_ci * This is used to tunnel 6LowPAN over UDP.
6195972f6Sopenharmony_ci */
7195972f6Sopenharmony_ci
8195972f6Sopenharmony_ci/*
9195972f6Sopenharmony_ci * Copyright (c) 2018 Simon Goldschmidt
10195972f6Sopenharmony_ci * All rights reserved.
11195972f6Sopenharmony_ci *
12195972f6Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification,
13195972f6Sopenharmony_ci * are permitted provided that the following conditions are met:
14195972f6Sopenharmony_ci *
15195972f6Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice,
16195972f6Sopenharmony_ci *    this list of conditions and the following disclaimer.
17195972f6Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice,
18195972f6Sopenharmony_ci *    this list of conditions and the following disclaimer in the documentation
19195972f6Sopenharmony_ci *    and/or other materials provided with the distribution.
20195972f6Sopenharmony_ci * 3. The name of the author may not be used to endorse or promote products
21195972f6Sopenharmony_ci *    derived from this software without specific prior written permission.
22195972f6Sopenharmony_ci *
23195972f6Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24195972f6Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25195972f6Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26195972f6Sopenharmony_ci * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27195972f6Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28195972f6Sopenharmony_ci * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29195972f6Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30195972f6Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31195972f6Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32195972f6Sopenharmony_ci * OF SUCH DAMAGE.
33195972f6Sopenharmony_ci *
34195972f6Sopenharmony_ci * This file is part of the lwIP TCP/IP stack.
35195972f6Sopenharmony_ci *
36195972f6Sopenharmony_ci * Author: Simon Goldschmidt <goldsimon@gmx.de>
37195972f6Sopenharmony_ci *
38195972f6Sopenharmony_ci */
39195972f6Sopenharmony_ci
40195972f6Sopenharmony_ci#ifndef LWIP_HDR_ZEPIF_H
41195972f6Sopenharmony_ci#define LWIP_HDR_ZEPIF_H
42195972f6Sopenharmony_ci
43195972f6Sopenharmony_ci#include "lwip/opt.h"
44195972f6Sopenharmony_ci#include "netif/lowpan6.h"
45195972f6Sopenharmony_ci
46195972f6Sopenharmony_ci#if LWIP_IPV6 && LWIP_UDP /* don't build if not configured for use in lwipopts.h */
47195972f6Sopenharmony_ci
48195972f6Sopenharmony_ci#include "lwip/netif.h"
49195972f6Sopenharmony_ci
50195972f6Sopenharmony_ci#ifdef __cplusplus
51195972f6Sopenharmony_ciextern "C" {
52195972f6Sopenharmony_ci#endif
53195972f6Sopenharmony_ci
54195972f6Sopenharmony_ci#define ZEPIF_DEFAULT_UDP_PORT  17754
55195972f6Sopenharmony_ci
56195972f6Sopenharmony_ci/** Pass this struct as 'state' to netif_add to control the behaviour
57195972f6Sopenharmony_ci * of this netif. If NULL is passed, default behaviour is chosen */
58195972f6Sopenharmony_cistruct zepif_init {
59195972f6Sopenharmony_ci  /** The UDP port used to ZEP frames from (0 = default) */
60195972f6Sopenharmony_ci  u16_t               zep_src_udp_port;
61195972f6Sopenharmony_ci  /** The UDP port used to ZEP frames to (0 = default) */
62195972f6Sopenharmony_ci  u16_t               zep_dst_udp_port;
63195972f6Sopenharmony_ci  /** The IP address to sed ZEP frames from (NULL = ANY) */
64195972f6Sopenharmony_ci  const ip_addr_t    *zep_src_ip_addr;
65195972f6Sopenharmony_ci  /** The IP address to sed ZEP frames to (NULL = BROADCAST) */
66195972f6Sopenharmony_ci  const ip_addr_t    *zep_dst_ip_addr;
67195972f6Sopenharmony_ci  /** If != NULL, the udp pcb is bound to this netif */
68195972f6Sopenharmony_ci  const struct netif *zep_netif;
69195972f6Sopenharmony_ci  /** MAC address of the 6LowPAN device */
70195972f6Sopenharmony_ci  u8_t                addr[6];
71195972f6Sopenharmony_ci};
72195972f6Sopenharmony_ci
73195972f6Sopenharmony_cierr_t zepif_init(struct netif *netif);
74195972f6Sopenharmony_ci
75195972f6Sopenharmony_ci#ifdef __cplusplus
76195972f6Sopenharmony_ci}
77195972f6Sopenharmony_ci#endif
78195972f6Sopenharmony_ci
79195972f6Sopenharmony_ci#endif /* LWIP_IPV6 && LWIP_UDP */
80195972f6Sopenharmony_ci
81195972f6Sopenharmony_ci#endif /* LWIP_HDR_ZEPIF_H */
82