| 1 |
/* |
| 2 |
* Smux module authored by Rohit Dube. |
| 3 |
* Rewritten by Nick Amato <[email protected]>. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef NETSNMP_TRANSPORT_IPV4BASE_DOMAIN |
| 7 |
config_error(smux/smux depends on the IPv4Base transport domain); |
| 8 |
#endif |
| 9 |
|
| 10 |
config_belongs_in(agent_module); |
| 11 |
|
| 12 |
#define SMUXPORT 199 |
| 13 |
|
| 14 |
#define SMUXMAXPKTSIZE 1500 |
| 15 |
#define SMUXMAXSTRLEN 1024 |
| 16 |
#define SMUXMAXPEERS 10 |
| 17 |
|
| 18 |
#define SMUX_OPEN (ASN_APPLICATION | ASN_CONSTRUCTOR | 0) |
| 19 |
#define SMUX_CLOSE (ASN_APPLICATION | ASN_PRIMITIVE | 1) |
| 20 |
#define SMUX_RREQ (ASN_APPLICATION | ASN_CONSTRUCTOR | 2) |
| 21 |
#define SMUX_RRSP (ASN_APPLICATION | ASN_PRIMITIVE | 3) |
| 22 |
#define SMUX_SOUT (ASN_APPLICATION | ASN_PRIMITIVE | 4) |
| 23 |
|
| 24 |
#define SMUX_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0) |
| 25 |
#define SMUX_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1) |
| 26 |
#define SMUX_GETRSP (ASN_CONTEXT | ASN_CONSTRUCTOR | 2) |
| 27 |
#define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3) |
| 28 |
#define SMUX_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4) |
| 29 |
|
| 30 |
#define SMUXC_GOINGDOWN 0 |
| 31 |
#define SMUXC_UNSUPPORTEDVERSION 1 |
| 32 |
#define SMUXC_PACKETFORMAT 2 |
| 33 |
#define SMUXC_PROTOCOLERROR 3 |
| 34 |
#define SMUXC_INTERNALERROR 4 |
| 35 |
#define SMUXC_AUTHENTICATIONFAILURE 5 |
| 36 |
|
| 37 |
#define SMUX_MAX_PEERS 10 |
| 38 |
#define SMUX_MAX_PRIORITY 2147483647 |
| 39 |
|
| 40 |
#define SMUX_REGOP_DELETE 0 |
| 41 |
#define SMUX_REGOP_REGISTER_RO 1 |
| 42 |
#define SMUX_REGOP_REGISTER_RW 2 |
| 43 |
|
| 44 |
/* |
| 45 |
* Authorized peers read from the config file |
| 46 |
*/ |
| 47 |
typedef struct _smux_peer_auth { |
| 48 |
oid sa_oid[MAX_OID_LEN]; /* name of peer */ |
| 49 |
size_t sa_oid_len; /* length of peer name */ |
| 50 |
char sa_passwd[SMUXMAXSTRLEN]; /* configured passwd */ |
| 51 |
int sa_active_fd; /* the peer using this auth */ |
| 52 |
} smux_peer_auth; |
| 53 |
|
| 54 |
/* |
| 55 |
* Registrations |
| 56 |
*/ |
| 57 |
typedef struct _smux_reg { |
| 58 |
oid sr_name[MAX_OID_LEN]; /* name of subtree */ |
| 59 |
size_t sr_name_len; /* length of subtree name */ |
| 60 |
int sr_priority; /* priority of registration */ |
| 61 |
int sr_fd; /* descriptor of owner */ |
| 62 |
struct _smux_reg *sr_next; /* next one */ |
| 63 |
netsnmp_handler_registration *reginfo; |
| 64 |
} smux_reg; |
| 65 |
|
| 66 |
extern void init_smux(void); |
| 67 |
extern void real_init_smux(void); |
| 68 |
extern int smux_accept(int); |
| 69 |
extern u_char *smux_snmp_process(int, oid *, size_t *, size_t *, u_char *, |
| 70 |
int); |
| 71 |
extern int smux_process(int); |
| 72 |
extern void smux_parse_peer_auth(const char *, char *); |
| 73 |
extern void smux_free_peer_auth(void); |
| 74 |
|
| 75 |
/* Add socket-fd to list */ |
| 76 |
int smux_snmp_select_list_add(int sd); |
| 77 |
|
| 78 |
/* Remove socket-fd from list */ |
| 79 |
int smux_snmp_select_list_del(int sd); |
| 80 |
|
| 81 |
/* Returns the count of added socket-fd's in the list */ |
| 82 |
int smux_snmp_select_list_get_length(void); |
| 83 |
|
| 84 |
/* Returns the socket-fd number from the position of the list */ |
| 85 |
int smux_snmp_select_list_get_SD_from_List(int pos); |
| 86 |
|