Thursday, 29 December 2016

Re: Using the dummy0 interface for a local-only service to be broadcasted by Avahi

On 12/29/2016 04:53 PM, Stéphane Graber wrote:
> On Thu, Dec 29, 2016 at 04:38:05PM -0200, Till Kamppeter wrote:
>> Thank you. I want to bind with the bind(2) function in C. How do I supply
>> the interface here or what function do I need to call instead?
>> Till
> #include <arpa/inet.h>
> #include <net/if.h>
> int main(int argc, char *argv[])
> {
> int s;
> struct sockaddr_in6 ip6;
> // Basic inet6 socket
> s = socket(AF_INET6, SOCK_DGRAM, 0);
> // Initialize the ip6 struct
> ip6.sin6_family=AF_INET6;
> ip6.sin6_addr=in6addr_any;
> ip6.sin6_port=htons(1234);
> ip6.sin6_scope_id=if_nametoindex("ippusbxd");
> inet_pton(AF_INET6, "fe80::3004:2dff:feb6:b5c7", (void *)&ip6.sin6_addr.s6_addr);
> // Bind
> bind(s, (struct sockaddr *)&ip6, sizeof(struct sockaddr_in6));
> }

This works now (had to add the
"ip6.sin6_scope_id=if_nametoindex("ippusbxd");"). So ippusbxd is running
now mirroring the printer onto fe80::e828:7eff:fe19:9962, port 60000 on
the ippusbxd interface.

This would especially mean that I can access the printer's web admin
interface by pointing a browser to this address so I try the simple
command line browser wget:

till@till-x1carbon:~$ wget

http://[fe80::e828:7eff:fe19:9962%ippusbxd]:60000/: Invalid IPv6 numeric

till@till-x1carbon:~$ wget http://[fe80::e828:7eff:fe19:9962]:60000/

--2016-12-29 17:07:43-- http://[fe80::e828:7eff:fe19:9962]:60000/
Connecting to [fe80::e828:7eff:fe19:9962]:60000... failed: Invalid argument.

till@till-x1carbon:~$ wget

http://[fe80::e828:7eff:fe19:9962]%ippusbxd:60000/: Invalid host name.

till@till-x1carbon:~$ wget

http://[fe80::e828:7eff:fe19:9962]:60000%ippusbxd/: Bad port number.

till@till-x1carbon:~$ wget http://fe80::e828:7eff:fe19:9962:60000/

http://fe80::e828:7eff:fe19:9962:60000/: Bad port number.

till@till-x1carbon:~$ wget http://fe80::e828:7eff:fe19:9962%ippusbxd:60000/

http://fe80::e828:7eff:fe19:9962%ippusbxd:60000/: Bad port number.



ubuntu-devel mailing list
Modify settings or unsubscribe at: