summaryrefslogtreecommitdiff
path: root/package/br2684ctl
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2011-01-29 02:14:22 +0000
committerFlorian Fainelli <florian@openwrt.org>2011-01-29 02:14:22 +0000
commit3810bdf32067ab871de85895caa89d8545d52fd7 (patch)
tree469bf13ea0538ce31e71c95dca7af3ca3c9aff09 /package/br2684ctl
parent4e6bca2d05df5962620e9fb02170d0f89ebc1896 (diff)
downloadmtk-20170518-3810bdf32067ab871de85895caa89d8545d52fd7.zip
mtk-20170518-3810bdf32067ab871de85895caa89d8545d52fd7.tar.gz
mtk-20170518-3810bdf32067ab871de85895caa89d8545d52fd7.tar.bz2
br2684ctl from linux-atm
Signed-off-by: Philip Prindeville <philipp_subx@redfish-solutions.com> SVN-Revision: 25225
Diffstat (limited to 'package/br2684ctl')
-rw-r--r--package/br2684ctl/Makefile42
-rwxr-xr-xpackage/br2684ctl/files/br2684ctl60
-rw-r--r--package/br2684ctl/patches/100-debian.patch91
-rw-r--r--package/br2684ctl/patches/101-routed_support.patch300
4 files changed, 0 insertions, 493 deletions
diff --git a/package/br2684ctl/Makefile b/package/br2684ctl/Makefile
deleted file mode 100644
index f8bf4ae..0000000
--- a/package/br2684ctl/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (C) 2006 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=br2684ctl
-PKG_VERSION:=20040226
-PKG_RELEASE:=2
-
-PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
-PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/b/br2684ctl
-PKG_MD5SUM:=6eb4d8cd174e24a7c078eb4f594f5b69
-
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION).orig
-PKG_BUILD_DEPENDS:=linux-atm
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/$(PKG_NAME)
- SECTION:=net
- CATEGORY:=Base system
- TITLE:=ATM Ethernet bridging configuration utility
- DEPENDS:=+linux-atm
- URL:=http://ftp.debian.org/debian/pool/main/b/br2684ctl
-endef
-
-TARGET_CPPFLAGS += -I$(LINUX_DIR)/include
-MAKE_FLAGS += CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(TARGET_LDFLAGS)"
-
-define Package/$(PKG_NAME)/install
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
-endef
-
-$(eval $(call BuildPackage,$(PKG_NAME)))
diff --git a/package/br2684ctl/files/br2684ctl b/package/br2684ctl/files/br2684ctl
deleted file mode 100755
index 929e2b8..0000000
--- a/package/br2684ctl/files/br2684ctl
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh /etc/rc.common
-START=50
-
-start_daemon() {
- local cfg="$1"
-
- local atmdev
- config_get atmdev "$cfg" atmdev 0
-
- local unit
- config_get unit "$cfg" unit 0
-
- local vpi
- config_get vpi "$cfg" vpi 8
-
- local vci
- config_get vci "$cfg" vci 35
-
- local encaps
- config_get encaps "$cfg" encaps
-
- case "$encaps" in
- 1|vc) encaps=1;;
- *) encaps=0;;
- esac
-
- local payload
- config_get payload "$cfg" payload
-
- case "$payload" in
- 0|routed) payload=0;;
- *) payload=1;;
- esac
-
- local qos
- config_get qos "$cfg" qos
-
- local circuit="$atmdev.$vpi.$vci"
- local pid="/var/run/br2684ctl-$circuit.pid"
-
- start-stop-daemon -S -b -x /usr/sbin/br2684ctl -m -p "$pid" -- \
- -c "$unit" -e "$encaps" -p "$payload" \
- -a "$circuit" ${qos:+-q "$qos"}
-}
-
-start() {
- insmod br2684 >/dev/null 2>/dev/null
- config_load network
- config_foreach start_daemon atm-bridge
-}
-
-stop() {
- local pid
- for pid in /var/run/br2684ctl-*.pid; do
- if [ -f "$pid" ]; then
- service_kill br2684ctl "$pid"
- rm -f "$pid"
- fi
- done
-}
diff --git a/package/br2684ctl/patches/100-debian.patch b/package/br2684ctl/patches/100-debian.patch
deleted file mode 100644
index 8a8b3b7..0000000
--- a/package/br2684ctl/patches/100-debian.patch
+++ /dev/null
@@ -1,91 +0,0 @@
---- a/br2684ctl.c
-+++ b/br2684ctl.c
-@@ -3,6 +3,8 @@
- #include <unistd.h>
- #include <errno.h>
- #include <sys/ioctl.h>
-+#include <sys/types.h>
-+#include <signal.h>
- #include <string.h>
- #include <syslog.h>
- #include <atm.h>
-@@ -22,9 +24,9 @@
- */
-
-
--#define LOG_NAME "RFC1483/2684 bridge"
--#define LOG_OPTION LOG_PERROR
--#define LOG_FACILITY LOG_LOCAL0
-+#define LOG_NAME "br2684ctl"
-+#define LOG_OPTION LOG_PERROR|LOG_PID
-+#define LOG_FACILITY LOG_LOCAL2
-
-
- int lastsock, lastitf;
-@@ -39,10 +41,16 @@ void fatal(const char *str, int i)
-
- void exitFunc(void)
- {
-- syslog (LOG_PID,"Daemon terminated\n");
-+ syslog (LOG_NOTICE,"Daemon terminated\n");
- }
-
-
-+void int_signal(int dummy)
-+{
-+ syslog (LOG_INFO,"Killed by a signal\n");
-+ exit(0);
-+}
-+
- int create_pidfile(int num)
- {
- FILE *pidfile = NULL;
-@@ -80,7 +88,7 @@ int create_br(char *nstr)
- err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni);
-
- if (err == 0)
-- syslog(LOG_INFO, "Interface \"%s\" created sucessfully\n",ni.ifname);
-+ syslog(LOG_NOTICE, "Interface \"%s\" created sucessfully\n",ni.ifname);
- else
- syslog(LOG_INFO, "Interface \"%s\" could not be created, reason: %s\n",
- ni.ifname,
-@@ -112,7 +120,7 @@ int assign_vcc(char *astr, int encap, in
- addr.sap_addr.vpi = 0;
- addr.sap_addr.vci = vci;
- #endif
-- syslog(LOG_INFO,"Communicating over ATM %d.%d.%d, encapsulation: %s\n", addr.sap_addr.itf,
-+ syslog(LOG_NOTICE,"Communicating over ATM %d.%d.%d, encapsulation: %s\n", addr.sap_addr.itf,
- addr.sap_addr.vpi,
- addr.sap_addr.vci,
- encap?"VC mux":"LLC");
-@@ -261,11 +269,13 @@ int main (int argc, char **argv)
- }
-
- create_pidfile(itfnum);
-+ signal(SIGINT, int_signal);
-+ signal(SIGTERM, int_signal);
-
- syslog (LOG_INFO, "RFC 1483/2684 bridge daemon started\n");
- atexit (exitFunc);
-
-- while (1) sleep(30); /* to keep the sockets... */
-+ while (1) pause(); /* to keep the sockets... */
- return 0;
- }
-
---- /dev/null
-+++ b/Makefile
-@@ -0,0 +1,13 @@
-+OPTS := -O2
-+CFLAGS := -Wall -g
-+LIBS := -latm
-+
-+all: br2684ctl
-+
-+br2684ctl: br2684ctl.c
-+ $(CC) $(OPTS) $(CFLAGS) $(LIBS) $< -o $@
-+
-+distclean: clean
-+clean:
-+ rm -f br2684ctl
-+
diff --git a/package/br2684ctl/patches/101-routed_support.patch b/package/br2684ctl/patches/101-routed_support.patch
deleted file mode 100644
index afad932..0000000
--- a/package/br2684ctl/patches/101-routed_support.patch
+++ /dev/null
@@ -1,300 +0,0 @@
---- a/br2684ctl.c
-+++ b/br2684ctl.c
-@@ -10,6 +10,10 @@
- #include <atm.h>
- #include <linux/atmdev.h>
- #include <linux/atmbr2684.h>
-+#ifndef BR2684_FLAG_ROUTED
-+#warning "Kernel missing routed support for br2684"
-+#define BR2684_FLAG_ROUTED (1<<16) /* payload is routed, not bridged */
-+#endif
-
- /* Written by Marcell GAL <cell@sch.bme.hu> to make use of the */
- /* ioctls defined in the br2684... kernel patch */
-@@ -28,26 +32,35 @@
- #define LOG_OPTION LOG_PERROR|LOG_PID
- #define LOG_FACILITY LOG_LOCAL2
-
-+struct br2684_params {
-+ int itfnum;
-+ int encap;
-+ int sndbuf;
-+ int payload;
-+ char *astr; /* temporary */
-+ struct atm_qos reqqos;
-+};
-+
-
- int lastsock, lastitf;
-
-
--void fatal(const char *str, int i)
-+void fatal(const char *str, int err)
- {
-- syslog (LOG_ERR,"Fatal: %s",str);
-+ syslog (LOG_ERR,"Fatal: %s; %s", str, strerror(err));
- exit(-2);
- };
-
-
- void exitFunc(void)
- {
-- syslog (LOG_NOTICE,"Daemon terminated\n");
-+ syslog (LOG_NOTICE,"Daemon terminated");
- }
-
-
- void int_signal(int dummy)
- {
-- syslog (LOG_INFO,"Killed by a signal\n");
-+ syslog (LOG_INFO,"Killed by a signal");
- exit(0);
- }
-
-@@ -58,7 +71,7 @@ int create_pidfile(int num)
-
- if (num < 0) return -1;
-
-- snprintf(name, 20, "/var/run/nas%d.pid", num);
-+ snprintf(name, 32, "/var/run/br2684ctl-nas%d.pid", num);
- pidfile = fopen(name, "w");
- if (pidfile == NULL) return -1;
- fprintf(pidfile, "%d", getpid());
-@@ -67,9 +80,9 @@ int create_pidfile(int num)
- return 0;
- }
-
--int create_br(char *nstr)
-+int create_br(int itfnum, int payload)
- {
-- int num, err;
-+ int err;
-
- if(lastsock<0) {
- lastsock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
-@@ -78,31 +91,36 @@ int create_br(char *nstr)
- syslog(LOG_ERR, "socket creation failed: %s",strerror(errno));
- } else {
- /* create the device with ioctl: */
-- num=atoi(nstr);
-- if( num>=0 && num<1234567890){
-+ if( itfnum>=0 && itfnum<1234567890){
- struct atm_newif_br2684 ni;
- ni.backend_num = ATM_BACKEND_BR2684;
- ni.media = BR2684_MEDIA_ETHERNET;
-+#ifdef BR2684_FLAG_ROUTED
-+ if (payload == 0)
-+ ni.media |= BR2684_FLAG_ROUTED;
-+#endif
- ni.mtu = 1500;
-- sprintf(ni.ifname, "nas%d", num);
-+ sprintf(ni.ifname, "nas%d", itfnum);
- err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni);
-
- if (err == 0)
-- syslog(LOG_NOTICE, "Interface \"%s\" created sucessfully\n",ni.ifname);
-+ syslog(LOG_NOTICE, "Interface \"%s\" created sucessfully",ni.ifname);
- else
-- syslog(LOG_INFO, "Interface \"%s\" could not be created, reason: %s\n",
-+ syslog(LOG_INFO, "Interface \"%s\" could not be created, reason: %s",
- ni.ifname,
- strerror(errno));
-- lastitf=num; /* even if we didn't create, because existed, assign_vcc wil want to know it! */
-+ lastitf=itfnum; /* even if we didn't create, because existed,
-+ assign_vcc wil want to know it! */
- } else {
-- syslog(LOG_ERR,"err: strange interface number %d", num );
-+ syslog(LOG_ERR,"err: strange interface number %d", itfnum );
- }
- }
- return 0;
- }
-
-
--int assign_vcc(char *astr, int encap, int bufsize, struct atm_qos qos)
-+int assign_vcc(char *astr, int encap, int payload,
-+ int bufsize, struct atm_qos qos)
- {
- int err;
- struct sockaddr_atmpvc addr;
-@@ -112,21 +130,17 @@ int assign_vcc(char *astr, int encap, in
- memset(&addr, 0, sizeof(addr));
- err=text2atm(astr,(struct sockaddr *)(&addr), sizeof(addr), T2A_PVC);
- if (err!=0)
-- syslog(LOG_ERR,"Could not parse ATM parameters (error=%d)\n",err);
-+ syslog(LOG_ERR,"Could not parse ATM parameters (error=%d)",err);
-
--#if 0
-- addr.sap_family = AF_ATMPVC;
-- addr.sap_addr.itf = itf;
-- addr.sap_addr.vpi = 0;
-- addr.sap_addr.vci = vci;
--#endif
-- syslog(LOG_NOTICE,"Communicating over ATM %d.%d.%d, encapsulation: %s\n", addr.sap_addr.itf,
-+ syslog(LOG_NOTICE,"Communicating over ATM %d.%d.%d, encapsulation: %s",
-+ addr.sap_addr.itf,
- addr.sap_addr.vpi,
- addr.sap_addr.vci,
- encap?"VC mux":"LLC");
-
- if ((fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0)
-- syslog(LOG_ERR,"failed to create socket %d, reason: %s", errno,strerror(errno));
-+ syslog(LOG_ERR,"failed to create socket %d, reason: %s",
-+ errno,strerror(errno));
-
- if (qos.aal == 0) {
- qos.aal = ATM_AAL5;
-@@ -137,7 +151,7 @@ int assign_vcc(char *astr, int encap, in
- }
-
- if ( (err=setsockopt(fd,SOL_SOCKET,SO_SNDBUF, &bufsize ,sizeof(bufsize))) )
-- syslog(LOG_ERR,"setsockopt SO_SNDBUF: (%d) %s\n",err, strerror(err));
-+ syslog(LOG_ERR,"setsockopt SO_SNDBUF: (%d) %s",err, strerror(err));
-
- if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
- syslog(LOG_ERR,"setsockopt SO_ATMQOS %d", errno);
-@@ -145,7 +159,7 @@ int assign_vcc(char *astr, int encap, in
- err = connect(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_atmpvc));
-
- if (err < 0)
-- fatal("failed to connect on socket", err);
-+ fatal("failed to connect on socket", errno);
-
- /* attach the vcc to device: */
-
-@@ -169,10 +183,30 @@ int assign_vcc(char *astr, int encap, in
- return fd ;
- }
-
-+void start_interface(struct br2684_params* params)
-+{
-+ if (params->astr==NULL) {
-+ syslog(LOG_ERR, "Required ATM parameters not specified.");
-+ exit(1);
-+ }
-+
-+ create_br(params->itfnum, params->payload);
-+ assign_vcc(params->astr, params->encap, params->payload, params->sndbuf,
-+ params->reqqos);
-+}
-+
-
- void usage(char *s)
- {
-- printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-a [itf.]vpi.vci]*]*\n", s);
-+ printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
-+ "[-a [itf.]vpi.vci]*]*\n"
-+ " -b = run in background (daemonize)\n"
-+ " -c <num> = use interface nas<num>\n"
-+ " -e 0|1 = encapsulation (0=LLC, 1=VC Mux)\n"
-+ " -p 0|1 = payload type (0=routed,1=bridged)\n"
-+ " -s <num> = set sndbuf (send buffer) size (default 8192)\n"
-+ " -a [itf.]vpi.vci = ATM interface no, VPI, VCI\n",
-+ s);
- exit(1);
- }
-
-@@ -180,47 +214,63 @@ void usage(char *s)
-
- int main (int argc, char **argv)
- {
-- int c, background=0, encap=0, sndbuf=8192;
-- struct atm_qos reqqos;
-- int itfnum;
-+ int c, background=0;
-+
-+ struct br2684_params params;
-+ params.itfnum=-1;
-+ params.encap=0;
-+ params.sndbuf=8192;
-+ params.payload=1;
-+ params.astr=NULL;
-+ memset(&params.reqqos, 0, sizeof(params.reqqos));
-+
- lastsock=-1;
- lastitf=0;
-
- /* st qos to 0 */
-- memset(&reqqos, 0, sizeof(reqqos));
-
- openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY);
- if (argc>1)
-- while ((c = getopt(argc, argv,"q:a:bc:e:s:?h")) !=EOF)
-+ while ((c = getopt(argc, argv,"q:a:bc:e:s:p:?h")) !=EOF)
- switch (c) {
- case 'q':
- printf ("optarg : %s",optarg);
-- if (text2qos(optarg,&reqqos,0)) fprintf(stderr,"QOS parameter invalid\n");
-+ if (text2qos(optarg,&params.reqqos,0))
-+ fprintf(stderr,"QOS parameter invalid\n");
- break;
- case 'a':
-- assign_vcc(optarg, encap, sndbuf, reqqos);
-+ params.astr=optarg;
- break;
- case 'b':
- background=1;
- break;
- case 'c':
-- create_br(optarg);
-- itfnum = atoi(optarg);
-+ /* temporary, to make it work with multiple interfaces: */
-+ if (params.itfnum>=0) start_interface(&params);
-+ params.itfnum= atoi(optarg);
- break;
- case 'e':
-- encap=(atoi(optarg));
-- if(encap<0){
-- syslog (LOG_ERR, "invalid encapsulation: %s:\n",optarg);
-- encap=0;
-+ params.encap=(atoi(optarg));
-+ if(params.encap<0){
-+ syslog (LOG_ERR, "invalid encapsulation: %s:",optarg);
-+ params.encap=0;
- }
- break;
- case 's':
-- sndbuf=(atoi(optarg));
-- if(sndbuf<0){
-- syslog(LOG_ERR, "Invalid sndbuf: %s, using size of 8192 instead\n",optarg);
-- sndbuf=8192;
-+ params.sndbuf=(atoi(optarg));
-+ if(params.sndbuf<0){
-+ syslog(LOG_ERR, "Invalid sndbuf: %s, using size of 8192 instead",
-+ optarg);
-+ params.sndbuf=8192;
- }
- break;
-+ case 'p': /* payload type: routed (0) or bridged (1) */
-+#ifdef BR2684_FLAG_ROUTED
-+ params.payload = atoi(optarg);
-+ break;
-+#else
-+ syslog(LOG_ERR, "payload option not supported.");
-+#endif
- case '?':
- case 'h':
- default:
-@@ -231,6 +281,8 @@ int main (int argc, char **argv)
-
- if (argc != optind) usage(argv[0]);
-
-+ start_interface(&params);
-+
- if(lastsock>=0) close(lastsock);
-
- if (background) {
-@@ -268,11 +320,11 @@ int main (int argc, char **argv)
-
- }
-
-- create_pidfile(itfnum);
-+ create_pidfile(params.itfnum);
- signal(SIGINT, int_signal);
- signal(SIGTERM, int_signal);
-
-- syslog (LOG_INFO, "RFC 1483/2684 bridge daemon started\n");
-+ syslog (LOG_INFO, "RFC 1483/2684 bridge daemon started");
- atexit (exitFunc);
-
- while (1) pause(); /* to keep the sockets... */