From eab20964b2f059898fc804584e55a157c021afc0 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 21 Jan 2011 18:00:36 +0100 Subject: udp: Make the SNMP code asynchronous Do not block the application when doing a SNMP request. Work with the results coming back from the callback. Right now a link can only be taken down and up. --- include/bsc_data.h | 2 +- include/snmp_mtp.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/bsc_data.h b/include/bsc_data.h index 3311d53..1092d6e 100644 --- a/include/bsc_data.h +++ b/include/bsc_data.h @@ -141,7 +141,7 @@ void update_con_state(struct mtp_link_set *link, int rc, struct sccp_parse_resul unsigned int sls_for_src_ref(struct sccp_source_reference *ref); /* udp init */ -int link_global_init(struct mtp_udp_data *data, int src_port); +int link_global_init(struct mtp_udp_data *data, char *dest_ip, int src_port); int link_udp_init(struct mtp_udp_link *data, const char *dest_ip, int port); int link_init(struct bsc_data *bsc); int link_shutdown_all(struct mtp_link_set *); diff --git a/include/snmp_mtp.h b/include/snmp_mtp.h index 045e90f..8c15df7 100644 --- a/include/snmp_mtp.h +++ b/include/snmp_mtp.h @@ -26,6 +26,27 @@ struct snmp_mtp_session { netsnmp_session session, *ss; + void *data; + + /* + * The callbacks will be called multiple times. Even if + * we only toggle one object. Remember which request we + * are handling here and then we will claim success on the + * first of a series of PDUs. This is the easies to manage + * and if a link fails to come up the SLTM will catch it. + */ + int last_up_req; + int last_do_req; +}; + +enum { + SNMP_LINK_UP, + SNMP_LINK_DOWN, +}; + +enum { + SNMP_STATUS_OK, + SNMP_STATUS_TIMEOUT, }; struct snmp_mtp_session *snmp_mtp_session_create(char *host); @@ -33,4 +54,7 @@ void snmp_mtp_deactivate(struct snmp_mtp_session *, int link_id); void snmp_mtp_activate(struct snmp_mtp_session *, int link_id); void snmp_mtp_poll(); +/* to be implemented by the handler */ +void snmp_mtp_callback(struct snmp_mtp_session *, int area, int res, int link_id); + #endif -- cgit v1.2.3