summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorroot <root@dagwood.rellim.com>2010-03-25 17:47:54 -0700
committerroot <root@dagwood.rellim.com>2010-03-25 17:47:54 -0700
commitf9b85731994460d56087a994ffe72fd9473608f2 (patch)
treea5bfc69c4377f992415c1d3313560e96c74999e1 /gpsd.c
parente6777ffacbad92eb7bb3d281e853993e48469cf5 (diff)
downloadgpsd-f9b85731994460d56087a994ffe72fd9473608f2.tar.gz
Better logging of IPv4 and IPv6 bind port operations.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gpsd.c b/gpsd.c
index aae06be7..b0b1b51a 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -294,6 +294,7 @@ static int passivesock_af(int af, char *service, char *protocol, int qlen)
int sin_len = 0;
int s = -1, type, proto, one = 1;
in_port_t port;
+ char *af_str = "";
if ((pse = getservbyname(service, protocol)))
port = ntohs((in_port_t)pse->s_port);
@@ -323,6 +324,7 @@ static int passivesock_af(int af, char *service, char *protocol, int qlen)
sat.sa_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
sat.sa_in.sin_port = htons(port);
+ af_str = "IPv4";
/* see PF_INET6 case below */
s = socket(PF_INET, type, proto);
break;
@@ -353,6 +355,7 @@ static int passivesock_af(int af, char *service, char *protocol, int qlen)
* leaves much of this unspecified, but requires that AF_INET
* be recognized. We follow tradition here.
*/
+ af_str = "IPv6";
s = socket(PF_INET6, type, proto);
break;
@@ -360,9 +363,10 @@ static int passivesock_af(int af, char *service, char *protocol, int qlen)
gpsd_report(LOG_ERROR, "Unhandled address family %d\n", af);
return -1;
}
+ gpsd_report(LOG_IO, "opening %s socket\n", af_str);
if (s == -1) {
- gpsd_report(LOG_ERROR, "Can't create socket\n");
+ gpsd_report(LOG_ERROR, "Can't create %s socket\n", af_str);
return -1;
}
if (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&one,
@@ -371,8 +375,8 @@ static int passivesock_af(int af, char *service, char *protocol, int qlen)
return -1;
}
if (bind(s, &sat.sa, sin_len) < 0) {
- gpsd_report(LOG_ERROR, "Can't bind to port %s, %s\n", service,
- strerror(errno));
+ gpsd_report(LOG_ERROR, "Can't bind to %s port %s, %s\n", af_str,
+ service, strerror(errno));
if (errno == EADDRINUSE) {
gpsd_report(LOG_ERROR, "Maybe gpsd is already running!\n");
}