From: Art Cancro Date: Thu, 19 Aug 2010 02:39:31 +0000 (+0000) Subject: * Removed the 'protocol' parameter from the sock_connect() function. All we have... X-Git-Tag: v8.01~870 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=272425172d6955f9c2c3929cdc0987056c0c01c8 * Removed the 'protocol' parameter from the sock_connect() function. All we have ever used here is TCP, and we don't have the functions in place to support UDP datagrams anyway. Removed the spurious parameter in preparation for an overhaul of this function. --- diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index 7220709ba..67414f93a 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -54,7 +54,7 @@ #define INADDR_NONE 0xffffffff #endif -int sock_connect(char *host, char *service, char *protocol) +int sock_connect(char *host, char *service) { struct hostent *phe; struct servent *pse; @@ -67,13 +67,11 @@ int sock_connect(char *host, char *service, char *protocol) return(-1); if ((service == NULL) || IsEmptyStr(service)) return(-1); - if ((protocol == NULL) || IsEmptyStr(protocol)) - return(-1); memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; - pse = getservbyname(service, protocol); + pse = getservbyname(service, "tcp"); if (pse) { sin.sin_port = pse->s_port; } else if ((sin.sin_port = htons((u_short) atoi(service))) == 0) { @@ -89,16 +87,11 @@ int sock_connect(char *host, char *service, char *protocol) host, strerror(errno)); return(-1); } - if ((ppe = getprotobyname(protocol)) == 0) { - CtdlLogPrintf(CTDL_CRIT, "Can't get %s protocol entry: %s\n", - protocol, strerror(errno)); + if ((ppe = getprotobyname("tcp")) == 0) { + CtdlLogPrintf(CTDL_CRIT, "Can't get tcp protocol entry: %s\n", strerror(errno)); return(-1); } - if (!strcmp(protocol, "udp")) { - type = SOCK_DGRAM; - } else { - type = SOCK_STREAM; - } + type = SOCK_STREAM; s = socket(PF_INET, type, ppe->p_proto); if (s < 0) { diff --git a/citadel/clientsocket.h b/citadel/clientsocket.h index 0274052a5..794a6dbf3 100644 --- a/citadel/clientsocket.h +++ b/citadel/clientsocket.h @@ -20,7 +20,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -int sock_connect(char *host, char *service, char *protocol); +int sock_connect(char *host, char *service); int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_until_full); int sock_read(int *sock, char *buf, int bytes, int keep_reading_until_full); int sock_write(int *sock, const char *buf, int nbytes); diff --git a/citadel/modules/clamav/serv_virus.c b/citadel/modules/clamav/serv_virus.c index 38b47de84..ab77f1865 100644 --- a/citadel/modules/clamav/serv_virus.c +++ b/citadel/modules/clamav/serv_virus.c @@ -102,10 +102,10 @@ int clamd(struct CtdlMessage *msg) { extract_token(hostbuf, buf, 0, ':', sizeof hostbuf); if (extract_token(portbuf, buf, 1, ':', sizeof portbuf)==-1) /* Didn't specify a port so we'll try the psuedo-standard 3310 */ - sock = sock_connect(hostbuf, CLAMD_PORT, "tcp"); + sock = sock_connect(hostbuf, CLAMD_PORT); else /* Port specified lets try connecting to it! */ - sock = sock_connect(hostbuf, portbuf, "tcp"); + sock = sock_connect(hostbuf, portbuf); if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n"); } @@ -140,7 +140,7 @@ int clamd(struct CtdlMessage *msg) { extract_token(portbuf, buf, 1, ' ', sizeof portbuf); /* Attempt to establish connection to STREAM socket */ - streamsock = sock_connect(hostbuf, portbuf, "tcp"); + streamsock = sock_connect(hostbuf, portbuf); if (streamsock < 0) { /* If the service isn't running, just pass the mail diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index e89f26eec..964f1611c 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -2075,7 +2075,7 @@ void network_poll_node(char *node, char *secret, char *host, char *port) { CtdlLogPrintf(CTDL_DEBUG, "network: polling <%s>\n", node); CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port); - sock = sock_connect(host, port, "tcp"); + sock = sock_connect(host, port); if (sock < 0) { CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno)); network_talking_to(node, NTT_REMOVE); diff --git a/citadel/modules/pop3client/serv_pop3client.c b/citadel/modules/pop3client/serv_pop3client.c index 3bc098483..4250cc446 100644 --- a/citadel/modules/pop3client/serv_pop3client.c +++ b/citadel/modules/pop3client/serv_pop3client.c @@ -90,7 +90,7 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3 if (CtdlThreadCheckStop()) return; - sock = sock_connect(pop3host, "110", "tcp"); + sock = sock_connect(pop3host, "110"); if (sock < 0) { CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno)); return; diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 3cc6d5e84..b6ae6d044 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -1083,7 +1083,7 @@ void smtp_try(const char *key, const char *addr, int *status, strcpy(mx_port, "25"); } CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port); - sock = sock_connect(mx_host, mx_port, "tcp"); + sock = sock_connect(mx_host, mx_port); snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno)); if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n"); if (sock < 0) { diff --git a/citadel/modules/spam/serv_spam.c b/citadel/modules/spam/serv_spam.c index 235b0caa3..3473a82d2 100644 --- a/citadel/modules/spam/serv_spam.c +++ b/citadel/modules/spam/serv_spam.c @@ -95,7 +95,7 @@ int spam_assassin(struct CtdlMessage *msg) { for (sa=0; sa\n", buf); - sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp"); + sock = sock_connect(buf, SPAMASSASSIN_PORT); if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n"); }