Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Tun/Tap driver for qnx: (9 Items)
   
Tun/Tap driver for qnx  
Hi there,

  I have to write a Tap interface to send/receive ipv6 packets through ethernet via raw sockets/libpcap. I followed this
 link: http://forum.kpda.ru/index.php/topic,179.0.html and I found that "devnp-qtap.so" library is missing. Also there 
is no cloning device "/dev/tap" or "/dev/net/tun". Please point out where to get this library and an example code for 
creating a tap interface on qnx.
Re: Tun/Tap driver for qnx  
First of all there are multiple ways of sending and receiving raw packets:
1) Raw sockets
2) libpcap (which uses BPF) or BPF itself
3) tun/tap

You have mentioned all 3 in your message.

You also don't mention which version of QNX you are on and whether you are up to date on your io-pkt versions. Later 
versions of io-pkt have tun/tap support built in.

Regards,
Nick.
Re: Tun/Tap driver for qnx  
Hi Nick,

  We are using qnx660 with io-pkt-v6-hc. It seems it doesn't have the tun/tap support.
Re: Tun/Tap driver for qnx  
1.       We are using QNX 6.6 on ARMv7 based board

2.       We are creating a tap interface using “ifconfig tap0 create”

3.       We also assign IPv4 address using “ifconfig tap0 10.0.0.1 up”

4.       We are referring following links provided by QNX technical article
            a.       http://www.qnx.com/developers/articles/rel_5189_46.html 
            b.       http://netbsd.gw.com/cgi-bin/man-cgi?tap++NetBSD-current

5.       Based on the above article, we expect to see /dev/tap0 but we don’t see it

6.       Our aim is to have a program that
            a.       opens /dev/tap0
            b.       capture packet using read of /dev/tap0
            c.       inject packet using write to /dev/tap0
 
Appreciate any help to achieve capture/inject using tap interface on QNX.
Re: Tun/Tap driver for qnx  
The tap behaviour has changed since 6.6.0 shipped with a PSP. What does "use -i io-pkt-v4-hc" show?

If you are running the original 6.6.0 shipping io-pkt then in the /dev directory there should be tap, tap0 tap1 tap2 
tap3 already created and when you ifconfig tap0 create then you should be able to capture and inject packets on /dev/
tap0

If you are up to date on your patches then the later version of io-pkt just creates a /dev/tap entry, but doing the 
ifconfig tap0 create will create the /dev/tap0 entry.

The /dev/tap entry is a cloner interface that can be used for creating entries, but in your case it's probably easier to
 just do it with the ifconfig tap0 create and then start your app afterwards.

I'm assuming that you are only running one copy of io-pkt. If you are running multiple copies with the prefix option on 
io-pkt requiring the SOCK environment variable on your ifconfig, then be aware that the /dev directory you are looking 
for is under your prefix directory.
Re: Tun/Tap driver for qnx  
Hi nick,
     Thank you for your quick response. I am using "io-pkt-V6-hc" driver. 

# use -i io-pkt-v6-hc
"QNX_BUILDID=(GNU)e95deb846dd9d566e9778f9582863b43
NAME=io-pkt-v6-hc
DESCRIPTION=TCP/IP protocol module.
DATE=2016/02/10-11:08:06-EST
STATE=experimental
HOST=gusbuild10
USER=builder
VERSION=897
TAGID=PSP_networking_br660_be660

As you suggested, I could find the tap interface /alt2/dev/tap. 

I wrote an application 
- opening this tap interface
- sending ioctl with TAPGIFNAME
- read on the tap fd in an infinite loop

Code snippet for this, 
tap_fd = open("/alt2/dev/tap", O_RDONLY);
.
.
ifr.ifr_flags = TAPGIFNAME;
strncpy(ifr.ifr_name, "tap0", IFNAMSIZ);
ret = ioctl(tap_fd, TAPGIFNAME, &ifr);
.
.
system("ifconfig tap0 up");
while (1) {
  ret = read(tap_fd, tap_buf, sizeof(tap_buf));
  .
  .
  print_data()
}

After running this app in background, I'm assigning a IPv6 IP (2001::2/64) to the tap0 interface. 


In another application (running on same board), I'm opening an IPv6 UDP socket and sending datagram packets to the tap0 
interface's IP.
But I'm not receiving any packets in my first application 'read'ing on the tap0 interface.


Is it not a valid scenario? 
What could be the posible issue in this? Appreciate any help in this regard. 

Thank you,
Jashitha
Re: Tun/Tap driver for qnx  
Hi Jashitha,
You need to send traffic to a host address that is on the subnet of the tap interface, but not to the address of the tap
 interface itself. Traffic to addresses that are the host are sent via the loopback interface back in to the network 
stack itself.

Think about an Ethernet interface, if you ping that address from that host then the traffic doesn't actually go out on 
the wire. You need to ping something out on the same subnet for traffic to be sent on the wire. The same applies to the 
tap interface.

Regards,
Nick.
Re: Tun/Tap driver for qnx  
Hi Nick,
Thank you for your quick response.

 I am using "io-pkt-v6-hc" driver. I am trying to tap the ipv6 udp packets through this.
 
 I am reading from "/alt2/dev/tap" and printing it to a file.
 
 However, I receive only 4 ICMPv6 packets. I don't see any IPv6 UDP packets. 
 
 Wireshark is able to capture the IPv6 UDP packets. They are being mulitcasted.
 
 Please let me know the following:
 
 1. Is the tap-cloning device that I am using correct ==> "/alt2/dev/tap"
 I don't find any other tap-cloning device in "io-pkt-v6-hc" driver
 
 2. Why do I always see only 4 packets in my tap0 device?
 
 Please let me know if there is any problem with what I am trying.

Thanks,
Jashitha
Re: Tun/Tap driver for qnx  
Hi Jashitha,
As these are multicast packets, you will need to join the group on the 
interface for the packets to be received.

I suspect the ICMPv6 you see are the normal DAD etc packets.
Regards,
Nick.

On 2017-07-04 09:02 AM, jashitha kp wrote:
> Hi Nick,
> Thank you for your quick response.
> 
>   I am using "io-pkt-v6-hc" driver. I am trying to tap the ipv6 udp packets through this.
>   
>   I am reading from "/alt2/dev/tap" and printing it to a file.
>   
>   However, I receive only 4 ICMPv6 packets. I don't see any IPv6 UDP packets.
>   
>   Wireshark is able to capture the IPv6 UDP packets. They are being mulitcasted.
>   
>   Please let me know the following:
>   
>   1. Is the tap-cloning device that I am using correct ==> "/alt2/dev/tap"
>   I don't find any other tap-cloning device in "io-pkt-v6-hc" driver
>   
>   2. Why do I always see only 4 packets in my tap0 device?
>   
>   Please let me know if there is any problem with what I am trying.
> 
> Thanks,
> Jashitha
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post117843
> To cancel your subscription to this discussion, please e-mail drivers-networking-unsubscribe@community.qnx.com
>