lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 24 Nov 2008 10:56:23 +0100
From:	"Miguel Ángel Álvarez" <gotzoncabanes@...il.com>
To:	"Krzysztof Halasa" <khc@...waw.pl>
Cc:	"Francois Romieu" <romieu@...zoreil.com>, netdev@...r.kernel.org
Subject: Re: How to use ixp4xx_hss (or generic-hdlc?)

Hi

2008/11/22 Krzysztof Halasa <khc@...waw.pl>:
> "Miguel Ángel Álvarez" <gotzoncabanes@...il.com> writes:
>
>> I have also taken a look to the code of sethdlc to see how the socket
>> to the interface was set. He made "sock = socket(PF_INET, SOCK_DGRAM,
>> IPPROTO_IP);" which I suppose does not care a lot because sethdlc only
>> uses the socket to send ioctls, and not any data transfers.
>
> This is a bit different matter, though you may need it to get ifr_index.
>
Sure. You are right.

>> However, in my case, I need to send data in a non-IP world using the
>> interface. So... Is this the way I should open the socket? Would this
>> encapsulate my data in hdlc before sending it to the interface?
>>
>> if I open the socket using sock = socket(PF_PACKET, SOCK_RAW,
>> htons(ETH_P_ALL)); I can send data into the interface, but it is just
>> sent as raw data (which is logic).
>
> It should be bit-stuffed and encapsulated in HDLC frames (flags etc),
> assuming a real HDLC device.
>
> You may need to prepend some headers, though.
>

I am not sure of having understood you. The buffer I send using sendto
should be just the payload and the generic-hdlc (or the hardware)
encapsulates it in an hdlc frame, or should I prepare the whole frame?

> The basic idea is:
>
>        int sock;
>        struct ifreq ifr;
>        struct sockaddr_ll addr;
>
>        strcpy(ifr.ifr_name, "hdlc0");
>        if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0)
>                error();
>        if (ioctl(sock, SIOCGIFINDEX, &ifr))
>                error();
>        close(sock);
>
>        if ((sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
>                error();
>
>        memset(&addr, 0, sizeof(addr));
>        addr.sll_family = AF_PACKET;
>        addr.sll_protocol = htons(ETH_P_ALL);
>        addr.sll_ifindex = ifr.ifr_ifindex;
> then:
>        sendto(sock, packet_data, packet_size, 0, &addr, sizeof(addr)) < 0)
>
> for RX:
>        if (bind(sock, &addr, sizeof(addr)) < 0)
>                error();
> then:
>        recvfrom(sock, buffer, max_packet_size, 0, &addr, &addr_len)

I took a little different approach, using the same PF_PACKET socket to
obtain the ifr_ifindex, but in any case using your method or "my"
method, and activating the debugging in ixp4xx_hss, when I do a two
byte (0x30 0x31) sendto, the traces in debug_pkt give me:

1970/01/01,00:00:47 (none) user.debug kernel: hdlc0: hss_hdlc_xmit(2)
<7> 30<7>31<7>

I cannot test the real hardware output in the lines at the moment, so
I do not know if this is what I was supposed to obtain, or not
(talking about the hdlc headers and trailers...).

Thanks

Miguel Ángel
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ