1 #ifndef _SNMP_TRANSPORT_H
2 #define _SNMP_TRANSPORT_H
5 #include <net-snmp/library/asn1.h>
11 /* Some transport-type constants. */
13 #ifndef NETSNMP_STREAM_QUEUE_LEN
14 #define NETSNMP_STREAM_QUEUE_LEN 5
17 /* Some transport-type flags. */
19 #define NETSNMP_TRANSPORT_FLAG_STREAM 0x01
20 #define NETSNMP_TRANSPORT_FLAG_LISTEN 0x02
22 /* The standard SNMP domains. */
24 extern oid netsnmpUDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 1 }; */
25 extern oid netsnmpCLNSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 2 }; */
26 extern oid netsnmpCONSDomain[]; /* = { 1, 3, 6, 1, 6, 1, 3 }; */
27 extern oid netsnmpDDPDomain[]; /* = { 1, 3, 6, 1, 6, 1, 4 }; */
28 extern oid netsnmpIPXDomain[]; /* = { 1, 3, 6, 1, 6, 1, 5 }; */
29 extern size_t netsnmpUDPDomain_len;
30 extern size_t netsnmpCLNSDomain_len;
31 extern size_t netsnmpCONSDomain_len;
32 extern size_t netsnmpDDPDomain_len;
33 extern size_t netsnmpIPXDomain_len;
35 /* Structure which defines the transport-independent API. */
37 typedef struct netsnmp_transport_s {
38 /* The transport domain object identifier. */
41 int domain_length; /* In sub-IDs, not octets. */
43 /* Local transport address (in relevant SNMP-style encoding). */
46 int local_length; /* In octets. */
48 /* Remote transport address (in relevant SNMP-style encoding). */
50 unsigned char *remote;
51 int remote_length; /* In octets. */
53 /* The actual socket. */
57 /* Flags (see #definitions above). */
61 /* Protocol-specific opaque data pointer. */
66 /* Maximum size of PDU that can be sent/received by this transport. */
70 /* Callbacks. Arguments are:
72 * "this" pointer, fd, buf, size, *opaque, *opaque_length
75 int (*f_recv) (struct netsnmp_transport_s *, void *,
77 int (*f_send) (struct netsnmp_transport_s *, void *,
79 int (*f_close) (struct netsnmp_transport_s *);
81 /* This callback is only necessary for stream-oriented transports. */
83 int (*f_accept) (struct netsnmp_transport_s *);
85 /* Optional callback to format a transport address. */
87 char *(*f_fmtaddr)(struct netsnmp_transport_s *, void *,
91 typedef struct netsnmp_transport_list_s {
92 netsnmp_transport *transport;
93 struct netsnmp_transport_list_s *next;
94 } netsnmp_transport_list;
96 typedef struct netsnmp_tdomain_s {
100 netsnmp_transport *(*f_create_from_tstring) (const char *, int);
101 netsnmp_transport *(*f_create_from_ostring) (const u_char *, size_t, int);
103 struct netsnmp_tdomain_s *next;
107 /* Some utility functions. */
109 int netsnmp_transport_add_to_list(netsnmp_transport_list **transport_list,
110 netsnmp_transport *transport);
111 int netsnmp_transport_remove_from_list(netsnmp_transport_list **transport_list,
112 netsnmp_transport *transport);
116 * Return an exact (deep) copy of t, or NULL if there is a memory allocation
117 * problem (for instance).
120 netsnmp_transport *netsnmp_transport_copy(netsnmp_transport *t);
123 /* Free an netsnmp_transport. */
125 void netsnmp_transport_free(netsnmp_transport *t);
129 * If the passed oid (in_oid, in_len) corresponds to a supported transport
130 * domain, return 1; if not return 0. If out_oid is not NULL and out_len is
131 * not NULL, then the "internal" oid which should be used to identify this
132 * domain (e.g. in pdu->tDomain etc.) is written to *out_oid and its length to
136 int netsnmp_tdomain_support(const oid *in_oid, size_t in_len,
137 const oid **out_oid, size_t *out_len);
139 int netsnmp_tdomain_register(netsnmp_tdomain *domain);
141 int netsnmp_tdomain_unregister(netsnmp_tdomain *domain);
143 void netsnmp_tdomain_init(void);
145 netsnmp_transport *netsnmp_tdomain_transport(const char *string,
150 netsnmp_transport *netsnmp_tdomain_transport_oid(const oid * dom,
159 #endif/*_SNMP_TRANSPORT_H*/