[g-a-devel]gnopernicus network code ...



Hi there,

	Bill asked me to look at the Gnopernicus network code, had a brief
poke; this:

	srcore/srbrl.c

    h = gethostbyname(brlip);
...   
    remote_braille_addr.sin_family = h->h_addrtype;
   
    memcpy((char *) &remote_braille_addr.sin_addr.s_addr,
                  h->h_addr_list[0], h->h_length);

    remote_braille_addr.sin_port = htons(brlport);


	But 

struct sockaddr_in remote_braille_addr;

	In linc we turn on IPv6 resolution if we can, and it's not a good idea
to turn it off. The h->h_length will then be a 16 bytes, and the
h_addr_list[0] member a struct sockaddr_in6 - so you start scribbling
all over addresses nearby.

	Similarly:

rc = sendto(rsd, sendtmp, sizeof(sendtmp), 0,
		    (struct sockaddr *) &remote_braille_addr,
		    sizeof(remote_braille_addr));

	Isn't going to work; the size field / address will be horribly mangled.

	So - this may explain why there are issues post initialization of linc
on some systems.

	There are several ways around the problem; most straightforwardly,
allocating an address structure for the correct address size; etc.

	You could (profitably) re-use the linc code that does this already,
with something like:

	proto = linc_protocol_find ("IPv4");
	addr = (struct sockaddr_in *)linc_protocol_get_sockaddr (
		proto, "127.0.0.1", "1047", &saddr_len);

	Which will tie you to IPv4; see linc/src/linc-protocols.c for the code.

	Alternatively just do the allocation yourself,

	HTH,

		Michael.

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]