T:basic test function
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
S:EHLO example.com
-R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.0.0.1/localhost.localdomain]
+#R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.0.0.1/localhost.localdomain]
+R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN...
R:250-SIZE 52428800
R:250-STARTTLS
R:250-8BITMIME
C:GOTLS
R:250 Link now encryp...
S:EHLO example.com
-R:250-mailleur.example.com, link (crypted) ready, your IP/FQDN=[127.0.0.1/localhost.localdomain]
+#R:250-mailleur.example.com, link (crypted) ready, your IP/FQDN=[127.0.0.1/localhost.localdomain]
+R:250-mailleur.example.com, link (crypted) ready, your IP/FQDN...
R:250-SIZE 52428800
R:250-8BITMIME
R:250-ENHANCEDSTATUSCODES
int handle;
struct linger slg;
-struct sockaddr_in server_addr;
int reuse;
int phase;
_Bool proceed;
}
break;
case 4 : //getting socket option
- server_addr.sin_family = AF_INET;
- inet_pton(AF_INET,"127.0.0.1", &(server_addr.sin_addr));
- server_addr.sin_port = htons(2525);
if (bind(handle,ai->ai_addr,ai->ai_addrlen)<0) {
(void) rou_alert(0,"%s Unable to bind on IP/port <%s/%s> (error='%s')",
OPEP,ai->ai_canonname,soc->port,strerror(errno));
/* server. Return a socptr if successful. */
/* */
/********************************************************/
-PUBLIC SOCPTR *soc_openonesock(PROTYP proto,const char *ip,const char *port)
+PUBLIC SOCPTR *soc_openonesock(PROTYP proto,const char *src,const char *ip,const char *port)
{
#define OPEP "devsoc.c:soc_openonesoc"
phase=999; //no need to go further
}
break;
- case 3 : //connecting to remote
+ case 3 : //Need to bind from a specific source address
+ if (src!=(const char *)0) {
+ struct sockaddr_in server_addr;
+
+ (void) memset(&server_addr,'\000',sizeof(server_addr));
+ server_addr.sin_family=AF_INET;
+ inet_pton(AF_INET,src, &(server_addr.sin_addr));
+ if (bind(handle,(struct sockaddr*)&server_addr,sizeof(server_addr))<0) {
+ (void) rou_alert(0,"%s Unable to bind on <%s> error=<%s>",
+ OPEP,src,strerror(errno));
+ (void) close(handle);
+ phase=999;
+ }
+ }
+ break;
+ case 4 : //connecting to remote
if (connect(handle,ai->ai_addr,ai->ai_addrlen)<0) {
switch (errno) {
case EINPROGRESS : //its acceptable
(void) rou_alert(1,"%s unable to make connection with '%s.%s' "
"(error=<%s>)",
OPEP,ip,port,strerror(errno));
+ (void) close(handle);
phase=999;
break;
}
}
break;
- case 4 : //getting newhandle flag
+ case 5 : //getting newhandle flag
if ((flags=fcntl(handle,F_GETFL,0))<0) {
(void) rou_core_dump("%s, Unable to get socket descripteur on "
"IP/PORT <%s/%s> (Bug? error=<%s>)",
phase=999; //never reached
}
break;
- case 5 : //setting newhandle working mode
+ case 6 : //setting newhandle working mode
if ((flags=fcntl(handle,F_SETFL,flags|O_NONBLOCK))<0) {
(void) rou_core_dump("%s, Unable to set socket descripteur on "
"IP/PORT <%s/%s> (Bug? error=<%s>)",
phase=999; //never reached
}
break;
- case 6 : //socket is now ready
+ case 7 : //socket is now ready
soc=newsocket();
soc->proto=proto;
soc->connected=true;