SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lorcansmith 0:2a53a4c3238c 1 /*
lorcansmith 0:2a53a4c3238c 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
lorcansmith 0:2a53a4c3238c 3 * All rights reserved.
lorcansmith 0:2a53a4c3238c 4 *
lorcansmith 0:2a53a4c3238c 5 * Redistribution and use in source and binary forms, with or without modification,
lorcansmith 0:2a53a4c3238c 6 * are permitted provided that the following conditions are met:
lorcansmith 0:2a53a4c3238c 7 *
lorcansmith 0:2a53a4c3238c 8 * 1. Redistributions of source code must retain the above copyright notice,
lorcansmith 0:2a53a4c3238c 9 * this list of conditions and the following disclaimer.
lorcansmith 0:2a53a4c3238c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
lorcansmith 0:2a53a4c3238c 11 * this list of conditions and the following disclaimer in the documentation
lorcansmith 0:2a53a4c3238c 12 * and/or other materials provided with the distribution.
lorcansmith 0:2a53a4c3238c 13 * 3. The name of the author may not be used to endorse or promote products
lorcansmith 0:2a53a4c3238c 14 * derived from this software without specific prior written permission.
lorcansmith 0:2a53a4c3238c 15 *
lorcansmith 0:2a53a4c3238c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
lorcansmith 0:2a53a4c3238c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
lorcansmith 0:2a53a4c3238c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
lorcansmith 0:2a53a4c3238c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
lorcansmith 0:2a53a4c3238c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
lorcansmith 0:2a53a4c3238c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
lorcansmith 0:2a53a4c3238c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
lorcansmith 0:2a53a4c3238c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
lorcansmith 0:2a53a4c3238c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
lorcansmith 0:2a53a4c3238c 25 * OF SUCH DAMAGE.
lorcansmith 0:2a53a4c3238c 26 *
lorcansmith 0:2a53a4c3238c 27 * This file is part of the lwIP TCP/IP stack.
lorcansmith 0:2a53a4c3238c 28 *
lorcansmith 0:2a53a4c3238c 29 * Author: Adam Dunkels <adam@sics.se>
lorcansmith 0:2a53a4c3238c 30 *
lorcansmith 0:2a53a4c3238c 31 */
lorcansmith 0:2a53a4c3238c 32 #ifndef __LWIP_API_MSG_H__
lorcansmith 0:2a53a4c3238c 33 #define __LWIP_API_MSG_H__
lorcansmith 0:2a53a4c3238c 34
lorcansmith 0:2a53a4c3238c 35 #include "lwip/opt.h"
lorcansmith 0:2a53a4c3238c 36
lorcansmith 0:2a53a4c3238c 37 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
lorcansmith 0:2a53a4c3238c 38
lorcansmith 0:2a53a4c3238c 39 #include <stddef.h> /* for size_t */
lorcansmith 0:2a53a4c3238c 40
lorcansmith 0:2a53a4c3238c 41 #include "lwip/ip_addr.h"
lorcansmith 0:2a53a4c3238c 42 #include "lwip/err.h"
lorcansmith 0:2a53a4c3238c 43 #include "lwip/sys.h"
lorcansmith 0:2a53a4c3238c 44 #include "lwip/igmp.h"
lorcansmith 0:2a53a4c3238c 45 #include "lwip/api.h"
lorcansmith 0:2a53a4c3238c 46
lorcansmith 0:2a53a4c3238c 47 #ifdef __cplusplus
lorcansmith 0:2a53a4c3238c 48 extern "C" {
lorcansmith 0:2a53a4c3238c 49 #endif
lorcansmith 0:2a53a4c3238c 50
lorcansmith 0:2a53a4c3238c 51 #define NETCONN_SHUT_RD 1
lorcansmith 0:2a53a4c3238c 52 #define NETCONN_SHUT_WR 2
lorcansmith 0:2a53a4c3238c 53 #define NETCONN_SHUT_RDWR 3
lorcansmith 0:2a53a4c3238c 54
lorcansmith 0:2a53a4c3238c 55 /* IP addresses and port numbers are expected to be in
lorcansmith 0:2a53a4c3238c 56 * the same byte order as in the corresponding pcb.
lorcansmith 0:2a53a4c3238c 57 */
lorcansmith 0:2a53a4c3238c 58 /** This struct includes everything that is necessary to execute a function
lorcansmith 0:2a53a4c3238c 59 for a netconn in another thread context (mainly used to process netconns
lorcansmith 0:2a53a4c3238c 60 in the tcpip_thread context to be thread safe). */
lorcansmith 0:2a53a4c3238c 61 struct api_msg_msg {
lorcansmith 0:2a53a4c3238c 62 /** The netconn which to process - always needed: it includes the semaphore
lorcansmith 0:2a53a4c3238c 63 which is used to block the application thread until the function finished. */
lorcansmith 0:2a53a4c3238c 64 struct netconn *conn;
lorcansmith 0:2a53a4c3238c 65 /** The return value of the function executed in tcpip_thread. */
lorcansmith 0:2a53a4c3238c 66 err_t err;
lorcansmith 0:2a53a4c3238c 67 /** Depending on the executed function, one of these union members is used */
lorcansmith 0:2a53a4c3238c 68 union {
lorcansmith 0:2a53a4c3238c 69 /** used for do_send */
lorcansmith 0:2a53a4c3238c 70 struct netbuf *b;
lorcansmith 0:2a53a4c3238c 71 /** used for do_newconn */
lorcansmith 0:2a53a4c3238c 72 struct {
lorcansmith 0:2a53a4c3238c 73 u8_t proto;
lorcansmith 0:2a53a4c3238c 74 } n;
lorcansmith 0:2a53a4c3238c 75 /** used for do_bind and do_connect */
lorcansmith 0:2a53a4c3238c 76 struct {
lorcansmith 0:2a53a4c3238c 77 ip_addr_t *ipaddr;
lorcansmith 0:2a53a4c3238c 78 u16_t port;
lorcansmith 0:2a53a4c3238c 79 } bc;
lorcansmith 0:2a53a4c3238c 80 /** used for do_getaddr */
lorcansmith 0:2a53a4c3238c 81 struct {
lorcansmith 0:2a53a4c3238c 82 ip_addr_t *ipaddr;
lorcansmith 0:2a53a4c3238c 83 u16_t *port;
lorcansmith 0:2a53a4c3238c 84 u8_t local;
lorcansmith 0:2a53a4c3238c 85 } ad;
lorcansmith 0:2a53a4c3238c 86 /** used for do_write */
lorcansmith 0:2a53a4c3238c 87 struct {
lorcansmith 0:2a53a4c3238c 88 const void *dataptr;
lorcansmith 0:2a53a4c3238c 89 size_t len;
lorcansmith 0:2a53a4c3238c 90 u8_t apiflags;
lorcansmith 0:2a53a4c3238c 91 } w;
lorcansmith 0:2a53a4c3238c 92 /** used for do_recv */
lorcansmith 0:2a53a4c3238c 93 struct {
lorcansmith 0:2a53a4c3238c 94 u32_t len;
lorcansmith 0:2a53a4c3238c 95 } r;
lorcansmith 0:2a53a4c3238c 96 /** used for do_close (/shutdown) */
lorcansmith 0:2a53a4c3238c 97 struct {
lorcansmith 0:2a53a4c3238c 98 u8_t shut;
lorcansmith 0:2a53a4c3238c 99 } sd;
lorcansmith 0:2a53a4c3238c 100 #if LWIP_IGMP
lorcansmith 0:2a53a4c3238c 101 /** used for do_join_leave_group */
lorcansmith 0:2a53a4c3238c 102 struct {
lorcansmith 0:2a53a4c3238c 103 ip_addr_t *multiaddr;
lorcansmith 0:2a53a4c3238c 104 ip_addr_t *netif_addr;
lorcansmith 0:2a53a4c3238c 105 enum netconn_igmp join_or_leave;
lorcansmith 0:2a53a4c3238c 106 } jl;
lorcansmith 0:2a53a4c3238c 107 #endif /* LWIP_IGMP */
lorcansmith 0:2a53a4c3238c 108 #if TCP_LISTEN_BACKLOG
lorcansmith 0:2a53a4c3238c 109 struct {
lorcansmith 0:2a53a4c3238c 110 u8_t backlog;
lorcansmith 0:2a53a4c3238c 111 } lb;
lorcansmith 0:2a53a4c3238c 112 #endif /* TCP_LISTEN_BACKLOG */
lorcansmith 0:2a53a4c3238c 113 } msg;
lorcansmith 0:2a53a4c3238c 114 };
lorcansmith 0:2a53a4c3238c 115
lorcansmith 0:2a53a4c3238c 116 /** This struct contains a function to execute in another thread context and
lorcansmith 0:2a53a4c3238c 117 a struct api_msg_msg that serves as an argument for this function.
lorcansmith 0:2a53a4c3238c 118 This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
lorcansmith 0:2a53a4c3238c 119 struct api_msg {
lorcansmith 0:2a53a4c3238c 120 /** function to execute in tcpip_thread context */
lorcansmith 0:2a53a4c3238c 121 void (* function)(struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 122 /** arguments for this function */
lorcansmith 0:2a53a4c3238c 123 struct api_msg_msg msg;
lorcansmith 0:2a53a4c3238c 124 };
lorcansmith 0:2a53a4c3238c 125
lorcansmith 0:2a53a4c3238c 126 #if LWIP_DNS
lorcansmith 0:2a53a4c3238c 127 /** As do_gethostbyname requires more arguments but doesn't require a netconn,
lorcansmith 0:2a53a4c3238c 128 it has its own struct (to avoid struct api_msg getting bigger than necessary).
lorcansmith 0:2a53a4c3238c 129 do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
lorcansmith 0:2a53a4c3238c 130 (see netconn_gethostbyname). */
lorcansmith 0:2a53a4c3238c 131 struct dns_api_msg {
lorcansmith 0:2a53a4c3238c 132 /** Hostname to query or dotted IP address string */
lorcansmith 0:2a53a4c3238c 133 const char *name;
lorcansmith 0:2a53a4c3238c 134 /** Rhe resolved address is stored here */
lorcansmith 0:2a53a4c3238c 135 ip_addr_t *addr;
lorcansmith 0:2a53a4c3238c 136 /** This semaphore is posted when the name is resolved, the application thread
lorcansmith 0:2a53a4c3238c 137 should wait on it. */
lorcansmith 0:2a53a4c3238c 138 sys_sem_t *sem;
lorcansmith 0:2a53a4c3238c 139 /** Errors are given back here */
lorcansmith 0:2a53a4c3238c 140 err_t *err;
lorcansmith 0:2a53a4c3238c 141 };
lorcansmith 0:2a53a4c3238c 142 #endif /* LWIP_DNS */
lorcansmith 0:2a53a4c3238c 143
lorcansmith 0:2a53a4c3238c 144 void do_newconn ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 145 void do_delconn ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 146 void do_bind ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 147 void do_connect ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 148 void do_disconnect ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 149 void do_listen ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 150 void do_send ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 151 void do_recv ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 152 void do_write ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 153 void do_getaddr ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 154 void do_close ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 155 void do_shutdown ( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 156 #if LWIP_IGMP
lorcansmith 0:2a53a4c3238c 157 void do_join_leave_group( struct api_msg_msg *msg);
lorcansmith 0:2a53a4c3238c 158 #endif /* LWIP_IGMP */
lorcansmith 0:2a53a4c3238c 159
lorcansmith 0:2a53a4c3238c 160 #if LWIP_DNS
lorcansmith 0:2a53a4c3238c 161 void do_gethostbyname(void *arg);
lorcansmith 0:2a53a4c3238c 162 #endif /* LWIP_DNS */
lorcansmith 0:2a53a4c3238c 163
lorcansmith 0:2a53a4c3238c 164 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
lorcansmith 0:2a53a4c3238c 165 void netconn_free(struct netconn *conn);
lorcansmith 0:2a53a4c3238c 166
lorcansmith 0:2a53a4c3238c 167 #ifdef __cplusplus
lorcansmith 0:2a53a4c3238c 168 }
lorcansmith 0:2a53a4c3238c 169 #endif
lorcansmith 0:2a53a4c3238c 170
lorcansmith 0:2a53a4c3238c 171 #endif /* LWIP_NETCONN */
lorcansmith 0:2a53a4c3238c 172
lorcansmith 0:2a53a4c3238c 173 #endif /* __LWIP_API_MSG_H__ */