summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8d1c115)
raw | patch | inline | side by side (parent: 8d1c115)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 26 Oct 2010 13:09:10 +0000 (15:09 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 26 Oct 2010 13:09:10 +0000 (15:09 +0200) |
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index 2e7f2889ac13077ed4666211a352b15253eff155..139fa97ca72f37be4d3eb65622a960b99e27e2f2 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
double latency;
uint32_t dropped;
int recv_ttl;
- unsigned recv_tos;
+ uint8_t recv_tos;
char *data;
void *context;
double timeout;
int ttl;
int addrfamily;
- unsigned tos;
+ uint8_t tos;
char *data;
struct sockaddr *srcaddr;
}
if (ptr != NULL){
- ptr->recv_ttl = ip_hdr->ip_ttl;
- ptr->recv_tos = ip_hdr->ip_tos;
+ ptr->recv_ttl = (int) ip_hdr->ip_ttl;
+ ptr->recv_tos = (uint8_t) ip_hdr->ip_tos;
}
return (ptr);
}
struct timeval diff;
pinghost_t *host = NULL;
int recv_ttl;
- unsigned recv_tos;
+ uint8_t recv_tos;
/*
* Set up the receive buffer..
/* Iterate over all auxiliary data in msghdr */
recv_ttl = -1;
- recv_tos = 0xffff;
+ recv_tos = 0xff;
for (cmsg = CMSG_FIRSTHDR (&msghdr); /* {{{ */
cmsg != NULL;
cmsg = CMSG_NXTHDR (&msghdr, cmsg))
{
memcpy (&recv_tos, CMSG_DATA (cmsg),
sizeof (recv_tos));
- dprintf ("TOSv4 = %u;\n", recv_tos);
+ dprintf ("TOSv4 = %#04"PRIx8";\n", recv_tos);
} else
if (cmsg->cmsg_type == IP_TTL)
{
{
memcpy (&recv_tos, CMSG_DATA (cmsg),
sizeof (recv_tos));
- dprintf ("TOSv6 = %u;\n", recv_tos);
+ dprintf ("TOSv6 = %#04"PRIx8";\n", recv_tos);
} else
if (cmsg->cmsg_type == IPV6_HOPLIMIT)
{
/*
* Set the TOS of a socket protocol independently.
*/
-static int ping_set_tos (pinghost_t *ph, unsigned tos)
+static int ping_set_tos (pinghost_t *ph, uint8_t tos)
{
int ret = -2;
if ((obj = (pingobj_t *) malloc (sizeof (pingobj_t))) == NULL)
return (NULL);
- memset (obj, '\0', sizeof (pingobj_t));
+ memset (obj, 0, sizeof (pingobj_t));
obj->timeout = PING_DEF_TIMEOUT;
obj->ttl = PING_DEF_TTL;
obj->addrfamily = PING_DEF_AF;
obj->data = strdup (PING_DEF_DATA);
- obj->tos = 0;
+ obj->tos = 0;
return (obj);
}
switch (option)
{
- case PING_OPT_TOS:{
- obj->tos=*(unsigned *)value;
+ case PING_OPT_TOS:
+ {
pinghost_t *ph;
+
+ obj->tos = *((uint8_t *) value);
for (ph = obj->head; ph != NULL; ph = ph->next)
ping_set_tos (ph, obj->tos);
break;
}
+
case PING_OPT_TIMEOUT:
obj->timeout = *((double *) value);
if (obj->timeout < 0.0)