[Prev][Next][Index][Thread]

# Re: connection_name() or whatever

- Date: Wed, 22 May 1996 20:29:18 PDT
- From:
- cc: MOO-Cows.PARC@xerox.com
- In-Reply-to: "Seth I. Rich's message of \"Wed, 22 May 1996 16:39:15 PDT\" <199605222339.TAA20921@kanga.INS.CWRU.Edu>ands."

    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:

- connection_name() or whatever

- From: sir@po.cwru.edu (Seth I. Rich)

- Prev: connection_name() or whatever
- Next: connection_options() inconsistency
- Index: MOO-cows
- Thread: MOO-cows

Home | Subject Index | Thread Index