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 /* Some transport-type constants. */ 00012 00013 #ifndef NETSNMP_STREAM_QUEUE_LEN 00014 #define NETSNMP_STREAM_QUEUE_LEN 5 00015 #endif 00016 00017 /* Some transport-type flags. */ 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 /* indicates opaque is a 00023 TSM tmStateReference */ 00024 #define NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10 00025 #define NETSNMP_TRANSPORT_FLAG_HOSTNAME 0x80 /* for fmtaddr hook */ 00026 00027 /* The standard SNMP domains. */ 00028 00029 NETSNMP_IMPORT oid netsnmpUDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 1 }; */ 00030 NETSNMP_IMPORT oid netsnmpCLNSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 2 }; */ 00031 NETSNMP_IMPORT oid netsnmpCONSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 3 }; */ 00032 NETSNMP_IMPORT oid netsnmpDDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 4 }; */ 00033 NETSNMP_IMPORT oid netsnmpIPXDomain[]; /* = { 1, 3, 6, 1, 6, 1, 5 }; */ 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 /* Structure which stores transport security model specific parameters */ 00041 /* isms-secshell-11 section 4.1 */ 00042 00043 /* contents documented in draft-ietf-isms-transport-security-model 00044 Section 3.2 */ 00045 /* note: VACM only allows <= 32 so this is overkill till another ACM comes */ 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; /* XXX: May have mem leak issues */ 00067 } netsnmp_tmStateReference; 00068 00069 /* Structure which defines the transport-independent API. */ 00070 00071 typedef struct netsnmp_transport_s { 00072 /* The transport domain object identifier. */ 00073 00074 const oid *domain; 00075 int domain_length; /* In sub-IDs, not octets. */ 00076 00077 /* Local transport address (in relevant SNMP-style encoding). */ 00078 00079 unsigned char *local; 00080 int local_length; /* In octets. */ 00081 00082 /* Remote transport address (in relevant SNMP-style encoding). */ 00083 00084 unsigned char *remote; 00085 int remote_length; /* In octets. */ 00086 00087 /* The actual socket. */ 00088 00089 int sock; 00090 00091 /* Flags (see #definitions above). */ 00092 00093 unsigned int flags; 00094 00095 /* Protocol-specific opaque data pointer. */ 00096 00097 void *data; 00098 int data_length; 00099 00100 /* Maximum size of PDU that can be sent/received by this transport. */ 00101 00102 size_t msgMaxSize; 00103 00104 /* TM state reference per ISMS WG solution */ 00105 netsnmp_tmStateReference *tmStateRef; 00106 00107 /* Callbacks. Arguments are: 00108 * 00109 * "this" pointer, fd, buf, size, *opaque, *opaque_length 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 /* This callback is only necessary for stream-oriented transports. */ 00119 00120 int (*f_accept) (struct netsnmp_transport_s *); 00121 00122 /* Optional callback to format a transport address. */ 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 * The f_create_from_tstring field is deprecated, please do not use it 00140 * for new code and try to migrate old code away from using it. 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 /* Some utility functions. */ 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 * Return an exact (deep) copy of t, or NULL if there is a memory allocation 00164 * problem (for instance). 00165 */ 00166 00167 netsnmp_transport *netsnmp_transport_copy(netsnmp_transport *t); 00168 00169 00170 /* Free an netsnmp_transport. */ 00171 00172 void netsnmp_transport_free(netsnmp_transport *t); 00173 00174 00175 /* 00176 * If the passed oid (in_oid, in_len) corresponds to a supported transport 00177 * domain, return 1; if not return 0. If out_oid is not NULL and out_len is 00178 * not NULL, then the "internal" oid which should be used to identify this 00179 * domain (e.g. in pdu->tDomain etc.) is written to *out_oid and its length to 00180 * *out_len. 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/*_SNMP_TRANSPORT_H*/
1.5.7.1
Last modified: Tuesday, 23-Dec-2025 17:22:04 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.