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]
Message-ID: <m37i6wslpr.fsf@maximus.localdomain>
Date:	Sat, 22 Nov 2008 00:28:16 +0100
From:	Krzysztof Halasa <khc@...waw.pl>
To:	Miguel Ángel Álvarez <gotzoncabanes@...il.com>
Cc:	"Francois Romieu" <romieu@...zoreil.com>, netdev@...r.kernel.org
Subject: Re: How to use ixp4xx_hss (or generic-hdlc?)

"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.

> 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.

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)
-- 
Krzysztof Halasa
--
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