STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
snmp_threadsync.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Dirk Ziegelmeier <dziegel@gmx.de>
30  *
31  */
32 
33 #ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H
34 #define LWIP_HDR_APPS_SNMP_THREADSYNC_H
35 
36 #include "lwip/apps/snmp_opts.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
43 
44 #include "lwip/apps/snmp_core.h"
45 #include "lwip/sys.h"
46 
47 typedef void (*snmp_threadsync_called_fn)(void* arg);
48 typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg);
49 
50 
52 struct threadsync_data
53 {
54  union {
55  snmp_err_t u8;
56  u16_t u16;
57  } retval;
58  union {
59  const u32_t *root_oid;
60  void *value;
61  } arg1;
62  union {
63  u8_t root_oid_len;
64  u16_t len;
65  } arg2;
66  const struct snmp_threadsync_node *threadsync_node;
67  struct snmp_node_instance proxy_instance;
68 };
69 
71 struct snmp_threadsync_instance
72 {
73  sys_sem_t sem;
74  sys_mutex_t sem_usage_mutex;
75  snmp_threadsync_synchronizer_fn sync_fn;
76  struct threadsync_data data;
77 };
78 
80 struct snmp_threadsync_node
81 {
82  /* inherited "base class" members */
83  struct snmp_leaf_node node;
84 
85  const struct snmp_leaf_node *target;
86  struct snmp_threadsync_instance *instance;
87 };
88 
89 snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
90 snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
91 
92 #define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \
93  {{{ SNMP_NODE_THREADSYNC, (oid) }, \
94  snmp_threadsync_get_instance, \
95  snmp_threadsync_get_next_instance }, \
96  (target_leaf_node), \
97  (threadsync_instance) }
98 
99 void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
100 
101 #endif /* LWIP_SNMP */
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */
unsigned long u32_t
Definition: cc.h:42
osSemaphoreId sys_sem_t
Definition: sys_arch.h:44
unsigned char u8_t
Definition: cc.h:38
unsigned short u16_t
Definition: cc.h:40
osSemaphoreId sys_mutex_t
Definition: sys_arch.h:45