Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
snmp_threadsync.h
Go to the documentation of this file.
00001 /** 00002 * @file 00003 * SNMP server MIB API to implement thread synchronization 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Dirk Ziegelmeier <dziegel@gmx.de> 00035 * 00036 */ 00037 00038 #ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H 00039 #define LWIP_HDR_APPS_SNMP_THREADSYNC_H 00040 00041 #include "lwip/apps/snmp_opts.h" 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ 00048 00049 #include "lwip/apps/snmp_core.h" 00050 #include "lwip/sys.h" 00051 00052 typedef void (*snmp_threadsync_called_fn)(void* arg); 00053 typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg); 00054 00055 00056 /** Thread sync runtime data. For internal usage only. */ 00057 struct threadsync_data 00058 { 00059 union { 00060 snmp_err_t err; 00061 s16_t s16; 00062 } retval; 00063 union { 00064 const u32_t *root_oid; 00065 void *value; 00066 } arg1; 00067 union { 00068 u8_t root_oid_len; 00069 u16_t len; 00070 } arg2; 00071 const struct snmp_threadsync_node *threadsync_node; 00072 struct snmp_node_instance proxy_instance; 00073 }; 00074 00075 /** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */ 00076 struct snmp_threadsync_instance 00077 { 00078 sys_sem_t sem; 00079 sys_mutex_t sem_usage_mutex; 00080 snmp_threadsync_synchronizer_fn sync_fn; 00081 struct threadsync_data data; 00082 }; 00083 00084 /** SNMP thread sync proxy leaf node */ 00085 struct snmp_threadsync_node 00086 { 00087 /* inherited "base class" members */ 00088 struct snmp_leaf_node node; 00089 00090 const struct snmp_leaf_node *target; 00091 struct snmp_threadsync_instance *instance; 00092 }; 00093 00094 snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); 00095 snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); 00096 00097 /** Create thread sync proxy node */ 00098 #define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \ 00099 {{{ SNMP_NODE_THREADSYNC, (oid) }, \ 00100 snmp_threadsync_get_instance, \ 00101 snmp_threadsync_get_next_instance }, \ 00102 (target_leaf_node), \ 00103 (threadsync_instance) } 00104 00105 /** Create thread sync instance data */ 00106 void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn); 00107 00108 #endif /* LWIP_SNMP */ 00109 00110 #ifdef __cplusplus 00111 } 00112 #endif 00113 00114 #endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */
Generated on Sun Jul 17 2022 08:25:30 by 1.7.2