Send host name string to DHCP server

52 views
Skip to first unread message

Klemen10

unread,
May 6, 2013, 3:03:39 AM5/6/13
to avr...@googlegroups.com
I can't figure out why my router D-LINK DIR-451 all the time for my AVR device shows unknown host name in DHCP client list. I am working with uhttpd-avr project which use same DHCPD code like avr-uIP.

I add lines in send_discover and send_request to send option 12 Host name which is ''KCO''. I succed one one older router, where I could actually found KCO in my DCHP client list, but not on Dlink router all the time  shows unknown.

DHCP routine also didn't work on many routers until I didn't increase UIP_BUFSIZE from 400 to 600 bytes.

#define DHCP_OPTION_HOST_NAME    12
static u8_t * add_host_name(u8_t *optptr){
   
    *optptr++ = DHCP_OPTION_HOST_NAME;
    *optptr++ = 3;
    *optptr++ = 'K';
    *optptr++ = 'C';
    *optptr++ = 'O';
   
  return optptr;
}
send_discover(void)
{
  u8_t *end;
  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;

  create_msg(m);

  end = add_msg_type(&m->options[4], DHCPDISCOVER);
  end = add_host_name(end);
  end = add_req_options(end);
  end = add_end(end);

  uip_send(uip_appdata, end - (u8_t *)uip_appdata);
}
static void
send_request(void)
{
  u8_t *end;
  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;

  create_msg(m);
 
  end = add_msg_type(&m->options[4], DHCPREQUEST);
  end = add_server_id(end);
  end = add_req_ipaddr(end);
  end = add_host_name(end);
 // end = add_osem_ena_name(end);
  end = add_end(end);
  uip_send(uip_appdata, end - (u8_t *)uip_appdata);
}

Best regards,
Klemen

Jonas Finnemann Jensen

unread,
May 8, 2013, 3:36:48 AM5/8/13
to avr...@googlegroups.com
Hi Klemen,

It's been a couple of years since I played with uIP, but as far as I can remember I was never really successful with DHCP.
I configured static IP, and used mdns for hostname resolution... This way my device had a .local name on platforms with mdns support (linux/os x, don't know about windows).
However, mdns support requires multicast which isn't supported by uIP without a patch. I posted my mDNS implementation and uIP multicast patch to [uip-users] a couple of years ago. It's also available here: http://jonasfj.dk/downloads/uip-mdns.tar.gz

Anyways, that's is just another way to do name resolution on local network, in case you are interested.


--
Regards Jonas Finnemann Jensen.



--
You received this message because you are subscribed to the Google Groups "avr-uip" group.
To unsubscribe from this group and stop receiving emails from it, send an email to avr-uip+u...@googlegroups.com.
To post to this group, send email to avr...@googlegroups.com.
Visit this group at http://groups.google.com/group/avr-uip?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Quentin Arce

unread,
Jul 3, 2013, 3:58:58 PM7/3/13
to avr...@googlegroups.com
please open a bug on the project page.
also, please assign it to dianem...@gmail.com

Thank you



--
Reply all
Reply to author
Forward
0 new messages