diff -r -c openssh-3.1p1/packet.c openssh-3.1p1-withaccounting/packet.c
*** openssh-3.1p1/packet.c	Tue Mar  5 02:31:29 2002
--- openssh-3.1p1-withaccounting/packet.c	Sun May 12 15:06:50 2002
***************
*** 1138,1143 ****
--- 1138,1144 ----
  			else
  				fatal("Write failed: %.100s", strerror(errno));
  		}
+ 		else netout_bytes += len;
  		buffer_consume(&output, len);
  	}
  }
diff -r -c openssh-3.1p1/packet.h openssh-3.1p1-withaccounting/packet.h
*** openssh-3.1p1/packet.h	Tue Mar  5 02:53:05 2002
--- openssh-3.1p1-withaccounting/packet.h	Sun May 12 15:06:50 2002
***************
*** 85,88 ****
--- 85,91 ----
  	} \
  } while (0)
  
+ extern long netin_bytes;    /* bytes read from network connection */
+ extern long netout_bytes;   /* bytes written to network connection */
+ 
  #endif				/* PACKET_H */
diff -r -c openssh-3.1p1/servconf.c openssh-3.1p1-withaccounting/servconf.c
*** openssh-3.1p1/servconf.c	Tue Feb  5 02:26:35 2002
--- openssh-3.1p1-withaccounting/servconf.c	Sun May 12 15:08:44 2002
***************
*** 75,80 ****
--- 75,81 ----
  	options->hostbased_uses_name_from_packet_only = -1;
  	options->rsa_authentication = -1;
  	options->pubkey_authentication = -1;
+ 	options->log_accounting = -1;
  #if defined(KRB4) || defined(KRB5)
  	options->kerberos_authentication = -1;
  	options->kerberos_or_local_passwd = -1;
***************
*** 235,240 ****
--- 236,245 ----
  	}
  	if (options->authorized_keys_file == NULL)
  		options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS;
+ 
+ 	if (options->log_accounting == -1)
+ 	        options->log_accounting = 0;
+ 
  }
  
  /* Keyword tokens. */
***************
*** 267,272 ****
--- 272,278 ----
  	sBanner, sVerifyReverseMapping, sHostbasedAuthentication,
  	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
  	sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
+         sAccounting,
  	sDeprecated
  } ServerOpCodes;
  
***************
*** 295,300 ****
--- 301,307 ----
  	{ "rsaauthentication", sRSAAuthentication },
  	{ "pubkeyauthentication", sPubkeyAuthentication },
  	{ "dsaauthentication", sPubkeyAuthentication },			/* alias */
+ 	{ "accounting", sAccounting },
  #if defined(KRB4) || defined(KRB5)
  	{ "kerberosauthentication", sKerberosAuthentication },
  	{ "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
***************
*** 856,861 ****
--- 863,872 ----
  	case sClientAliveCountMax:
  		intptr = &options->client_alive_count_max;
  		goto parse_int;
+ 
+ 	case sAccounting:
+ 	        intptr = &options->log_accounting;
+ 		goto parse_flag;
  
  	case sDeprecated:
  		log("%s line %d: Deprecated option %s",
Only in openssh-3.1p1-withaccounting: servconf.c~
diff -r -c openssh-3.1p1/servconf.h openssh-3.1p1-withaccounting/servconf.h
*** openssh-3.1p1/servconf.h	Tue Mar  5 02:53:05 2002
--- openssh-3.1p1-withaccounting/servconf.h	Sun May 12 15:06:50 2002
***************
*** 131,136 ****
--- 131,137 ----
  	char   *authorized_keys_file2;
  	int	pam_authentication_via_kbd_int;
  
+         int log_accounting;             /* log traffic send/received to/from network */
  }       ServerOptions;
  
  void	 initialize_server_options(ServerOptions *);
diff -r -c openssh-3.1p1/serverloop.c openssh-3.1p1-withaccounting/serverloop.c
*** openssh-3.1p1/serverloop.c	Fri Feb  8 12:07:17 2002
--- openssh-3.1p1-withaccounting/serverloop.c	Sun May 12 15:06:50 2002
***************
*** 362,367 ****
--- 362,368 ----
  			}
  		} else {
  			/* Buffer any received data. */
+ 		        netin_bytes += len;
  			packet_process_incoming(buf, len);
  		}
  	}
diff -r -c openssh-3.1p1/ssh-keyscan.c openssh-3.1p1-withaccounting/ssh-keyscan.c
*** openssh-3.1p1/ssh-keyscan.c	Tue Mar  5 02:54:53 2002
--- openssh-3.1p1-withaccounting/ssh-keyscan.c	Sun May 12 15:06:50 2002
***************
*** 98,103 ****
--- 98,106 ----
  TAILQ_HEAD(conlist, Connection) tq;	/* Timeout Queue */
  con *fdcon;
  
+ /* note: these are not really used but required to be able to link ssh */
+ long netin_bytes,netout_bytes;
+ 
  /*
   *  This is just a wrapper around fgets() to make it usable.
   */
diff -r -c openssh-3.1p1/ssh.c openssh-3.1p1-withaccounting/ssh.c
*** openssh-3.1p1/ssh.c	Tue Feb 19 05:20:58 2002
--- openssh-3.1p1-withaccounting/ssh.c	Sun May 12 15:06:50 2002
***************
*** 121,126 ****
--- 121,129 ----
  /* optional user configfile */
  char *config = NULL;
  
+ /* note: these are not really used but required to be able to link ssh */
+ long netin_bytes,netout_bytes;
+ 
  /*
   * Name of the host we are connecting to.  This is the name given on the
   * command line, or the HostName specified for the user-supplied name in a
diff -r -c openssh-3.1p1/sshconnect.c openssh-3.1p1-withaccounting/sshconnect.c
*** openssh-3.1p1/sshconnect.c	Tue Mar  5 19:59:46 2002
--- openssh-3.1p1-withaccounting/sshconnect.c	Sun May 12 15:06:50 2002
***************
*** 479,484 ****
--- 479,485 ----
  	    SSH_VERSION);
  	if (atomicio(write, connection_out, buf, strlen(buf)) != strlen(buf))
  		fatal("write: %.100s", strerror(errno));
+ 	netout_bytes += strlen(buf);
  	client_version_string = xstrdup(buf);
  	chop(client_version_string);
  	chop(server_version_string);
diff -r -c openssh-3.1p1/sshd.8 openssh-3.1p1-withaccounting/sshd.8
*** openssh-3.1p1/sshd.8	Tue Mar  5 02:38:59 2002
--- openssh-3.1p1-withaccounting/sshd.8	Sun May 12 15:06:50 2002
***************
*** 329,334 ****
--- 329,339 ----
  keywords and their meanings are as follows (note that
  keywords are case-insensitive and arguments are case-sensitive):
  .Bl -tag -width Ds
+ .It Cm Accounting
+ If enabled, the server will log connection time and number of bytes
+ received from and sent to the network for each session.
+ Default is
+ .Dq no .
  .It Cm AFSTokenPassing
  Specifies whether an AFS token may be forwarded to the server.
  Default is
diff -r -c openssh-3.1p1/sshd.c openssh-3.1p1-withaccounting/sshd.c
*** openssh-3.1p1/sshd.c	Tue Mar  5 02:31:30 2002
--- openssh-3.1p1-withaccounting/sshd.c	Sun May 12 15:06:50 2002
***************
*** 189,194 ****
--- 189,197 ----
  int *startup_pipes = NULL;
  int startup_pipe;		/* in child */
  
+ long netin_bytes = 0;    /* bytes read from network connection */
+ long netout_bytes = 0;   /* bytes written to network connection */
+ 
  /* Prototypes for various functions defined later in this file. */
  void destroy_sensitive_data(void);
  
***************
*** 596,601 ****
--- 599,605 ----
  	int startups = 0;
  	Key *key;
  	int ret, key_used = 0;
+ 	time_t net_time;
  
  	__progname = get_progname(av[0]);
  	init_rng();
***************
*** 1129,1134 ****
--- 1133,1142 ----
  
  	/* This is the child processing a new connection. */
  
+ 	/* clear accounting counters */
+ 	netin_bytes = netout_bytes = 0;
+ 	net_time = time(NULL);
+ 
  	/*
  	 * Disable the key regeneration alarm.  We will not regenerate the
  	 * key since we are no longer in a position to give it to anyone. We
***************
*** 1242,1247 ****
--- 1250,1258 ----
  	}
  	/* The connection has been terminated. */
  	verbose("Closing connection to %.100s", remote_ip);
+ 	if (options.log_accounting) {
+ 	         log("accounting: %ld %ld %ld",netin_bytes,netout_bytes,(long)(time(NULL)-net_time));
+ 	}
  
  #ifdef USE_PAM
  	finish_pam();
