MOO-cows Mailing List Archive
[Prev][Next][Index][Thread]
Re: connection_name() or whatever
Seth I. Rich writes:
> Ok. I want connection_name() to give me IP addresses. This could be
> because I don't want to deal with the overhead of the lookup tasks, or
> it could be for speed, or whatever. Is there a way to do this? Is
> this a difficult hack job in the server?
If you just want to avoid doing the lookups on incoming connections, it should
be pretty easy. The code in question is in net_bsd_tcp.c, at the end of
proto_accept_connection():
stream_printf(s, "%s, port %d",
lookup_name_from_addr(&address, timeout),
(int) ntohs(address.sin_port));
*name = reset_stream(s);
Replace the call to lookup_name_from_addr() with a version of this code from
the bottom of lookup_name_from_addr() (in name_lookup.c):
{
static char decimal[20];
unsigned32 a = ntohl(addr->sin_addr.s_addr);
sprintf(decimal, "%u.%u.%u.%u",
(unsigned) (a >> 24) & 0xff, (unsigned) (a >> 16) & 0xff,
(unsigned) (a >> 8) & 0xff, (unsigned) a & 0xff);
return decimal;
}
Enjoy,
Pavel
References:
Home |
Subject Index |
Thread Index