I've tired by filling within the ng_hub node the sockaddr_in structure named
connect_addr:
connect_addr->sin_len = 16;
connect_addr->sin_family = AF_INET;
connect_addr->sin_port = htons(55056);
connect_addr->sin_addr.s_addr = htonl(IP_REMOTE);
And send it to the following node as:
*(struct sockaddr_in *)msg->data = connect_addr;
NG_MKMESSAGE(msg,NGM_GINSOCKET_COOKIE,NGM_GINSOCKET_CONNECT,sizeof(struct
sockaddr_in),M_NOWAIT);
NG_SEND_MSG_HOOK(error,node,msg,hook2,0);
But first of all, I don't know how I can convert the IP_REMOTE, which is
currently IP_REMOTE = "10.0.0.90", into a in_addr structure...
Does anyone can suggest me how to fix it?
Thank you,
Serena
On Apr 6, 2010, at 8:32 AM, serena zanetta wrote:
> But first of all, I don't know how I can convert the IP_REMOTE, which is
> currently IP_REMOTE = "10.0.0.90", into a in_addr structure...
To convert a string to an IP address kept as an in_addr, you want inet_aton(), used like so:
const char *ipstr = "127.0.0.1";
struct in_addr ip;
if (!inet_aton(ipstr, &ip))
errx(1, "can't parse IP address %s", ipstr);
[ Example borrowed from "man gethostbyaddr" ]
Regards,
--
-Chuck