I am trying to set the ip & hostname for a netif as below in
tcpip_thread() as below:
tcpip_thread()
{
................
................
rtl8139_netif = netif_find("ne0");
rtl8139_netif->ip_addr.addr = 0x0101a8c0;
rtl8139_netif->netmask.addr = 0x00ffffff;
rtl8139_netif->gw.addr = 0xfe01a881;
rtl8139_netif->hostname = "mylwip";
netif_set_default(rtl8139_netif);
netif_set_up(rtl8139_netif);
...................
...................
}
I am trying to use lwip in a lightweight kernel called kitten running
in a VM. When the VM comes up I could ping it using the statically
defined IP but not using hostname.
I checked on the lwip archive for previous discussions on this topic.
Few threads adviced to use the contrib/apps/netbios/netbios.c file.
They asked to set NETBIOS_LWIP_NAME to the host name and call
netbios_init().
I have set the NETBIOS_LWIP_NAME to the required hostname and called
netbios_init() after tcpip_init(). But still I could not ping using
hostname but I can ping using statically defined IP. Kindly let me
know what I am missing here?
Thanks,
karthik
_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users
Simon
Thanks for your inputs Simon.
Regards,
karthik
Another method would be mDNS, but that's not available yet for lwIP
(although there's a task for that on savannah, already) and you need
special software for unix, too.
Simon
If SAMBA is installed on the unix machine, you can use the 'nmblookup'
command to look up a NetBIOS name.
I don't know if later versions are any better, but the one I have (supplied
with Mac OS X 10.6, Samba version 3.0.28a-apple) doesn't have any options to
tidy up its output in a way which allows it to be easily used in conjunction
with
other commands, so you need to do some postprocessing with other tools.
Its normal output looks like this, if it finds the name on the first
available network interface:
% nmblookup foo
querying name on 192.168.0.255
192.168.0.17 foo<00>
If it can't find the name, it does this:
% nmblookup foo
querying name on 192.168.0.255
querying name on 172.16.191.255
name_query failed to find name foo
If you assume the name lookup will be successful, this trick can be used to
extract the IP address:
% nmblookup foo | tail -1 | sed 's/ .*//'
192.168.0.17
(tail -1 gets the last line, and sed with that argument strips off
everything on the line
beginning with the first space.)
If the name is not found, it returns
% nmblookup bar | tail -1 | sed 's/ .*//'
name_query
I'm sure a more seasoned unix shell scripter can turn this into an alias
with a parameter, or come up with a tidier way to extract the first "word"
from the last line of the output of nmblookup.
You can combine the command with another one by using backticks:
% ping `nmblookup foo | tail -1 | sed 's/ .*//'`
PING 192.168.0.17 (192.168.0.17): 56 data bytes
64 bytes from 192.168.0.17: icmp_seq=0 ttl=128 time=0.528 ms
64 bytes from 192.168.0.17: icmp_seq=1 ttl=128 time=0.598 ms
64 bytes from 192.168.0.17: icmp_seq=2 ttl=128 time=0.572 ms
^C
--- 192.168.0.17 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.528/0.566/0.598/0.029 ms
(A failed lookup will attempt to ping 'name_query', which isn't likely to
achieve much.)
Thanks,
Karthik