net: dtls_server: Avoid using #ifdef and #ifndef
It is prefered to use #if (!)defined form for checking defines since it can actually check more complex conditions. Change-Id: Ia8ab6898d340967759a8ecbda65c4bcacdc0293e Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
f32a837c9b
commit
758b159120
1 changed files with 12 additions and 12 deletions
|
@ -62,7 +62,7 @@ static const unsigned char ecdsa_pub_key_y[] = {
|
||||||
*/
|
*/
|
||||||
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||||
|
|
||||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
#if 0
|
#if 0
|
||||||
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
|
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
|
||||||
#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
||||||
|
@ -76,7 +76,7 @@ static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||||
|
|
||||||
#define MY_PORT 4242
|
#define MY_PORT 4242
|
||||||
|
|
||||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
||||||
static struct in6_addr in6addr_my = MY_IPADDR;
|
static struct in6_addr in6addr_my = MY_IPADDR;
|
||||||
#else
|
#else
|
||||||
|
@ -90,7 +90,7 @@ static inline void init_app(void)
|
||||||
|
|
||||||
net_set_mac(my_mac, sizeof(my_mac));
|
net_set_mac(my_mac, sizeof(my_mac));
|
||||||
|
|
||||||
#ifdef CONFIG_NETWORKING_WITH_IPV4
|
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
||||||
{
|
{
|
||||||
uip_ipaddr_t addr;
|
uip_ipaddr_t addr;
|
||||||
uip_ipaddr(&addr, 192,0,2,2);
|
uip_ipaddr(&addr, 192,0,2,2);
|
||||||
|
@ -98,7 +98,7 @@ static inline void init_app(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NETWORKING_IPV6_NO_ND
|
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
||||||
{
|
{
|
||||||
uip_ipaddr_t *addr;
|
uip_ipaddr_t *addr;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ static inline struct net_context *get_context(void)
|
||||||
static struct net_addr my_addr;
|
static struct net_addr my_addr;
|
||||||
struct net_context *ctx;
|
struct net_context *ctx;
|
||||||
|
|
||||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
any_addr.in6_addr = in6addr_any;
|
any_addr.in6_addr = in6addr_any;
|
||||||
any_addr.family = AF_INET6;
|
any_addr.family = AF_INET6;
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static int send_to_peer(struct dtls_context_t *ctx,
|
||||||
/* Note that we have reversed the addresses here
|
/* Note that we have reversed the addresses here
|
||||||
* because net_reply() will reverse them again.
|
* because net_reply() will reverse them again.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
uip_ip6addr_copy(&NET_BUF_IP(buf)->destipaddr,
|
uip_ip6addr_copy(&NET_BUF_IP(buf)->destipaddr,
|
||||||
(uip_ip6addr_t *)&in6addr_my);
|
(uip_ip6addr_t *)&in6addr_my);
|
||||||
uip_ip6addr_copy(&NET_BUF_IP(buf)->srcipaddr,
|
uip_ip6addr_copy(&NET_BUF_IP(buf)->srcipaddr,
|
||||||
|
@ -264,7 +264,7 @@ out:
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DTLS_PSK
|
#if defined(DTLS_PSK)
|
||||||
/* This function is the "key store" for tinyDTLS. It is called to
|
/* This function is the "key store" for tinyDTLS. It is called to
|
||||||
* retrieve a key for the given identity within this particular
|
* retrieve a key for the given identity within this particular
|
||||||
* session. */
|
* session. */
|
||||||
|
@ -313,7 +313,7 @@ static int get_psk_info(struct dtls_context_t *ctx,
|
||||||
}
|
}
|
||||||
#endif /* DTLS_PSK */
|
#endif /* DTLS_PSK */
|
||||||
|
|
||||||
#ifdef DTLS_ECC
|
#if defined(DTLS_ECC)
|
||||||
static int get_ecdsa_key(struct dtls_context_t *ctx,
|
static int get_ecdsa_key(struct dtls_context_t *ctx,
|
||||||
const session_t *session,
|
const session_t *session,
|
||||||
const dtls_ecdsa_key_t **result)
|
const dtls_ecdsa_key_t **result)
|
||||||
|
@ -362,10 +362,10 @@ static void init_dtls(struct net_context *recv, dtls_context_t **dtls)
|
||||||
.write = send_to_peer,
|
.write = send_to_peer,
|
||||||
.read = read_from_peer,
|
.read = read_from_peer,
|
||||||
.event = handle_event,
|
.event = handle_event,
|
||||||
#ifdef DTLS_PSK
|
#if defined(DTLS_PSK)
|
||||||
.get_psk_info = get_psk_info,
|
.get_psk_info = get_psk_info,
|
||||||
#endif /* DTLS_PSK */
|
#endif /* DTLS_PSK */
|
||||||
#ifdef DTLS_ECC
|
#if defined(DTLS_ECC)
|
||||||
.get_ecdsa_key = get_ecdsa_key,
|
.get_ecdsa_key = get_ecdsa_key,
|
||||||
.verify_ecdsa_key = verify_ecdsa_key
|
.verify_ecdsa_key = verify_ecdsa_key
|
||||||
#endif /* DTLS_ECC */
|
#endif /* DTLS_ECC */
|
||||||
|
@ -373,7 +373,7 @@ static void init_dtls(struct net_context *recv, dtls_context_t **dtls)
|
||||||
|
|
||||||
PRINT("DTLS server started\n");
|
PRINT("DTLS server started\n");
|
||||||
|
|
||||||
#ifdef CONFIG_TINYDTLS_DEBUG
|
#if defined(CONFIG_TINYDTLS_DEBUG)
|
||||||
dtls_set_log_level(DTLS_LOG_DEBUG);
|
dtls_set_log_level(DTLS_LOG_DEBUG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void startup(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NANOKERNEL
|
#if defined(CONFIG_NANOKERNEL)
|
||||||
|
|
||||||
#define STACKSIZE 3000
|
#define STACKSIZE 3000
|
||||||
char fiberStack[STACKSIZE];
|
char fiberStack[STACKSIZE];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue