GETHOSTBYNAME()
Hi All
I am trying to find the gethostbyname() equivalent function in kernel space. Does any one know that.
The reason is...
I am using UDP to transfer data from one machine to another. It is not one time transfer. Once I get a message from machine A; I need to send some message back to Machine A from Machine B. For that I was using the following lines in user space program. I need to do the same in kernel space. Could any one help me out in this.
struct hostent *data;
struct sockaddr_in server;
int sock;
sock = socket(AF_INET, SOCK_DGRAM , 0)
/* binding and all are done here */
data = gethostbyname("158.168.1.1");
memcpy (&server.sin_addrs, data->h_addr, data->h_length); retval = sendto(sock,msg,sizeof(msg), 0, (struct sockaddr *) &server,
sizeof server);
Thanking You
Shesha
_________________________________________________________________
Cricket - World Cup 2003 http://server1.msn.co.in/msnspecials/worldcup03/ News, Views and Match Reports.
hi,
i dont think there is one similar to gethostbyname in the
kernel-space. I do think so because most of the work done by gethostbyname is based on the nameservices and is generally not required in the kernel-space. Implementing it should not be that big a problem. once you have the IP of the name server (/etc/resolve.conf???) you can always connect to it and get the IP of the given host.
Prasad.
Quoted 37 lines · shesha bhushan
Hi All
I am trying to find thegethostbyname()equivalent function in kernel space. Does any one know that.
The reason is...
I am using UDP to transfer data from one machine to another. It is not one time transfer. Once I get a message from machine A; I need to send some message back to Machine A from Machine B. For that I was using the following lines in user space program. I need to do the same in kernel space. Could any one help me out in this.struct hostent *data;
structsockaddr_inserver;
int sock;sock =
socket(AF_INET, SOCK_DGRAM , 0)/* binding and all are done here */
data =
gethostbyname("158.168.1.1");
memcpy (&server.sin_addrs,data->h_addr,data->h_length); retval = sendto(sock,msg,sizeof(msg), 0, (struct sockaddr *) &server,
sizeof server);Thanking You
Shesha_________________________________________________________________
Cricket - World Cup 2003 http://server1.msn.co.in/msnspecials/worldcup03/
News, Views and Match Reports.-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Failure is not an option
Quoted 8 lines · Prasad
hi,
i dont think there is one similar to gethostbyname in the
kernel-space. I do think so because most of the work done by gethostbyname is based on the nameservices and is generally not required in the kernel-space. Implementing it should not be that big a problem. once you have the IP of the name server (/etc/resolve.conf???) you can always connect to it and get the IP of the given host.
Implementing it is a big problem, since gethostbyname usualy means a DNS lookup. Best way to do it in kernel is call_usermode_helper('/sbin/khost') and call gethostbyname in there.
Quoted 16 lines · shesha bhushan
Quoted 15 lines
Hi All
I am trying to find thegethostbyname()equivalent function in kernel space. Does any one know that.
The reason is...
I am using UDP to transfer data from one machine to another. It is not one time transfer. Once I get a message from machine A; I need to send some message back to Machine A from Machine B. For that I was using the following lines in user space program. I need to do the same in kernel space. Could any one help me out in this.struct hostent *data;
structsockaddr_inserver;
int sock;
Quoted 5 lines
Quoted 5 lines
sock =
socket(AF_INET, SOCK_DGRAM , 0)/* binding and all are done here */
data = gethostbyname("158.168.1.1");
However as long as you are resolving IP address, you should not ask for gethostbyname. You should ask for inet_aton, which does exist (the name was mentioned in some list (linux-kernel or this one) not long ago, but I do not remember it).
Quoted 12 lines
Quoted 12 lines
memcpy (&server.sin_addrs,
data->h_addr,data->h_length); retval = sendto(sock,msg,sizeof(msg), 0, (struct sockaddr *) &server,
sizeof server);Thanking You
Shesha_________________________________________________________________
Cricket - World Cup 2003 http://server1.msn.co.in/msnspecials/worldcup03/
News, Views and Match Reports.
Quoted 15 lines
Quoted 6 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/Signature · 6 lines
Failure is not an option -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
Hello!
Quoted 1 line
data =
gethostbyname("158.168.1.1");
If you use gethostbyname only on numerical addresses, then it's fine to replace it by htonl(0x98a80101) etc.
Have a nice fortnight
Signature · 3 lines
Martin `MJ' Mares <[email protected]> http://atrey.karlin.mff.cuni.cz/~mj/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth A Bash poem: time for echo in canyon; do echo $echo $echo; done