From ab959d7b4194715870128e616b8e29d4a101e488 Mon Sep 17 00:00:00 2001 From: etobi Date: Tue, 3 Sep 2013 09:48:41 +0200 Subject: Imported Upstream version 1.1.1+rev1207 --- lib/libdvbapi/dvbnet.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 lib/libdvbapi/dvbnet.c (limited to 'lib/libdvbapi/dvbnet.c') diff --git a/lib/libdvbapi/dvbnet.c b/lib/libdvbapi/dvbnet.c new file mode 100644 index 0000000..f0f08f9 --- /dev/null +++ b/lib/libdvbapi/dvbnet.c @@ -0,0 +1,104 @@ +/* + * libdvbnet - a DVB network support library + * + * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dvbnet.h" + +int dvbnet_open(int adapter, int netdeviceid) +{ + char filename[PATH_MAX+1]; + int fd; + + sprintf(filename, "/dev/dvb/adapter%i/net%i", adapter, netdeviceid); + if ((fd = open(filename, O_RDWR)) < 0) { + // if that failed, try a flat /dev structure + sprintf(filename, "/dev/dvb%i.net%i", adapter, netdeviceid); + fd = open(filename, O_RDWR); + } + + return fd; +} + +int dvbnet_add_interface(int fd, uint16_t pid, enum dvbnet_encap encapsulation) +{ + struct dvb_net_if params; + int status; + + memset(¶ms, 0, sizeof(params)); + params.pid = pid; + + switch(encapsulation) { + case DVBNET_ENCAP_MPE: + params.feedtype = DVB_NET_FEEDTYPE_MPE; + break; + + case DVBNET_ENCAP_ULE: + params.feedtype = DVB_NET_FEEDTYPE_ULE; + break; + + default: + return -EINVAL; + } + + status = ioctl(fd, NET_ADD_IF, ¶ms); + if (status < 0) + return status; + return params.if_num; +} + +int dvbnet_get_interface(int fd, int ifnum, uint16_t *pid, enum dvbnet_encap *encapsulation) +{ + struct dvb_net_if info; + int res; + + memset(&info, 0, sizeof(struct dvb_net_if)); + info.if_num = ifnum; + + if ((res = ioctl(fd, NET_GET_IF, &info)) < 0) + return res; + + *pid = info.pid; + switch(info.feedtype) { + case DVB_NET_FEEDTYPE_MPE: + *encapsulation = DVBNET_ENCAP_MPE; + break; + + case DVB_NET_FEEDTYPE_ULE: + *encapsulation = DVBNET_ENCAP_ULE; + break; + + default: + return -EINVAL; + } + return 0; +} + +int dvbnet_remove_interface(int fd, int ifnum) +{ + return ioctl(fd, NET_REMOVE_IF, ifnum); +} -- cgit v1.2.3 libvncserver-dev to enable new drivers 2012-05-19Bump dh to v9Jonathan McCrohan4-82/+17 Switch to dh-style debian/rules 2012-05-19Import upstream version 0.11.0~svn1189Jonathan McCrohan3-6/+6 2012-05-19Fixes plugin_file syslog flood if file does not existJonathan McCrohan1-0/+1 2012-05-17d/rules: Add get-orig-source targetJonathan McCrohan3-0/+23 2012-05-17Import upstream version 0.11.0~svn1188Jonathan McCrohan12-428/+435 2012-05-17Undo wrap-and-sort for Uploaders: field.Jonathan McCrohan1-2/+1 dch thinks I'm NMU'ing. 2012-03-18update debian/changelogReinhard Tartler1-1/+6 2012-03-18Update Vcs-Bzr control field to new team addressReinhard Tartler1-1/+1 2012-03-09* Rewrite init script to use lsb-base functionsJonathan McCrohan2-7/+13 - fixes issue where invoke-rc.d would return error status during installation 2012-03-09Add watchfile lintian override; Using upstream svn instead Jonathan McCrohan2-1/+4 2012-03-08Update to S-V 3.9.3Jonathan McCrohan2-2/+3 2012-03-08* Rewrite init script to use lsb-base functions.Jonathan McCrohan3-15/+16 - init.d-script-does-not-implement-optional-option 2012-03-08copyright-refers-to-symlink-licenseJonathan McCrohan2-2/+3 2012-03-08* Lintian fixesJonathan McCrohan2-4/+7 - spelling-error-in-manpage 2012-03-08Import upstream version 0.11.0~svn1180Jonathan McCrohan19-2871/+3952 2011-12-27Import upstream version 0.11.0~svn1165Jonathan McCrohan6-166/+495 2011-12-25Import upstream version 0.11.0~svn1164Jonathan McCrohan11-162/+315 2011-12-25Update libmysqlclient-dev virtual package in build-depends.Jonathan McCrohan1-1/+1 Thanks to Clint Byrum <clint@ubuntu.com> for the patch. 2011-08-31Import upstream version 0.11.0~svn1159Jonathan McCrohan4-5/+5 2011-08-30update debian/changelogReinhard Tartler1-1/+4 2011-08-28* New upstream snapshotJonathan McCrohan2-4/+11 * Make lcd4linux linux specific (requested by kFreeBSD team) * Add optional build targets build-indep and build-dep (thanks to lintian for catching this) 2011-08-26Import upstream version 0.11.0~svn1158Reinhard Tartler34-1743/+4490 2011-08-20normalize with wrap-and-sort(1)Reinhard Tartler2-17/+20 2011-08-20Make lcd4linux linux specificReinhard Tartler1-2/+1 on request of freebsd porters: http://permalink.gmane.org/gmane.linux.debian.devel.general/164670 2011-04-29add sqlite3-dev to build dependssiretart@tauware.de2-2/+4 2011-04-29mention new co-maintainersiretart@tauware.de1-0/+1 2011-04-29add libdbus-1-dev to build dependssiretart@tauware.de2-1/+3 2011-04-29normalize fields with wrap-and-sort(1)siretart@tauware.de2-18/+20 2011-04-29fix order of calling dh_autoreconf_cleansiretart@tauware.de1-1/+1 avoids leftover debhelper log file 2011-04-29Add Uploader details to Debian PackageJonathan McCrohan1-0/+1 2011-04-27Bug fix: "script lcd4linux/init.d/lcd4linux missing dependency onReinhard Tartler2-1/+5 $syslog", thanks to Petter Reinholdtsen (Closes: #582825). 2011-04-27No longer build the mpd module. Closes: #578226Reinhard Tartler1-0/+1 2011-04-27No longer compile against Python. Python 2.6 now links against libssl,Reinhard Tartler2-2/+3 which is in conflicts with the package license GPL.