00001 #ifndef _SNMP_TRANSPORT_H
00002 #define _SNMP_TRANSPORT_H
00003
00004 #include <sys/types.h>
00005 #include <net-snmp/library/asn1.h>
00006
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010
00011
00012
00013 #ifndef NETSNMP_STREAM_QUEUE_LEN
00014 #define NETSNMP_STREAM_QUEUE_LEN 5
00015 #endif
00016
00017
00018
00019 #define NETSNMP_TRANSPORT_FLAG_STREAM 0x01
00020 #define NETSNMP_TRANSPORT_FLAG_LISTEN 0x02
00021 #define NETSNMP_TRANSPORT_FLAG_TUNNELED 0x04
00022 #define NETSNMP_TRANSPORT_FLAG_TMSTATE 0x08
00023
00024 #define NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
00025 #define NETSNMP_TRANSPORT_FLAG_HOSTNAME 0x80
00026
00027
00028
00029 NETSNMP_IMPORT oid netsnmpUDPDomain[];
00030 NETSNMP_IMPORT oid netsnmpCLNSDomain[];
00031 NETSNMP_IMPORT oid netsnmpCONSDomain[];
00032 NETSNMP_IMPORT oid netsnmpDDPDomain[];
00033 NETSNMP_IMPORT oid netsnmpIPXDomain[];
00034 NETSNMP_IMPORT size_t netsnmpUDPDomain_len;
00035 NETSNMP_IMPORT size_t netsnmpCLNSDomain_len;
00036 NETSNMP_IMPORT size_t netsnmpCONSDomain_len;
00037 NETSNMP_IMPORT size_t netsnmpDDPDomain_len;
00038 NETSNMP_IMPORT size_t netsnmpIPXDomain_len;
00039
00040
00041
00042
00043
00044
00045
00046 #define NETSNMP_TM_MAX_SECNAME 256
00047
00048 typedef struct netsnmp_addr_pair_s {
00049 struct sockaddr_in remote_addr;
00050 struct in_addr local_addr;
00051 } netsnmp_addr_pair;
00052
00053 typedef struct netsnmp_tmStateReference_s {
00054 oid transportDomain[MAX_OID_LEN];
00055 size_t transportDomainLen;
00056 char securityName[NETSNMP_TM_MAX_SECNAME];
00057 size_t securityNameLen;
00058 int requestedSecurityLevel;
00059 int transportSecurityLevel;
00060 char sameSecurity;
00061 int sessionID;
00062
00063 char have_addresses;
00064 netsnmp_addr_pair addresses;
00065
00066 void *otherTransportOpaque;
00067 } netsnmp_tmStateReference;
00068
00069
00070
00071 typedef struct netsnmp_transport_s {
00072
00073
00074 const oid *domain;
00075 int domain_length;
00076
00077
00078
00079 unsigned char *local;
00080 int local_length;
00081
00082
00083
00084 unsigned char *remote;
00085 int remote_length;
00086
00087
00088
00089 int sock;
00090
00091
00092
00093 unsigned int flags;
00094
00095
00096
00097 void *data;
00098 int data_length;
00099
00100
00101
00102 size_t msgMaxSize;
00103
00104
00105 netsnmp_tmStateReference *tmStateRef;
00106
00107
00108
00109
00110
00111
00112 int (*f_recv) (struct netsnmp_transport_s *, void *,
00113 int, void **, int *);
00114 int (*f_send) (struct netsnmp_transport_s *, void *,
00115 int, void **, int *);
00116 int (*f_close) (struct netsnmp_transport_s *);
00117
00118
00119
00120 int (*f_accept) (struct netsnmp_transport_s *);
00121
00122
00123
00124 char *(*f_fmtaddr)(struct netsnmp_transport_s *, void *,
00125 int);
00126 } netsnmp_transport;
00127
00128 typedef struct netsnmp_transport_list_s {
00129 netsnmp_transport *transport;
00130 struct netsnmp_transport_list_s *next;
00131 } netsnmp_transport_list;
00132
00133 typedef struct netsnmp_tdomain_s {
00134 const oid *name;
00135 size_t name_length;
00136 const char **prefix;
00137
00138
00139
00140
00141
00142 netsnmp_transport *(*f_create_from_tstring) (const char *, int);
00143
00144 netsnmp_transport *(*f_create_from_ostring) (const u_char *, size_t, int);
00145
00146 struct netsnmp_tdomain_s *next;
00147
00148 netsnmp_transport *(*f_create_from_tstring_new) (const char *, int,
00149 const char*);
00150
00151 } netsnmp_tdomain;
00152
00153
00154
00155
00156 int netsnmp_transport_add_to_list(netsnmp_transport_list **transport_list,
00157 netsnmp_transport *transport);
00158 int netsnmp_transport_remove_from_list(netsnmp_transport_list **transport_list,
00159 netsnmp_transport *transport);
00160
00161
00162
00163
00164
00165
00166
00167 netsnmp_transport *netsnmp_transport_copy(netsnmp_transport *t);
00168
00169
00170
00171
00172 void netsnmp_transport_free(netsnmp_transport *t);
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 int netsnmp_tdomain_support(const oid *in_oid, size_t in_len,
00184 const oid **out_oid, size_t *out_len);
00185
00186 int netsnmp_tdomain_register(netsnmp_tdomain *domain);
00187
00188 int netsnmp_tdomain_unregister(netsnmp_tdomain *domain);
00189
00190 void netsnmp_clear_tdomain_list(void);
00191
00192 void netsnmp_tdomain_init(void);
00193
00194 netsnmp_transport *netsnmp_tdomain_transport(const char *str,
00195 int local,
00196 const char *default_domain);
00197
00198 netsnmp_transport *netsnmp_tdomain_transport_full(const char *application,
00199 const char *str,
00200 int local,
00201 const char *default_domain,
00202 const char *default_target);
00203
00204 netsnmp_transport *netsnmp_tdomain_transport_oid(const oid * dom,
00205 size_t dom_len,
00206 const u_char * o,
00207 size_t o_len,
00208 int local);
00209
00210 netsnmp_transport*
00211 netsnmp_transport_open_client(const char* application, const char* str);
00212
00213 netsnmp_transport*
00214 netsnmp_transport_open_server(const char* application, const char* str);
00215
00216 netsnmp_transport*
00217 netsnmp_transport_open(const char* application, const char* str, int local);
00218
00219 #ifdef __cplusplus
00220 }
00221 #endif
00222 #endif