summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2012-01-25Split out debug packagesJonathan McCrohan2-1/+6
2011-12-31Fix debian/rulesJonathan McCrohan1-1/+1
2011-12-31Remove shlibsJonathan McCrohan1-2/+0
2011-12-31Remove NMU from changelogJonathan McCrohan1-1/+0
2011-12-31Lintian FixesJonathan McCrohan1-2/+4
2011-12-31Remove Makefile patchJonathan McCrohan1-1/+0
2011-12-31Update MakefilesJonathan McCrohan10-248/+8222
2011-12-31Updated makefilesJonathan McCrohan1-0/+1
2011-12-31Add untracked debian patchesJonathan McCrohan1-0/+0
2011-12-31Add myself as uploader.Jonathan McCrohan1-0/+1
2011-12-31Lintian fixes.Jonathan McCrohan1-2/+7
2011-12-02v1.4.8Jonathan McCrohan15-8303/+252
2011-12-01Merge commit 'upstream/1.4.8'Jonathan McCrohan160-28756/+43594
Conflicts: debian/changelog debian/control debian/libconfig++9-dev.install debian/libconfig8.install debian/libconfig9-dev.install debian/rules
2011-12-01Imported Upstream version 1.4.8upstream/1.4.8Jonathan McCrohan156-28873/+43602
2011-12-01Imported Debian patch 1.3.2-2debian/1.3.2-2Jose Luis Tallon16-191/+102
2011-12-01Imported Upstream version 1.3.2upstream/1.3.2Jonathan McCrohan80-0/+69508
5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* 
 * dvbnet.c
 *
 * Copyright (C) 2003 TV Files S.p.A
 *                    L.Y.Mesentsev <lymes@tiscalinet.it>
 *
 * 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>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#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

#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 {
	UNKNOWN,
	LST_INTERFACE,
	ADD_INTERFACE,
	DEL_INTERFACE
} op_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 char dvb_net_device[40];

int main(int argc, char **argv)
{
	int fd_net;

	hello();

	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);
		return FAIL;
	}

	switch (op_mode) {
	case DEL_INTERFACE:
		if (ioctl(fd_net, NET_REMOVE_IF, net_data.if_num))
			fprintf(stderr,
				"Error: couldn't remove interface %d: %d %m.\n",
				net_data.if_num, errno);
		else
			printf("Status: device %d removed successfully.\n",
			       net_data.if_num);
		break;

	case ADD_INTERFACE:
		if (ioctl(fd_net, NET_ADD_IF, &net_data))
			fprintf(stderr,
				"Error: couldn't add interface for pid %d: %d %m.\n",
				net_data.pid, errno);
		else
			printf
			    ("Status: device dvb%d_%d for pid %d created successfully.\n",
			     adapter, net_data.if_num, net_data.pid);
		break;

	case LST_INTERFACE:
		queryInterface(fd_net, 0);
		break;

	default:
		usage(argv[0]);
		return FAIL;
	}

	close(fd_net);
	return OK;
}


int queryInterface(int fd_net, int dev)
{
	struct dvb_net_if data;
	int IF, nIFaces = 0, ret = FAIL;

	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))
			continue;

		if (dev == data.if_num)
			ret = OK;

		printf("Found device %d: interface dvb%d_%d, "
		       "listening on PID %d\n",
		       IF, adapter, data.if_num, data.pid);

		nIFaces++;
	}

	printf("-----------------------------\n");
	printf("Found %d interface(s).\n\n", nIFaces);
	return ret;
}


void parse_args(int argc, char **argv)
{
	char c, *s;
	op_mode = UNKNOWN;
	while ((c = getopt(argc, argv, "a:n:p:d:lvh")) != EOF) {
		switch (c) {
		case 'a':
			adapter = strtol(optarg, NULL, 0);
			break;
		case 'n':
			netdev = strtol(optarg, NULL, 0);
			break;
		case 'p':
			net_data.pid = strtol(optarg, NULL, 0);
			op_mode = ADD_INTERFACE;
			break;
		case 'd':
			net_data.if_num = strtol(optarg, NULL, 0);
			op_mode = DEL_INTERFACE;
			break;
		case 'l':
			op_mode = LST_INTERFACE;
			break;
		case 'v':
			exit(OK);
		case 'h':
		default:
			s = strrchr(argv[0], '/') + 1;
			usage((s) ? s : argv[0]);
			exit(FAIL);
		}
	}
}


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-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-v     : Print current version\n\n");
}


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");
}