From 765c48aba794bc86f83e617ab68ab64f9f2d5ecf Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 22 Jan 2012 09:28:57 +0000 Subject: mgcp: Move to using the NexusWare API for Timeslot config --- src/Makefile.am | 2 +- src/mgcp_hw.c | 119 +++++++------------------------------------------------- 2 files changed, 15 insertions(+), 106 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2e76b66..4ef3edf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,7 @@ sbin_PROGRAMS = cellmgr_ng osmo_stp mgcp_mgw mgcp_mgw_SOURCES = mgcp_ss7.c mgcp_ss7_vty.c mgcp_hw.c thread.c debug.c \ mgcp/mgcp_protocol.c mgcp/mgcp_network.c mgcp/mgcp_vty.c mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS) \ - $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) -lpthread -lnetsnmp -lcrypto + $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) -lpthread -lcrypto cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \ bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c links.c \ diff --git a/src/mgcp_hw.c b/src/mgcp_hw.c index 0356440..ea33bdc 100644 --- a/src/mgcp_hw.c +++ b/src/mgcp_hw.c @@ -18,14 +18,11 @@ * */ -#include -#include -#include - #include #include -#define HSCOMM "PTI-NexusWare-HSCMCONN-MIB::" +#ifndef NO_UNIPORTE +#include "NexusWare.h" #define PTMC_STREAM_A_RX0 0 #define PTMC_STREAM_A_TX0 128 @@ -33,30 +30,6 @@ #define PTMC_STREAM_A_TX1 1152 -static netsnmp_session g_session, *g_ss; - -static void add_pdu_var(netsnmp_pdu *pdu, const char *mib_name, - int id1, int id2, const char *value) -{ - oid oid_name[MAX_OID_LEN]; - size_t name_length; - - char buf[4096]; - buf[4095] = '\0'; - snprintf(buf, sizeof(buf)-1, "%s.%d.%d", mib_name, id1, id2); - - name_length = MAX_OID_LEN; - if (snmp_parse_oid(buf, oid_name, &name_length) == NULL) { - snmp_perror(buf); - return; - } - - if (snmp_add_var(pdu, oid_name, name_length, 'i', value)) { - snmp_perror(buf); - return; - } -} - static int rx_port_get(int port) { if (port > 60) @@ -72,98 +45,34 @@ static int tx_port_get(int port) else return PTMC_STREAM_A_TX0 + port; } +#endif int mgcp_hw_init() { - init_snmp("mgcp_mgw"); - snmp_sess_init(&g_session); - g_session.version = SNMP_VERSION_1; - g_session.community = (unsigned char *) "private"; - g_session.community_len = strlen((const char *) g_session.community); - - g_session.peername = "127.0.0.1"; - g_ss = snmp_open(&g_session); - if (!g_ss) { - snmp_perror("create failure"); - snmp_log(LOG_ERR, "Could not connect to the remote.\n"); - LOGP(DINP, LOGL_ERROR, "Failed to open a SNMP session.\n"); - return -1; - } - return 0; } int mgcp_hw_connect(int port, int trunk, int timeslot) { +#ifdef NO_UNIPORTE +#warning "NO Uniporte" +#else int status; - netsnmp_pdu *response = NULL; - netsnmp_pdu *pdu; int _rx_port, _tx_port; - char tx_port[10]; - char trunk_name[13], tslot_name[13]; - - if (!g_ss) - return -1; - - /* have the trunk/timeslot as value */ - snprintf(trunk_name, sizeof(trunk_name), "%d", trunk); - snprintf(tslot_name, sizeof(tslot_name), "%d", timeslot); /* rx port, tx side for the port */ _rx_port = rx_port_get(port); _tx_port = tx_port_get(port); - snprintf(tx_port, sizeof(tx_port), "%d", _tx_port); - pdu = snmp_pdu_create(SNMP_MSG_SET); - if (!pdu) { - LOGP(DINP, LOGL_ERROR, "Failed to allocate PDU.\n"); + status = PTI_ConnectHSCM(PTI_HSCM_TRUNK + trunk, timeslot - 1, + PTI_HSCM_PTMC, _rx_port, 1, 0); + if (status != 0) return -1; - } - - /* This connects the TX side to the given trunk/timeslot */ - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceType.hscmconnStreamTrunk", - trunk, timeslot, "hscmconnStreamPtmc"); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTypeInstance.hscmconnStreamTrunk", - trunk, timeslot, "1"); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTimeslot.hscmconnStreamTrunk", - trunk, timeslot, tx_port); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourcePattern.hscmconnStreamTrunk", - trunk, timeslot, "0"); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTimeslotCount.hscmconnStreamTrunk", - trunk, timeslot, "1"); - add_pdu_var(pdu, HSCOMM "hscmconnConnectBidirectional.hscmconnStreamTrunk", - trunk, timeslot, "false"); - /* This connect the RX side to the given trunk/timeslot */ - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceType.hscmconnStreamPtmc", - 1, _rx_port, "hscmconnStreamTrunk"); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTypeInstance.hscmconnStreamPtmc", - 1, _rx_port, trunk_name); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTimeslot.hscmconnStreamPtmc", - 1, _rx_port, tslot_name); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourcePattern.hscmconnStreamPtmc", - 1, _rx_port, "0"); - add_pdu_var(pdu, HSCOMM "hscmconnNewDataSourceTimeslotCount.hscmconnStreamPtmc", - 1, _rx_port, "1"); - add_pdu_var(pdu, HSCOMM "hscmconnConnectBidirectional.hscmconnStreamPtmc", - 1, _rx_port, "false"); - - - status = snmp_synch_response(g_ss, pdu, &response); - if (status == STAT_ERROR) { - snmp_sess_perror("set failed", g_ss); - goto failure; - } else if (status == STAT_TIMEOUT) { - fprintf(stderr, "Timeout for SNMP.\n"); - goto failure; - } - - if (response) - snmp_free_pdu(response); + status = PTI_ConnectHSCM(PTI_HSCM_PTMC, _tx_port, + PTI_HSCM_TRUNK + trunk, timeslot - 1, 1, 0); + if (status != 0) + return -1; +#endif return 0; - -failure: - if (response) - snmp_free_pdu(response); - return -1; } -- cgit v1.2.3