[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] endiness fix which works for big and little endian systems
From: |
Thomas Glanzmann |
Subject: |
[PATCH] endiness fix which works for big and little endian systems |
Date: |
Tue, 23 Aug 2005 14:54:05 +0200 |
User-agent: |
Mutt/1.5.9i |
Hello Mark,
cfengine:faui01: Couldn't connect to host
mephisto.informatik.uni-erlangen.de
cfengine:faui01: Unable to establish connection with
mephisto.informatik.uni-erlangen.de (failover)
connect(3, {sa_family=AF_FILE, path="/var/run/.nscd_socket"}, 110) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(48148),
sin_addr=inet_addr("131.188.30.104")}, 16) = -1 ECONNREFUSED (Connection
refused)
connect(3, {sa_family=AF_FILE, path="/var/run/.nscd_socket"}, 110) = 0
sikagies has logged off pts/24 from p5495dfe8.dip.t-dialin.net
As you can see cfengine tries to connect to port 48148 which is 5308 in
wrong endiness. This happens on Linux when the cfengine port is
referenced in /etc/services. The following patch fixes this both on big
and little endian systems. The first delta is the fix. And the second
one is eye candy because htons and ntohs on a 16 bit value is
equivalent.
Thomas
--- a/src/ip.c
+++ b/src/ip.c
@@ -208,7 +208,7 @@
}
else
{
- SHORT_CFENGINEPORT = htons(server->s_port);
+ SHORT_CFENGINEPORT = server->s_port;
}
Verbose("Setting cfengine new port to %u\n",SHORT_CFENGINEPORT);
@@ -227,7 +227,7 @@
}
else
{
- snprintf(STR_CFENGINEPORT,15,"%d",htons(server->s_port));
+ snprintf(STR_CFENGINEPORT,15,"%d",ntohs(server->s_port));
}
Verbose("Setting cfengine old port to %s\n",STR_CFENGINEPORT);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] endiness fix which works for big and little endian systems,
Thomas Glanzmann <=