X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fproto-p10.c;h=d44d8a288c664722f19ce63a72bfb8d9bab4ed5c;hb=46a83ccaf7c031c84ea50138d1ebf60c10515dd1;hp=c7d69b06476c68a124cdf270ebeb215545f1a526;hpb=32bf3697265d4a5dcb94d32f418672dc5de9c2a2;p=srvx.git diff --git a/src/proto-p10.c b/src/proto-p10.c index c7d69b0..d44d8a2 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -596,6 +596,21 @@ irc_pong(const char *who, const char *data) putsock("%s " P10_PONG " %s :%s", self->numeric, who, data); } +void +irc_pong_asll(const char *who, const char *orig_ts) +{ + char *delim; + struct timeval orig; + struct timeval now; + int diff; + + orig.tv_sec = strtoul(orig_ts, &delim, 10); + orig.tv_usec = (*delim == '.') ? strtoul(delim + 1, NULL, 10) : 0; + gettimeofday(&now, NULL); + diff = (now.tv_sec - orig.tv_sec) * 1000 + (now.tv_usec - orig.tv_usec) / 1000; + putsock("%s " P10_PONG " %s %s %d " FMT_TIME_T ".%06u", self->numeric, who, orig_ts, diff, now.tv_sec, (unsigned)now.tv_usec); +} + void irc_pass(const char *passwd) { @@ -957,8 +972,8 @@ static CMD_FUNC(cmd_ping) struct server *srv; struct userNode *un; - if(argc > 3) - irc_pong(argv[2], argv[1]); + if (argc > 3) + irc_pong_asll(argv[2], argv[3]); else if ((srv = GetServerH(origin))) irc_pong(self->name, srv->numeric); else if ((un = GetUserH(origin)))