(void) prc_preptitle(argc,argv,environ);
(void) rou_setappname(RECNAME);
(void) rou_modesubrou(true);
- (void) par_modeunipar(true);
(void) prc_modeuniprc(true);
(void) sig_modeunisig(true);
- (void) rec_modemodrec(true);
(void) sig_trapsignal(true,sig_alrm);
break;
case 2 : //doing main task
(void) prc_cleantitle();
params=par_freeparams(params);
(void) sig_trapsignal(false,sig_alrm);
- (void) rec_modemodrec(false);
(void) sig_modeunisig(false);
(void) prc_modeuniprc(false);
- (void) par_modeunipar(false);
(void) rou_modesubrou(false);
break;
default : //end of task
case 2 : //initialising process
(void) prc_preptitle(argc,argv,environ);
(void) rou_modesubrou(true);
- (void) par_modeunipar(true);
(void) prc_modeuniprc(true);
(void) sig_modeunisig(true);
(void) sig_trapsignal(true,sig_alrm);
(void) sig_trapsignal(false,sig_alrm);
(void) sig_modeunisig(false);
(void) prc_modeuniprc(false);
- (void) par_modeunipar(false);
(void) rou_modesubrou(false);
break;
default : //end of task
TIMESPEC start; //log start time
}LOGTYP;
-static _Bool modopen; //boolean module open/close
/*
^L
*/
return taille;
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-PUBLIC int log_modedevlog(_Bool mode)
-
-{
-#define OPEP "devlog.c:log_modedevlog"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//current daily log
extern int log_mergelog(char *logname);
-//homework to be done before starting/stopping module.
-extern int log_modedevlog(_Bool mode);
-
#endif
int iteration; //number of soc slot used on the IP
}SOCTYP;
-static _Bool modopen; //module open/close status
/*
\f
*/
^L
*/
/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-int soc_modedevsoc(_Bool mode)
-
-{
-#define OPEP "unidoc.c:soc_modeunisoc"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- (void) rou_modesubrou(mode);
- (void) eml_modeunieml(mode);
- (void) prc_modeuniprc(mode);
- (void) tls_modeunitls(mode);
- break;
- case false :
- (void) tls_modeunitls(mode);
- (void) prc_modeuniprc(mode);
- (void) eml_modeunieml(mode);
- (void) rou_modesubrou(mode);
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
-/*
-^L
-*/
-/********************************************************/
/* */
/* Procedure to switch a plain socket channel to */
/* crypted channel, return true is successful. */
//procedure to initiate crypted mode on plain channel
extern _Bool soc_starttls(SOCPTR *socptr,const char *peerip);
-//homework to be done before starting/stopping module.
-extern int soc_modedevsoc(_Bool mode);
-
#endif
mch_unknown //unknown mechanism
}MCHTYP;
-static _Bool modopen; //module open/close status
/*
\f
*/
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-int spf_modegesspf(_Bool mode)
-
-{
-#define OPEP "unidoc.c:soc_modeunisoc"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- (void) rou_modesubrou(mode);
- (void) afn_modesubafn(mode);
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//get the SPF status for a specific domain and a remote peer IP
extern SPFENU spf_getstatus(int *try,char *domain,AFNTYP *afnnum);
-//homework to be done before starting/stopping module.
-extern int spf_modegesspf(_Bool mode);
-
#endif
// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/********************************************************/
/* */
-/* Module for signal handling level */
+/* Module to handle TCP communication */
/* */
/********************************************************/
#include <sys/wait.h>
#include "uniprc.h"
#include "gestcp.h"
-static _Bool modopen; //boolean module open/close
/*
^L
*/
return contact;
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-PUBLIC int tcp_modegestcp(_Bool mode)
-
-{
-#define OPEP "unisig.c:sig_modeunisig"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- (void) rou_modesubrou(mode);
- (void) sig_modeunisig(mode);
- (void) prc_modeuniprc(mode);
- (void) eml_modeunieml(mode);
- (void) soc_modedevsoc(mode);
- break;
- case false :
- (void) soc_modedevsoc(mode);
- (void) eml_modeunieml(mode);
- (void) sig_modeunisig(mode);
- (void) prc_modeuniprc(mode);
- (void) rou_modesubrou(mode);
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//drop contact established by remote
extern CONTYP *tcp_dropcontact(CONTYP *contact);
-//homework to be done before starting/stopping module.
-extern int tcp_modegestcp(_Bool mode);
-
#endif
#include "lvleml.h"
-
-static _Bool modopen; //module open/close status
/*
^L
*/
/* if EHLO message is not accepted. */
/* */
/************************************************/
-static _Bool dohelo(CONTYP *contact,char *keyword,char *parameter)
+static _Bool dohelo(CONTYP *contact,char *parameter)
{
#define OPEP "unieml.c:dohelo"
/* if EHLO message is not accepted. */
/* */
/************************************************/
-static _Bool doehlo(CONTYP *contact,char *keyword,char *parameter)
+static _Bool doehlo(CONTYP *contact,char *parameter)
{
static char *ehlostr[]= {
/* Procedure to rset the current session */
/* */
/************************************************/
-static _Bool doreset(CONTYP *contact,char *keyword,char *parameter)
+static _Bool doreset(CONTYP *contact,char *parameter)
{
(void) transmit(contact,"%d 2.0.0 Flushed session %s",CMDOK,contact->cursesid);
(void) signon(contact);
while (proceed==true) {
char *line;
- char *parameter;
TIMESPEC attend;
attend.tv_sec=60;
if (status<=0) //timeout or trouble?
break; //no need to go further
(void) log_fprintlog(contact->logptr,false,"%s",line);
- if (line!=(char *)0) {
- parameter=strchr(line,' ');
- if (parameter==(char *)0)
- parameter=strchr(line,'\t');
- if (parameter!=(char *)0) {
- *parameter='\000';
- parameter++;
- while ((*parameter==' ')||(*parameter=='\t'))
- parameter++;
- }
- }
switch (eml_getcode(line)) {
case c_helo : //HELO SMTP protocol
- proceed=dohelo(contact,line,parameter);
+ proceed=dohelo(contact,line);
break;
case c_ehlo : //EHLO SMTP protocol
- proceed=doehlo(contact,line,parameter);
+ proceed=doehlo(contact,line);
break;
case c_quit : //QUIT SMTP protocol
(void) transmit(contact,"%d 2.0.0 Bye, closing connection %s",
QUITOK,contact->mainsesid);
proceed=false;
break;
+ case c_mail : //MAIL FROM: checking originator
+ (void) rou_alert(0,"JMPDBG parameter=<%s>",line);
+ break;
case c_rset : //Doing session reset
- proceed=doreset(contact,line,parameter);
+ proceed=doreset(contact,line);
break;
case c_starttls : //EHLO start encryptel link
switch (soc_starttls(contact->socptr,contact->peerip)) {
return status;
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-int eml_modelvleml(_Bool mode)
-
-{
-#define OPEP "unidoc.c:soc_modeunisoc"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- (void) rou_modesubrou(mode);
- (void) eml_modeunieml(mode);
- (void) log_modedevlog(mode);
- break;
- case false :
- (void) log_modedevlog(mode);
- (void) eml_modeunieml(mode);
- (void) rou_modesubrou(mode);
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//procedure to extract line and proceed with peer contact
extern int eml_docontact(CONTYP *contact);
-//homework to be done before starting/stopping module.
-extern int eml_modelvleml(_Bool mode);
-
#endif
#include "lvleml.h"
#include "modrec.h"
-static _Bool modopen; //boolean module open/close
#define DFLTIP "127.0.10.25" //smtp test IP
#define SMTPORT "1025" //smtp test port
/*
char *ptr;
char config[80];
- (void) strncpy(config,argv[i],sizeof(ptr));
+ (void) strncpy(config,argv[i],sizeof(config));
ptr=config;
iteration=1;
proto=pro_smtp;
}
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-PUBLIC int rec_modemodrec(_Bool mode)
-
-{
-#define OPEP "mode.c:rec_modemoderec"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- (void) rou_modesubrou(mode);
- (void) prc_modeuniprc(mode);
- (void) sig_modeunisig(mode);
- (void) soc_modedevsoc(mode);
- (void) tcp_modegestcp(mode);
- (void) eml_modelvleml(mode);
- break;
- case false :
- (void) eml_modelvleml(mode);
- (void) tcp_modegestcp(mode);
- (void) soc_modedevsoc(mode);
- (void) sig_modeunisig(mode);
- (void) prc_modeuniprc(mode);
- (void) rou_modesubrou(mode);
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
#include <stdbool.h>
-//procedure to receive email form outside
+//procedure to receive email from outside
extern void rec_handlesmtp(int argc,char *argv[]);
-//homework to be done before starting/stoping module.
-extern int rec_modemodrec(_Bool mode);
-
#endif
#define PUBLIC //to specify public variable
-static _Bool modopen; //module open/close status
/*
\f
*/
}
return areequal;
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-PUBLIC int afn_modesubafn(_Bool mode)
-
-{
-#define OPEP "subafn.c:afn_modesubafn"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//procedure to compare 2 same class IP according a mask value
extern int afn_cmpipnum(AFNTYP *afnnum1,AFNTYP *afnnum2,int mask);
-//homework to be done before starting/stoping module.
-extern int afn_modesubafn(_Bool mode);
-
#endif
u_char buf[B64K]; //according US Cert VU#738331
}RSPTYP;
-static _Bool modopen; //module open/close status
/*
\f
*/
}
return mxlist;
-#undef OPEP
-}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-int dns_modeunidns(_Bool mode)
-
-{
-#define OPEP "unidoc.c:soc_modeunisoc"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- (void) rou_modesubrou(mode);
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
#undef OPEP
}
/*
//of domain A record list
extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask);
-//homework to be done before starting/stopping module.
-extern int dns_modeunidns(_Bool mode);
-
#endif
#include "subrou.h"
#include "unieml.h"
-static _Bool modopen; //module open/close status
-
typedef struct {
CODTYP code; //keyword code
const char *key; //keyword itself
{c_ehlo,"EHLO"},
{c_quit,"QUIT"},
{c_rset,"RSET"},
+ {c_mail,MAILF},
{c_starttls,"STARTTLS"},
{c_unknown,(const char *)0}
};
code=c_unknown;
for (ptr=vocsmtp;ptr->code!=c_unknown;ptr++) {
- if (strncasecmp(ptr->key,keyword,strlen(keyword))==0) {
+ if (strncasecmp(ptr->key,keyword,strlen(ptr->key))==0) {
+ char *par;
+
code=ptr->code;
+ par=keyword+strlen(ptr->key);
+ while ((*par==' ')||(*par=='\t'))
+ par++;
+ (void) strcpy(keyword,par);
break;
}
}
return code;
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-int eml_modeunieml(_Bool mode)
-
-{
-#define OPEP "unidoc.c:soc_modeunisoc"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- (void) rou_modesubrou(mode);
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
#define BADPAR 501 //error in parameters
#define CMDBAD 502 //command not implemented
+
+//SMTP avail command
+#define MAILF "MAIL FROM:" //Mail from a sender
+
//list of keyword
typedef enum { //list of SMTP protocol keyword
c_helo, //Basic Helo command
c_ehlo, //EHLO command
c_quit, //quit exchange
c_rset, //resetting session
+ c_mail, //mail from sequence detected
c_starttls, //Starting a TLS crypted link
c_unknown //key word unknown
}CODTYP;
//convert SMTP keyword to CODTYP
extern CODTYP eml_getcode(char *keyword);
-//homework to be done before starting/stopping module.
-extern int eml_modeunieml(_Bool mode);
-
#endif
#include "subrou.h"
#include "unipar.h"
-static _Bool modopen; //module open/close status
/*
^L
*/
}
return params;
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to "open/close" module and do */
-/* homework purpose */
-/* return zero if everything right */
-/* */
-/********************************************************/
-PUBLIC int par_modeunipar(_Bool mode)
-
-{
-#define OPEP "unipar.c:uni_modeunipar"
-
-int status;
-
-status=0;
-if (mode!=modopen) {
- (void) rou_modesubrou(mode);
- switch ((int)mode) {
- case true :
- break;
- case false :
- break;
- default :
- (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):",
- OPEP,(int)mode);
- status=-1;
- break;
- }
- modopen=mode;
- }
-return status;
-#undef OPEP
-}
//allocated memory and parse an argment list
extern ARGTYP *par_getparams(int argc,char * const argv[],const char *optstring);
-//homework to be done before starting/stopping module.
-extern int par_modeunipar(_Bool mode);
-
#endif