#define OPEP "gesttcp.c:freecontact"
if (contact!=(CONTYP *)0) {
+ contact->sessid=rou_freestr(contact->sessid);
contact->fqdn=rou_freestr(contact->fqdn);
contact->peerip=rou_freestr(contact->peerip);
contact->locname=rou_freestr(contact->locname);
contact->locname=soc_getaddrinfo(contact->socptr,true,true);
contact->locserv=soc_getaddrinfo(contact->socptr,true,false);
contact->peerip=soc_getaddrinfo(contact->socptr,false,true);
+ contact->sessid=eml_getsessionid();
if ((contact->locname==(char *)0)||(contact->peerip==(char *)0)) {
(void) rou_alert(0,"%s Unable to establish contact entities",OPEP);
contact=freecontact(contact);
phase=999; //no identity
}
break;
- case 3 : //contact is good sending signon
+ case 3 : //contact is good, then sending a signon
if (tcp_signon(contact)<=0) {
contact=freecontact(contact);
phase=999; //no contact
char *locname; //socket local hostname
char *locserv; //local service port
char *peerip; //socket remote peer IP
+ char *sessid; //current session ID
+ int numreset; //number of SMTP reset received
}CONTYP;
//read a line from contact up to CRLF
proceed=doehlo(contact,line,parameter);
break;
case c_quit : //QUIT SMTP protocol
- (void) transmit(contact,"%d 2.0.0 Bye, closing connection",QUITOK);
+ (void) transmit(contact,"%d 2.0.0 Bye, closing connection %s",
+ QUITOK,contact->sessid);
proceed=false;
break;
case c_starttls : //EHLO start encryptel link
/* Module for low level subroutine */
/* */
/********************************************************/
+#include <sys/time.h>
#include <dirent.h>
#include <errno.h>
#include <math.h>
//version definition
-#define VERSION "0.4"
-#define RELEASE "2"
+#define VERSION "0.4.1"
+#define RELEASE "1"
//Public variables
PUBLIC int debug=0; //debug level
static _Bool current=false;
-if (current!=onoff) {
+if ((debug>2)&&(current!=onoff)) {
int status;
char cmd[200];
*/
/********************************************************/
/* */
+/* Procedure to return the current time */
+/* expressed with a millisecond precision starting */
+/* from the firt time it was called. */
+/* */
+/********************************************************/
+PUBLIC unsigned int rou_getmillisec()
+
+{
+struct timeval newtime;
+(void) gettimeofday(&newtime,(struct timezone *)0);
+return (unsigned int)((newtime.tv_usec/1000));
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to transform the local system time in */
+/* ASCII time stamp. */
+/* Stored in STATIC memory area. */
+/* */
+/********************************************************/
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to transform the local system time in */
/* ASCII time stamp. */
/* Stored in STATIC memory area. */
//open/close memory leak detector.
extern void rou_checkleak(_Bool onoff);
+//procedure to return the current number of milli-second
+extern unsigned int rou_getmillisec();
+
//transform local system time in ASCII stamp.
extern char *rou_ascsysstamp(time_t curtime);
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include "subrou.h"
#include "unieml.h"
*/
/********************************************************/
/* */
+/* Procedure to format and return a dynamicaly */
+/* allocated char array filled with uniq session ID*/
+/* */
+/********************************************************/
+PUBLIC char *eml_getsessionid()
+
+{
+#define UFTIME "%Y%m%d%H%M%S"
+#define UNIQUE "%05d-%s-%04d"
+
+time_t curtime;
+char asctemps[100];
+char buffer[300];
+
+curtime=time((time_t)0);
+(void) strftime(asctemps,sizeof(asctemps),UFTIME,localtime(&curtime));
+(void) snprintf(buffer,sizeof(buffer),UNIQUE,getpid(),asctemps,rou_getmillisec());
+return strdup(buffer);
+#undef UNIQUE
+#undef UFTIME
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
/* Procedure to return a protocol keywork code */
/* */
/********************************************************/
c_unknown //key word unknown
}CODTYP;
-//conver keyword to CODTYP
+//get a session unique id
+extern char *eml_getsessionid();
+
+//convert SMTP keyword to CODTYP
extern CODTYP eml_getcode(char *keyword);
//homework to be done before starting/stopping module.