git » nmdb » commit 596535f

Don't send TCP packets when in passive mode.

author Alberto Bertogli
2007-06-01 06:28:27 UTC
committer Alberto Bertogli
2007-06-01 06:28:27 UTC
parent b48cd139e5cf92c79e286df389ab430b7b41b8ba

Don't send TCP packets when in passive mode.

The passive mode is not very useful in TCP, but that doesn't mean we
should ignore it.

If we refuse to answer TIPC requests, we should do the same for TCP
unless somebody gives a good reason not to.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

nmdb/tcp.c +9 -0

diff --git a/nmdb/tcp.c b/nmdb/tcp.c
index a81e53f..c159315 100644
--- a/nmdb/tcp.c
+++ b/nmdb/tcp.c
@@ -99,6 +99,9 @@ static void rep_send_error(const struct req_info *req, const unsigned int code)
 	uint32_t l, r, c;
 	unsigned char minibuf[4 * 4];
 
+	if (settings.passive)
+		return;
+
 	/* Network format: length (4), ID (4), REP_ERR (4), error code (4) */
 	l = htonl(4 + 4 + 4 + 4);
 	r = htonl(REP_ERR);
@@ -122,6 +125,9 @@ static int rep_send(const struct req_info *req, const unsigned char *buf,
 {
 	int rv;
 
+	if (settings.passive)
+		return 1;
+
 	rv = send(req->fd, buf, size, 0);
 	if (rv < 0) {
 		rep_send_error(req, ERR_SEND);
@@ -139,6 +145,9 @@ void tcp_mini_reply(struct req_info *req, uint32_t reply)
 	uint32_t len;
 	unsigned char minibuf[12];
 
+	if (settings.passive)
+		return;
+
 	len = htonl(12);
 	reply = htonl(reply);
 	memcpy(minibuf, &len, 4);