diff options
Diffstat (limited to 'lib/smux.c')
| -rw-r--r-- | lib/smux.c | 93 |
1 files changed, 21 insertions, 72 deletions
diff --git a/lib/smux.c b/lib/smux.c index a9c99e1545..032801f6df 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -13,15 +13,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <zebra.h> -#if defined HAVE_SNMP && defined SNMP_SMUX +#ifdef SNMP_SMUX #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -154,16 +153,10 @@ static int smux_socket (void) { int ret; -#ifdef HAVE_IPV6 struct addrinfo hints, *res0, *res; int gai; -#else - struct sockaddr_in serv; - struct servent *sp; -#endif int sock = 0; -#ifdef HAVE_IPV6 memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; @@ -183,9 +176,7 @@ smux_socket (void) for(res=res0; res; res=res->ai_next) { if (res->ai_family != AF_INET -#ifdef HAVE_IPV6 && res->ai_family != AF_INET6 -#endif /* HAVE_IPV6 */ ) continue; @@ -206,40 +197,6 @@ smux_socket (void) freeaddrinfo(res0); if (sock < 0) zlog_warn ("Can't connect to SNMP agent with SMUX"); -#else - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - zlog_warn ("Can't make socket for SNMP"); - return -1; - } - - memset (&serv, 0, sizeof (struct sockaddr_in)); - serv.sin_family = AF_INET; -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - serv.sin_len = sizeof (struct sockaddr_in); -#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - - sp = getservbyname ("smux", "tcp"); - if (sp != NULL) - serv.sin_port = sp->s_port; - else - serv.sin_port = htons (SMUX_PORT_DEFAULT); - - serv.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - sockopt_reuseaddr (sock); - sockopt_reuseport (sock); - - ret = connect (sock, (struct sockaddr *) &serv, sizeof (struct sockaddr_in)); - if (ret < 0) - { - close (sock); - smux_sock = -1; - zlog_warn ("Can't connect to SNMP agent with SMUX"); - return -1; - } -#endif return sock; } @@ -1239,13 +1196,18 @@ smux_event (enum smux_event event, int sock) switch (event) { case SMUX_SCHEDULE: - smux_connect_thread = thread_add_event (smux_master, smux_connect, NULL, 0); + smux_connect_thread = NULL; + thread_add_event(smux_master, smux_connect, NULL, 0, + &smux_connect_thread); break; case SMUX_CONNECT: - smux_connect_thread = thread_add_timer (smux_master, smux_connect, NULL, 10); + smux_connect_thread = NULL; + thread_add_timer(smux_master, smux_connect, NULL, 10, + &smux_connect_thread); break; case SMUX_READ: - smux_read_thread = thread_add_read (smux_master, smux_read, NULL, sock); + smux_read_thread = NULL; + thread_add_read(smux_master, smux_read, NULL, sock, &smux_read_thread); break; default: break; @@ -1370,7 +1332,8 @@ DEFUN (smux_peer, "SNMP MUX peer settings\n" "Object ID used in SMUX peering\n") { - if (smux_peer_oid (vty, argv[0], NULL) == 0) + int idx_oid = 2; + if (smux_peer_oid (vty, argv[idx_oid]->arg, NULL) == 0) { smux_start(); return CMD_SUCCESS; @@ -1387,7 +1350,8 @@ DEFUN (smux_peer_password, "SMUX peering object ID\n" "SMUX peering password\n") { - if (smux_peer_oid (vty, argv[0], argv[1]) == 0) + int idx_oid = 2; + if (smux_peer_oid (vty, argv[idx_oid]->arg, argv[3]->rg) == 0) { smux_start(); return CMD_SUCCESS; @@ -1398,32 +1362,17 @@ DEFUN (smux_peer_password, DEFUN (no_smux_peer, no_smux_peer_cmd, - "no smux peer", + "no smux peer [OID [PASSWORD]]", NO_STR "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n") + "SNMP MUX peer settings\n" + "SMUX peering object ID\n" + "SMUX peering password\n") { smux_stop(); return smux_peer_default (); } -ALIAS (no_smux_peer, - no_smux_peer_oid_cmd, - "no smux peer OID", - NO_STR - "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n" - "SMUX peering object ID\n") - -ALIAS (no_smux_peer, - no_smux_peer_oid_password_cmd, - "no smux peer OID PASSWORD", - NO_STR - "SNMP MUX protocol settings\n" - "SNMP MUX peer settings\n" - "SMUX peering object ID\n" - "SMUX peering password\n") - static int config_write_smux (struct vty *vty) { @@ -1500,4 +1449,4 @@ smux_start(void) /* Schedule first connection. */ smux_event (SMUX_SCHEDULE, 0); } -#endif /* HAVE_SNMP */ +#endif /* SNMP_SMUX */ |
