-2

Trying to implement a customized DHCP Server which Just send an IP Address in BOOTP/DHCP Packet. Parsing of the Received DISCOVER Packet was done.After filling the structure; am unable to send OFFER Packet via sendto function. OFFER Packet seems to be a Unicast Packet where destination address is the IP that we are going to give to the Client Machine.

Bit confused on; How to throw DHCP OFFER Packet using normal DGRAM Sockets for a non existing IP Address?? Also; do I need to enable SO_BROADCAST Flag while throwing the Packet ?

Any Help is really appreciated !!!

-Thnx, DDPS.

1 Answers1

0

I think it's not OK to send using normal DGRAM(SOCK_DGRM, IPPROTO_UDP). Because the OS will first send out an ARP to locate the destination. You have to use raw socket (SOCK_RAW, IPPROTO_RAW), or even(SOCK_RAW, htons(ETH_P_ALL)). and setsockopt with IPHDRINCL. It means that you'll fill in the IP header by yourself. So the OS won't check it for you and send out as is constructed.

nouney
  • 4,363
  • 19
  • 31
Hot.PxL
  • 1,902
  • 1
  • 17
  • 30