* 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>
enum smux_event {SMUX_SCHEDULE, SMUX_CONNECT, SMUX_READ};
void smux_event (enum smux_event, int);
-\f
+
/* SMUX socket. */
int smux_sock = -1;
};
/* thread master */
-static struct thread_master *master;
-\f
+static struct thread_master *smux_master;
+
static int
oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len)
{
return 0;
}
-\f
+
static void
smux_oid_dump (const char *prefix, const oid *oid, size_t oid_len)
{
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;
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;
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;
}
u_char *ptr;
size_t len;
long version;
- const char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
+ const char progname[] = FRR_SMUX_NAME "-" FRR_VERSION;
if (debug_smux)
{
smux_sock = -1;
}
}
-\f
+
void
switch (event)
{
case SMUX_SCHEDULE:
- smux_connect_thread = thread_add_event (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 (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 (master, smux_read, NULL, sock);
+ smux_read_thread = NULL;
+ thread_add_read(smux_master, smux_read, NULL, sock, &smux_read_thread);
break;
default:
break;
}
}
-\f
+
static int
smux_str2oid (const char *str, oid *oid, size_t *oid_len)
{
"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;
"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;
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)
{
void
smux_init (struct thread_master *tm)
{
+ assert (tm);
/* copy callers thread master */
- master = tm;
+ smux_master = tm;
/* Make MIB tree. */
treelist = list_new();
/* Schedule first connection. */
smux_event (SMUX_SCHEDULE, 0);
}
-#endif /* HAVE_SNMP */
+#endif /* SNMP_SMUX */