Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 2002 22:32:19 +0300 (MSK)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/45296: net/ehnt update (0.3_1 -> 0.3_2)
Message-ID:  <200211141932.gAEJWJPk085539@woozle.rinet.ru>

next in thread | raw e-mail | index | archive | help

>Number:         45296
>Category:       ports
>Synopsis:       net/ehnt update (0.3_1 -> 0.3_2)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 14 11:40:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4-STABLE i386
>Organization:
Cronyx Plus LLC (RiNet ISP)
>Environment:
System: FreeBSD 4-STABLE 


>Description:

This is update net/ehnt port to sync it with both nikw development and my CVS state.

Includes:
- fixed small bug in colondump mode (missing colon)
- fixed tty interaction in colondump mode
- socket space is configurable now

>How-To-Repeat:

>Fix:

Update contains 2 patches and 3 new files.

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/ehnt/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- Makefile    4 Nov 2002 03:17:28 -0000       1.5
+++ Makefile    14 Nov 2002 19:30:56 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=      ehnt
 PORTVERSION=   0.3
-PORTREVISION=  1
+PORTREVISION=  2
 CATEGORIES=    net
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=    ${PORTNAME}
Index: files/patch-config-h
===================================================================
RCS file: /home/ncvs/ports/net/ehnt/files/patch-config-h,v
retrieving revision 1.1
diff -u -r1.1 patch-config-h
--- files/patch-config-h	11 Aug 2001 17:38:05 -0000	1.1
+++ files/patch-config-h	14 Nov 2002 19:27:34 -0000
@@ -1,11 +1,18 @@
---- config.h.orig	Wed Jul 18 00:47:37 2001
-+++ config.h		Fri Aug  3 19:57:51 2001
-@@ -27,3 +27,8 @@
- #define DEFAULT_UDP_PORT	4444
+
+$FreeBSD$
+
+--- config.h.orig	Thu Oct  4 22:18:29 2001
++++ config.h	Thu Nov 14 22:20:47 2002
+@@ -32,4 +32,12 @@
  /* The default mode of the client.  Can be either EM_REPORT or EM_DUMP.*/
- #define EM_DEFAULT EM_REPORT
-+
+ #define EM_DEFAULT EM_TOP
+ 
 +#ifndef ASNCDIR
 +#define ASNCDIR "."
 +#endif
-+
+ 
++/* Default size of socket buffer. FreeBSD default is Limited to 256k,
++    + * but misteriously enough maximum space available for buf is 233016 */
++#define DEFAULT_SOCKBUF                (192*1024)
++/* Reasonable minimum socket buffer size. I assume it's about 16k */
++#define MIN_SOCKBUF            (16*1024)


# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	files/patch-ehnt__client.c
#	files/patch-ehnt__processflow.c
#	files/patch-ehntserv.c
#
echo x - files/patch-ehnt__client.c
sed 's/^X//' >files/patch-ehnt__client.c << 'END-of-files/patch-ehnt__client.c'
X
X$FreeBSD$
X
X--- ehnt_client.c.orig	Thu Oct  4 22:18:29 2001
X+++ ehnt_client.c	Thu Nov 14 22:12:07 2002
X@@ -89,7 +89,7 @@
X    if (FD_ISSET(sockfd,&read_fds)) {
X      ehnt_client_processmessage(sockfd,routeraddr,my_ehnt_struct);
X    }
X-   if (FD_ISSET(STDIN_FILENO,&read_fds)) {
X+   if (e_cfg->mode != EM_COLONDUMP && FD_ISSET(STDIN_FILENO,&read_fds)) {
X      char key;
X      key=getkey();
X      switch (key) {
END-of-files/patch-ehnt__client.c
echo x - files/patch-ehnt__processflow.c
sed 's/^X//' >files/patch-ehnt__processflow.c << 'END-of-files/patch-ehnt__processflow.c'
X
X$FreeBSD$
X
X--- ehnt_processflow.c.orig	Thu Oct  4 22:18:29 2001
X+++ ehnt_processflow.c	Thu Nov 14 22:17:18 2002
X@@ -218,7 +218,7 @@
X 	dstip.s_addr=rec->dstaddr;
X 	nexthop.s_addr=rec->nexthop;
X 
X-	printf("%.0f:%s",local_flowcount,routeraddr_string);
X+	printf("%.0f:%s:",local_flowcount,routeraddr_string);
X 	printf("%d:%s:%d:",
X 	       rec->input_index,
X 	       inet_ntoa(srcip),
END-of-files/patch-ehnt__processflow.c
echo x - files/patch-ehntserv.c
sed 's/^X//' >files/patch-ehntserv.c << 'END-of-files/patch-ehntserv.c'
X
X$FreeBSD$
X
X--- ehntserv.c.orig	Thu Oct  4 22:18:29 2001
X+++ ehntserv.c	Thu Nov 14 22:18:40 2002
X@@ -33,8 +33,8 @@
X #define MAXCLIENTS 256
X #define MAXPACKET 8192
X 
X-int SetUDPOpts(int);
X-int SetTCPOpts(int);
X+int SetUDPOpts(int, int);
X+int SetTCPOpts(int, int);
X 
X int debug;
X int use_syslog;
X@@ -54,6 +54,8 @@
X  int packetcounter=0;
X  extern char *optarg;
X  int c_udpport, c_tcpport;
X+ int one = -1;
X+ int bufsize = DEFAULT_SOCKBUF;
X 
X  debug=0;
X  use_syslog=0;
X@@ -61,7 +63,7 @@
X  c_udpport=DEFAULT_UDP_PORT;
X  c_tcpport=DEFAULT_TCP_PORT;
X 
X- while( (c=getopt(argc,argv,"u:t:d")) != -1) {
X+ while( (c=getopt(argc,argv,"u:t:s:d")) != -1) {
X 
X    switch(c) {
X    case 'u':
X@@ -70,6 +72,13 @@
X    case 't':
X      sscanf(optarg,"%d",&c_tcpport);
X      break;
X+   case 's':
X+     sscanf(optarg,"%d",&bufsize);
X+     if (bufsize < MIN_SOCKBUF) {
X+	     perror("too low buffer size or bad format: %s", optarg);
X+	     exit(1);
X+     }
X+     break;
X    case 'd':
X      debug=1;
X      break;
X@@ -77,6 +86,7 @@
X      printf("Usage: %s [ -u <udpport> ] [ -t <tcpport> ]\n",argv[0]);
X      printf("  -u <udpport>  Listen on UDP port <udpport> for netflow packets.  Default %d\n",DEFAULT_UDP_PORT);
X      printf("  -t <tcpport>  Listen on TCP port <tcpport> for client connections.  Default %d\n",DEFAULT_TCP_PORT);
X+     printf("  -s <bufsize>  Set tcp/udp buffer size.  Default %d\n",DEFAULT_SOCKBUF);
X      printf("  -d            Debug.  Don't become a daemon, displays all messages on stdout,");
X      printf("                displays lots of extra information\n");
X      exit(0);
X@@ -87,22 +97,22 @@
X 
X  /* set up the netflow udp socket */
X  if ( (nf_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
X-   { log_error("socket (udp) error"); exit(0); }
X+   { log_error("socket (udp) error"); exit(1); }
X  memset(&nf_servaddr,0,sizeof(nf_servaddr));
X  nf_servaddr.sin_family      = AF_INET;
X  nf_servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
X  nf_servaddr.sin_port        = htons(c_udpport);
X  if ( bind(nf_fd, (struct sockaddr *) &nf_servaddr, sizeof(nf_servaddr)) < 0)
X-   { log_error("bind UDP error"); exit(0); }
X+   { log_error("bind UDP error"); exit(1); }
X 
X- SetUDPOpts(nf_fd);
X+ SetUDPOpts(nf_fd, bufsize);
X 
X  nf_clilen = (socklen_t) sizeof(nf_cliaddr);
X  l_clilen = (socklen_t) sizeof(l_cliaddr);
X  
X  /* set up the listening tcp socket*/
X  if ( (l_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
X-   { log_error("socket (tcp) error"); exit(0); }
X+   { log_error("socket (tcp) error"); exit(1); }
X  memset(&l_servaddr,0,sizeof(l_servaddr));
X  l_servaddr.sin_family      = AF_INET;
X  l_servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
X@@ -112,9 +122,9 @@
X   setsockopt(l_fd, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one));
X  }
X  if ( bind(l_fd,(struct sockaddr *) &l_servaddr, sizeof(l_servaddr)) < 0)
X-   { log_error ("bind TCP error"); exit(0); }
X+   { log_error ("bind TCP error"); exit(1); }
X  if ( listen(l_fd, 32) < 0)
X-   { log_error("listen error"); exit(0); }
X+   { log_error("listen error"); exit(1); }
X  printf("Listening on UDP port %d and TCP port %d (with a backlog of 32)\n",c_udpport,c_tcpport);
X  memset(l_clients,0,sizeof(l_clients));
X 
X@@ -157,7 +167,7 @@
X   }
X 
X   if ( (c=select(maxfd+1,&read_fds,NULL,NULL,NULL)) < 0)
X-    { log_error("select (read) error"); exit(0); }
X+    { log_error("select (read) error"); exit(1); }
X   
X   if (FD_ISSET(nf_fd,&read_fds)) {  /*a netflow message is waiting*/
X 
X@@ -168,7 +178,7 @@
X     /* new packet */
X     if ( (nf_rcount=recvfrom(nf_fd,(char *)(nf_packet + sizeof(nf_cliaddr.sin_addr.s_addr)),
X 			     MAXPACKET,0,(struct sockaddr *)&nf_cliaddr,&nf_clilen)) < 0)
X-      { log_error("recvfrom error"); exit(0); }
X+      { log_error("recvfrom error"); exit(1); }
X     
X     /* Here we use a non-blocking select to find out which tcp clients we 
X        can write to.  This ensures the write won't block, which would of course
X@@ -189,7 +199,7 @@
X     timeout.tv_sec=0;
X     timeout.tv_usec=0;
X     if ( (c=select(maxfd+1,NULL,&write_fds,NULL,&timeout)) < 0)
X-      { log_error("select (write) error"); exit(0); }
X+      { log_error("select (write) error"); exit(1); }
X     for (i=0; i<MAXCLIENTS; i++) {
X       if (l_clients[i] > 0) {
X 	if (FD_ISSET(l_clients[i],&write_fds)) {
X@@ -220,9 +230,9 @@
X     /*    printf("incoming connection on tcp 4444\n");*/
X     l_addrlen=sizeof(l_cliaddr);
X     if ( (l_connfd = accept(l_fd,(struct sockaddr *) l_cliaddr, &l_addrlen)) < 0)
X-      { log_error("accept error"); exit(0); }
X+      { log_error("accept error"); exit(1); }
X 
X-    SetTCPOpts(l_connfd);
X+    SetTCPOpts(l_connfd, bufsize);
X 
X     for (i=0; i<MAXCLIENTS; i++) {
X       if (l_clients[i]==0) {
X@@ -268,25 +278,26 @@
X }
X 
X  /* Increase our receive buffer for nf_fd: */
X-int SetUDPOpts(int fd){
X-  int r,p,n;
X+int SetUDPOpts(int fd, int rcvsize){
X+  int r,p;
X   socklen_t       optlen;
X   
X-  n=512*1024;
X   optlen = sizeof(p);
X   
X   if (debug) {
X     r=getsockopt(fd,SOL_SOCKET,SO_RCVBUF,&p,&optlen);
X     printf("Before setsockopt, SO_RCVBUF is %d\n",p);
X   }
X-  r=setsockopt(fd,SOL_SOCKET,SO_RCVBUF,&n,sizeof(n));
X+  if (setsockopt(fd,SOL_SOCKET,SO_RCVBUF,&rcvsize,sizeof(rcvsize)) < 0) {
X+    perror("setsockopt SO_RCVBUF:");
X+  }
X   if (debug) {
X     r=getsockopt(fd,SOL_SOCKET,SO_RCVBUF,&p,&optlen);
X     printf("After setsockopt, SO_RCVBUF is %d\n",p);
X   }
X }
X 
X-int SetTCPOpts(int fd) { 
X+int SetTCPOpts(int fd, int bufsize) { 
X   int r,p,n;
X   socklen_t       optlen;
X   
X@@ -296,8 +307,7 @@
X     r=getsockopt(fd,SOL_SOCKET,SO_SNDBUF,&p,&optlen);
X     printf("Before setsockopt, SO_SNDBUF is %d\n",p);
X   }
X-  n=512*1024;
X-  r=setsockopt(fd,SOL_SOCKET,SO_SNDBUF,&n,sizeof(n));
X+  r=setsockopt(fd,SOL_SOCKET,SO_SNDBUF,&bufsize,sizeof(bufsize));
X   if (r<0) { log_error("setsockopt SO_SNDBUF"); }
X   if (debug) {
X     r=getsockopt(fd,SOL_SOCKET,SO_SNDBUF,&p,&optlen);
END-of-files/patch-ehntserv.c
exit

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211141932.gAEJWJPk085539>