]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/smux.c
*: make consistent & update GPLv2 file headers
[mirror_frr.git] / lib / smux.c
index 82bf64f1c8f4b8d5f9894f302c92a466a1eda347..032801f6dfabf46c24eb95283c34b33365313ac7 100644 (file)
  * 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;
 }
 
@@ -922,7 +879,7 @@ smux_open (int 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)
     {
@@ -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;
@@ -1487,4 +1449,4 @@ smux_start(void)
   /* Schedule first connection. */
   smux_event (SMUX_SCHEDULE, 0);
 }
-#endif /* HAVE_SNMP */
+#endif /* SNMP_SMUX */