[asterisk-dev] Implementation using libpri and socketpair()
Paulo Garcia
paulo.astdev at gmail.com
Wed Mar 14 04:34:02 MST 2007
Hi,
just for feedback.
I choose to create the fifo kernel module to accomplish the task since I
found more suitable to my needs. If someone wants to check this kernel
module, it is available at
http://dgvchannel.cvs.sourceforge.net/dgvchannel/unstable/fifodev/.
I'm testing it now and probably needs improvements but I think it is very
stable and solve the intermixing problem.
Thanks for all
Paulo Garcia
On 2/8/07, Christian <crich-ml at beronet.com> wrote:
>
> yeah my approach works only if you can modify the "write" as well.
>
> the only way i know which would definitely work is: you need to write a
> kernel module which creates a char device, there each write results in a
> single "copy_from_user" and you won't have intermixing of packets. then
> you could send the packet either directly to your hardware or you use
> another character device to send it up to your process which will also
> send the exact amount of data, like:
>
> /dev/packetloopIN + /dev/packetloopOUT
>
>
> but that's probably as much work as interpreting the q.921 header ;-)
>
>
>
>
>
>
> Paulo Garcia wrote:
> > Hi Christian,
> >
> > I think I understand what you are saying but the data read comes
> > directly from libpri and I cannot realize how can I put some data
> > before the package, because I saw that into libpri there are two
> > writes to my socket file descriptor but in the read part (inside my
> > program thread) there are only one read with both packets togheter.
> >
> > After I receive the packet from libpri, I can send it directly to my
> > card and the packet arrives at other side perfectly since my hardware
> > already prepared to do it. The only problem is when I get two packets
> > joint togheter.
> >
> > I´m thinking if using another kind of interprocess communication I can
> > avoid this socketpair behaviour.
> >
> > Thanks in advance!
> >
> >
> > Paulo
> >
> >
> >
> >
> > On 2/7/07, * Christian* <crich-ml at beronet.com
> > <mailto:crich-ml at beronet.com>> wrote:
> >
> > Hi Paulo,
> >
> > i have had similar issues with a quite different use-case ;-) the
> > problem is that you need to frame your messages and transmit these
> > frames instead of the transparent data. you can use hdlc for
> > example, i
> > believe there are some simple implementations out there, but that is
> > sort of overkill. The most simple thing would be to just put the
> > length
> > of the frame before each packet, the length could be of maximum 4
> > bytes,
> > then do a read of just as much bytes which you know from this
> > length, like:
> >
> > uint32 len;
> > char buf[1024];
> > read(fd, &len, 4);
> > read(fd,buf,len);
> >
> > then you can be sure that you've got only this single frame in buf,
> > (well if read returns less then len you need to reread of course).
> >
> > Besides that i have somewhere read that you can set a HDLC
> > Property via
> > fcntl to terminals, but i haven't had ever the time to test that
> out.
> >
> >
> > cheers,
> >
> > christian
> >
> >
> > Paulo Garcia wrote:
> > > Hi,
> > >
> > > in my own channel, I'm implementing ISDN support using Libpri. The
> > > implementation is completely independent from zaptel then I'm
> > trying
> > > to do all communications between my hardware and libpri using
> > > socketpair function.
> > >
> > > The idea is to create a socketpair, passing fd[0] to pri_new
> > function
> > > and writing to fd[1] to pass data to libpri. So far so good...
> > >
> > > To receive data from libpri, I have a thread checking for all file
> > > descriptors fd[1] using select() function and when I receive
> > > something, I pass it to my card. This approach also works well but
> > > sometimes I receive two messages (from libpri) in only one read()
> > > call. I think this is because of libpri writes two messages so
> fast
> > > then when the read is called, there are already two messages in
> > socket
> > > buffer...
> > >
> > > How can I avoid this behavior? Maybe using another way different
> of
> > > socketpair ? This communication will be used only inside the same
> > > process, between different threads.
> > >
> > > Any path or idea will be appreciated.
> > >
> > >
> > > Regards
> > >
> > >
> > > Paulo Garcia
> > >
> >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > --Bandwidth and Colocation provided by Easynews.com
> > <http://Easynews.com> --
> > >
> > > asterisk-dev mailing list
> > > To UNSUBSCRIBE or update options visit:
> > > http://lists.digium.com/mailman/listinfo/asterisk-dev
> > >
> >
> > _______________________________________________
> > --Bandwidth and Colocation provided by Easynews.com
> > <http://Easynews.com> --
> >
> > asterisk-dev mailing list
> > To UNSUBSCRIBE or update options visit:
> > http://lists.digium.com/mailman/listinfo/asterisk-dev
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > --Bandwidth and Colocation provided by Easynews.com --
> >
> > asterisk-dev mailing list
> > To UNSUBSCRIBE or update options visit:
> > http://lists.digium.com/mailman/listinfo/asterisk-dev
> >
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20070314/b499f18f/attachment-0001.htm
More information about the asterisk-dev
mailing list