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 "bhp/event.h"
24 #include "event.h"
25 #include "lwip/netif.h"
26 #include "net/netif.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct {
37  struct netif lwip_netif;
40 #ifdef MODULE_BHP_EVENT
42 #endif
43 #if (IS_USED(MODULE_NETDEV_NEW_API))
44  thread_t *thread_doing_tx;
45 #endif
46 } lwip_netif_t;
47 
53 static inline void lwip_netif_dev_lock_init(struct netif *netif)
54 {
55  lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
56  rmutex_init(&compat_netif->lock);
57 }
58 
64 static inline void lwip_netif_dev_acquire(struct netif *netif)
65 {
66  lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
67  rmutex_lock(&compat_netif->lock);
68 }
69 
75 static inline void lwip_netif_dev_release(struct netif *netif)
76 {
77  lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
78  rmutex_unlock(&compat_netif->lock);
79 }
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif /* LWIP_NETIF_COMPAT_H */
static void lwip_netif_dev_release(struct netif *netif)
Release the LWIP netif network device.
Definition: compat.h:75
static void lwip_netif_dev_acquire(struct netif *netif)
Acquire the LWIP netif network device.
Definition: compat.h:64
static void lwip_netif_dev_lock_init(struct netif *netif)
Init the LWIP netif network device lock.
Definition: compat.h:53
#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.
Asynchronous sock using Event Queue definitions.
Common network interface API definitions.
thread_t holds thread's context data.
Definition: thread.h:168
Event based Bottom Half Processor descriptor.
Definition: event.h:32
Bottom Half Processor descriptor.
Definition: bhp.h:51
event structure
Definition: event.h:148
Representation of a network interface.
Definition: compat.h:35
netif_t common_netif
network interface descriptor
Definition: compat.h:36
event_t ev_isr
ISR event.
Definition: compat.h:39
rmutex_t lock
lock for the interface
Definition: compat.h:38
Network interface descriptor.
Definition: netif.h:71
Mutex structure.
Definition: rmutex.h:38