Loading...
Searching...
No Matches
compat.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Google LLC
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef LWIP_NETIF_COMPAT_H
21#define LWIP_NETIF_COMPAT_H
22
23#include "lwip/netif.h"
24#include "net/netif.h"
25#include "bhp/msg.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34typedef struct {
36 struct netif lwip_netif;
38#if IS_USED(MODULE_BHP_MSG)
40#endif
42
48static inline void lwip_netif_dev_lock_init(struct netif *netif)
49{
50 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
51 rmutex_init(&compat_netif->lock);
52}
53
59static inline void lwip_netif_dev_acquire(struct netif *netif)
60{
61 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
62 rmutex_lock(&compat_netif->lock);
63}
64
70static inline void lwip_netif_dev_release(struct netif *netif)
71{
72 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
73 rmutex_unlock(&compat_netif->lock);
74}
75
85static inline bhp_msg_t *lwip_netif_get_bhp(struct netif *netif)
86{
87#if IS_USED(MODULE_BHP_MSG)
88 lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
89 return &compat_netif->bhp;
90#else
91 (void) netif;
92 return NULL;
93#endif
94}
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* LWIP_NETIF_COMPAT_H */
static void lwip_netif_dev_release(struct netif *netif)
Release the LWIP netif network device.
Definition compat.h:70
static void lwip_netif_dev_acquire(struct netif *netif)
Acquire the LWIP netif network device.
Definition compat.h:59
static void lwip_netif_dev_lock_init(struct netif *netif)
Init the LWIP netif network device lock.
Definition compat.h:48
static bhp_msg_t * lwip_netif_get_bhp(struct netif *netif)
Get the IPC based Bottom Half Processor for LWIP.
Definition compat.h:85
#define container_of(PTR, TYPE, MEMBER)
Returns the container of a pointer to a member.
Definition container.h:62
void rmutex_lock(rmutex_t *rmutex)
Locks a recursive mutex, blocking.
static void rmutex_init(rmutex_t *rmutex)
Initializes a recursive mutex object.
Definition rmutex.h:75
void rmutex_unlock(rmutex_t *rmutex)
Unlocks the recursive mutex.
Common network interface API definitions.
Message based Bottom Half Processor descriptor.
Definition msg.h:43
Bottom Half Processor descriptor.
Definition bhp.h:51
Representation of a network interface.
Definition compat.h:34
netif_t common_netif
network interface descriptor
Definition compat.h:35
rmutex_t lock
lock for the interface
Definition compat.h:37
Network interface descriptor.
Definition netif.h:71
Mutex structure.
Definition rmutex.h:38