*/
/********************************************************/
/* */
-/* Procedure to override remote IP number, ORGN is */
-/* used in debug mode test ONLY. */
-/* */
-/********************************************************/
-static void doorgn(CONTYP *contact,char *newip)
-
-{
-#define OPEP "lvleml.c:doorgn,"
-
-struct addrinfo *res;
-int phase;
-_Bool proceed;
-
-res=(struct addrinfo *)0;
-phase=0;
-proceed=true;
-while (proceed==true) {
- //(void) rou_alert(0,"JMPDBG %s phase='%d' parm=<%s>",OPEP,phase,newip);
- switch (phase) {
- case 0 : //checking if we have a parameter
- while ((*newip==' ')||(*newip=='\t'))
- newip++; //removing unneeded space
- if (strlen(newip)==0) {
- (void) rou_alert(0,"%s, newip not specified (debug?)",OPEP);
- phase=999; //No need to go further
- }
- break;
- case 1 : //Getting Override HOST
- if (strlen(newip)>0) { //always
- int status;
- struct addrinfo hints;
-
- (void) memset(&hints,'\000',sizeof(hints));
- hints.ai_family=PF_UNSPEC;
- hints.ai_socktype=SOCK_STREAM;
- hints.ai_flags=HINTFLG;
- status=getaddrinfo(newip,"",&hints,&res);
- if (status!=0) {
- (void) transmit(contact,"%d 5.5.4 <%s> is not an IP number",BADPAR,newip);
- phase=999; //no need to go further
- }
- }
- break;
- case 2 : //setting new remote name
- if (res!=(struct addrinfo *)0) { //always
- int namestat;
- char host[NI_MAXHOST];
-
- (void) strcpy(host,"No.Reverse");
- namestat=getnameinfo(res->ai_addr,res->ai_addrlen,
- host,sizeof(host),(char *)0,0,NI_NAMEREQD);
- switch (namestat) {
- case 0 :
- case EAI_AGAIN :
- case EAI_NONAME :
- contact->peerip=rou_freestr(contact->peerip);
- contact->peername=rou_freestr(contact->peername);
- contact->peerip=strdup(newip);
- contact->peername=strdup(host);
- (void) transmit(contact,"%d 2.9.9 New peer [%s/%s] set",
- CMDOK,newip,host);
- break;
- default :
- (void) rou_alert(0,"%s, Unexpected namestat='%d' (IP=<%s>) (bug?)",
- OPEP,namestat,newip);
- (void) transmit(contact,"%d 5.5.4 Bug! with <%s>",BADPAR,newip);
- phase=999; //Trouble trouble
- break;
- }
- }
- break;
- default : //SAFE guard
- proceed=false;
- break;
- }
- phase++;
- }
-if (res!=(struct addrinfo *)0)
- (void) freeaddrinfo(res);
-
-#undef OPEP
-}
-/*
-^L
-*/
-/********************************************************/
-/* */
/* Procedure to check if helo or ehlo paratmeter */
/* is a correct one */
/* */
*/
/************************************************/
/* */
+/* Procedure to manage a "RCPT TO:" */
+/* ommand from the SMTP client. */
+/* */
+/************************************************/
+static _Bool checkto(CONTYP *contact,char *rcptto)
+
+{
+_Bool success;
+_Bool proceed;
+int phase;
+
+success=false;
+proceed=true;
+phase=0;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //do we have an originator
+ if ((rcptto==(char *)0)||(strlen(rcptto)<3)) {
+ (void) transmit(contact,"%d 5.6.0 <%s> recipient not specified",
+ BADPAR,rcptto);
+ phase=999; //no need to go further
+ }
+ break;
+ case 1 : //check rcpt format
+ if ((rcptto[0]!='<')||(rcptto[strlen(rcptto)-1]!='>')) {
+ (void) transmit(contact,"%d 5.6.1 '%s' bad Format error",
+ BADPAR,rcptto);
+ phase=999; //no need to go further
+ }
+ rcptto[strlen(rcptto)-1]='\000';
+ (void) memmove(rcptto,rcptto+1,strlen(rcptto));
+ break;
+ case 2 : //everything ok
+ (void) transmit(contact,"%d 2.6.2 Address accepted",CMDOK);
+ break;
+ default : //SAFE guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return success;
+}
+/*
+\f
+*/
+/************************************************/
+/* */
/* Procedure to reset the current session */
/* */
/************************************************/
(void) signon(contact);
while (proceed==true) {
char *line;
+ CODTYP code;
line=(char *)0;
got=tcp_getline(contact->socptr,delay,&line);
break; //no need to go further
}
(void) log_fprintlog(contact->logptr,false,"%s",line);
- switch (eml_getcode(line)) {
+ code=eml_getcode(line);
+ switch (code) {
case c_helo : //HELO SMTP protocol
proceed=dohelo(contact,line);
break;
(void) transmit(contact,"%d 2.0.0 OK, %s",
CMDOK,contact->mainsesid);
break;
- case c_orgn :
- (void) doorgn(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);
(void) checkfrom(contact,line);
break;
+ case c_rcpt : //Doing rpt scanning
+ (void) checkto(contact,line);
+ break;
case c_rset : //Doing session reset
proceed=doreset(contact,line);
break;
CMDBAD,contact->mainsesid);
break;
default :
- (void) rou_alert(0,"Unable to find keyword for <%s> (Bug?)",OPEP,line);
- (void) transmit(contact,"%d 2.0.0 Bye, closing connection %s",
+ (void) rou_alert(0,"%s Unable to find entry for code='%d' (Bug?)",OPEP,code);
+ (void) transmit(contact,"%d-5.5.1 Unrecognized command, see RFC 5321",CMDBAD);
+ (void) transmit(contact,"%d 2.0.0 Bug!, closing connection Immediatly (%s)",
QUITOK,contact->mainsesid);
status=-1; //remote is a trouble maker
status=-3;