# DVB Network API

The DVB net device controls the mapping of data packages that are part of a transport stream to be mapped into a virtual network interface, visible through the standard Linux network protocol stack.

Currently, two encapsulations are supported:

- Multi Protocol Encapsulation (MPE)

- Ultra Lightweight Encapsulation (ULE)

In order to create the Linux virtual network interfaces, an application needs to tell to the Kernel what are the PIDs and the encapsulation types that are present on the transport stream. This is done through `/dev/dvb/adapter?/net?` device node. The data will be available via virtual `dvb?_?` network interfaces, and will be controled/routed via the standard ip tools (like ip, route, netstat, ifconfig, etc).

Data types and and ioctl definitions are defined via `linux/dvb/net.h` header.

# DVB net Function Calls

ioctl NET_ADD_IF
&manvol;

## NET_ADD_IF

Creates a new network interface for a given Packet ID.

    	int ioctl
    	int fd
    	int request
    	struct dvb_net_if *net_if

### Arguments

`fd`

  &fe_fd;

`request`

  FE_SET_TONE

`net_if`

  pointer to &dvb-net-if;

### Description

The NET_ADD_IF ioctl system call selects the Packet ID (PID) that contains a TCP/IP traffic, the type of encapsulation to be used (MPE or ULE) and the interface number for the new interface to be created. When the system call successfully returns, a new virtual network interface is created.

The &dvb-net-if;::ifnum field will be filled with the number of the created interface.

&return-value-dvb;

### struct dvb_net_if description

#### struct dvb_net_if

&cs-def;
ID | Description
--- | ---
pid | Packet ID (PID) of the MPEG-TS that contains data
ifnum | number of the DVB interface.
feedtype | Encapsulation type of the feed. It can be: `DVB_NET_FEEDTYPE_MPE` for MPE encoding or `DVB_NET_FEEDTYPE_ULE` for ULE encoding.

ioctl NET_REMOVE_IF
&manvol;

## NET_REMOVE_IF

Removes a network interface.

    	int ioctl
    	int fd
    	int request
    	int ifnum

### Arguments

`fd`

  &fe_fd;

`request`

  FE_SET_TONE

`net_if`

  number of the interface to be removed

### Description

The NET_REMOVE_IF ioctl deletes an interface previously created via &NET-ADD-IF;.

&return-value-dvb;
ioctl NET_GET_IF
&manvol;

## NET_GET_IF

Read the configuration data of an interface created via &NET-ADD-IF;.

    	int ioctl
    	int fd
    	int request
    	struct dvb_net_if *net_if

### Arguments

`fd`

  &fe_fd;

`request`

  FE_SET_TONE

`net_if`

  pointer to &dvb-net-if;

### Description

The NET_GET_IF ioctl uses the interface number given by the &dvb-net-if;::ifnum field and fills the content of &dvb-net-if; with the packet ID and encapsulation type used on such interface. If the interface was not created yet with &NET-ADD-IF;, it will return -1 and fill the `errno` with `EINVAL` error code.

&return-value-dvb;