diff options
author | Mark Purcell <msp@debian.org> | 2008-06-22 11:00:40 +1000 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:42 +0200 |
commit | 891c51ff368ed700dec6025eeb47ce4d96f76418 (patch) | |
tree | 3729664829e4faa691d403274f38eb10890b533c /util/dvbnet | |
parent | 1c6e1f28f54ec2606c23936c1d8689f2be55a86c (diff) | |
parent | ab959d7b4194715870128e616b8e29d4a101e488 (diff) | |
download | linux-dvb-apps-a966623153d5c69ef1565422644280751ce04112.tar.gz |
Imported Debian patch 1.1.1+rev1207-1debian/1.1.1+rev1207-1
Diffstat (limited to '')
-rw-r--r-- | util/dvbnet/Makefile | 32 | ||||
-rw-r--r-- | util/dvbnet/dvbnet.c | 106 | ||||
-rw-r--r--[-rwxr-xr-x] | util/dvbnet/net_start.pl | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | util/dvbnet/net_start.sh | 0 | ||||
-rw-r--r-- | util/dvbnet/version.h.in | 1 |
5 files changed, 63 insertions, 77 deletions
diff --git a/util/dvbnet/Makefile b/util/dvbnet/Makefile index 187dee2..c9ebab9 100644 --- a/util/dvbnet/Makefile +++ b/util/dvbnet/Makefile @@ -1,29 +1,15 @@ +# Makefile for linuxtv.org dvb-apps/util/dvbnet -CC = gcc -CFLAGS = -g -O2 -MD -Wall -I. -I../../include -LFLAGS = +binaries = dvbnet -OBJS = dvbnet.o -TARGET = dvbnet -DESTDIR = /usr/local/bin/ +inst_bin = $(binaries) -all: version.h $(TARGET) +CPPFLAGS += -I../../lib +LDFLAGS += -L../../lib/libdvbapi +LDLIBS += -ldvbapi -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ +.PHONY: all -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) $(LFLAGS) - -version.h: - printf '#define VERSION_INFO "%s (Build %s)"\n' \ - "`cat $@.in`" "`date +'%a %b %d %X %Y'`" > $@ - -install: all - install -m 755 $(TARGET) $(DESTDIR) - -clean: - rm -f $(TARGET) $(OBJS) version.h core* *~ *.d - --include $(wildcard *.d) dummy +all: $(binaries) +include ../../Make.rules diff --git a/util/dvbnet/dvbnet.c b/util/dvbnet/dvbnet.c index a58f156..53aa719 100644 --- a/util/dvbnet/dvbnet.c +++ b/util/dvbnet/dvbnet.c @@ -1,26 +1,29 @@ -/* +/* * dvbnet.c * * Copyright (C) 2003 TV Files S.p.A * L.Y.Mesentsev <lymes@tiscalinet.it> * + * Ported to use new DVB libraries: + * Copyright (C) 2006 Andrew de Quincey <adq_dvb@lidskialf.net> + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html - * + * */ #include <stdio.h> @@ -33,19 +36,10 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/ioctl.h> - -#include <linux/dvb/net.h> -#include <version.h> - -#ifndef VERSION_INFO -#define VERSION_INFO "1.1.1" -#endif +#include <libdvbapi/dvbnet.h> #define OK 0 #define FAIL -1 -#define DVB_NET_DEVICE "/dev/dvb/adapter%d/net%d" -#define DVB_NET_DEVICES_MAX 10 -#define IFNAME_DVB "dvb" enum Mode { @@ -57,14 +51,15 @@ enum Mode { static int adapter = 0; static int netdev = 0; -static struct dvb_net_if net_data; static void hello(void); static void usage(char *); static void parse_args(int, char **); -static int queryInterface(int, int); +static void queryInterface(int); -static char dvb_net_device[40]; +int ifnum; +int pid; +int encapsulation; int main(int argc, char **argv) { @@ -74,40 +69,36 @@ int main(int argc, char **argv) parse_args(argc, argv); - sprintf(dvb_net_device, DVB_NET_DEVICE, adapter, netdev); - - printf("Device: %s\n", dvb_net_device); - - if ((fd_net = open(dvb_net_device, O_RDWR | O_NONBLOCK)) < 0) { - fprintf(stderr, "Error: couldn't open device %s: %d %m\n", - dvb_net_device, errno); + if ((fd_net = dvbnet_open(adapter, netdev)) < 0) { + fprintf(stderr, "Error: couldn't open device %d: %d %m\n", + netdev, errno); return FAIL; } switch (op_mode) { case DEL_INTERFACE: - if (ioctl(fd_net, NET_REMOVE_IF, net_data.if_num)) + if (dvbnet_remove_interface(fd_net, ifnum)) fprintf(stderr, "Error: couldn't remove interface %d: %d %m.\n", - net_data.if_num, errno); + ifnum, errno); else printf("Status: device %d removed successfully.\n", - net_data.if_num); + ifnum); break; case ADD_INTERFACE: - if (ioctl(fd_net, NET_ADD_IF, &net_data)) + if ((ifnum = dvbnet_add_interface(fd_net, pid, encapsulation)) < 0) fprintf(stderr, "Error: couldn't add interface for pid %d: %d %m.\n", - net_data.pid, errno); + pid, errno); else printf ("Status: device dvb%d_%d for pid %d created successfully.\n", - adapter, net_data.if_num, net_data.pid); + adapter, ifnum, pid); break; case LST_INTERFACE: - queryInterface(fd_net, 0); + queryInterface(fd_net); break; default: @@ -120,39 +111,48 @@ int main(int argc, char **argv) } -int queryInterface(int fd_net, int dev) +void queryInterface(int fd_net) { - struct dvb_net_if data; - int IF, nIFaces = 0, ret = FAIL; + int IF, nIFaces = 0; + char *encap; printf("Query DVB network interfaces:\n"); printf("-----------------------------\n"); - for (IF = 0; IF < DVB_NET_DEVICES_MAX; IF++) { - data.if_num = IF; - if (ioctl(fd_net, NET_GET_IF, &data)) + for (IF = 0; IF < DVBNET_MAX_INTERFACES; IF++) { + uint16_t _pid; + enum dvbnet_encap _encapsulation; + if (dvbnet_get_interface(fd_net, IF, &_pid, &_encapsulation)) continue; - if (dev == data.if_num) - ret = OK; + encap = "???"; + switch(_encapsulation) { + case DVBNET_ENCAP_MPE: + encap = "MPE"; + break; + case DVBNET_ENCAP_ULE: + encap = "ULE"; + break; + } printf("Found device %d: interface dvb%d_%d, " - "listening on PID %d\n", - IF, adapter, data.if_num, data.pid); + "listening on PID %d, encapsulation %s\n", + IF, adapter, IF, _pid, encap); nIFaces++; } printf("-----------------------------\n"); printf("Found %d interface(s).\n\n", nIFaces); - return ret; } void parse_args(int argc, char **argv) { - char c, *s; + int c; + char *s; op_mode = UNKNOWN; - while ((c = getopt(argc, argv, "a:n:p:d:lvh")) != EOF) { + encapsulation = DVBNET_ENCAP_MPE; + while ((c = getopt(argc, argv, "a:n:p:d:lUvh")) != EOF) { switch (c) { case 'a': adapter = strtol(optarg, NULL, 0); @@ -161,16 +161,19 @@ void parse_args(int argc, char **argv) netdev = strtol(optarg, NULL, 0); break; case 'p': - net_data.pid = strtol(optarg, NULL, 0); + pid = strtol(optarg, NULL, 0); op_mode = ADD_INTERFACE; break; case 'd': - net_data.if_num = strtol(optarg, NULL, 0); + ifnum = strtol(optarg, NULL, 0); op_mode = DEL_INTERFACE; break; case 'l': op_mode = LST_INTERFACE; break; + case 'U': + encapsulation = DVBNET_ENCAP_ULE; + break; case 'v': exit(OK); case 'h': @@ -187,12 +190,12 @@ void usage(char *prog_name) { fprintf(stderr, "Usage: %s [options]\n", prog_name); fprintf(stderr, "Where options are:\n"); - fprintf(stderr, "\t-a AD : Adapter card AD (default 0)\n"); - fprintf(stderr, "\t-n NET : Net demux NET (default 0)\n"); + fprintf(stderr, "\t-a AD : Adapter card (default 0)\n"); + fprintf(stderr, "\t-n DD : Demux (default 0)\n"); fprintf(stderr, "\t-p PID : Add interface listening on PID\n"); - fprintf(stderr, "\t-d NUM : Remove interface dvbAD_NUM\n"); - fprintf(stderr, - "\t-l : List currently available interfaces\n"); + fprintf(stderr, "\t-d NUM : Remove interface NUM\n"); + fprintf(stderr, "\t-l : List currently available interfaces\n"); + fprintf(stderr, "\t-U : use ULE framing (default: MPE)\n" ); fprintf(stderr, "\t-v : Print current version\n\n"); } @@ -200,6 +203,5 @@ void usage(char *prog_name) void hello(void) { printf("\nDVB Network Interface Manager\n"); - printf("Version %s\n", VERSION_INFO); printf("Copyright (C) 2003, TV Files S.p.A\n\n"); } diff --git a/util/dvbnet/net_start.pl b/util/dvbnet/net_start.pl index 71e6367..f31ba22 100755..100644 --- a/util/dvbnet/net_start.pl +++ b/util/dvbnet/net_start.pl @@ -22,4 +22,3 @@ sub dvbnet system("/sbin/ifconfig $DEV_NAME"); } - diff --git a/util/dvbnet/net_start.sh b/util/dvbnet/net_start.sh index b155989..b155989 100755..100644 --- a/util/dvbnet/net_start.sh +++ b/util/dvbnet/net_start.sh diff --git a/util/dvbnet/version.h.in b/util/dvbnet/version.h.in deleted file mode 100644 index d0a6e20..0000000 --- a/util/dvbnet/version.h.in +++ /dev/null @@ -1 +0,0 @@ -1.1.0-TVF |