Date: 26 Jan 1998 11:04:59 +0100 From: dag-erli@ifi.uio.no (Dag-Erling Coidan Smørgrav) To: marc@bowtie.nl Cc: hackers@FreeBSD.ORG Subject: Re: Is it possible to .. Message-ID: <xzpg1mbft4k.fsf@gjallarhorn.ifi.uio.no> In-Reply-To: Marc van Kempen's message of "Mon, 26 Jan 1998 10:35:11 %2B0100" References: <199801260935.KAA27363@bowtie.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
Marc van Kempen <marc@bowtie.nl> writes: > send/receive udp (broadcast) packets when you don't know > your IP nr. yet? It must be possible since bootp does it, > but how? According to RFC 951 (Bootstrap protocol), a client which does not know its own IP address sets the source address of the bootrequest to 0.0.0.0. The server sets the yiaddr (Your Ip ADDRess) field in the bootreply packet to the client's IP address. The reply is sent to the broadcast address at a reserved port so that other hosts that see the bootreply are not confused by it. Obviously, if you know the underlying hardware protocol, you can do better than that. In most cases (take Ethernet as an example), the server shouldn't need to actually broadcast the bootreply, since it knows the MAC address of the requesting host; but the destination IP address should still be set to the broadcast address, otherwise the client will drop the packet as 'not for me'. If what you really meant to ask is "how do I use a network interface before it's configured", you can always ifconfig with a bogus address (0.0.0.0), enable promiscuous mode, and then use bpf to bypass the TCP/IP stack and "roll your own packets". Again, this requires knowledge of the underlying hardware protocol. Ethernet should be simple enough; read /sys/net/ethernet.h and /sys/net/if_ethersubr.c. -- * Finrod (INTJ) * Unix weenie * dag-erli@ifi.uio.no * cellular +47-92835919 * RFC1123: "Be liberal in what you accept, and conservative in what you send"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpg1mbft4k.fsf>