On Tuesday 28 February 2006 11:32, Tomas Vilda wrote:
>
> I can see what is going on E1 D channel, it's what both sides sends to each
> other.

Fine.

> Because there is not much comments on visdn source code I can't figure out,
> how to open lapd socket to netdev

Ok, let's do one step a time. I recently restructured the sockets model to be 
even more generic and versatile.

Each socket represents a DLC. A DLC (Data Link Connection) is a virtual 
channel between a (the, in your case) TE and the NT.

A DLC is identified by the pari SAPI and TEI which comprise the DLCI (DLC 
Identifier).

The SAPI is the application identifier, 0 for q.931, 16 for X.25...

The TEI is the TE identifier, it may be dynamic in point-to-multipoint buses 
or fixed to 0 in point-to-point interfaces (PRIs are P2P).

So, limiting ourselves to P2P interfaces you need at least a socket bound to 
DLC 0/0 (SAPI=0, TEI=0), the steps are:

Create a socket:

    s = socket(PF_LAPD, SOCK_SEQPACKET, 0); /* 0 = SAPI 0 */

Bind it to the interface:

    #include <linux/lapd.h>

    char intf[] = "visdn0";
    setsockopt(s, SOL_LAPD, SO_BINDTODEVICE, intf, strlen(intf));

Bind it to the TEI 0:

    struct sockaddr_lapd sal;
    sal.sal_family = AF_LAPD;
    sal.sal_tei = 0;

    bind(s, (struct sockaddr *)&sal, sizeof(sal);

Now begin a select/poll loop on the socket and read the frames with recvmsg(2)

You may want to set the socket non-blocking as the whole q.921/q.931 is 
asynchronous:

    int oldflags;
    oldflags = fcntl(s, F_GETFL, 0);
    fcntl(s, F_SETFL, oldflags | O_NONBLOCK);

Note that U-frames will be received and transmitted with the MSG_OOB flag.

Looking at tests/traffic.c should be helpful understanding the sockets model.

End of lesson 1

Ciao :)

-- 
  Daniele Orlandi
_______________________________________________
Visdn-hackers mailing list
[email protected]
https://mailman.uli.it/mailman/listinfo/visdn-hackers

Reply via email to