From: Felix Fietkau Date: Thu, 31 Mar 2005 22:12:20 +0000 (+0000) Subject: package wlc, jffs2root, mtd as "openwrt-utils" X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=53633c24d4caf5fe04ee3beace879c6a5d784dd2;p=lede.git package wlc, jffs2root, mtd as "openwrt-utils" SVN-Revision: 493 --- diff --git a/openwrt/package/openwrt/Makefile b/openwrt/package/openwrt/Makefile index 1b6de828a8..4c129fd4ce 100644 --- a/openwrt/package/openwrt/Makefile +++ b/openwrt/package/openwrt/Makefile @@ -2,6 +2,12 @@ include $(TOPDIR)/rules.mk +PKG_NAME := openwrt-utils +PKG_RELEASE := 1 +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) +PKG_IPK:=$(PACKAGE_DIR)/$(PKG_NAME)_$(PKG_RELEASE)_$(ARCH).ipk +PKG_IPK_DIR:=$(PKG_BUILD_DIR)/ipkg + SHARED_INCLUDE:=${shell pwd}/include libshared-compile libnvram-compile wlc-compile: @@ -13,13 +19,17 @@ libshared-install libnvram-install wlc-install: libshared-clean libnvram-clean wlc-clean: @$(MAKE) -C $(patsubst %-clean,%,$@) clean -$(TARGET_DIR)/sbin/mtd: mtd.c +$(PKG_IPK_DIR)/sbin/mtd: mtd.c + mkdir -p $(PKG_IPK_DIR)/sbin $(TARGET_CC) -o $@ $< - $(STRIP) $@ -$(TARGET_DIR)/sbin/jffs2root: jffs2root.c +$(PKG_IPK_DIR)/sbin/jffs2root: jffs2root.c + mkdir -p $(PKG_IPK_DIR)/sbin $(TARGET_CC) -o $@ $< - $(STRIP) $@ + +$(PKG_IPK_DIR)/usr/sbin/wlc: wlc.c libshared-compile + mkdir -p $(PKG_IPK_DIR)/usr/sbin + $(TARGET_CC) -o $@ $< -lshared -L./libshared -I$(SHARED_INCLUDE) # wlconf tool extracted from linksys firmware GPL.unpackedtree # WRT54GS_3_37_2_1109_US @@ -44,13 +54,23 @@ $(TARGET_DIR)/usr/sbin/wlconf: $(LINKSYS_WLCONF_DIR)/.unpacked install $(STRIP) $@ -source: -prepare: -compile: libnvram-compile libshared-compile wlc-compile -install: libnvram-install libshared-install wlc-install \ - $(TARGET_DIR)/sbin/mtd $(TARGET_DIR)/sbin/jffs2root $(TARGET_DIR)/usr/sbin/wlconf +$(PKG_IPK): $(PKG_IPK_DIR)/sbin/mtd $(PKG_IPK_DIR)/sbin/jffs2root $(PKG_IPK_DIR)/usr/sbin/wlc + $(SCRIPT_DIR)/make-ipkg-dir.sh $(PKG_IPK_DIR) $(PKG_NAME).control $(PKG_RELEASE) $(ARCH) + $(STRIP) $(PKG_IPK_DIR)/usr/sbin/* + $(STRIP) $(PKG_IPK_DIR)/sbin/* + mkdir -p $(PACKAGE_DIR) + $(IPKG_BUILD) $(PKG_IPK_DIR) $(PACKAGE_DIR) + +$(IPKG_STATE_DIR)/info/$(PKG_NAME).list: $(PKG_IPK) + $(IPKG) install $(PKG_IPK) + +source: $(DL_DIR)/$(LINKSYS_WLCONF_TGZ) +prepare: $(LINKSYS_WLCONF_DIR)/.unpacked +compile: prepare libnvram-compile libshared-compile $(PKG_IPK) +install: libnvram-install libshared-install \ + $(TARGET_DIR)/usr/sbin/wlconf \ + $(IPKG_STATE_DIR)/info/$(PKG_NAME).list -clean: libnvram-clean libshared-clean wlc-clean - rm -rf $(LINKSYS_WLCONF_DIR) - rm -f $(TARGET_DIR)/sbin/mtd - rm -f $(TARGET_DIR)/sbin/jffs2root +clean: libshared-clean libnvram-clean + rm -rf $(PKG_BUILD_DIR) + rm -f $(PKG_IPK) diff --git a/openwrt/package/openwrt/openwrt-utils.control b/openwrt/package/openwrt/openwrt-utils.control new file mode 100644 index 0000000000..b42669b969 --- /dev/null +++ b/openwrt/package/openwrt/openwrt-utils.control @@ -0,0 +1,10 @@ +Package: openwrt-utils +Priority: optional +Section: sys +Maintainer: Felix Fietkau +Source: buildroot internal +Description: Basic OpenWrt utilities + This package contains: + mtd: Tool for modifying the flash chip + jffs2root: Expands the jffs2 root partition + wlc: Tool for setting various broadcom driver options diff --git a/openwrt/package/openwrt/wlc.c b/openwrt/package/openwrt/wlc.c new file mode 100644 index 0000000000..8cb6dd375a --- /dev/null +++ b/openwrt/package/openwrt/wlc.c @@ -0,0 +1,180 @@ +/* + * wlc - tool for configuring the Broadcom Wireless Network Adapter + * Copyright (C) 2005 Felix Fietkau + * + * 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. + * + * $Id$ + * + */ + +#include +#include +#include + +#include +#include + +int _argc; +char **_argv; + +void qtxpwr() { + int i = 0; + + if (_argc > 3) { + if (_argv[3][0] == '@') { + i = atoi(_argv[3] + 1); + i |= 0x80000000; + } else { + i = atoi(_argv[3]); + } + wl_set_val(_argv[1], "qtxpower", &i, sizeof(i)); + } else { + wl_get_val(_argv[1], "qtxpower", &i, sizeof(i)); + if ((i & 0x80000000) == 0x80000000) + printf("@"); + printf("%d\n", i & 0x7ffffff); + } +} + + +struct wl_config { + char *name, *desc; + enum { + INT, + BOOL, + OTHER + } type; + int get, set; + int r1, r2; + void *handler; +}; + +struct wl_config commands[] = { + {"txpwr", "transmit power (in mW)", INT, WLC_GET_TXPWR, WLC_SET_TXPWR, 0, 255, NULL}, + {"qtxpwr", "\ttransmit power (in qdbm)\n\t\t\t\"@\" before value means regulatory override", OTHER, 0, 0, 0, 0, qtxpwr}, + {"promisc", "promiscuous mode", BOOL, WLC_GET_PROMISC, WLC_SET_PROMISC, 0, 0, NULL}, + {"monitor", "monitor mode", BOOL, WLC_GET_MONITOR, WLC_SET_MONITOR, 0, 0, NULL}, + {"passive", "passive mode", BOOL, WLC_GET_PASSIVE, WLC_SET_PASSIVE, 0, 0, NULL}, + {"ap", "access point mode (0 = STA, 1 = AP)", BOOL, WLC_GET_AP, WLC_SET_AP, 0, 0, NULL}, + {"infra", "infrastructure mode (0 = IBSS, 1 = Infra BSS)", BOOL, WLC_GET_INFRA, WLC_SET_INFRA, 0, 0, NULL}, + {"antdiv", "rx antenna diversity (0 = antenna 0, 1 = antenna 1, 3 = auto select)", INT, WLC_GET_ANTDIV, WLC_SET_ANTDIV, 0, 3, NULL}, + {"txant", "set tx antenna (0 = antenna 0, 1 = antenna 1, 3 = rx antenna)", INT, WLC_GET_TXANT, WLC_SET_TXANT, 0, 3, NULL}, + {"wet", "wireless ethernet bridging mode", BOOL, WLC_GET_WET, WLC_SET_WET, 0, 0, NULL}, + {"channel", "set channel", INT, WLC_GET_CHANNEL, WLC_SET_CHANNEL, 1, 14, NULL}, + {NULL, NULL, 0, 0, 0, 0, 0, NULL} +}; + +void set_int(char *name, int ioctl, int value, int r1, int r2) +{ + if ((value >= r1) || (value <= r2)) { + wl_ioctl(name, ioctl, &value, sizeof(value)); + } else + fprintf(stderr, "invalid value.\n"); +} + +void get_int(char *name, int ioctl) +{ + int value = 0; + wl_ioctl(name, ioctl, &value, sizeof(value)); + printf("%d\n", value); +} + +int main(int argc, char **argv) +{ + struct wl_config *cmd; + int i; + + _argc = argc; + _argv = argv; + + if (argc < 3) { + fprintf(stderr, "Usage: %s [...]\n\n", argv[0]); + fprintf(stderr, "Commands:\n\n"); + + cmd = commands; + while (cmd->name != NULL) { + fprintf(stderr, "\t%s", cmd->name); + switch (cmd->type) { + case INT: + fprintf(stderr, " [%d-%d]", cmd->r1, cmd->r2); + break; + case BOOL: + fprintf(stderr, " [0|1]"); + cmd->r1 = 0; + cmd->r2 = 1; + + } + fprintf(stderr, "\t%s\n", cmd->desc); + cmd++; + } + fprintf(stderr, "\n"); + + return -1; + } + + if (wl_probe(argv[1]) < 0) { + fprintf(stderr, "No broadcom extensions detected on interface %s\n", argv[1]); + return -1; + } + + if ((argc > 4) && (strcmp(argv[2], "ioctl") == 0)) { + if (strcmp(argv[3], "int") == 0) { + int ioctl = atoi(argv[4]); + if (argc > 5) + i = atoi(argv[5]); + else + i = 0; + fprintf(stderr, "ioctl = 0x%x (%d)\nold value = 0x%x (%d)\n", ioctl, ioctl, i, i); + wl_ioctl(argv[1], ioctl, &i, sizeof(i)); + fprintf(stderr, "new value = 0x%x (%d)\n", i, i); + } else if (strcmp(argv[3], "intval") == 0) { + i = 0; + fprintf(stderr, "var = \"%s\"\nold value = 0x%x (%d)\n", argv[4], i, i); + if (argc > 5) { + i = atoi(argv[5]); + wl_set_val(argv[1], argv[4], &i, sizeof(i)); + } else { + wl_get_val(argv[1], argv[4], &i, sizeof(i)); + } + fprintf(stderr, "new value = 0x%x (%d)\n", i, i); + } + return 0; + } + cmd = commands; + while (cmd->name != NULL) { + if (strcmp(argv[2], cmd->name) == 0) { + switch (cmd->type) { + case INT: + case BOOL: + if (argc < 4) { + get_int(argv[1], cmd->get); + } else { + set_int(argv[1], cmd->set, atoi(argv[3]), cmd->r1, cmd->r2); + } + break; + case OTHER: { + void (*handler)(void) = cmd->handler; + handler(); + } + break; + } + } + cmd++; + } + + + return 0; +} diff --git a/openwrt/package/openwrt/wlc/Makefile b/openwrt/package/openwrt/wlc/Makefile deleted file mode 100644 index 8a1e970d97..0000000000 --- a/openwrt/package/openwrt/wlc/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# $Id$ - -include $(TOPDIR)/rules.mk - -PKG_NAME:=wlc -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) - -EXTRA_CFLAGS := -c -I. -I../include - -all: compile - -WLC_OBJS:= -define OBJ_template -$(PKG_BUILD_DIR)/$(1): $(PKG_BUILD_DIR) - $(TARGET_CC) $(TARGET_CFLAGS) $(EXTRA_CFLAGS) -o $$@ $$(patsubst %.o,%.c,$(1)) -WLC_OBJS += $(PKG_BUILD_DIR)/$(1) -endef - -OBJS := wlc.o -$(foreach obj,$(OBJS),$(eval $(call OBJ_template,$(obj)))) - -$(PKG_BUILD_DIR): - mkdir -p $(PKG_BUILD_DIR) - -$(PKG_BUILD_DIR)/wlc: $(WLC_OBJS) - $(TARGET_CC) -o $@ $^ -L$(BUILD_DIR)/libshared -lshared - -$(TARGET_DIR)/usr/sbin/wlc: $(PKG_BUILD_DIR)/wlc - install -m 755 $^ $@ - $(STRIP) $@ - -compile: $(PKG_BUILD_DIR)/wlc -install: $(TARGET_DIR)/usr/sbin/wlc - -clean: - rm -rf $(PKG_BUILD_DIR) diff --git a/openwrt/package/openwrt/wlc/wlc.c b/openwrt/package/openwrt/wlc/wlc.c deleted file mode 100644 index 8cb6dd375a..0000000000 --- a/openwrt/package/openwrt/wlc/wlc.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * wlc - tool for configuring the Broadcom Wireless Network Adapter - * Copyright (C) 2005 Felix Fietkau - * - * 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. - * - * $Id$ - * - */ - -#include -#include -#include - -#include -#include - -int _argc; -char **_argv; - -void qtxpwr() { - int i = 0; - - if (_argc > 3) { - if (_argv[3][0] == '@') { - i = atoi(_argv[3] + 1); - i |= 0x80000000; - } else { - i = atoi(_argv[3]); - } - wl_set_val(_argv[1], "qtxpower", &i, sizeof(i)); - } else { - wl_get_val(_argv[1], "qtxpower", &i, sizeof(i)); - if ((i & 0x80000000) == 0x80000000) - printf("@"); - printf("%d\n", i & 0x7ffffff); - } -} - - -struct wl_config { - char *name, *desc; - enum { - INT, - BOOL, - OTHER - } type; - int get, set; - int r1, r2; - void *handler; -}; - -struct wl_config commands[] = { - {"txpwr", "transmit power (in mW)", INT, WLC_GET_TXPWR, WLC_SET_TXPWR, 0, 255, NULL}, - {"qtxpwr", "\ttransmit power (in qdbm)\n\t\t\t\"@\" before value means regulatory override", OTHER, 0, 0, 0, 0, qtxpwr}, - {"promisc", "promiscuous mode", BOOL, WLC_GET_PROMISC, WLC_SET_PROMISC, 0, 0, NULL}, - {"monitor", "monitor mode", BOOL, WLC_GET_MONITOR, WLC_SET_MONITOR, 0, 0, NULL}, - {"passive", "passive mode", BOOL, WLC_GET_PASSIVE, WLC_SET_PASSIVE, 0, 0, NULL}, - {"ap", "access point mode (0 = STA, 1 = AP)", BOOL, WLC_GET_AP, WLC_SET_AP, 0, 0, NULL}, - {"infra", "infrastructure mode (0 = IBSS, 1 = Infra BSS)", BOOL, WLC_GET_INFRA, WLC_SET_INFRA, 0, 0, NULL}, - {"antdiv", "rx antenna diversity (0 = antenna 0, 1 = antenna 1, 3 = auto select)", INT, WLC_GET_ANTDIV, WLC_SET_ANTDIV, 0, 3, NULL}, - {"txant", "set tx antenna (0 = antenna 0, 1 = antenna 1, 3 = rx antenna)", INT, WLC_GET_TXANT, WLC_SET_TXANT, 0, 3, NULL}, - {"wet", "wireless ethernet bridging mode", BOOL, WLC_GET_WET, WLC_SET_WET, 0, 0, NULL}, - {"channel", "set channel", INT, WLC_GET_CHANNEL, WLC_SET_CHANNEL, 1, 14, NULL}, - {NULL, NULL, 0, 0, 0, 0, 0, NULL} -}; - -void set_int(char *name, int ioctl, int value, int r1, int r2) -{ - if ((value >= r1) || (value <= r2)) { - wl_ioctl(name, ioctl, &value, sizeof(value)); - } else - fprintf(stderr, "invalid value.\n"); -} - -void get_int(char *name, int ioctl) -{ - int value = 0; - wl_ioctl(name, ioctl, &value, sizeof(value)); - printf("%d\n", value); -} - -int main(int argc, char **argv) -{ - struct wl_config *cmd; - int i; - - _argc = argc; - _argv = argv; - - if (argc < 3) { - fprintf(stderr, "Usage: %s [...]\n\n", argv[0]); - fprintf(stderr, "Commands:\n\n"); - - cmd = commands; - while (cmd->name != NULL) { - fprintf(stderr, "\t%s", cmd->name); - switch (cmd->type) { - case INT: - fprintf(stderr, " [%d-%d]", cmd->r1, cmd->r2); - break; - case BOOL: - fprintf(stderr, " [0|1]"); - cmd->r1 = 0; - cmd->r2 = 1; - - } - fprintf(stderr, "\t%s\n", cmd->desc); - cmd++; - } - fprintf(stderr, "\n"); - - return -1; - } - - if (wl_probe(argv[1]) < 0) { - fprintf(stderr, "No broadcom extensions detected on interface %s\n", argv[1]); - return -1; - } - - if ((argc > 4) && (strcmp(argv[2], "ioctl") == 0)) { - if (strcmp(argv[3], "int") == 0) { - int ioctl = atoi(argv[4]); - if (argc > 5) - i = atoi(argv[5]); - else - i = 0; - fprintf(stderr, "ioctl = 0x%x (%d)\nold value = 0x%x (%d)\n", ioctl, ioctl, i, i); - wl_ioctl(argv[1], ioctl, &i, sizeof(i)); - fprintf(stderr, "new value = 0x%x (%d)\n", i, i); - } else if (strcmp(argv[3], "intval") == 0) { - i = 0; - fprintf(stderr, "var = \"%s\"\nold value = 0x%x (%d)\n", argv[4], i, i); - if (argc > 5) { - i = atoi(argv[5]); - wl_set_val(argv[1], argv[4], &i, sizeof(i)); - } else { - wl_get_val(argv[1], argv[4], &i, sizeof(i)); - } - fprintf(stderr, "new value = 0x%x (%d)\n", i, i); - } - return 0; - } - cmd = commands; - while (cmd->name != NULL) { - if (strcmp(argv[2], cmd->name) == 0) { - switch (cmd->type) { - case INT: - case BOOL: - if (argc < 4) { - get_int(argv[1], cmd->get); - } else { - set_int(argv[1], cmd->set, atoi(argv[3]), cmd->r1, cmd->r2); - } - break; - case OTHER: { - void (*handler)(void) = cmd->handler; - handler(); - } - break; - } - } - cmd++; - } - - - return 0; -}