finally move buildroot-ng to trunk

This commit is contained in:
Felix Fietkau 2006-10-13 22:51:49 +02:00
commit 60c1f0f64d
907 changed files with 495477 additions and 0 deletions

2
BSDmakefile Normal file
View file

@ -0,0 +1,2 @@
world ${.TARGETS}:
@gmake $@

101
Config.in Normal file
View file

@ -0,0 +1,101 @@
#
mainmenu "OpenWrt Configuration"
config HAVE_DOT_CONFIG
bool
default y
source "target/Config.in"
config ALL
bool "Select all packages by default"
default n
menuconfig DEVEL
bool "Advanced configuration options (for developers)"
default n
select BUILDOPTS
select TOOLCHAINOPTS if !NATIVE_TOOLCHAIN
config BROKEN
bool "Show broken platforms / packages" if DEVEL
default n
menuconfig BUILDOPTS
bool "Build Options" if DEVEL
config AUTOREBUILD
bool
prompt "Automatic rebuild of packages" if BUILDOPTS
default y
help
Automatically rebuild packages when their files change
config TAR_VERBOSITY
bool
prompt "Tar verbose" if BUILDOPTS
default n
config JLEVEL
int
prompt "Number of jobs to run simultaneously" if BUILDOPTS
default "1"
help
Number of jobs to run simultanesouly
config CCACHE
bool
prompt "Use ccache" if BUILDOPTS
default n
help
Compiler cache; see http://ccache.samba.org/
source "toolchain/Config.in"
source "target/sdk/Config.in"
menu "Target Images"
config TARGET_ROOTFS_INITRAMFS
bool "ramdisk"
default n
depends LINUX_2_6
help
Embed the rootfs into the kernel (initramfs)
config TARGET_ROOTFS_JFFS2
bool "jffs2"
default y if USES_JFFS2
depends !TARGET_ROOTFS_INITRAMFS
help
Build a jffs2 root filesystem
config TARGET_ROOTFS_SQUASHFS
bool "squashfs"
default y if USES_SQUASHFS
depends !TARGET_ROOTFS_INITRAMFS
help
Build a squashfs-lzma root filesystem
config TARGET_ROOTFS_TGZ
bool "tgz"
default y if !USES_SQUASHFS && !USES_JFFS2
depends !TARGET_ROOTFS_INITRAMFS
help
Build a compressed tar archive of the the root filesystem
config TARGET_ROOTFS_EXT2FS
bool "ext2"
default y if !USES_SQUASHFS && !USES_JFFS2
depends !TARGET_ROOTFS_INITRAMFS
help
Ext2 file system with some free space for uml images
comment "Image Options"
source "target/image/*/Config.in"
endmenu
source "target/linux/Config.in"
source ".config.in"

340
LICENSE Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

141
Makefile Normal file
View file

@ -0,0 +1,141 @@
# Makefile for OpenWrt
#
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
RELEASE:=Kamikaze
#VERSION:=2.0 # uncomment for final release
#--------------------------------------------------------------
# Just run 'make menuconfig', configure stuff, then run 'make'.
# You shouldn't need to mess with anything beyond this point...
#--------------------------------------------------------------
all: world
SHELL:=/usr/bin/env bash
export TOPDIR=${shell pwd}
include $(TOPDIR)/include/verbose.mk
OPENWRTVERSION:=$(RELEASE)
ifneq ($(VERSION),)
OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
else
REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
ifneq ($(REV),)
OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
endif
endif
export OPENWRTVERSION
ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo)
.pkginfo .config: FORCE
endif
ifeq ($(FORCE),)
.config scripts/config/conf scripts/config/mconf: .prereq-build
world: .prereq-packages
endif
.pkginfo:
@echo Collecting package info...
@-for dir in package/*/; do \
echo Source-Makefile: $${dir}Makefile; \
$(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir || echo "ERROR: please fix $${dir}Makefile" >&2; \
done > $@
pkginfo-clean: FORCE
-rm -f .pkginfo .config.in
.config.in: .pkginfo
@./scripts/gen_menuconfig.pl < $< > $@ || rm -f $@
.config: ./scripts/config/conf .config.in
@[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
@$< -D .config Config.in &> /dev/null
scripts/config/mconf:
@$(MAKE) -C scripts/config all
scripts/config/conf:
@$(MAKE) -C scripts/config conf
config: scripts/config/conf .config.in FORCE
$< Config.in
config-clean: FORCE
$(NO_TRACE_MAKE) -C scripts/config clean
defconfig: scripts/config/conf .config.in FORCE
touch .config
$< -D .config Config.in
oldconfig: scripts/config/conf .config.in FORCE
$< -o Config.in
menuconfig: scripts/config/mconf .config.in FORCE
$< Config.in
package/%: .pkginfo FORCE
$(MAKE) -C package $(patsubst package/%,%,$@)
target/%: .pkginfo FORCE
$(MAKE) -C target $(patsubst target/%,%,$@)
tools/%: FORCE
$(MAKE) -C tools $(patsubst tools/%,%,$@)
toolchain/%: FORCE
$(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
.prereq-build: include/prereq-build.mk
@$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \
rm -rf $(TOPDIR)/tmp; \
false; \
}
@rm -rf $(TOPDIR)/tmp
@touch $@
.prereq-packages: include/prereq.mk .pkginfo .config
@$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \
false; \
}
@rm -rf "$(TOPDIR)/tmp"
@touch $@
prereq: .prereq-build .prereq-packages FORCE
download: .config FORCE
$(MAKE) tools/download
$(MAKE) toolchain/download
$(MAKE) package/download
$(MAKE) target/download
world: .config FORCE
$(MAKE) tools/install
$(MAKE) toolchain/install
$(MAKE) target/compile
$(MAKE) package/compile
$(MAKE) package/install
$(MAKE) target/install
$(MAKE) package/index
clean: FORCE
rm -rf build_* bin
dirclean: clean
rm -rf staging_dir_* toolchain_build_* tool_build
distclean: dirclean config-clean
rm -rf dl .*config* .pkg* .prereq
.SILENT: clean dirclean distclean config-clean download world
FORCE: ;
.PHONY: FORCE
%: ;

24
README Normal file
View file

@ -0,0 +1,24 @@
This is the buildsystem for the OpenWrt Linux distribution
Please use "make menuconfig" to configure your appreciated
configuration for the toolchain and firmware.
You need to have installed gcc, binutils, patch, bzip2, flex, bison,
make, gettext, pkg-config, unzip, libz-dev and libc headers.
Simply running 'make' will build your firmware.
It will download all sources, build the cross-compile toolchain,
the kernel and all choosen applications.
You can use scripts/flash.sh for remotely updating your embedded system
via tftp.
The buildroot system is documented in docs/buildroot-documentation.html.
Building your own firmware you need to have access to a Linux system.
Sunshine!
Your OpenWrt Project
http://openwrt.org

72
docs/config.txt Normal file
View file

@ -0,0 +1,72 @@
== Structure of the configuration files ==
The config files are divided into sections and options/values.
Every section has a type, but does not necessarily have a name.
Every option has a name and a value and is assigned to the section
it was written under.
Syntax:
config <type> [<name>] # Section
option <name> <value> # Option
Every parameter needs to be a single string and is formatted exactly
like a parameter for a shell function. The same rules for Quoting and
special characters also apply, as it is parsed by the shell.
== Parsing configuration files in custom scripts ==
To be able to load configuration files, you need to include the common
functions with:
. /etc/functions.sh
Then you can use config_load <name> to load config files. The function
first checks for <name> as absolute filename and falls back to loading
it from /etc/config (which is the most common way of using it).
If you want to use special callbacks for sections and/or options, you
need to define the following shell functions before running config_load
(after including /etc/functions.sh):
config_cb() {
local type="$1"
local name="$2"
# commands to be run for every section
}
option_cb() {
# commands to be run for every option
}
You can also alter option_cb from config_cb based on the section type.
This allows you to process every single config section based on its type
individually.
config_cb is run every time a new section starts (before options are being
processed). You can access the last section through the CONFIG_SECTION
variable. Also an extra call to config_cb (without a new section) is generated
after config_load is done.
That allows you to process sections both before and after all options were
processed.
You can access already processed options with the config_get command
Syntax:
config_get <section> <option> # prints the value of the option
config_get <variable> <section> <option> # stores the value inside the variable
In busybox ash the three-option config_get is faster, because it does not
result in an extra fork, so it is the preferred way.
Additionally you can also modify or add options to sections by using the
config_set command.
Syntax:
config_set <section> <option> <value>

52
docs/network-scripts.txt Normal file
View file

@ -0,0 +1,52 @@
Structure of the network scripts in buildroot-ng
1) Usage
To be able to access the network functions, you need to include
the necessary shell scripts by running:
. /etc/functions.sh # common functions
include /lib/network # include /lib/network/*.sh
scan_interfaces # read and parse the network config
Some protocols, such as PPP might change the configured interface names
at run time (e.g. eth0 => ppp0 for PPPoE). That's why you have to run
scan_interfaces instead of reading the values from the config directly.
After running scan_interfaces, the 'ifname' option will always contain
the effective interface name (which is used for IP traffic) and if the
physical device name differs from it, it will be stored in the 'device'
option.
That means that running 'config_get lan ifname' after scan_interfaces
might not return the same result as running it before.
After running scan_interfaces, the following functions are available:
- find_config <interface> looks for a network configuration that includes
the specified network interface.
- setup_interface <interface> [<config>] [<protocol>] will set up the
specified interface, optionally overriding the network configuration
name or the protocol that it uses.
2) Writing protocol handlers
You can add custom protocol handlers by adding shell scripts to
/lib/network. They provide the following two shell functions:
scan_<protocolname>() {
local config="$1"
# change the interface names if necessary
}
setup_interface_<protocolname>() {
local interface="$1"
local config="$2"
# set up the interface
}
scan_<protocolname> is optional and only necessary if your protocol
uses a custom device, e.g. a tunnel or a PPP device.

79
docs/network.txt Normal file
View file

@ -0,0 +1,79 @@
Network configuration in buildroot-ng
The network configuration in buildroot-ng is stored in /etc/config/network
and is divided into interface configurations.
Each interface configuration either refers directly to an ethernet/wifi
interface (eth0, wl0, ..) or to a bridge containing multiple interfaces.
It looks like this:
config interface "lan"
option ifname "eth0"
option proto "static"
option ipaddr "192.168.1.1"
option netmask "255.255.255.0"
option gateway "192.168.1.254"
option dns "192.168.1.254"
"ifname" specifies the Linux interface name.
If you want to use bridging on one or more interfaces, set "ifname" to a list
of interfaces and add:
option type "bridge"
It is possible to use VLAN tagging on an interface simply by adding the VLAN IDs
to it, e.g. "eth0.1". These can be nested as well.
This sets up a simple static configuration for eth0. "proto" specifies the
'protocol' used for the interface. The default image usually provides 'none'
'static', 'dhcp' and 'pppoe'. Others can be added by installing additional
packages.
When using the 'static' method like in the example, the options "ipaddr" and
"netmask" are mandatory, while "gateway" and "dns" are optional.
DHCP currently only accepts "ipaddr" (IP address to request from the server)
and "hostname" (client hostname identify as) - both are optional.
PPP based protocols (pppoe, pptp, ...) accept these options:
username:
The PPP username (usually with PAP authentication)
password:
The PPP password
keepalive:
Ping the PPP server (using LCP). The value of this option
specifies the maximum number of failed pings before reconnecting.
The ping interval defaults to 5, but can be changed by appending
",<interval>" to the keepalive value
demand:
Use Dial on Demand (value specifies the maximum idle time)
(pptp)
server: The remote pptp server IP
For all protocol types, you can also specify the MTU by using the "mtu" option.
Setting up the switch (currently broadcom only)
The switch configuration is set by adding a 'switch' config section.
Example:
config switch eth0
option vlan0 "1 2 3 4 5*"
option vlan1 "0 5"
On Broadcom hardware the section name needs to be eth0, as the switch driver
does not detect the switch on any other physical device.
Every vlan option needs to have the name vlan<n> where <n> is the VLAN number
as used in the switch driver.
As value it takes a list of ports with these optional suffixes:
'*': Set the default VLAN (PVID) of the Port to the current VLAN
'u': Force the port to be untagged
't': Force the port to be tagged
The CPU port defaults to tagged, all other ports to untagged.
On Broadcom hardware the CPU port is always 5. The other ports may vary with
different hardware.

123
include/host-build.mk Normal file
View file

@ -0,0 +1,123 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(INCLUDE_DIR)/host.mk
ifneq ($(strip $(PKG_CAT)),)
ifeq ($(PKG_CAT),unzip)
UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
else
UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
endif
define Build/Prepare/Default
$(UNPACK)
@if [ -d ./patches ]; then \
$(PATCH) $(PKG_BUILD_DIR) ./patches; \
fi
endef
endif
define Build/Prepare
$(call Build/Prepare/Default)
endef
define Build/Configure/Default
@(cd $(PKG_BUILD_DIR)/$(3); \
[ -x configure ] && \
$(2) \
CPPFLAGS="-I$(STAGING_DIR)/host/include" \
LDFLAGS="-L$(STAGING_DIR)/host/lib" \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--program-prefix="" \
--program-suffix="" \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/man \
--infodir=/usr/info \
$(DISABLE_NLS) \
$(1); \
true; \
)
endef
define Build/Configure
$(call Build/Configure/Default)
endef
define Build/Compile/Default
$(MAKE) -C $(PKG_BUILD_DIR) $(1)
endef
define Build/Compile
$(call Build/Compile/Default)
endef
ifneq ($(strip $(PKG_SOURCE)),)
download: $(DL_DIR)/$(PKG_SOURCE)
$(DL_DIR)/$(PKG_SOURCE):
mkdir -p $(DL_DIR)
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
$(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
endif
define HostBuild
$(PKG_BUILD_DIR)/.prepared:
@-rm -rf $(PKG_BUILD_DIR)
@mkdir -p $(PKG_BUILD_DIR)
$(call Build/Prepare)
touch $$@
$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
$(call Build/Configure)
touch $$@
$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
$(call Build/Compile)
touch $$@
$(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
$(call Build/Install)
touch $$@
ifdef Build/Install
install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
endif
package-clean: FORCE
$(call Build/Clean)
$(call Build/Uninstall)
rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
download:
prepare: $(PKG_BUILD_DIR)/.prepared
configure: $(PKG_BUILD_DIR)/.configured
compile-targets: $(PKG_BUILD_DIR)/.built
compile: compile-targets
install-targets:
install: install-targets
clean-targets:
clean: FORCE
@$(MAKE) clean-targets
$(call Build/Clean)
rm -rf $(PKG_BUILD_DIR)
endef

31
include/host.mk Normal file
View file

@ -0,0 +1,31 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/.host.mk
export TAR
$(TOPDIR)/.host.mk: $(INCLUDE_DIR)/host.mk
@( \
HOST_OS=`uname`; \
case "$$HOST_OS" in \
Linux) HOST_ARCH=`uname -m`;; \
*) HOST_ARCH=`uname -p`;; \
esac; \
GNU_HOST_NAME=`gcc -dumpmachine`; \
[ -n "$$GNU_HOST_NAME" ] || \
GNU_HOST_NAME=`$(SCRIPT_DIR)/config.guess`; \
echo "HOST_OS:=$$HOST_OS" > $@; \
echo "HOST_ARCH:=$$HOST_ARCH" >> $@; \
echo "GNU_HOST_NAME:=$$GNU_HOST_NAME" >> $@; \
if tar --version 2>&1 | grep 'GNU' >/dev/null; then \
echo "TAR_WILDCARDS:=--wildcards" >> $@; \
fi; \
TAR=`which gtar tar | head -n 1`; \
echo "TAR:=$$TAR" >> $@; \
)

96
include/image.mk Normal file
View file

@ -0,0 +1,96 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
ifneq ($(CONFIG_BIG_ENDIAN),y)
JFFS2OPTS := --pad --little-endian --squash
SQUASHFS_OPTS := -le
else
JFFS2OPTS := --pad --big-endian --squash
SQUASHFS_OPTS := -be
endif
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
define Image/mkfs/jffs2
rm -rf $(BUILD_DIR)/root/jffs
$(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root
$(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root
# add End-of-Filesystem markers
echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-64k
echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-128k
$(call Image/Build,jffs2-64k)
$(call Image/Build,jffs2-128k)
endef
endif
ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
define Image/mkfs/squashfs
@mkdir -p $(BUILD_DIR)/root/jffs
$(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
$(call Image/Build,squashfs)
endef
endif
ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
define Image/mkfs/tgz
tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
endef
endif
endif
ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
define Image/mkfs/ext2
$(STAGING_DIR)/bin/genext2fs -q -b 8192 -I 1500 -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
$(call Image/Build,ext2)
endef
endif
define Image/mkfs/prepare/default
find $(BUILD_DIR)/root -type f -not -perm +0100 | xargs chmod 0644
find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755
find $(BUILD_DIR)/root -type d | xargs chmod 0755
mkdir -p $(BUILD_DIR)/root/tmp
chmod 0777 $(BUILD_DIR)/root/tmp
endef
define Image/mkfs/prepare
$(call Image/mkfs/prepare/default)
endef
define BuildImage
compile:
$(call Build/Compile)
install:
$(call Image/Prepare)
$(call Image/mkfs/prepare)
$(call Image/BuildKernel)
$(call Image/mkfs/jffs2)
$(call Image/mkfs/squashfs)
$(call Image/mkfs/tgz)
$(call Image/mkfs/ext2)
clean:
$(call Build/Clean)
endef
compile-targets:
install-targets:
clean-targets:
download:
prepare:
compile: compile-targets
install: compile install-targets
clean: clean-targets

145
include/kernel-build.mk Normal file
View file

@ -0,0 +1,145 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(INCLUDE_DIR)/host.mk
-include $(INCLUDE_DIR)/modules-$(KERNEL).mk
LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
LINUX_SITE=http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
KERNEL_IDIR:=$(KERNEL_BUILD_DIR)/kernel-ipkg
KERNEL_IPKG:=$(KERNEL_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
TARGETS += $(KERNEL_IPKG)
INSTALL_TARGETS += $(KERNEL_IPKG)
LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
-e 's/mipsel/mips/' \
-e 's/mipseb/mips/' \
-e 's/powerpc/ppc/' \
-e 's/sh[234]/sh/' \
-e 's/armeb/arm/' \
)
$(TARGETS): $(PACKAGE_DIR)
$(PACKAGE_DIR):
mkdir -p $@
$(DL_DIR)/$(LINUX_SOURCE):
-mkdir -p $(DL_DIR)
$(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
$(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
-mkdir -p $(KERNEL_BUILD_DIR)
bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS) -
touch $@
ifeq ($(KERNEL),2.4)
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
$(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig include/linux/compile.h include/linux/version.h
touch $@
$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
touch $@
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
else
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
touch $@
endif
ramdisk-config: $(LINUX_DIR)/.configured FORCE
mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
mkdir -p $(BUILD_DIR)/root/etc/init.d
$(CP) ../generic-2.6/files/init $(BUILD_DIR)/root/
else
rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
endif
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.linux-compile pkg-install ramdisk-config
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) $(KERNELNAME)
$(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
touch -c $(LINUX_KERNEL)
$(LINUX_DIR)/.modules_done:
rm -rf $(KERNEL_BUILD_DIR)/modules
$(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) modules
$(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
touch $(LINUX_DIR)/.modules_done
modules: $(LINUX_DIR)/.modules_done
packages: $(TARGETS)
$(LINUX_DIR)/.linux-compile:
@rm -f $(BUILD_DIR)/linux
ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
@$(MAKE) modules
touch $@
$(KERNEL_IPKG):
rm -rf $(KERNEL_IDIR)
mkdir -p $(KERNEL_IDIR)/etc
$(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
if [ -f ./config/$(BOARD).modules ]; then \
cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
fi
$(IPKG_BUILD) $(KERNEL_IDIR) $(KERNEL_BUILD_DIR)
$(TOPDIR)/.kernel.mk: $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL)/Makefile
echo "CONFIG_BOARD:=$(BOARD)" > $@
echo "CONFIG_KERNEL:=$(KERNEL)" >> $@
echo "CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
echo "CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
echo "CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
pkg-install: FORCE
@for pkg in $(INSTALL_TARGETS); do \
$(IPKG) install $$pkg || echo; \
done
download: $(DL_DIR)/$(LINUX_SOURCE)
prepare: $(LINUX_DIR)/.configured
@mkdir -p $(LINUX_DIR) $(PACKAGE_DIR)
compile: prepare $(LINUX_DIR)/.linux-compile
@$(MAKE) packages
install: compile $(LINUX_KERNEL)
mostlyclean: FORCE
rm -f $(LINUX_DIR)/.linux-compile
rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
rm -f $(LINUX_KERNEL)
rebuild: FORCE
-$(MAKE) mostlyclean
if [ -f $(LINUX_KERNEL) ]; then \
$(MAKE) clean; \
fi
$(MAKE) compile $(MAKE_TRACE)
clean: FORCE
rm -f $(STAMP_DIR)/.linux-compile
rm -rf $(KERNEL_BUILD_DIR)
rm -f $(TARGETS)

106
include/kernel.mk Normal file
View file

@ -0,0 +1,106 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
ifeq ($(DUMP),1)
KERNEL:=<KERNEL>
BOARD:=<BOARD>
LINUX_VERSION:=<LINUX_VERSION>
else
include $(TOPDIR)/.kernel.mk
include $(INCLUDE_DIR)/target.mk
# check to see if .kernel.mk matches target.mk
ifeq ($(CONFIG_BOARD)-$(CONFIG_KERNEL),$(BOARD)-$(KERNEL))
LINUX_VERSION:=$(CONFIG_LINUX_VERSION)
LINUX_RELEASE:=$(CONFIG_LINUX_RELEASE)
LINUX_KARCH:=$(CONFIG_LINUX_KARCH)
else
# oops, old .kernel.config; rebuild it (hiding the misleading errors this produces)
$(warning rebuilding .kernel.mk)
$(TOPDIR)/.kernel.mk: FORCE
@$(MAKE) -C $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL) $@ &>/dev/null
endif
ifeq ($(KERNEL),2.6)
LINUX_KMOD_SUFFIX=ko
else
LINUX_KMOD_SUFFIX=o
endif
KERNELNAME=
ifneq (,$(findstring x86,$(BOARD)))
KERNELNAME="bzImage"
endif
ifneq (,$(findstring ppc,$(BOARD)))
KERNELNAME="uImage"
endif
ifneq (,$(findstring uml,$(BOARD)))
LINUX_KARCH:=um
KERNEL_CC:=$(HOSTCC)
KERNEL_CROSS:=
else
KERNEL_CC:=$(TARGET_CC)
KERNEL_CROSS:=$(TARGET_CROSS)
endif
KERNEL_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
LINUX_DIR := $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
MODULES_DIR := $(KERNEL_BUILD_DIR)/modules/$(MODULES_SUBDIR)
TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
KMOD_BUILD_DIR := $(KERNEL_BUILD_DIR)/linux-modules
LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
endif
# FIXME: remove this crap
define KMOD_template
ifeq ($$(strip $(4)),)
KDEPEND_$(1):=m
else
KDEPEND_$(1):=$($(4))
endif
IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
ifeq ($$(KDEPEND_$(1)),m)
ifneq ($$(CONFIG_PACKAGE_KMOD_$(1)),)
TARGETS += $$(PKG_$(1))
endif
ifeq ($$(CONFIG_PACKAGE_KMOD_$(1)),y)
INSTALL_TARGETS += $$(PKG_$(1))
endif
endif
$$(PKG_$(1)): $(LINUX_DIR)/.modules_done
rm -rf $$(I_$(1))
$(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
ifneq ($(strip $(3)),)
mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
$(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
endif
ifneq ($(6),)
mkdir -p $$(I_$(1))/etc/modules.d
for module in $(7); do \
echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
done
echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
chmod 0755 $$(I_$(1))/CONTROL/postinst
endif
$(8)
$(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)
endef

196
include/modules-2.4.mk Normal file
View file

@ -0,0 +1,196 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(INCLUDE_DIR)/netfilter.mk
# Networking
$(eval $(call KMOD_template,ATM,atm,\
$(MODULES_DIR)/kernel/net/atm/atm.o \
$(MODULES_DIR)/kernel/net/atm/br2684.o \
,CONFIG_ATM,,50,atm))
# Block devices
$(eval $(call KMOD_template,LOOP,loop,\
$(MODULES_DIR)/kernel/drivers/block/loop.o \
,CONFIG_BLK_DEV_LOOP,,20,loop))
$(eval $(call KMOD_template,NBD,nbd,\
$(MODULES_DIR)/kernel/drivers/block/nbd.o \
,CONFIG_BLK_DEV_NBD,,20,nbd))
# Filesystems
$(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
$(MODULES_DIR)/kernel/fs/cifs/cifs.o \
,CONFIG_CIFS,,30,cifs))
$(eval $(call KMOD_template,FS_MINIX,fs-minix,\
$(MODULES_DIR)/kernel/fs/minix/*.o \
,CONFIG_MINIX_FS,,30,minix))
$(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
$(MODULES_DIR)/kernel/fs/ext2/*.o \
,CONFIG_EXT2_FS,,30,ext2))
$(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
$(MODULES_DIR)/kernel/fs/ext3/*.o \
$(MODULES_DIR)/kernel/fs/jbd/*.o \
,CONFIG_EXT3_FS,,30,jbd ext3))
$(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
$(MODULES_DIR)/kernel/fs/hfsplus/*.o \
,CONFIG_HFSPLUS_FS,,30,hfsplus))
$(eval $(call KMOD_template,FS_NFS,fs-nfs,\
$(MODULES_DIR)/kernel/fs/lockd/*.o \
$(MODULES_DIR)/kernel/fs/nfs/*.o \
$(MODULES_DIR)/kernel/net/sunrpc/*.o \
,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
$(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
$(MODULES_DIR)/kernel/fs/vfat/vfat.o \
$(MODULES_DIR)/kernel/fs/fat/fat.o \
,CONFIG_VFAT_FS,,30,fat vfat))
$(eval $(call KMOD_template,FS_XFS,fs-xfs,\
$(MODULES_DIR)/kernel/fs/xfs/*.o \
,CONFIG_XFS_FS,,30,xfs))
# Multimedia
$(eval $(call KMOD_template,PWC,pwc,\
$(MODULES_DIR)/kernel/drivers/usb/pwc.o \
,CONFIG_USB_PWC,kmod-videodev,63,pwc))
$(eval $(call KMOD_template,SOUNDCORE,soundcore,\
$(MODULES_DIR)/kernel/drivers/sound/soundcore.o \
,CONFIG_SOUND,,30,soundcore))
$(eval $(call KMOD_template,VIDEODEV,videodev,\
$(MODULES_DIR)/kernel/drivers/media/video/videodev.o \
,CONFIG_VIDEO_DEV,,62,videodev))
# Network devices
$(eval $(call KMOD_template,NET_AIRO,net-airo,\
$(MODULES_DIR)/kernel/drivers/net/wireless/airo.o \
,CONFIG_AIRO,,10,airo))
$(eval $(call KMOD_template,NET_HERMES,net-hermes,\
$(MODULES_DIR)/kernel/drivers/net/wireless/hermes.o \
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco.o \
,CONFIG_HERMES,,10,hermes orinoco))
$(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-pci,\
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_pci.o \
,CONFIG_PCI_HERMES,kmod-net-hermes,11,orinoco_pci))
$(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-plx,\
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_plx.o \
,CONFIG_PLX_HERMES,kmod-net-hermes,11,orinoco_plx))
$(eval $(call KMOD_template,NET_PRISM54,net-prism54,\
$(MODULES_DIR)/kernel/drivers/net/wireless/prism54/prism54.o \
,CONFIG_PRISM54,,10,prism54))
# PCMCIA/CardBus
$(eval $(call KMOD_template,PCMCIA_CORE,pcmcia-core,\
$(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia_core.o \
$(MODULES_DIR)/kernel/drivers/pcmcia/yenta_socket.o \
$(MODULES_DIR)/kernel/drivers/pcmcia/ds.o \
,CONFIG_PCMCIA,,50,pcmcia_core yenta_socket ds))
$(eval $(call KMOD_template,PCMCIA_SERIAL,pcmcia-serial,\
$(MODULES_DIR)/kernel/drivers/char/pcmcia/serial_cs.o \
,CONFIG_PCMCIA_SERIAL_CS,kmod-pcmcia-core,51,serial_cs))
# USB
$(eval $(call KMOD_template,USB,usb-core,\
$(MODULES_DIR)/kernel/drivers/usb/usbcore.o \
,CONFIG_USB,,50,usbcore))
$(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
$(MODULES_DIR)/kernel/drivers/usb/host/usb-ohci.o \
,CONFIG_USB_OHCI,kmod-usb-core,60,usb-ohci))
$(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
$(MODULES_DIR)/kernel/drivers/usb/host/uhci.o \
,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
$(eval $(call KMOD_template,USB2,usb2,\
$(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.o \
,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
$(eval $(call KMOD_template,USB_ACM,usb-acm,\
$(MODULES_DIR)/kernel/drivers/usb/acm.o \
,CONFIG_USB_ACM))
$(eval $(call KMOD_template,USB_AUDIO,usb-audio,\
$(MODULES_DIR)/kernel/drivers/usb/audio.o \
,CONFIG_USB_AUDIO,kmod-soundcore kmod-usb-core,61,audio))
$(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
$(MODULES_DIR)/kernel/drivers/usb/printer.o \
,CONFIG_USB_PRINTER,kmod-usb-core,60,printer))
$(eval $(call KMOD_template,USB_SERIAL,usb-serial,\
$(MODULES_DIR)/kernel/drivers/usb/serial/usbserial.o \
,CONFIG_USB_SERIAL,kmod-usb-core,60,usbserial))
$(eval $(call KMOD_template,USB_SERIAL_BELKIN,usb-serial-belkin,\
$(MODULES_DIR)/kernel/drivers/usb/serial/belkin_sa.o \
,CONFIG_USB_SERIAL_BELKIN,kmod-usb-serial,61,belkin_sa))
$(eval $(call KMOD_template,USB_SERIAL_FTDI,usb-serial-ftdi,\
$(MODULES_DIR)/kernel/drivers/usb/serial/ftdi_sio.o \
,CONFIG_USB_SERIAL_FTDI_SIO,kmod-usb-serial,61,ftdi_sio))
$(eval $(call KMOD_template,USB_SERIAL_MCT_U232,usb-serial-mct-u232,\
$(MODULES_DIR)/kernel/drivers/usb/serial/mct_u232.o \
,CONFIG_USB_SERIAL_MCT_U232,kmod-usb-serial,61,mct_u232))
$(eval $(call KMOD_template,USB_SERIAL_PL2303,usb-serial-pl2303,\
$(MODULES_DIR)/kernel/drivers/usb/serial/pl2303.o \
,CONFIG_USB_SERIAL_PL2303,kmod-usb-serial,61,pl2303))
$(eval $(call KMOD_template,USB_SERIAL_VISOR,usb-serial-visor,\
$(MODULES_DIR)/kernel/drivers/usb/serial/visor.o \
,CONFIG_USB_SERIAL_VISOR,kmod-usb-serial,61,visor))
$(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
$(MODULES_DIR)/kernel/drivers/scsi/*.o \
$(MODULES_DIR)/kernel/drivers/usb/storage/*.o \
,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
# Misc. devices
$(eval $(call KMOD_template,AX25,ax25,\
$(MODULES_DIR)/kernel/net/ax25/ax25.o \
$(MODULES_DIR)/kernel/drivers/net/hamradio/mkiss.o \
,CONFIG_AX25,,90,ax25 mkiss))
$(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
$(MODULES_DIR)/kernel/net/bluetooth/*.o \
$(MODULES_DIR)/kernel/net/bluetooth/rfcomm/*.o \
$(MODULES_DIR)/kernel/drivers/bluetooth/*.o \
,CONFIG_BLUEZ))
$(eval $(call KMOD_template,SOFTDOG,softdog,\
$(MODULES_DIR)/kernel/drivers/char/softdog.o \
,CONFIG_SOFT_WATCHDOG,,95,softdog))

233
include/modules-2.6.mk Normal file
View file

@ -0,0 +1,233 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
NF_2_6:=1
include $(INCLUDE_DIR)/netfilter.mk
# Networking
$(eval $(call KMOD_template,ATM,atm,\
$(MODULES_DIR)/kernel/net/atm/atm.ko \
$(MODULES_DIR)/kernel/net/atm/br2684.ko \
$(MODULES_DIR)/kernel/drivers/atm/atmtcp.ko \
,CONFIG_ATM,,50,atm))
# Block devices
$(eval $(call KMOD_template,LOOP,loop,\
$(MODULES_DIR)/kernel/drivers/block/loop.ko \
,CONFIG_BLK_DEV_LOOP,,20,loop))
$(eval $(call KMOD_template,NBD,nbd,\
$(MODULES_DIR)/kernel/drivers/block/nbd.ko \
,CONFIG_BLK_DEV_NBD,,20,nbd))
# Filesystems
$(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
$(MODULES_DIR)/kernel/fs/cifs/cifs.ko \
,CONFIG_CIFS,kmod-nls-base,30,cifs))
$(eval $(call KMOD_template,FS_MINIX,fs-minix,\
$(MODULES_DIR)/kernel/fs/minix/minix.ko \
,CONFIG_MINIX_FS,,30,minix))
$(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
$(MODULES_DIR)/kernel/fs/ext2/ext2.ko \
,CONFIG_EXT2_FS,,30,ext2))
$(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
$(MODULES_DIR)/kernel/fs/ext3/ext3.ko \
$(MODULES_DIR)/kernel/fs/jbd/jbd.ko \
,CONFIG_EXT3_FS,,30,jbd ext3))
$(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
$(MODULES_DIR)/kernel/fs/hfsplus/hfsplus.ko \
,CONFIG_HFSPLUS_FS,kmod-nls-base,30,hfsplus))
$(eval $(call KMOD_template,FS_NFS,fs-nfs,\
$(MODULES_DIR)/kernel/fs/lockd/lockd.ko \
$(MODULES_DIR)/kernel/fs/nfs/nfs.ko \
$(MODULES_DIR)/kernel/net/sunrpc/sunrpc.ko \
,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
$(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
$(MODULES_DIR)/kernel/fs/fat/fat.ko \
$(MODULES_DIR)/kernel/fs/vfat/vfat.ko \
,CONFIG_VFAT_FS,kmod-nls-base,30,fat vfat))
$(eval $(call KMOD_template,FS_XFS,fs-xfs,\
$(MODULES_DIR)/kernel/fs/xfs/xfs.ko \
,CONFIG_XFS_FS,,30,xfs))
# Multimedia
$(eval $(call KMOD_template,PWC,pwc,\
$(MODULES_DIR)/kernel/drivers/usb/media/pwc/pwc.ko \
,CONFIG_USB_PWC,kmod-videodev,63,pwc))
$(eval $(call KMOD_template,SOUNDCORE,soundcore,\
$(MODULES_DIR)/kernel/sound/soundcore.ko \
,CONFIG_SOUND,,30,soundcore))
$(eval $(call KMOD_template,VIDEODEV,videodev,\
$(MODULES_DIR)/kernel/drivers/media/video/v4l1-compat.ko \
$(MODULES_DIR)/kernel/drivers/media/video/v4l2-common.ko \
$(MODULES_DIR)/kernel/drivers/media/video/videodev.ko \
,CONFIG_VIDEO_DEV,,62,videodev))
# NLS
$(eval $(call KMOD_template,NLS_BASE,nls-base,\
$(MODULES_DIR)/kernel/fs/nls/nls_base.ko \
,CONFIG_NLS,,20,nls_base))
$(eval $(call KMOD_template,NLS_CP437,nls-cp437,\
$(MODULES_DIR)/kernel/fs/nls/nls_cp437.ko \
,CONFIG_NLS_CODEPAGE_437,,20,nls_cp437))
$(eval $(call KMOD_template,NLS_CP850,nls-cp850,\
$(MODULES_DIR)/kernel/fs/nls/nls_cp850.ko \
,CONFIG_NLS_CODEPAGE_850,,20,nls_cp850))
$(eval $(call KMOD_template,NLS_ISO8859_1,nls-iso8859-1,\
$(MODULES_DIR)/kernel/fs/nls/nls_iso8859-1.ko \
,CONFIG_NLS_ISO8859_1,,20,nls_iso8859-1))
$(eval $(call KMOD_template,NLS_ISO8859_15,nls-iso8859-15,\
$(MODULES_DIR)/kernel/fs/nls/nls_iso8859-15.ko \
,CONFIG_NLS_ISO8859_15,,20,nls_iso8859-15))
$(eval $(call KMOD_template,NLS_UTF8,nls-utf8,\
$(MODULES_DIR)/kernel/fs/nls/nls_utf8.ko \
,CONFIG_NLS_UTF8,,20,nls_utf8))
# Network devices
$(eval $(call KMOD_template,NET_AIRO,net-airo,\
$(MODULES_DIR)/kernel/drivers/net/wireless/airo.ko \
,CONFIG_AIRO,,10,airo))
$(eval $(call KMOD_template,NET_HERMES,net-hermes,\
$(MODULES_DIR)/kernel/drivers/net/wireless/hermes.ko \
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco.ko \
,CONFIG_HERMES,,10,hermes orinoco))
$(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-pci,\
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_pci.ko \
,CONFIG_PCI_HERMES,kmod-net-hermes,11,orinoco_pci))
$(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-plx,\
$(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_plx.ko \
,CONFIG_PLX_HERMES,kmod-net-hermes,11,orinoco_plx))
$(eval $(call KMOD_template,NET_PRISM54,net-prism54,\
$(MODULES_DIR)/kernel/drivers/net/wireless/prism54/prism54.ko \
,CONFIG_PRISM54,,10,prism54))
# PCMCIA/CardBus
$(eval $(call KMOD_template,PCMCIA_CORE,pcmcia-core,\
$(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia.ko \
$(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia_core.ko \
$(MODULES_DIR)/kernel/drivers/pcmcia/yenta_socket.ko \
$(MODULES_DIR)/kernel/drivers/pcmcia/rsrc_nonstatic.ko \
,CONFIG_PCMCIA,,50,pcmcia_core pcmcia yenta_socket rsrc_nonstatic))
$(eval $(call KMOD_template,PCMCIA_SERIAL,pcmcia-serial,\
$(MODULES_DIR)/kernel/drivers/serial/serial_cs.ko \
,CONFIG_SERIAL_8250_CS))
# USB
$(eval $(call KMOD_template,USB,usb-core,\
$(MODULES_DIR)/kernel/drivers/usb/core/usbcore.ko \
,CONFIG_USB,,50,usbcore))
$(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
$(MODULES_DIR)/kernel/drivers/usb/host/ohci-hcd.ko \
,CONFIG_USB_OHCI_HCD,kmod-usb-core,60,ohci-hcd))
$(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
$(MODULES_DIR)/kernel/drivers/usb/host/uhci-hcd.ko \
,CONFIG_USB_UHCI_HCD,kmod-usb-core,60,uhci-hcd))
$(eval $(call KMOD_template,USB2,usb2,\
$(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.ko \
,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
$(eval $(call KMOD_template,USB_ACM,usb-acm,\
$(MODULES_DIR)/kernel/drivers/usb/class/cdc-acm.ko \
,CONFIG_USB_ACM))
$(eval $(call KMOD_template,USB_AUDIO,usb-audio,\
$(MODULES_DIR)/kernel/drivers/usb/class/audio.ko \
,CONFIG_USB_AUDIO,kmod-soundcore kmod-usb-core,61,audio))
$(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
$(MODULES_DIR)/kernel/drivers/usb/class/usblp.ko \
,CONFIG_USB_PRINTER,kmod-usb-core,60,usblp))
$(eval $(call KMOD_template,USB_SERIAL,usb-serial,\
$(MODULES_DIR)/kernel/drivers/usb/serial/usbserial.ko \
,CONFIG_USB_SERIAL,kmod-usb-core,60,usbserial))
$(eval $(call KMOD_template,USB_SERIAL_BELKIN,usb-serial-belkin,\
$(MODULES_DIR)/kernel/drivers/usb/serial/belkin_sa.ko \
,CONFIG_USB_SERIAL_BELKIN,kmod-usb-serial,61,belkin_sa))
$(eval $(call KMOD_template,USB_SERIAL_FTDI,usb-serial-ftdi,\
$(MODULES_DIR)/kernel/drivers/usb/serial/ftdi_sio.ko \
,CONFIG_USB_SERIAL_FTDI_SIO,kmod-usb-serial,61,ftdi_sio))
$(eval $(call KMOD_template,USB_SERIAL_MCT_U232,usb-serial-mct-u232,\
$(MODULES_DIR)/kernel/drivers/usb/serial/mct_u232.ko \
,CONFIG_USB_SERIAL_MCT_U232,kmod-usb-serial,61,mct_u232))
$(eval $(call KMOD_template,USB_SERIAL_PL2303,usb-serial-pl2303,\
$(MODULES_DIR)/kernel/drivers/usb/serial/pl2303.ko \
,CONFIG_USB_SERIAL_PL2303,kmod-usb-serial,61,pl2303))
$(eval $(call KMOD_template,USB_SERIAL_VISOR,usb-serial-visor,\
$(MODULES_DIR)/kernel/drivers/usb/serial/visor.ko \
,CONFIG_USB_SERIAL_VISOR,kmod-usb-serial,61,visor))
$(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
$(MODULES_DIR)/kernel/drivers/scsi/scsi_mod.ko \
$(MODULES_DIR)/kernel/drivers/scsi/sd_mod.ko \
$(MODULES_DIR)/kernel/drivers/usb/storage/usb-storage.ko \
,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
$(eval $(call KMOD_template,USB_ATM,usb-atm,\
$(MODULES_DIR)/kernel/drivers/usb/atm/usbatm.ko \
,CONFIG_USB_ATM,kmod-usb-atm,50,usbatm))
$(eval $(call KMOD_template,USB_ATM_SPEEDTOUCH,usb-atm-speedtouch,\
$(MODULES_DIR)/kernel/drivers/usb/atm/speedtch.ko \
,CONFIG_USB_SPEEDTOUCH,kmod-usb-atm-speedtouch,50,speedtch))
# Misc. devices
$(eval $(call KMOD_template,AX25,ax25,\
$(MODULES_DIR)/kernel/net/ax25/ax25.ko \
$(MODULES_DIR)/kernel/drivers/net/hamradio/mkiss.ko \
,CONFIG_AX25,,90,ax25 mkiss))
$(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
$(MODULES_DIR)/kernel/net/bluetooth/bluetooth.ko \
$(MODULES_DIR)/kernel/net/bluetooth/l2cap.ko \
$(MODULES_DIR)/kernel/net/bluetooth/sco.ko \
$(MODULES_DIR)/kernel/net/bluetooth/rfcomm/rfcomm.ko \
$(MODULES_DIR)/kernel/drivers/bluetooth/hci_uart.ko \
$(MODULES_DIR)/kernel/drivers/bluetooth/hci_usb.ko \
,CONFIG_BT))

122
include/netfilter.mk Normal file
View file

@ -0,0 +1,122 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: netfilter.mk 2411 2005-11-11 03:41:43Z nico $
ifeq ($(NF_KMOD),1)
P_V4:=ipv4/netfilter/
P_XT:=netfilter/
endif
IPT_CONNTRACK-m :=
IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_CONNMARK) += $(P_V4)ipt_connmark
IPT_CONNTRACK-$(CONFIG_IP_NF_TARGET_CONNMARK) += $(P_V4)ipt_CONNMARK
IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_CONNTRACK) += $(P_V4)ipt_conntrack
IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_HELPER) += $(P_V4)ipt_helper
IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_STATE) += $(P_V4)ipt_state
IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += $(P_XT)xt_conntrack
IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += $(P_XT)xt_helper
IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_STATE) += $(P_XT)xt_state
IPT_EXTRA-m :=
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_CONDITION) += $(P_V4)ipt_condition
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_CONNBYTES) += $(P_V4)ipt_connbytes
IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_CONNBYTES) += $(P_XT)xt_connbytes
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_LIMIT) += $(P_V4)ipt_limit
IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += $(P_XT)xt_limit
IPT_EXTRA-$(CONFIG_IP_NF_TARGET_LOG) += $(P_V4)ipt_LOG
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_MULTIPORT) += $(P_XT)xt_multiport
IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += $(P_XT)xt_multiport
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_OWNER) += $(P_V4)ipt_owner
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_PHYSDEV) += $(P_V4)ipt_physdev
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_PKTTYPE) += $(P_V4)ipt_pkttype
IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += $(P_XT)xt_pkttype
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_QUOTA) += $(P_V4)ipt_quota
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_RECENT) += $(P_V4)ipt_recent
IPT_EXTRA-$(CONFIG_IP_NF_TARGET_REJECT) += $(P_V4)ipt_REJECT
IPT_EXTRA-$(CONFIG_IP_NF_MATCH_STRING) += $(P_V4)ipt_string
IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_STRING) += $(P_XT)xt_string
IPT_FILTER-m :=
IPT_FILTER-$(CONFIG_IP_NF_MATCH_IPP2P) += $(P_V4)ipt_ipp2p
IPT_FILTER-$(CONFIG_IP_NF_MATCH_LAYER7) += $(P_V4)ipt_layer7
IPT_IMQ-m :=
IPT_IMQ-$(CONFIG_IP_NF_TARGET_IMQ) += $(P_V4)ipt_IMQ
IPT_IPOPT-m :=
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_DSCP) += $(P_V4)ipt_dscp
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_DSCP) += $(P_V4)ipt_DSCP
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_ECN) += $(P_V4)ipt_ecn
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_ECN) += $(P_V4)ipt_ECN
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_LENGTH) += $(P_V4)ipt_length
IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += $(P_XT)xt_length
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_MAC) += $(P_V4)ipt_mac
IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_MAC) += $(P_XT)xt_mac
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_MARK) += $(P_V4)ipt_mark
IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_MARK) += $(P_XT)xt_mark
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_MARK) += $(P_V4)ipt_MARK
IPT_IPOPT-$(CONFIG_NETFILTER_XT_TARGET_MARK) += $(P_XT)xt_MARK
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TCPMSS) += $(P_V4)ipt_tcpmss
IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += $(P_XT)xt_tcpmss
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TCPMSS) += $(P_V4)ipt_TCPMSS
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TOS) += $(P_V4)ipt_tos
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TIME) += $(P_V4)ipt_time
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TOS) += $(P_V4)ipt_TOS
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TTL) += $(P_V4)ipt_ttl
IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TTL) += $(P_V4)ipt_TTL
IPT_IPOPT-$(CONFIG_IP_NF_MATCH_UNCLEAN) += $(P_V4)ipt_unclean
IPT_IPSEC-m :=
IPT_IPSEC-$(CONFIG_IP_NF_MATCH_AH_ESP) += $(P_V4)ipt_ah $(P_V4)ipt_esp
IPT_IPSEC-$(CONFIG_IP_NF_MATCH_AH) += $(P_V4)ipt_ah
IPT_IPSEC-$(CONFIG_NETFILTER_XT_MATCH_ESP) += $(P_XT)xt_esp
IPT_NAT-m :=
ifneq ($(NF_KMOD),1)
IPT_NAT-$(CONFIG_IP_NF_NAT) += $(P_V4)ipt_SNAT $(P_V4)ipt_DNAT
endif
IPT_NAT-$(CONFIG_IP_NF_TARGET_MASQUERADE) += $(P_V4)ipt_MASQUERADE
IPT_NAT-$(CONFIG_IP_NF_TARGET_MIRROR) += $(P_V4)ipt_MIRROR
IPT_NAT-$(CONFIG_IP_NF_TARGET_REDIRECT) += $(P_V4)ipt_REDIRECT
IPT_NAT-$(CONFIG_IP_NF_TARGET_NETMAP) += $(P_V4)ipt_NETMAP
IPT_NAT_EXTRA-m :=
IPT_NAT_EXTRA-$(CONFIG_IP_NF_AMANDA) += $(P_V4)ip_conntrack_amanda
IPT_NAT_EXTRA-$(CONFIG_IP_NF_CT_PROTO_GRE) += $(P_V4)ip_conntrack_proto_gre
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_PROTO_GRE) += $(P_V4)ip_nat_proto_gre
IPT_NAT_EXTRA-$(CONFIG_IP_NF_H323) += $(P_V4)ip_conntrack_h323
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_H323) += $(P_V4)ip_nat_h323
IPT_NAT_EXTRA-$(CONFIG_IP_NF_MMS) += $(P_V4)ip_conntrack_mms
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_MMS) += $(P_V4)ip_nat_mms
IPT_NAT_EXTRA-$(CONFIG_IP_NF_RTSP) += $(P_V4)ip_conntrack_rtsp
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_RTSP) += $(P_V4)ip_nat_rtsp
IPT_NAT_EXTRA-$(CONFIG_IP_NF_PPTP) += $(P_V4)ip_conntrack_pptp
IPT_NAT_EXTRA-$(CONFIG_IP_NF_SIP) += $(P_V4)ip_conntrack_sip
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_PPTP) += $(P_V4)ip_nat_pptp
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SIP) += $(P_V4)ip_nat_sip
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += $(P_V4)ip_nat_snmp_basic
IPT_NAT_EXTRA-$(CONFIG_IP_NF_SIP) += $(P_V4)ip_conntrack_sip
IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SIP) += $(P_V4)ip_nat_sip
IPT_NAT_EXTRA-$(CONFIG_IP_NF_TFTP) += $(P_V4)ip_conntrack_tftp
IPT_QUEUE-m :=
IPT_QUEUE-$(CONFIG_IP_NF_QUEUE) += $(P_V4)ip_queue
IPT_ULOG-m :=
IPT_ULOG-$(CONFIG_IP_NF_TARGET_ULOG) += $(P_V4)ipt_ULOG
IPT_BUILTIN := $(P_V4)ipt_standard
IPT_BUILTIN += $(P_V4)ipt_icmp $(P_V4)ipt_tcp $(P_V4)ipt_udp
IPT_BUILTIN += $(IPT_CONNTRACK-y)
IPT_BUILTIN += $(IPT_EXTRA-y)
IPT_BUILTIN += $(IPT_FILTER-y)
IPT_BUILTIN += $(IPT_IMQ-y)
IPT_BUILTIN += $(IPT_IPOPT-y)
IPT_BUILTIN += $(IPT_IPSEC-y)
IPT_BUILTIN += $(IPT_NAT-y)
IPT_BUILTIN += $(IPT_ULOG-y)

372
include/package.mk Normal file
View file

@ -0,0 +1,372 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
ifneq ($(DUMP),)
all: dumpinfo
else
all: compile
endif
include $(INCLUDE_DIR)/prereq.mk
include $(INCLUDE_DIR)/host.mk
define shvar
V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
endef
define shexport
$(call shvar,$(1))=$$(call $(1))
export $(call shvar,$(1))
endef
define Build/DefaultTargets
ifeq ($(DUMP),)
ifeq ($(CONFIG_AUTOREBUILD),y)
_INFO:=
ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),$(PKG_BUILD_DIR))
_INFO+=$(subst $(TOPDIR)/,,$(PKG_BUILD_DIR))
$(PKG_BUILD_DIR)/.prepared: package-clean
endif
endif
endif
$(PKG_BUILD_DIR)/.prepared:
@-rm -rf $(PKG_BUILD_DIR)
@mkdir -p $(PKG_BUILD_DIR)
$(call Build/Prepare)
touch $$@
$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
$(call Build/Configure)
touch $$@
$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
$(call Build/Compile)
touch $$@
ifdef Build/InstallDev
ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed $(PKG_BUILD_DIR)),$(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed)
$(PKG_BUILD_DIR)/.built: package-rebuild
endif
$(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
mkdir -p $(STAGING_DIR)/stampfiles
$(call Build/InstallDev)
touch $$@
compile-targets: $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
endif
package-clean: FORCE
$(call Build/Clean)
$(call Build/UninstallDev)
-rm -f $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
package-rebuild: FORCE
@-rm -f $(PKG_BUILD_DIR)/.built
define Build/DefaultTargets
endef
endef
define Package/Default
CONFIGFILE:=
SECTION:=opt
CATEGORY:=Extra packages
DEPENDS:=
EXTRA_DEPENDS:=
MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
ifneq ($(PKG_VERSION),)
ifneq ($(PKG_RELEASE),)
VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
else
VERSION:=$(PKG_VERSION)
endif
else
VERSION:=$(PKG_RELEASE)
endif
PKGARCH:=$(ARCH)
PRIORITY:=optional
DEFAULT:=
MENU:=
SUBMENU:=
SUBMENUDEP:=
TITLE:=
DESCRIPTION:=
endef
define BuildDescription
ifneq ($(DESCRIPTION),)
DESCRIPTION:=$(TITLE)\\ $(DESCRIPTION)
else
DESCRIPTION:=$(TITLE)
endif
endef
define BuildIPKGVariable
$(call shexport,Package/$(1)/$(2))
$(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2);
endef
define BuildPackage
$(eval $(call Package/Default))
$(eval $(call Package/$(1)))
$(eval $(call BuildDescription))
$(foreach FIELD, TITLE CATEGORY PRIORITY SECTION VERSION,
ifeq ($($(FIELD)),)
$$(error Package/$(1) is missing the $(FIELD) field)
endif
)
IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
ifdef Package/$(1)/install
ifeq ($(CONFIG_PACKAGE_$(1)),y)
install-targets: $$(INFO_$(1))
endif
ifneq ($(CONFIG_PACKAGE_$(1)),)
compile-targets: $$(IPKG_$(1))
else
compile-targets: $(1)-disabled
$(1)-disabled:
@echo "WARNING: skipping $(1) -- package not selected"
endif
endif
ifeq ($(FORCEREBUILD),y)
$$(IPKG_$(1)): FORCE
endif
IDEPEND_$(1):=$$(strip $$(DEPENDS))
ifneq ($(DUMP),)
DUMPINFO += \
echo "Package: $(1)";
ifneq ($(MENU),)
DUMPINFO += \
echo "Menu: $(MENU)";
endif
ifneq ($(SUBMENU),)
DUMPINFO += \
echo "Submenu: $(SUBMENU)";
ifneq ($(SUBMENUDEP),)
DUMPINFO += \
echo "Submenu-Depends: $(SUBMENUDEP)";
endif
endif
ifneq ($(DEFAULT),)
DUMPINFO += \
echo "Default: $(DEFAULT)";
endif
$(call shexport,Package/$(1)/description)
DUMPINFO += \
if [ "$$$$PREREQ_CHECK" = 1 ]; then echo "Prereq-Check: 1"; fi; \
echo "Version: $(VERSION)"; \
echo "Depends: $$(IDEPEND_$(1))"; \
echo "Build-Depends: $(PKG_BUILDDEP)"; \
echo "Category: $(CATEGORY)"; \
echo "Title: $(TITLE)"; \
if isset $(call shvar,Package/$(1)/description); then \
echo -n "Description: "; \
getvar $(call shvar,Package/$(1)/description); \
else \
echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g'; \
fi;
ifneq ($(URL),)
DUMPINFO += \
echo; \
echo "$(URL)";
endif
DUMPINFO += \
echo "@@";
$(call shexport,Package/$(1)/config)
DUMPINFO += \
if isset $(call shvar,Package/$(1)/config); then echo "Config: "; getvar $(call shvar,Package/$(1)/config); fi; \
echo "@@";
endif
$(eval $(call BuildIPKGVariable,$(1),conffiles))
$(eval $(call BuildIPKGVariable,$(1),preinst))
$(eval $(call BuildIPKGVariable,$(1),postinst))
$(eval $(call BuildIPKGVariable,$(1),prerm))
$(eval $(call BuildIPKGVariable,$(1),postrm))
$$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
mkdir -p $$(IDIR_$(1))/CONTROL
echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
( \
DEPENDS=; \
for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
done; \
echo "Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \
)
echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g' | sed -e 's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_$(1))/CONTROL/control
chmod 644 $$(IDIR_$(1))/CONTROL/control
(cd $$(IDIR_$(1))/CONTROL; \
$($(1)_COMMANDS) \
)
$$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
$(call Package/$(1)/install,$$(IDIR_$(1)))
mkdir -p $(PACKAGE_DIR)
-find $$(IDIR_$(1)) -name CVS | xargs rm -rf
-find $$(IDIR_$(1)) -name .svn | xargs rm -rf
-find $$(IDIR_$(1)) -name '.#*' | xargs rm -f
$(RSTRIP) $$(IDIR_$(1))
$(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
@[ -f $$(IPKG_$(1)) ] || false
$$(INFO_$(1)): $$(IPKG_$(1))
$(IPKG) install $$(IPKG_$(1))
$(1)-clean:
rm -f $(PACKAGE_DIR)/$(1)_*
clean: $(1)-clean
$(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared
-@rm $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
@touch $$@
$$(eval $$(call Build/DefaultTargets,$(1)))
ifneq ($$(CONFIG_PACKAGE_$(1)),)
ifneq ($(MAKECMDGOALS),prereq)
ifneq ($(DUMP),1)
ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1)))
_INFO+=$(subst $(TOPDIR)/,,$$(IPKG_$(1)))
$(PKG_BUILD_DIR)/.built: package-rebuild
endif
ifneq ($$(_INFO),)
$$(info Rebuilding $$(_INFO))
endif
endif
endif
endif
endef
ifneq ($(strip $(PKG_CAT)),)
ifeq ($(PKG_CAT),unzip)
UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
else
UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
endif
define Build/Prepare/Default
$(UNPACK)
@if [ -d ./patches ]; then \
$(PATCH) $(PKG_BUILD_DIR) ./patches; \
fi
endef
endif
define Build/Prepare
$(call Build/Prepare/Default,)
endef
define Build/Configure/Default
(cd $(PKG_BUILD_DIR)/$(3); \
if [ -x configure ]; then \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
CXXFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig" \
$(2) \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--program-prefix="" \
--program-suffix="" \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/man \
--infodir=/usr/info \
$(DISABLE_NLS) \
$(1); \
fi; \
)
endef
define Build/Configure
$(call Build/Configure/Default,)
endef
define Build/Compile/Default
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
CROSS="$(TARGET_CROSS)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include " \
EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib " \
ARCH="$(ARCH)" \
$(1);
endef
define Build/Compile
$(call Build/Compile/Default,)
endef
ifneq ($(DUMP),)
dumpinfo: FORCE
@$(DUMPINFO)
else
$(PACKAGE_DIR):
mkdir -p $@
ifneq ($(strip $(PKG_SOURCE)),)
download: $(DL_DIR)/$(PKG_SOURCE)
$(DL_DIR)/$(PKG_SOURCE):
mkdir -p $(DL_DIR)
$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
$(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
endif
download:
prepare: $(PKG_BUILD_DIR)/.prepared
configure: $(PKG_BUILD_DIR)/.configured
compile-targets:
compile: compile-targets
install-targets:
install: install-targets
clean-targets:
clean: FORCE
@$(MAKE) clean-targets
$(call Build/Clean)
rm -rf $(PKG_BUILD_DIR)
endif

105
include/prereq-build.mk Normal file
View file

@ -0,0 +1,105 @@
#
# 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
TMP_DIR:=$(TOPDIR)/tmp
include $(INCLUDE_DIR)/prereq.mk
include $(INCLUDE_DIR)/host.mk
define Require/non-root
[ "$$(shell whoami)" != "root" ]
endef
$(eval $(call Require,non-root, \
Please do not compile as root. \
))
# Required for the toolchain
define Require/working-make
echo 'all: test' > $(TMP_DIR)/check.mk
echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
$(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
endef
$(eval $(call Require,working-make, \
Please install GNU make v3.81 or later. (This version has bugs) \
))
define Require/working-gcc
echo 'int main(int argc, char **argv) { return 0; }' | \
gcc -x c -o $(TMP_DIR)/a.out -
endef
$(eval $(call Require,working-gcc, \
Please install the GNU C Compiler (gcc). \
))
define Require/working-g++
echo 'int main(int argc, char **argv) { return 0; }' | \
g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
endef
$(eval $(call Require,working-g++, \
Please install the GNU C++ Compiler (g++). \
))
define Require/ncurses
echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
endef
$(eval $(call Require,ncurses, \
Please install ncurses. (Missing libncurses.so or ncurses.h) \
))
define Require/zlib
echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
endef
$(eval $(call Require,zlib, \
Please install zlib. (Missing libz.so or zlib.h) \
))
$(eval $(call RequireCommand,bison, \
Please install GNU bison. \
))
$(eval $(call RequireCommand,flex, \
Please install flex. \
))
$(eval $(call RequireCommand,python, \
Please install python. \
))
$(eval $(call RequireCommand,unzip, \
Please install unzip. \
))
$(eval $(call RequireCommand,bzip2, \
Please install bzip2. \
))
$(eval $(call RequireCommand,patch, \
Please install patch. \
))
$(eval $(call RequireCommand,perl, \
Please install perl. \
))
define Require/gnutar
$(TAR) --version 2>&1 | grep GNU > /dev/null
endef
$(eval $(call Require,gnutar, \
Please install GNU tar. \
))

54
include/prereq.mk Normal file
View file

@ -0,0 +1,54 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
$(TMP_DIR):
mkdir -p $@
prereq:
if [ -f $(TMP_DIR)/.prereq-error ]; then \
echo; \
cat $(TMP_DIR)/.prereq-error; \
echo; \
rm -rf $(TMP_DIR); \
false; \
fi
rm -rf $(TMP_DIR)
mkdir -p $(TMP_DIR)
.SILENT: $(TMP_DIR) prereq
define Require
export PREREQ_CHECK=1
ifeq ($$(CHECK_$(1)),)
prereq: prereq-$(1)
prereq-$(1): $(TMP_DIR) FORCE
echo -n "Checking '$(1)'... "
if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
echo 'ok.'; \
else \
echo 'failed.'; \
echo -e "$(strip $(2))" >> $(TMP_DIR)/.prereq-error; \
fi
check-$(1): FORCE
$(call Require/$(1))
CHECK_$(1):=1
.SILENT: prereq-$(1) check-$(1)
endif
endef
define RequireCommand
define Require/$(1)
which $(1)
endef
$$(eval $$(call Require,$(1),$(2)))
endef

15
include/shell.sh Normal file
View file

@ -0,0 +1,15 @@
getvar() {
eval "echo \"\${$1}\""
}
var2file() {
local var
eval "var=\"\${$1}\""
if [ -n "$var" ]; then echo "$var" > "$2"; fi
}
isset() {
local var
eval "var=\"\${$1}\""
[ -n "$var" ]
}

31
include/target.mk Normal file
View file

@ -0,0 +1,31 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define kernel_template
ifeq ($(CONFIG_LINUX_$(3)),y)
KERNEL:=$(1)
BOARD:=$(2)
endif
endef
$(eval $(call kernel_template,2.4,brcm,2_4_BRCM))
$(eval $(call kernel_template,2.4,ar7,2_4_AR7))
$(eval $(call kernel_template,2.6,brcm,2_6_BRCM))
$(eval $(call kernel_template,2.6,brcm63xx,2_6_BRCM63XX))
$(eval $(call kernel_template,2.6,rb532,2_6_RB532))
$(eval $(call kernel_template,2.6,x86,2_6_X86))
$(eval $(call kernel_template,2.6,uml,2_6_UML))
$(eval $(call kernel_template,2.4,ar531x,2_4_AR531X))
$(eval $(call kernel_template,2.6,aruba,2_6_ARUBA))
$(eval $(call kernel_template,2.6,au1000,2_6_AU1000))
$(eval $(call kernel_template,2.6,xscale,2_6_XSCALE))
$(eval $(call kernel_template,2.6,magicbox,2_6_MAGICBOX))
$(eval $(call kernel_template,2.6,sibyte,2_6_SIBYTE))
export BOARD
export KERNEL

43
include/verbose.mk Normal file
View file

@ -0,0 +1,43 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id:$
ifeq ($(NO_TRACE_MAKE),)
NO_TRACE_MAKE := $(MAKE) V=99
export NO_TRACE_MAKE
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE:=0
endif
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE:=$(V)
endif
ifneq ($(shell tty -s <&3 || echo x),x)
_Y:="\\33[33m"# yellow
_N:="\\33[m"# normal
endif
ifneq ($(KBUILD_VERBOSE),99)
ifeq ($(QUIET),1)
$(MAKECMDGOALS): trace
trace: FORCE
@[ -f "$(MAKECMDGOALS)" ] || { \
[ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
echo -e "$(_Y)make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)$(_N)" >&3; \
}
else
export QUIET:=1
ifeq ($(KBUILD_VERBOSE),0)
MAKE:=&>/dev/null $(MAKE)
endif
MAKE:=cmd() { $(MAKE) $$* || { echo "Build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
endif
.SILENT: $(MAKECMDGOALS)
endif

69
package/Makefile Normal file
View file

@ -0,0 +1,69 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
include $(TOPDIR)/.config
include $(TOPDIR)/.pkgdeps
include $(TOPDIR)/host.mk
PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m))
DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
$(STAMP_DIR) $(TARGET_DIR):
mkdir -p $@
%-prereq: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-prereq,%,$@) prereq
%-download: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-download,%,$@) download
%-prepare: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-prepare,%,$@) prepare
%-compile: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-compile,%,$@) compile
%-install: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-install,%,$@) install
%-clean: $(STAMP_DIR) $(TARGET_DIR)
$(MAKE) -C $(patsubst %-clean,%,$@) clean
ifeq ($(SDK),1)
GENDEP_OPTS := -s
endif
$(TOPDIR)/.pkgdeps: $(TOPDIR)/.pkginfo
@$(TOPDIR)/scripts/gen_deps.pl $(GENDEP_OPTS) < $< > $@ || rm -f $@
all: compile
clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
prereq: $(PREREQ_PACKAGES)
download: $(DOWNLOAD_PACKAGES)
compile-targets: $(COMPILE_PACKAGES)
compile:
$(MAKE) compile-targets
install-targets: base-files-install $(INSTALL_PACKAGES)
install:
rm -rf $(BUILD_DIR)/root
$(MAKE) install-targets
index: $(PACKAGE_DIR)/Packages
$(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk
(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)
ifeq ($(MAKECMDGOALS),compile-targets)
MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL)
else
.NOTPARALLEL:
endif

81
package/alsa/Makefile Normal file
View file

@ -0,0 +1,81 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=alsa-driver
PKG_VERSION:=1.0.11
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.alsa-project.org/pub/driver/
PKG_MD5SUM:=57534e4297cd683371402220e3753885
PKG_CAT:=bzcat
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/kmod-alsa
SECTION:=kernel
CATEGORY:=Kernel drivers
DEPENDS:=@USB_SUPPORT
TITLE:=Advanced Linux Sound Architecture
URL:=http://alsa-project.org/
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
endef
ifeq ($(KERNEL),2.4)
ifeq ($(LINUX_KARCH),i386)
KERNEL_C_OPTS:= -Os -mpreferred-stack-boundary=2 -march=i486 -fno-unit-at-a-time
endif
ifeq ($(LINUX_KARCH),mips)
KERNEL_C_OPTS:= -Os -G 0 -mno-abicalls -fno-pic -finline-limit=100000 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap
endif
endif
ifeq ($(LINUX_KARCH),i386)
KERNEL_C_INCS:= -I$(LINUX_DIR)/include/asm-i386/mach-generic -I$(LINUX_DIR)/include/asm-i386/mach-default
endif
ifeq ($(LINUX_KARCH),mips)
KERNEL_C_INCS:= -I$(LINUX_DIR)/include/asm-mips/mach-generic
endif
define Build/Configure
(cd $(PKG_BUILD_DIR); \
CFLAGS="$(KERNEL_C_INCS)" \
./configure \
--with-build="$(LINUX_DIR)" \
--with-kernel="$(LINUX_DIR)" \
--with-cross="$(KERNEL_CROSS)" \
--with-redhat=no \
--with-suse=no \
--with-oss=yes \
--with-isapnp=no \
--with-sequencer=no \
--with-cards=usb-audio \
);
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
c_opts="$(KERNEL_C_OPTS)" \
all
endef
define Package/kmod-alsa/install
install -d -m0755 $(1)/lib/modules/$(LINUX_VERSION)
install -m0644 $(PKG_BUILD_DIR)/modules/*.$(LINUX_KMOD_SUFFIX) \
$(1)/lib/modules/$(LINUX_VERSION)/
install -d -m0755 $(1)/etc/modules.d
install -m0644 ./files/alsa.modules $(1)/etc/modules.d/70-alsa
endef
$(eval $(call BuildPackage,kmod-alsa))

View file

@ -0,0 +1,10 @@
snd-page-alloc
snd
snd-timer
snd-pcm
snd-rawmidi
snd-usb-lib
snd-hwdep
snd-usb-audio
snd-mixer-oss
snd-pcm-oss

View file

@ -0,0 +1,18 @@
diff -urN alsa.old/include/adriver.h alsa.dev/include/adriver.h
--- alsa.old/include/adriver.h 2006-04-19 08:24:30.000000000 +0200
+++ alsa.dev/include/adriver.h 2006-05-31 17:24:49.000000000 +0200
@@ -451,7 +451,7 @@
#endif /* < 2.6.0 */
/* workarounds for USB API */
-#if defined(SND_NEED_USB_WRAPPER) && (defined(CONFIG_USB) || defined(CONFIG_USB_MODULE))
+#if 1
#include <linux/usb.h>
@@ -1174,4 +1174,5 @@
*/
#define OPL3_HW_OPL3_PC98 0x0305 /* PC9800 */
+#undef info /* used in several structs */
#endif /* __SOUND_LOCAL_DRIVER_H */

View file

@ -0,0 +1,42 @@
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=arptables
PKG_VERSION:=0.0.3
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/ebtables
PKG_MD5SUM:=1672244603c8979577aa4738be35a759
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/arptables
SECTION:=net
CATEGORY:=Network
TITLE:=ARP firewalling software
URL:=http://ebtables.sourceforge.net
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
COPT_FLAGS="$(TARGET_CFLAGS)" \
KERNEL_DIR="./include/linux"
endef
define Package/arptables/install
install -m0755 -d $(1)/usr/sbin
$(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,arptables))

191
package/base-files/Makefile Normal file
View file

@ -0,0 +1,191 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=base-files
PKG_RELEASE:=8
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
ifeq ($(REV),)
REV:=0
endif
include $(INCLUDE_DIR)/package.mk
ifneq ($(DUMP),1)
TARGET:=-$(BOARD)-$(KERNEL)
UCLIBC_VERSION:=${shell cat $(STAGING_DIR)/uclibc_version 2>/dev/null}
LIBGCC_VERSION:=${shell cat $(STAGING_DIR)/gcc_version 2>/dev/null}
else
UCLIBC_VERSION:=<UCLIBC_VERSION>
LIBGCC_VERSION:=<LIBGCC_VERSION>
endif
CONFIG_PACKAGE_base-files$(TARGET):=$(CONFIG_PACKAGE_base-files)
define Package/base-files$(TARGET)
SECTION:=base
CATEGORY:=Base system
DEFAULT:=y
TITLE:=Base filesystem for OpenWrt
DESCRIPTION:=\
This package contains a base filesystem and system scripts for OpenWrt.
URL:=http://openwrt.org/
VERSION:=$(PKG_RELEASE)-$(REV)
endef
define -ar7-2.4/conffiles
/etc/config/network
endef
define -aruba-2.6/conffiles
/etc/config/network
endef
define -au1000-2.6/conffiles
/etc/config/network
endef
define -rb532-2.6/conffiles
/etc/config/network
endef
define -sibyte-2.6/conffiles
/etc/config/network
endef
define -x86-2.6/conffiles
/etc/config/network
endef
define -xscale-2.6/conffiles
/etc/config/network
endef
define Package/base-files$(TARGET)/conffiles
/etc/banner
/etc/hosts
/etc/inittab
/etc/group
/etc/passwd
/etc/profile
/etc/shells
/etc/ipkg.conf
/etc/sysctl.conf
$(call $(TARGET)/conffiles)
endef
define Package/libgcc
SECTION:=libs
CATEGORY:=Base system
DEFAULT:=y
DEPENDS:=@!NATIVE_TOOLCHAIN
TITLE:=GCC support library
URL:=http://gcc.gnu.org/
VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
endef
define Package/libpthread
SECTION:=libs
CATEGORY:=Libraries
DEPENDS:=@!NATIVE_TOOLCHAIN
TITLE:=POSIX thread library
URL:=http://uclibc.org/
VERSION:=$(UCLIBC_VERSION)-$(PKG_RELEASE)
endef
define Package/uclibc
SECTION:=libs
CATEGORY:=Base system
DEFAULT:=y
DEPENDS:=@!NATIVE_TOOLCHAIN
TITLE:=C library embedded systems
URL:=http://uclibc.org/
VERSION:=$(UCLIBC_VERSION)-$(PKG_RELEASE)
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile/ar7
$(TARGET_CC) -o $(PKG_BUILD_DIR)/adam2patcher src/adam2patcher.c
endef
define Build/Compile/brcm
$(TARGET_CC) -o $(PKG_BUILD_DIR)/jffs2root src/jffs2root.c
endef
define Build/Compile
$(call Build/Compile/$(BOARD))
endef
define Package/base-files$(TARGET)/install-ar7
mkdir -p $(1)/sbin
$(CP) $(PKG_BUILD_DIR)/adam2patcher $(1)/sbin
endef
define Package/base-files$(TARGET)/install-brcm
rm -f $(1)/etc/config/network
mkdir -p $(1)/sbin
$(CP) $(PKG_BUILD_DIR)/jffs2root $(1)/sbin
endef
define Package/base-files$(TARGET)/install
$(CP) ./default/* $(1)/
if [ -d $(BOARD)-$(KERNEL) ]; then \
$(CP) $(BOARD)-$(KERNEL)/* $(1)/; \
fi
$(SED) 's,$$$$R,r$(REV),g' $(1)/etc/banner
$(SED) 's,$$$$S,$(BOARD)-$(KERNEL),g' $(1)/etc/ipkg.conf
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
mkdir -p $(1)/jffs
mkdir -p $(1)/lib
mkdir -p $(1)/mnt
mkdir -p $(1)/proc
mkdir -p $(1)/tmp
mkdir -p $(1)/usr/lib
mkdir -p $(1)/usr/bin
mkdir -p $(1)/sys
mkdir -p $(1)/www
ln -sf /proc/mounts $(1)/etc/mtab
rm -f $(1)/var
ln -sf /tmp $(1)/var
mkdir -p $(1)/etc
$(call Package/base-files$(TARGET)/install-$(BOARD),$(1))
endef
define Package/libgcc/install
install -m0755 -d $(1)/lib
$(CP) $(STAGING_DIR)/lib/libgcc_s.so.* $(1)/lib/
endef
define Package/libpthread/install
install -m0755 -d $(1)/lib
$(CP) $(STAGING_DIR)/lib/libpthread.so.* $(1)/lib/
$(CP) $(STAGING_DIR)/lib/libpthread-$(UCLIBC_VERSION).so $(1)/lib/
endef
define Package/uclibc/install
install -m0755 -d $(1)/lib
for file in ld-uClibc libc libcrypt libdl libm libnsl libresolv librt libuClibc libutil; do \
$(CP) $(STAGING_DIR)/lib/$$$$file.so.* $(1)/lib/; \
$(CP) $(STAGING_DIR)/lib/$$$$file-$(UCLIBC_VERSION).so $(1)/lib/; \
done
endef
$(eval $(call BuildPackage,base-files$(TARGET)))
$(eval $(call BuildPackage,libgcc))
$(eval $(call BuildPackage,libpthread))
$(eval $(call BuildPackage,uclibc))

View file

@ -0,0 +1,89 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
dupe() { # <new_root> <old_root>
cd $1
echo -n "creating directories... "
{
cd $2
find . -xdev -type d
echo "./dev ./jffs ./mnt ./proc ./tmp ./sys"
# xdev skips mounted directories
cd $1
} | xargs mkdir -p
echo "done"
echo -n "setting up symlinks... "
for file in $(cd $2; find . -xdev -type f;); do
case "$file" in
./rom/note) ;; #nothing
./etc/config*|\
./etc/resolv.conf|\
./usr/lib/ipkg/info) cp -af $2/$file $file;;
*) ln -sf /rom/${file#./*} $file;;
esac
done
for file in $(cd $2; find . -xdev -type l;); do
cp -af $2/${file#./*} $file
done
echo "done"
}
pivot() { # <new_root> <old_root>
mount -o move /proc $1/proc && \
pivot_root $1 $1$2 && {
mount -o move $2/dev /dev
mount -o move $2/tmp /tmp
mount -o move $2/sys /sys
return 0
}
}
mountdp() { # <device> <mount_point> <ignored> <fs>
dev=$1; mnt=$2; shift 2; opt=$*
mount $dev $mnt $opt
dupe $mnt $rom
pivot $mnt /rom
}
ramoverlay() {
mkdir -p /tmp/root
mountdp /tmp/root /mnt -o bind
}
[ "${0##*/}" = "firstboot" ] && {
[ -z "$rom" ] && {
echo "You do not have a squashfs partition; aborting"
echo "(firstboot cannot be run on jffs2 based firmwares)"
exit 1
}
[ "$1" = "switch2jffs" ] && {
mtd erase OpenWrt
mount -o remount,ro none / # try to avoid fs changing while copying
mount -o bind / /mnt
mount /dev/mtdblock/4 /rom/jffs -t jffs2
echo -n "copying files ... "
cp -a /mnt/* /rom/jffs
umount /mnt
echo "done"
pivot /rom /mnt
mount -o move /mnt /tmp/root
pivot /jffs /rom
exit 0
}
# script run manually
[ \! -z "$jffs" ] && {
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
dupe $jffs $rom
exit 0
}
mtd erase OpenWrt
mountdp /dev/mtdblock/4 /jffs -t jffs2
}

View file

@ -0,0 +1,14 @@
# Network configuration file
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0

View file

@ -0,0 +1,12 @@
#!/bin/sh /etc/rc.common
# ADAM2 patcher for Netgear DG834 and compatible
# Copyright (C) 2006 OpenWrt.org
start() {
MD5="$(md5sum /dev/mtdblock/0 | awk '{print $1}')"
[ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
mtd unlock adam2
/sbin/adam2patcher /dev/mtdblock/0
}
rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
}

View file

@ -0,0 +1,11 @@
#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount none /proc -t proc
[ -f /etc/preinit.arch ] && . /etc/preinit.arch
[ -z "$FAILSAFE" ] || {
echo /bin/true > /proc/sys/kernel/hotplug
telnetd -l /bin/login <> /dev/null 2>&1
}
mount_root ${FAILSAFE:+failsafe}
exec /sbin/init

View file

@ -0,0 +1,28 @@
#!/bin/sh
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size
if [ "$1" != "failsafe" ]; then
mtd unlock linux
mount | grep jffs2 >&-
if [ $? = 0 ] ; then
if [ $(cat /proc/mtd | wc -l) = 6 ]; then
mtd erase OpenWrt
else
mount -o remount,rw /dev/root /
fi
else
. /bin/firstboot
echo "switching to jffs2"
mount /dev/mtdblock/4 /jffs -t jffs2
pivot /jffs /rom || {
echo "jffs2 unusable; using ramdisk"
ramoverlay
}
fi
fi
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
mkdir -p /dev/pts
mount none /dev/pts -t devpts
mount -t sysfs none /sys 2>&-

View file

@ -0,0 +1,11 @@
# Network configuration file
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto dhcp

View file

@ -0,0 +1,14 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option type bridge
option ifname "eth0 ath0"
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0

View file

@ -0,0 +1,26 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
mount none /proc -t proc
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size
if [ "$1" != "failsafe" ]; then
mtd unlock filesystem
mount | grep jffs2 >&-
if [ $? = 0 ] ; then
if [ $(cat /proc/mtd | wc -l) = 6 ]; then
mtd erase filesystem
jffs2root --move
else
mount -o remount,rw /dev/root /
fi
else
. /bin/firstboot
fi
fi
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
mkdir -p /dev/pts
mount none /dev/pts -t devpts
mount -t sysfs none /sys 2>&-

View file

@ -0,0 +1,90 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
dupe() { # <new_root> <old_root>
cd $1
echo -n "creating directories... "
{
cd $2
find . -xdev -type d
echo "./dev ./jffs ./mnt ./proc ./tmp ./sys"
# xdev skips mounted directories
cd $1
} | xargs mkdir -p
echo "done"
echo -n "setting up symlinks... "
for file in $(cd $2; find . -xdev -type f;); do
case "$file" in
./rom/note) ;; #nothing
./etc/config*|\
./etc/resolv.conf|\
./usr/lib/ipkg/info/*) cp -af $2/$file $file;;
*) ln -sf /rom/${file#./*} $file;;
esac
done
for file in $(cd $2; find . -xdev -type l;); do
cp -af $2/${file#./*} $file
done
echo "done"
}
pivot() { # <new_root> <old_root>
mount -o move /proc $1/proc && \
pivot_root $1 $1$2 && {
mount -o move $2/dev /dev
mount -o move $2/tmp /tmp
mount -o move $2/sys /sys
return 0
}
}
mountdp() { # <device> <mount_point> <ignored> <fs>
dev=$1; mnt=$2; shift 2; opt=$*
mount $dev $mnt $opt
dupe $mnt $rom
pivot $mnt /rom
}
ramoverlay() {
mkdir -p /tmp/root
mountdp /tmp/root /mnt -o bind
}
[ "${0##*/}" = "firstboot" ] && {
[ -z "$rom" ] && {
echo "You do not have a squashfs partition; aborting"
echo "(firstboot cannot be run on jffs2 based firmwares)"
exit 1
}
[ "$1" = "switch2jffs" ] && {
mtd erase OpenWrt
mount -o remount,ro none / # try to avoid fs changing while copying
mount -o bind / /mnt
mount /dev/mtdblock/4 /rom/jffs -t jffs2
echo -n "copying files ... "
cp -a /mnt/* /rom/jffs
umount /mnt
echo "done"
pivot /rom /mnt
mount -o move /mnt /tmp/root
pivot /jffs /rom
jffs2root --clean
exit 0
}
# script run manually
[ \! -z "$jffs" ] && {
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
dupe $jffs $rom
exit 0
}
mtd erase OpenWrt
mountdp /dev/mtdblock/4 /jffs -t jffs2
}

View file

@ -0,0 +1,14 @@
# Copyright (C) 2006 OpenWrt.org
config wifi-device wl0
option type broadcom
option channel 5
config wifi-iface
option device wl0
option mode ap
option ssid OpenWrt
option hidden 0
option encryption none

View file

@ -0,0 +1,87 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
[ -e /etc/config/network ] && exit 0
mkdir -p /etc/config
(
if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
# WGT634u
echo boardtype=wgt634u
else
strings /dev/mtdblock/3
fi
) | awk '
function p(cfgname, name) {
if (c[name] != "") print " option " cfgname " \"" c[name] "\""
}
BEGIN {
FS="="
c["lan_ifname"]="eth0.0 wl0"
c["wan_ifname"]="eth0.1"
c["vlan0ports"]="1 2 3 4 5*"
c["vlan1ports"]="0 5"
}
($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
nvram[$1] = $2
}
END {
# v1 hardware
if (nvram["boardtype"] == "bcm94710dev") {
# Asus WL-500g
if (nvram["boardnum"] == "asusX") {
c["lan_ifname"]="eth0 eth1 wl0" # FIXME
c["wan_ifname"]=""
}
}
if (nvram["boardtype"] == "wgt634u") {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
c["lan_ifname"] = "eth0.0 ath0"
}
if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
}
# WAP54G
if ((nvram["boardnum"] == "2") || \
(nvram["boardnum"] == "1024")) {
c["lan_ifname"]="eth0 wl0"
c["wan_ifname"]=""
}
print "#### VLAN configuration "
print "config switch eth0"
p("vlan0", "vlan0ports")
p("vlan1", "vlan1ports")
print ""
print ""
print "#### Loopback configuration"
print "config interface loopback"
print " option ifname \"lo\""
print " option proto static"
print " option ipaddr 127.0.0.1"
print " option netmask 255.0.0.0"
print ""
print ""
print "#### LAN configuration"
print "config interface lan"
print " option type bridge"
p("ifname", "lan_ifname")
print " option proto static"
print " option ipaddr 192.168.1.1"
print " option netmask 255.255.255.0"
print ""
print ""
print "#### WAN configuration"
print "config interface wan"
p("ifname", "wan_ifname")
print " option proto dhcp"
}' > /etc/config/network
}

View file

@ -0,0 +1,13 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount none /proc -t proc
[ -f /etc/preinit.arch ] && . /etc/preinit.arch
[ -z "$FAILSAFE" ] || {
echo /bin/true > /proc/sys/kernel/hotplug
telnetd -l /bin/login <> /dev/null 2>&1
}
mount_root ${FAILSAFE:+failsafe}
exec /sbin/init

View file

@ -0,0 +1,34 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
is_dirty() {
grep Broadcom /proc/cpuinfo >&- || return 1
OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
}
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size
if [ "$1" != "failsafe" ]; then
mtd unlock linux
mount | grep jffs2 >&-
if [ $? = 0 ] ; then
mount -o remount,rw /dev/root /
else
. /bin/firstboot
is_dirty
[ $? != 0 ] && {
echo "switching to jffs2"
mount /dev/mtdblock/4 /jffs -t jffs2
pivot /jffs /rom
} || {
echo "jffs2 unusable; using ramdisk"
ramoverlay
}
fi
fi
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
mkdir -p /dev/pts
mount none /dev/pts -t devpts

View file

@ -0,0 +1,90 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
dupe() { # <new_root> <old_root>
cd $1
echo -n "creating directories... "
{
cd $2
find . -xdev -type d
echo "./dev ./jffs ./mnt ./proc ./tmp ./sys"
# xdev skips mounted directories
cd $1
} | xargs mkdir -p
echo "done"
echo -n "setting up symlinks... "
for file in $(cd $2; find . -xdev -type f;); do
case "$file" in
./rom/note) ;; #nothing
./etc/config*|\
./etc/resolv.conf|\
./usr/lib/ipkg/info) cp -af $2/$file $file;;
*) ln -sf /rom/${file#./*} $file;;
esac
done
for file in $(cd $2; find . -xdev -type l;); do
cp -af $2/${file#./*} $file
done
echo "done"
}
pivot() { # <new_root> <old_root>
mount -o move /proc $1/proc && \
pivot_root $1 $1$2 && {
mount -o move $2/dev /dev
mount -o move $2/tmp /tmp
mount -o move $2/sys /sys
return 0
}
}
mountdp() { # <device> <mount_point> <ignored> <fs>
dev=$1; mnt=$2; shift 2; opt=$*
mount $dev $mnt $opt
dupe $mnt $rom
pivot $mnt /rom
}
ramoverlay() {
mkdir -p /tmp/root
mountdp /tmp/root /mnt -o bind
}
[ "${0##*/}" = "firstboot" ] && {
[ -z "$rom" ] && {
echo "You do not have a squashfs partition; aborting"
echo "(firstboot cannot be run on jffs2 based firmwares)"
exit 1
}
[ "$1" = "switch2jffs" ] && {
mtd erase OpenWrt
mount -o remount,ro none / # try to avoid fs changing while copying
mount -o bind / /mnt
mount /dev/mtdblock/4 /rom/jffs -t jffs2
echo -n "copying files ... "
cp -a /mnt/* /rom/jffs
umount /mnt
echo "done"
pivot /rom /mnt
mount -o move /mnt /tmp/root
pivot /jffs /rom
jffs2root --clean
exit 0
}
# script run manually
[ \! -z "$jffs" ] && {
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
dupe $jffs $rom
exit 0
}
mtd erase OpenWrt
mountdp /dev/mtdblock/4 /jffs -t jffs2
}

View file

@ -0,0 +1,87 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
[ -e /etc/config/network ] && exit 0
mkdir -p /etc/config
(
if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
# WGT634u
echo boardtype=wgt634u
else
strings /dev/mtdblock/3
fi
) | awk '
function p(cfgname, name) {
if (c[name] != "") print " option " cfgname " \"" c[name] "\""
}
BEGIN {
FS="="
c["lan_ifname"]="eth0.0 wl0"
c["wan_ifname"]="eth0.1"
c["vlan0ports"]="1 2 3 4 5*"
c["vlan1ports"]="0 5"
}
($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
nvram[$1] = $2
}
END {
# v1 hardware
if (nvram["boardtype"] == "bcm94710dev") {
# Asus WL-500g
if (nvram["boardnum"] == "asusX") {
c["lan_ifname"]="eth0 eth1 wl0" # FIXME
c["wan_ifname"]=""
}
}
if (nvram["boardtype"] == "wgt634u") {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
c["lan_ifname"] = "eth0.0 ath0"
}
if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
}
# WAP54G
if ((nvram["boardnum"] == "2") || \
(nvram["boardnum"] == "1024")) {
c["lan_ifname"]="eth0 wl0"
c["wan_ifname"]=""
}
print "#### VLAN configuration "
print "config switch eth0"
p("vlan0", "vlan0ports")
p("vlan1", "vlan1ports")
print ""
print ""
print "#### Loopback configuration"
print "config interface loopback"
print " option ifname \"lo\""
print " option proto static"
print " option ipaddr 127.0.0.1"
print " option netmask 255.0.0.0"
print ""
print ""
print "#### LAN configuration"
print "config interface lan"
print " option type bridge"
p("ifname", "lan_ifname")
print " option proto static"
print " option ipaddr 192.168.1.1"
print " option netmask 255.255.255.0"
print ""
print ""
print "#### WAN configuration"
print "config interface wan"
p("ifname", "wan_ifname")
print " option proto dhcp"
}' > /etc/config/network
}

View file

@ -0,0 +1,13 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount none /proc -t proc
[ -f /etc/preinit.arch ] && . /etc/preinit.arch
[ -z "$FAILSAFE" ] || {
echo /bin/true > /proc/sys/kernel/hotplug
telnetd -l /bin/login <> /dev/null 2>&1
}
mount_root ${FAILSAFE:+failsafe}
exec /sbin/init

View file

@ -0,0 +1,35 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
is_dirty() {
grep Broadcom /proc/cpuinfo >&- || return 1
OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
}
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size
if [ "$1" != "failsafe" ]; then
mtd unlock linux
mount | grep jffs2 >&-
if [ $? = 0 ] ; then
mount -o remount,rw /dev/root /
else
. /bin/firstboot
is_dirty
[ $? != 0 ] && {
echo "switching to jffs2"
mount /dev/mtdblock/4 /jffs -t jffs2
pivot /jffs /rom
} || {
echo "jffs2 unusable; using ramdisk"
ramoverlay
}
fi
fi
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
mkdir -p /dev/pts
mount none /dev/pts -t devpts
mount -t sysfs none /sys 2>&-

View file

@ -0,0 +1,32 @@
#!/bin/sh
awk -f /usr/lib/common.awk -f - $* <<EOF
BEGIN {
ipaddr=ip2int(ARGV[1])
netmask=ip2int(ARGV[2])
network=and(ipaddr,netmask)
broadcast=or(network,compl(netmask))
start=or(network,and(ip2int(ARGV[3]),compl(netmask)))
limit=network+1
if (start<limit) start=limit
end=start+ARGV[4]
limit=or(network,compl(netmask))-1
if (end>limit) end=limit
print "IP="int2ip(ipaddr)
print "NETMASK="int2ip(netmask)
print "BROADCAST="int2ip(broadcast)
print "NETWORK="int2ip(network)
print "PREFIX="32-bitcount(compl(netmask))
# range calculations:
# ipcalc <ip> <netmask> <start> <num>
if (ARGC > 3) {
print "START="int2ip(start)
print "END="int2ip(end-1)
}
}
EOF

View file

@ -0,0 +1,18 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
grep '^root:[^!]' /etc/passwd >&- 2>&-
[ "$?" = "0" -a -z "$FAILSAFE" ] &&
{
echo "Login failed."
exit 0
} || {
cat << EOF
=== IMPORTANT ============================
Use 'passwd' to set your login password
this will disable telnet and enable SSH
------------------------------------------
EOF
}
exec /bin/ash --login

View file

@ -0,0 +1,159 @@
#!/bin/sh
# Shell script for interacting with config files
#
# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraumhofer.de>
# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
#
# 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
. /etc/functions.sh
include /lib/config
do_get() {
[ $# -ne 3 ] && {
uci_usage get
exit 1
}
local PACKAGE="$1"
local CONFIG="$2"
local OPTION="$3"
uci_load "$PACAKGE"
config_get "$CONFIG" "$OPTION"
}
do_set() {
[ $# -ne 4 ] && {
uci_usage set
exit 1
}
uci_set "$@"
}
do_add() {
[ $# -ne 3 ] && {
uci_usage add
exit 1
}
uci_add "$@"
}
do_rename() {
[ $# -ne 3 ] && {
uci_usage rename
exit 1
}
uci_rename "$@"
}
do_remove() {
[ $# -ne 3 -a $# -ne 2 ] && {
uci_usage rename
exit 1
}
uci_remove "$@"
}
do_commit() {
[ $# -ne 1 ] && {
uci_usage commit
exit 1
}
uci_commit "$1"
}
do_show() {
[ $# -gt 2 -o $# -lt 1 ] && {
uci_usage show
exit 1
}
PACKAGE="$1"
CONFIG="$2"
SECTION=""
config_cb() {
if [ -z "$CONFIG" -o "$CONFIG" = "$2" ]; then
append SECTION "$2"
option_cb() {
append "${CONFIG_SECTION}_VARS" "$1"
}
else
option_cb() {
return 0
}
fi
}
uci_load "$PACKAGE"
for section in $SECTION; do
config_get type "$section" TYPE
[ -z "$type" ] && continue
echo "@$section=$type"
eval "VARS=\"\${${section}_VARS}\""
for var in $VARS; do
config_get val "$section" "$var"
[ -n "$val" ] && {
echo "${section}.${var}=${val}"
config_set "$section" "$var" ""
}
done
config_set "$section" TYPE ""
done
}
uci_usage() {
case "$1" in
show) echo "$0 show <package> [<config>]";;
get) echo "$0 get <package> <config> <option>";;
set) echo "$0 set <package> <config> <option> <value>";;
add) echo "$0 add <package> <type> <config>";;
del) echo "$0 del <package> <config> [<option>]";;
rename) echo "$0 rename <package> <config> <name>";;
commit) echo "$0 commit <package>";;
*)
echo "Syntax: $0 <command> <arguments...>"
echo
uci_usage show
uci_usage get
uci_usage set
uci_usage add
uci_usage del
uci_usage rename
uci_usage commit
echo
exit 1
;;
esac
}
if [ $# -eq 0 ] ; then
uci_usage
exit 0
fi
CMD="$1"
shift
case "$CMD" in
set) do_set "$@";;
add) do_add "$@";;
del) do_remove "$@";;
rename) do_rename "$@";;
get) do_get "$@";;
show) do_show "$@";;
commit) do_commit "$@";;
*) uci_usage;;
esac
exit 0

View file

@ -0,0 +1,10 @@
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
KAMIKAZE (bleeding edge, $R) -------------------
* 10 oz Vodka Shake well with ice and strain
* 10 oz Triple sec mixture into 10 shot glasses.
* 10 oz lime juice Salute!
---------------------------------------------------

View file

@ -0,0 +1,13 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0

View file

@ -0,0 +1,119 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
alias debug=${DEBUG:-:}
# newline
N="
"
_C=0
# valid interface?
if_valid () (
ifconfig "$1" >&- 2>&- ||
[ "${1%%[0-9]}" = "br" ] ||
{ debug "# missing interface '$1' ignored"; false; }
)
hotplug_dev() {
env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
}
append() {
local var="$1"
local value="$2"
local sep="${3:- }"
eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}\$value\""
}
reset_cb() {
config_cb() {
return 0
}
option_cb() {
return 0
}
}
reset_cb
config () {
local cfgtype="$1"
local name="$2"
_C=$(($_C + 1))
name="${name:-cfg${_C}}"
config_cb "$cfgtype" "$name"
export CONFIG_SECTION="$name"
export CONFIG_${CONFIG_SECTION}_TYPE="$cfgtype"
}
option () {
local varname="$1"; shift
export CONFIG_${CONFIG_SECTION}_${varname}="$*"
option_cb "$varname" "$*"
}
config_rename() {
local OLD="$1"
local NEW="$2"
local oldsetting
local newvar
[ -z "$OLD" -o -z "$NEW" ] && return
for oldsetting in `set | grep ^CONFIG_${OLD}_ | \
sed -e 's/\(.*\)=.*$/\1/'` ; do
newvar="CONFIG_${NEW}_${oldsetting##CONFIG_${OLD}_}"
eval "${newvar}=\${$oldsetting}"
unset "$oldsetting"
done
[ "$CONFIG_SECTION" = "$OLD" ] && CONFIG_SECTION="$NEW"
}
config_unset() {
config_set "$1" "$2" ""
}
config_clear() {
[ -z "$CONFIG_SECTION" ] && return
for oldsetting in `set | grep ^CONFIG_${CONFIG_SECTION}_ | \
sed -e 's/\(.*\)=.*$/\1/'` ; do
unset $oldsetting
done
unset CONFIG_SECTION
}
config_load() {
local DIR="./"
_C=0
[ \! -e "$1" -a -e "/etc/config/$1" ] && {
DIR="/etc/config/"
}
[ -e "$DIR$1" ] && {
CONFIG_FILENAME="$DIR$1"
. ${CONFIG_FILENAME}
} || return 1
${CD:+cd -} >/dev/null
${CONFIG_SECTION:+config_cb}
}
config_get() {
case "$3" in
"") eval "echo \"\${CONFIG_${1}_${2}}\"";;
*) eval "$1=\"\${CONFIG_${2}_${3}}\"";;
esac
}
config_set() {
export CONFIG_${1}_${2}="${3}"
}
load_modules() {
sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
}
include() {
for file in $(ls $1/*.sh 2>/dev/null); do
. $file
done
}

View file

@ -0,0 +1,2 @@
root:x:0:
nogroup:x:65534:

View file

@ -0,0 +1 @@
127.0.0.1 localhost OpenWrt

View file

@ -0,0 +1,26 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
DEV=${DEVPATH##*/}
{
echo "ACTION=$ACTION DEVPATH=$DEVPATH $0 $*"
case "$ACTION" in
add)
echo -ne "waiting for $DEV"
while [ ! -b /dev/$DEV ]; do {
echo -ne "."
sleep 1
time=$((time+1)); [ $time -gt 10 ] && break
}; done
[ ${DEV%%[0-9]} != ${DEV} ] && {
mkdir -p /tmp/$DEV
mount /dev/$DEV /tmp/$DEV -t auto -o sync
}
;;
remove)
umount /tmp/$DEV
rm -rf /dev/$DEV /tmp/$DEV
;;
esac
} 2>&1 | logger

View file

@ -0,0 +1,28 @@
# Copyright (C) 2006 OpenWrt.org
include /lib/network
addif() {
scan_interfaces
setup_interface "$INTERFACE"
# find all vlan configurations for this interface and set them up as well
for ifc in $interfaces; do
config_get iftype "$ifc" type
config_get ifs "$ifc" device
for dev in $ifs; do
[ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
add_vlan "$dev"
}
done
done
}
case "$ACTION" in
add|register)
case "$PHYSDEVDRIVER" in
natsemi) sleep 1;;
esac
addif
;;
esac

View file

@ -0,0 +1,33 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
case "$ACTION" in
add)
[ -f /sys/${DEVPATH}/idVendor -a "$(cat /sys/${DEVPATH}/idVendor)" -ne "0000" ] && {
cd /sys/${DEVPATH}
NUM=${DEVPATH##*/}
HOST=$(find ${NUM}:*/host* -type d)
HOST=${HOST##*/host}
echo -ne "waiting for disk"
while [ ! -d "/dev/scsi/host${HOST}/bus0/target0/lun0" ]; do {
echo -ne "."
sleep 1;
time=$((time+1)); [ $time -gt 10 ] && break
}; done
echo
cd /sys/bus/scsi/devices/${HOST}\:0\:0\:0
for BLOCK in block:* ; do {
cd ${BLOCK}
BLOCK=${BLOCK##block\:}
ln -sf /dev/scsi/host${HOST}/bus0/target0/lun0/disc /dev/${BLOCK}
for DEV in ${BLOCK}*; do {
ln -sf /dev/scsi/host${HOST}/bus0/target0/lun0/part${DEV##$BLOCK} /dev/$DEV
}; done
}; done
} 2>&1 | logger
;;
esac

View file

@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
[ -f /proc/mounts ] || /sbin/mount_root
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
vconfig set_name_type DEV_PLUS_VID_NO_PAD
HOSTNAME=${wan_hostname%%.*}
echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
mkdir -p /var/run
mkdir -p /var/log
mkdir -p /var/lock
touch /var/log/wtmp
touch /var/log/lastlog
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
# manually trigger hotplug before loading modules
for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
/usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug net
done
load_modules /etc/modules /etc/modules.d/*
}

View file

@ -0,0 +1,11 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
setup_switch() { return 0; }
include /lib/network
setup_switch
/sbin/wifi
}

View file

@ -0,0 +1,10 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
[ -d /www ] && httpd -p 80 -h /www -r OpenWrt
}
stop() {
killall httpd
}

View file

@ -0,0 +1,10 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
}
stop() {
killall telnetd
}

View file

@ -0,0 +1,12 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start () {
mkdir -p /var/spool/cron
ln -s /etc/crontabs /var/spool/cron/crontabs
crond -c /etc/crontabs
}
stop() {
killall crond
}

View file

@ -0,0 +1,26 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
${FAILSAFE:+exit}
# FIXME: add logging configuration
#[ -f /etc/config/network ] && . /etc/config/network
#eval $(ipcalc "$log_ipaddr")
#[ "$log_ipaddr" = "$IP" ] || log_ipaddr=""
syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
klogd
(
for i in /etc/init.d/S*; do
$i start 2>&1
done
sysctl -p >&-
# automagically run firstboot
{ mount|grep "on / type tmpfs" 1>&-; } && {
lock /tmp/.switch2jffs
firstboot switch2jffs
lock -u /tmp/.switch2jffs
}
) | logger -s -p 6 -t '' &

View file

@ -0,0 +1,3 @@
::sysinit:/etc/init.d/rcS
tts/0::askfirst:/bin/ash --login
#tts/1::askfirst:/bin/ash --login

View file

@ -0,0 +1,3 @@
src snapshots http://openwrt.org/downloads/snapshots/$S/packages
dest root /
dest ram /tmp

View file

@ -0,0 +1,19 @@
#!/bin/ash
# Copyright (C) 2006 OpenWrt.org
# allow env to override nvram
nvram () {
if [ -x /usr/sbin/nvram ]; then
case $1 in
get) eval "echo \${$2:-\$(/usr/sbin/nvram get $2)}";;
*) /usr/sbin/nvram $*;;
esac
else
case $1 in
get) eval "echo \${$2:-\${DEFAULT_$2}}";;
*);;
esac
fi
}

View file

@ -0,0 +1,2 @@
root:!:0:0:root:/tmp:/bin/ash
nobody:*:65534:65534:nobody:/var:/bin/false

View file

@ -0,0 +1,12 @@
#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PS1='\u@\h:\w\$ '
alias more=less
[ -x /usr/bin/vim ] || alias vim=vi
arp() { cat /proc/net/arp; }
ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
reboot() { ifdown wan 2>&1 >/dev/null ; /sbin/reboot; }

View file

@ -0,0 +1,56 @@
# Internet (IP) protocols
#
# Updated from http://www.iana.org/assignments/protocol-numbers and other
# sources.
# New protocols will be added on request if they have been officially
# assigned by IANA and are not historical.
# If you need a huge list of used numbers please install the nmap package.
ip 0 IP # internet protocol, pseudo protocol number
#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # Internet Group Management
ggp 3 GGP # gateway-gateway protocol
ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
st 5 ST # ST datagram mode
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
igp 9 IGP # any private interior gateway (Cisco)
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # "reliable datagram" protocol
iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
xtp 36 XTP # Xpress Transfer Protocol
ddp 37 DDP # Datagram Delivery Protocol
idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
ipv6 41 IPv6 # Internet Protocol, version 6
ipv6-route 43 IPv6-Route # Routing Header for IPv6
ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
idrp 45 IDRP # Inter-Domain Routing Protocol
rsvp 46 RSVP # Reservation Protocol
gre 47 GRE # General Routing Encapsulation
esp 50 IPSEC-ESP # Encap Security Payload [RFC2046]
ah 51 IPSEC-AH # Authentication Header [RFC2402]
skip 57 SKIP # SKIP
ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
vmtp 81 VMTP # Versatile Message Transport
eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
ospf 89 OSPFIGP # Open Shortest Path First IGP
ax.25 93 AX.25 # AX.25 frames
ipip 94 IPIP # IP-within-IP Encapsulation Protocol
etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
# 99 # any private encryption scheme
pim 103 PIM # Protocol Independent Multicast
ipcomp 108 IPCOMP # IP Payload Compression Protocol
vrrp 112 VRRP # Virtual Router Redundancy Protocol
l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
isis 124 ISIS # IS-IS over IPv4
sctp 132 SCTP # Stream Control Transmission Protocol
fc 133 FC # Fibre Channel

View file

@ -0,0 +1,73 @@
#!/bin/sh
. /etc/functions.sh
start() {
return 0
}
stop() {
return 0
}
reload() {
return 1
}
restart() {
stop
start
}
boot() {
start
}
shutdown() {
return 0
}
disable() {
rm -f /etc/rc.d/${initscript##*/}
}
enable() {
disable
ln -s /etc/init.d/${initscript##*/} /etc/rc.d/${initscript##*/}
}
depends() {
return 0
}
help() {
cat <<EOF
Syntax: $initscript [command]
Available commands:
start Start the service
stop Stop the service
restart Restart the service
reload Reload configuration files (or restart if that fails)
$EXTRA_HELP
EOF
}
initscript="$1"
action="$2"
. "$initscript"
cmds=
for cmd in $EXTRA_COMMANDS; do
cmds="$cmd) $cmd;;"
done
eval "case \"\$action\" in
start) start;;
stop) stop;;
reload) reload || restart;;
restart) restart;;
boot) boot;;
shutdown) shutdown;;
$cmds
*) help;;
esac"

View file

@ -0,0 +1,2 @@
nameserver 127.0.0.1
search lan

View file

@ -0,0 +1 @@
/bin/ash

View file

@ -0,0 +1,12 @@
kernel.panic=3
net.ipv4.conf.default.arp_ignore=1
net.ipv4.conf.all.arp_ignore=1
net.ipv4.ip_forward=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_ignore_bogus_error_responses=1
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_keepalive_time=120
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_timestamps=0
net.ipv4.ip_conntrack_tcp_timeouts="300 43200 120 60 120 120 10 60 30 120"
net.ipv4.ip_conntrack_udp_timeouts="60 180"

View file

@ -0,0 +1,160 @@
# Configuration update functions
#
# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
#
# 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
function read_file(filename, result) {
while ((getline <filename) == 1) {
result = result $0 "\n"
}
gsub(/\n*$/, "", result)
return result
}
function cmd2option(str, tmp) {
if (match(str,"=")!=0) {
res = "\toption " substr(str,1,RSTART-1) "\t'" substr(str,RSTART+1) "'"
} else {
res= ""
}
return res
}
function cmd2config(atype, aname) {
return "config \"" atype "\" \"" aname "\""
}
function update_config(cfg, update, \
lines, line, l, n, i, i2, section, scnt, remove, tmp, aidx, rest) {
scnt = 1
linecnt=split(cfg "\n", lines, "\n")
cfg = ""
for (n = 1; n < linecnt; n++) {
# stupid parser for quoted arguments (e.g. for the type string).
# not to be used to gather variable values (backslash escaping doesn't work)
line = lines[n]
gsub(/^[ \t]*/, "", line)
gsub(/#.*$/, "", line)
i2 = 1
delete l
rest = line
while (length(rest)) {
if (match(rest, /[ \t\"]+/)) {
if (RSTART>1) {
l[i2] = substr(rest,1,RSTART-1)
i2++
}
aidx=index(rest,"\"")
if (aidx>=RSTART && aidx<=RSTART+RLENGTH) {
rest=substr(rest,aidx+1)
# find the end of the string
match(rest,/\"/)
l[i2]=substr(rest,1,RSTART-1)
i2++
}
rest=substr(rest,RSTART+RLENGTH)
} else {
l[i2] = rest
i2++
rest = ""
}
}
line = lines[n]
# when a command wants to set a config value for the current
# section and a blank line is encountered before an option with
# the same name, insert it here to maintain some coherency between
# manually and automatically created option lines
# if an option with the same name appears after this point, simply
# ignore it, because it is already set.
if ((section != "") && (l[1] != "option")) {
if (line ~ /^[ \t]*$/) {
if (update ~ "^" section "\\.") {
gsub("^" section ".", "", update)
cfg = cfg cmd2option(update) "\n"
gsub(/=.*$/, "", update)
update = "-" section "." update
}
}
}
if (l[1] == "config") {
# look for all unset values
if (section != "") {
flag=0
if (update ~ "^" section "\\.") {
flag=1
gsub("^" section ".", "", update)
cfg = cfg cmd2option(update) "\n"
update = "-" section "." update
}
if (flag!=0) cfg = cfg "\n"
}
remove = ""
section = l[3]
if (!length(section)) {
section = "cfg" scnt
}
scnt++
if (update == "-" section) {
remove = "section"
update = ""
} else if (update ~ "^@" section "=") {
update = ""
} else if (update ~ "^&" section "=") {
gsub("^&" section "=", "", update)
line = cmd2config(l[2],update)
update = ""
}
}
if (remove == "option") remove = ""
if (l[1] == "option") {
if (update ~ "^-" section "\\." l[2] "$") remove = "option"
# if a supplied config value already exists, replace the whole line
if (match(update, "^" section "." l[2] "=")) {
gsub("^" section ".", "", update)
line = cmd2option(update)
update = ""
}
}
if (remove == "") cfg = cfg line "\n"
}
# any new options for the last section??
if (section != "") {
if (update ~ "^" section "\\.") {
gsub("^" section ".", "", update)
cfg = cfg cmd2option(update) "\n"
update = "-" section "." update
}
}
if (update ~ "^@") {
# new section
section = stype = substr(update,2)
gsub(/=.*$/,"",section)
gsub(/^.*=/,"",stype)
cfg = cfg "\nconfig \"" stype "\" \"" section "\"\n"
}
return cfg
}

View file

@ -0,0 +1,138 @@
#!/bin/sh
# Shell script defining macros for manipulating config files
#
# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraumhofer.de>
# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
#
# 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
uci_load() {
config_load "$PACKAGE"
local PACKAGE_BASE="$(basename "$PACKAGE")"
[ -f "/tmp/.uci/${PACKAGE_BASE}" ] && {
. "/tmp/.uci/${PACKAGE_BASE}"
config_cb
}
}
uci_do_update() {
local FILENAME="$1"
local UPDATE="$2"
awk -f /lib/config/uci-update.awk -f - <<EOF
BEGIN {
config = read_file("$FILENAME")
$UPDATE
print config
}
EOF
}
uci_add_update() {
local PACKAGE="$1"
local UPDATE="$2"
local PACKAGE_BASE="$(basename "$PACKAGE")"
# FIXME: add locking?
mkdir -p "/tmp/.uci"
echo "$UPDATE" >> "/tmp/.uci/${PACKAGE_BASE}"
}
uci_set() {
local PACKAGE="$1"
local CONFIG="$2"
local OPTION="$3"
local VALUE="$4"
( # spawn a subshell so you don't mess up the current environment
uci_load "$PACKAGE"
config_get type "$CONFIG" TYPE
[ -z "$type" ]
) || uci_add_update "$PACKAGE" "CONFIG_SECTION='$CONFIG'${N}option '$OPTION' '$VALUE'"
}
uci_add() {
local PACKAGE="$1"
local TYPE="$2"
local CONFIG="$3"
uci_add_update "$PACKAGE" "config '$TYPE' '$CONFIG'"
}
uci_rename() {
local PACKAGE="$1"
local CONFIG="$2"
local VALUE="$3"
uci_add_update "$PACKAGE" "config_rename '$CONFIG' '$VALUE'"
}
uci_remove() {
local PACKAGE="$1"
local CONFIG="$2"
local OPTION="$3"
if [ -z "$OPTION" ]; then
uci_add_update "$PACKAGE" "config_clear '$CONFIG'"
else
uci_add_update "$PACKAGE" "config_unset '$CONFIG' '$OPTION'"
fi
}
uci_commit() {
local PACKAGE="$1"
local PACKAGE_BASE="$(basename "$PACKAGE")"
mkdir -p /tmp/.uci
lock "/tmp/.uci/$PACKAGE_BASE.lock"
[ -f "/tmp/.uci/$PACKAGE_BASE" ] && (
updatestr=""
# replace handlers
config() {
append updatestr "config = update_config(config, \"@$2=$1\")" "$N"
}
option() {
append updatestr "config = update_config(config, \"$CONFIG_SECTION.$1=$2\")" "$N"
}
config_rename() {
append updatestr "config = update_config(config, \"&$1=$2\")" "$N"
}
config_unset() {
append updatestr "config = update_config(config, \"-$1.$2\")" "$N"
}
config_clear() {
append updatestr "config = update_config(config, \"-$1\")" "$N"
}
. "/tmp/.uci/$PACKAGE_BASE"
# completely disable handlers so that they don't get in the way
config() {
return 0
}
option() {
return 0
}
config_load "$PACKAGE" || CONFIG_FILENAME="$ROOT/etc/config/$PACKAGE_BASE"
uci_do_update "$CONFIG_FILENAME" "$updatestr" > "/tmp/.uci/$PACKAGE_BASE.new" && {
mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \
rm -f "/tmp/.uci/$PACKAGE_BASE"
}
)
lock -u "/tmp/.uci/$PACKAGE_BASE.lock"
}

View file

@ -0,0 +1,143 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# DEBUG="echo"
find_config() {
local iftype device iface ifaces ifn
for ifn in $interfaces; do
config_get iftype "$ifn" type
config_get iface "$ifn" ifname
case "$iftype" in
bridge) config_get ifaces "$ifn" ifnames;;
esac
config_get device "$ifn" device
for ifc in $device $iface $ifaces; do
[ "$ifc" = "$1" ] && {
echo "$ifn"
return 0
}
done
done
return 1;
}
scan_interfaces() {
local mode iftype iface ifname device
interfaces=
config_cb() {
config_get iftype "$CONFIG_SECTION" TYPE
case "$iftype" in
interface)
config_get proto "$CONFIG_SECTION" proto
append interfaces "$CONFIG_SECTION"
config_get iftype "$CONFIG_SECTION" type
config_get ifname "$CONFIG_SECTION" ifname
config_set "$CONFIG_SECTION" device "$ifname"
case "$iftype" in
bridge)
config_set "$CONFIG_SECTION" ifnames "$ifname"
config_set "$CONFIG_SECTION" ifname br-"$CONFIG_SECTION"
;;
esac
( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$CONFIG_SECTION'"
;;
esac
}
config_load network
}
add_vlan() {
local vif="${1%\.*}"
[ "$1" = "$vif" ] || ifconfig "$1" >/dev/null 2>/dev/null || {
ifconfig "$vif" up 2>/dev/null >/dev/null || add_vlan "$vif"
$DEBUG vconfig add "$vif" "${1##*\.}"
}
}
setup_interface() {
local iface="$1"
local config="$2"
local proto
[ -n "$config" ] || {
config=$(find_config "$iface")
[ "$?" = 0 ] || return 1
}
proto="${3:-$(config_get "$config" proto)}"
config_get iftype "$config" type
# Setup VLAN interfaces
add_vlan "$iface"
# Setup bridging
case "$iftype" in
bridge)
ifconfig "$iface" up 2>/dev/null >/dev/null
ifconfig "br-$config" 2>/dev/null >/dev/null && {
$DEBUG brctl addif "br-$config" "$iface"
return 0
} || {
$DEBUG brctl addbr "br-$config"
$DEBUG brctl setfd "br-$config" 0
$DEBUG brctl addif "br-$config" "$iface"
iface="br-$config"
}
;;
esac
# Interface settings
config_get mtu "$config" mtu
$DEBUG ifconfig "$iface" ${mtu:+mtu $mtu} up
pidfile="/var/run/$iface.pid"
case "$proto" in
static)
config_get ipaddr "$config" ipaddr
config_get netmask "$config" netmask
[ -z "$ipaddr" -o -z "$netmask" ] && return 1
config_get ip6addr "$config" ip6addr
config_get gateway "$config" gateway
config_get dns "$config" dns
$DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
[ -z "$gateway" ] || route add default gw "$gateway"
[ -z "$dns" -o -f /tmp/resolv.conf ] || {
for ns in $dns; do
echo "nameserver $ns" >> /tmp/resolv.conf
done
}
env -i ACTION="ifup" INTERFACE="config" DEVICE="$iface" PROTO=static /sbin/hotplug "iface" &
;;
dhcp)
pid="$(cat "$pidfile" 2>/dev/null)"
[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 "$pid"
config_get ipaddr "$config" ipaddr
config_get netmask "$config" netmask
config_get hostname "$config" hostname
config_get proto1 "$config" proto
[ -z "$ipaddr" ] || \
$DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
# don't stay running in background if dhcp is not the main proto on the interface (e.g. when using pptp)
[ "$proto1" != "$proto" ] && dhcpopts="-n -q"
$DEBUG udhcpc -i "$iface" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} -b -p "$pidfile" ${dhcpopts:- -R &}
;;
*)
if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
eval "setup_interface_$proto '$iface' '$config' '$proto'"
else
echo "Interface type $proto not supported."
return 1
fi
;;
esac
}

View file

@ -0,0 +1,3 @@
SQUASHFS USERS:
After firstboot has been run, / will be jffs2 and /rom will be squashfs
(* except when in failsafe)

View file

@ -0,0 +1,26 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# bypass the normal hotplug path for firmware loading
# would otherwise cause problems with drivers like bcm43xx
[ "$1" = "firmware" -a "$ACTION" = "add" ] && {
[ -f "/lib/firmware/$FIRMWARE" ] && {
echo 1 > "/sys$DEVPATH/loading"
cp "/lib/firmware/$FIRMWARE" "/sys$DEVPATH/data"
echo 0 > "/sys$DEVPATH/loading"
}
exit 0
}
. /etc/functions.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LOGNAME=root
USER=root
export PATH LOGNAME USER
[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
[ -f $script ] && . $script
); done
}

View file

@ -0,0 +1,34 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
[ $# = 0 ] && { echo " $0 <group>"; exit; }
. /etc/functions.sh
include /lib/network
scan_interfaces
cfg=$1
debug "### ifdown $cfg ###"
config_get proto "$cfg" proto
[ -z "$proto" ] && { echo "interface not found."; exit; }
# kill active ppp daemon
pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
[ -n "$pid" -a -d "/proc/$pid" ] && {
kill $pid
sleep 1
[ -d "/proc/$pid" ] && kill -9 $pid
}
# kill any other process associated with the interface
config_get ifname "$cfg" ifname
pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
config_get ifname "$cfg" ifname
ifconfig "$ifname" >/dev/null 2>/dev/null && {
ifconfig "$ifname" 0.0.0.0 down
config_get iftype "$cfg" type
[ "$iftype" = "bridge" ] && brctl delbr "$ifname"
}

View file

@ -0,0 +1,14 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
. /sbin/ifdown "$@"
config_get iftype "$1" type
case "$iftype" in
bridge) config_get ifname "$1" ifnames;;
*) config_get ifname "$1" ifname;;
esac
for dev in $ifname; do
setup_interface "$dev" "$1"
done

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
mount none /proc -t proc
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
mount none /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
mkdir -p /dev/pts
mount none /dev/pts -t devpts
mount -t sysfs none /sys 2>&-
mount -o remount,rw /dev/root /

View file

@ -0,0 +1,44 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
. /etc/functions.sh
config_get_bool() {
local _tmp
config_get "$1" "$2" "$3"
eval "_tmp=\$$1"
case "$_tmp" in
1|on|enabled) eval "$1=1";;
0|off|disabled) eval "$1=0";;
*) eval "$1=${4:-0}";;
esac
}
config_cb() {
config_get TYPE "$CONFIG_SECTION" TYPE
case "$TYPE" in
wifi-device)
append DEVICES "$CONFIG_SECTION"
;;
wifi-iface)
config_get device "$CONFIG_SECTION" device
config_get vifs "$device" vifs
append vifs "$CONFIG_SECTION"
config_set "$device" vifs "$vifs"
;;
esac
}
config_load wireless
include /lib/wifi
for device in $DEVICES; do (
config_get iftype "$device" type
eval "type setup_$iftype" 2>/dev/null >/dev/null && {
eval "scan_$iftype '$device'"
eval "setup_$iftype '$device'" && {
# TODO: set up network settings
/bin/true
} || echo "$device($iftype): Setup failed" || true
} || echo "$device($iftype): Interface type not supported"
); done

View file

@ -0,0 +1,68 @@
# Copyright (C) 2006 OpenWrt.org
function portstr(type, str) {
gsub(/-/, ":", str)
if (insmod_mport != 1) {
print "insmod ipt_multiport >&- 2>&-"
insmod_mport = 1
}
if (type == "src") return " -m multiport --sports " str
else return " -m multiport --dports " str
}
function str2ipt(str) {
str2data(str)
_cmd = ""
if (_l["src"] != "") _cmd = _cmd " -s " _l["src"]
if (_l["dest"] != "") _cmd = _cmd " -d " _l["dest"]
if (_l["proto"] != "") {
_cmd = _cmd " -p " _l["proto"]
}
# scripts need to check for proto="" and emit two rules in that case
if ((_l["proto"] == "") || (_l["proto"] == "tcp") || (_l["proto"] == "udp")) {
if (_l["sport"] != "") _cmd = _cmd portstr("src", _l["sport"])
if (_l["dport"] != "") _cmd = _cmd portstr("dest", _l["dport"])
}
if (_l["layer7"] != "") {
if (insmod_l7 != 1) {
print "insmod ipt_layer7 >&- 2>&-"
insmod_l7 = 1
}
_cmd = _cmd " -m layer7 --l7proto " _l["layer7"]
}
return _cmd
}
function str2data(str) {
delete _l
_n = split(str, _o, "[\t ]")
for (_i = 1; _i <= _n; _i++) {
_n2 = split(_o[_i], _c, "=")
if (_n2 == 2) _l[_c[1]] = _c[2]
}
}
function bitcount(c) {
c=and(rshift(c, 1),0x55555555)+and(c,0x55555555)
c=and(rshift(c, 2),0x33333333)+and(c,0x33333333)
c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f)
c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff)
c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff)
return c
}
function validate_netmask(nm) {
return and(-nm,compl(nm))
}
function ip2int(ip) {
for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
return ret
}
function int2ip(ip,ret,x) {
ret=and(ip,255)
ip=rshift(ip,8)
for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++);
return ret
}

View file

@ -0,0 +1,42 @@
# Copyright (C) 2006 OpenWrt.org
{
line=$0
gsub(/^[ \t]*/, "")
gsub(/[ \t]*$/, "")
}
$1 == "@define" {
v[$2] = $3
}
$1 == "@ifdef" {
if_open = 1
if (v[$2] != "") noprint = 0
else noprint = 1
}
$1 == "@ifndef" {
if_open = 1
if (v[$2] != "") noprint = 1
else noprint = 0
}
$1 == "@else" {
if (noprint == 1) noprint = 0
else noprint = 1
}
($1 !~ /^@[a-zA-Z]/) && (noprint != 1) {
n=split(line "@@", a, /@@/)
for (i=1; i<=n; i++) {
if ((i % 2) == 1) printf a[i]
else printf v[a[i]]
}
print ""
}
$1 == "@endif" {
if_open = 0
noprint = 0
}

View file

@ -0,0 +1,57 @@
#!/bin/sh
[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
. /etc/functions.sh
include /lib/network
RESOLV_CONF="/tmp/resolv.conf"
hotplug_event() {
scan_interfaces
for ifc in $interfaces; do
config_get ifname $ifc ifname
[ "$ifname" = "$interface" ] || continue
config_get proto $ifc proto
[ "$proto" = "dhcp" ] || continue
env -i ACTION="$1" INTERFACE="$ifname" PROTO=dhcp /sbin/hotplug iface
done
}
case "$1" in
deconfig)
ifconfig $interface 0.0.0.0
hotplug_event ifdown
;;
renew|bound)
ifconfig $interface $ip \
netmask ${subnet:-255.255.255.0} \
broadcast ${broadcast:-+}
if [ -n "$router" ] ; then
echo "deleting routers"
while route del default gw 0.0.0.0 dev $interface >&- 2>&- ; do :; done
for i in $router ; do
echo "adding router $i"
route add default gw $i dev $interface
done
fi
[ -n "$dns" ] && {
echo -n > $RESOLV_CONF
${domain:+echo search $domain} >> $RESOLV_CONF
for i in $dns ; do
echo "adding dns $i"
echo "nameserver $i" >> $RESOLV_CONF
done
}
hotplug_event ifup
# user rules
[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
;;
esac
exit 0

View file

@ -0,0 +1,12 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto dhcp

View file

@ -0,0 +1,14 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option type bridge
option ifname "eth0 ath0"
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0

View file

@ -0,0 +1,5 @@
# Copyright (C) 2006 OpenWrt.org
::sysinit:/etc/init.d/rcS
duart/0::askfirst:/bin/ash --login
#tts/1::askfirst:/bin/ash --login

View file

@ -0,0 +1,59 @@
/*
* patcher.c - ADAM2 patcher for Netgear DG834 (and compatible)
*
* Copyright (C) 2006 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
int fd;
char *ptr;
uint32_t *i;
if (argc != 2) {
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
exit(1);
}
if (((fd = open(argv[1], O_RDWR)) < 0)
|| ((ptr = mmap(0, 128 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1))) {
fprintf(stderr, "Can't open file\n");
exit(1);
}
i = (uint32_t *) &ptr[0x3944];
if (*i == 0x0c000944) {
fprintf(stderr, "Unpatched ADAM2 detected. Patching... ");
*i = 0x00000000;
msync(i, sizeof(*i), MS_SYNC|MS_INVALIDATE);
fprintf(stderr, "done!\n");
} else if (*i == 0x00000000) {
fprintf(stderr, "Patched ADAM2 detected.\n");
} else {
fprintf(stderr, "Unknown ADAM2 detected. Can't patch!\n");
}
close(fd);
}

View file

@ -0,0 +1,133 @@
/*
* jffs2root.c
*
* Copyright (C) 2005 Mike Baker
*
* 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 <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/mtd/mtd.h>
#define FILENAME "/dev/mtdblock/1"
struct trx_header {
unsigned magic; /* "HDR0" */
unsigned len; /* Length of file including header */
unsigned crc32; /* 32-bit CRC from flag_version to end of file */
unsigned flag_version; /* 0:15 flags, 16:31 version */
unsigned offsets[3]; /* Offsets of partitions from start of header */
};
unsigned long *crc32;
void init_crc32()
{
unsigned long crc;
unsigned long poly = 0xEDB88320L;
int n, bit;
if ((crc32 = (unsigned long *) malloc(256 * sizeof(unsigned long))) == (void *)-1) {
perror("malloc");
exit(1);
}
for (n = 0; n < 256; n++) {
crc = (unsigned long) n;
for (bit = 0; bit < 8; bit++)
crc = (crc & 1) ? (poly ^ (crc >> 1)) : (crc >> 1);
crc32[n] = crc;
}
}
unsigned int crc32buf(char *buf, size_t len)
{
unsigned int crc = 0xFFFFFFFF;
for (; len; len--, buf++)
crc = crc32[(crc ^ *buf) & 0xff] ^ (crc >> 8);
return crc;
}
int main(int argc, char **argv)
{
int fd;
struct mtd_info_user mtdInfo;
unsigned long len;
struct trx_header *ptr;
char *buf;
if (((fd = open(FILENAME, O_RDWR)) < 0)
|| ((len = lseek(fd, 0, SEEK_END)) < 0)
|| ((ptr = (struct trx_header *) mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1))
|| (ptr->magic != 0x30524448)) {
printf("Error reading trx info\n");
exit(-1);
}
close (fd);
if (((fd = open("/dev/mtd/1", O_RDWR)) < 0)
|| (ioctl(fd, MEMGETINFO, &mtdInfo))) {
fprintf(stderr, "Could not get MTD device info from %s\n", FILENAME);
close(fd);
exit(1);
}
close(fd);
if (argc > 1 && !strcmp(argv[1],"--move")) {
if (ptr->offsets[2] >= ptr->len) {
printf("Partition already moved outside trx\n");
} else {
init_crc32();
ptr->offsets[2] += (mtdInfo.erasesize - 1);
ptr->offsets[2] &= ~(mtdInfo.erasesize - 1);
ptr->len = ptr->offsets[2];
ptr->crc32 = crc32buf((void *) &(ptr->flag_version), ptr->len - offsetof(struct trx_header, flag_version));
msync(ptr,sizeof(struct trx_header),MS_SYNC|MS_INVALIDATE);
printf("Partition moved; please reboot\n");
}
} else if (argc > 1 && !strcmp(argv[1], "--clean")) {
buf = (char *) ptr;
if (buf[ptr->offsets[1] - 1] == 0) {
init_crc32();
buf[ptr->offsets[1] - 1] = 1;
ptr->crc32 = crc32buf((void *) &(ptr->flag_version), ptr->len - offsetof(struct trx_header, flag_version));
msync(ptr,sizeof(struct trx_header),MS_SYNC|MS_INVALIDATE);
printf("Partition marked as clean\n");
}
} else {
int x;
printf(" erase: 0x%08x\n",mtdInfo.erasesize);
printf("=== trx ===\n");
printf("mapped: 0x%08x\n", (unsigned)ptr);
printf(" magic: 0x%08x\n", ptr->magic);
printf(" len: 0x%08x\n", ptr->len);
printf(" crc: 0x%08x\n", ptr->crc32);
for (x = 0; x < 3; x++)
printf(" offset[%d]: 0x%08x\n", x, ptr->offsets[x]);
}
munmap((void *) ptr, len);
return 0;
}

View file

@ -0,0 +1,19 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option type bridge
option ifname "eth1 eth2"
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
config interface wan
option ifname eth0
option proto dhcp

View file

@ -0,0 +1,19 @@
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option type bridge
option ifname "eth1 eth2"
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
config interface wan
option ifname eth0
option proto dhcp

View file

@ -0,0 +1,11 @@
# Network configuration file
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto dhcp

46
package/bridge/Makefile Normal file
View file

@ -0,0 +1,46 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=bridge
PKG_VERSION:=1.0.6
PKG_RELEASE:=1
PKG_SOURCE:=bridge-utils-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/bridge
PKG_MD5SUM:=9b7dc52656f5cbec846a7ba3299f73bd
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/bridge-utils-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/bridge
SECTION:=net
CATEGORY:=Base system
DEFAULT:=y
TITLE:=Ethernet bridging configuration utility
DESCRIPTION:=\
Manage ethernet bridging: a way to connect networks together to \\\
form a larger network.
URL:=http://bridge.sourceforge.net/
endef
define Build/Configure
$(call Build/Configure/Default, \
--with-linux-headers="$(LINUX_DIR)" \
)
endef
define Package/bridge/install
install -m0755 -d $(1)/usr/sbin
install -m0755 $(PKG_BUILD_DIR)/brctl/brctl $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,bridge))

View file

@ -0,0 +1,11 @@
--- bridge-utils-0.9.6/libbridge/Makefile.in.dist 2004-03-01 20:55:52.000000000 -0600
+++ bridge-utils-0.9.6/libbridge/Makefile.in 2004-03-01 20:56:23.000000000 -0600
@@ -5,7 +5,7 @@
RANLIB=@RANLIB@
CC=@CC@
-CFLAGS = -Wall -g $(KERNEL_HEADERS)
+CFLAGS = -Wall -g @CFLAGS@ $(KERNEL_HEADERS)
prefix=@prefix@
exec_prefix=@exec_prefix@

View file

@ -0,0 +1,148 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 2480 2005-11-14 02:07:33Z nbd $
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=broadcom-wl
PKG_VERSION:=4.80.17.0
PKG_RELEASE:=1
WLC_VERSION:=0.1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
PKG_MD5SUM:=3183ddb60e3e882b41df1776c89b614c
PKG_CAT:=bzcat
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/broadcom-wl/Default
SECTION:=net
CATEGORY:=Kernel drivers
DEPENDS:=@PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mimo
SUBMENU:=Proprietary BCM43xx WiFi driver
SUBMENUDEP:=@LINUX_2_4_BRCM
endef
define Package/kmod-brcm-wl/Default
$(call Package/broadcom-wl/Default)
SECTION:=kernel
DEPENDS:=@LINUX_2_4_BRCM
TITLE:=Kernel driver for BCM43xx chipsets
DESCRIPTION:=\
This package contains the proprietary wireless driver for the Broadcom \\\
BCM43xx chipset
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(PKG_RELEASE)
endef
define Package/kmod-brcm-wl
$(call Package/kmod-brcm-wl/Default)
DEFAULT:=y
TITLE+= (normal version)
DESCRIPTION+= (normal version).
endef
define Package/kmod-brcm-wl-mimo
$(call Package/kmod-brcm-wl/Default)
TITLE+= (MIMO version)
DESCRIPTION+= (MIMO version).
endef
define Package/wlc
$(call Package/broadcom-wl/Default)
DEFAULT:=y
TITLE:=Proprietary Broadcom wl driver setup utility
DESCRIPTION:=\
This package contains an utility for initializing the proprietary Broadcom \\\
wl driver.
endef
define Package/wl
$(call Package/broadcom-wl/Default)
TITLE:=Proprietary Broadcom wl driver config utility
DESCRIPTION:=\
This package contains the proprietary utility (wl) for configuring the \\\
proprietary Broadcom wl driver.
endef
define Package/nas
$(call Package/broadcom-wl/Default)
DEPENDS+= +nvram
TITLE:=Proprietary Broadcom WPA/WPA2 authenticator
DESCRIPTION:=\
This package contains the proprietary WPA/WPA2 authenticator (nas) for the \\\
proprietary Broadcom wl driver.
endef
MAKEFLAGS_KMOD:= -C "$(LINUX_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
PATH="$(TARGET_PATH)" \
SUBDIRS="$(PKG_BUILD_DIR)/kmod"
define Build/Prepare
$(call Build/Prepare/Default)
$(CP) src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
# Compile the kernel part
$(MAKE) $(MAKEFLAGS_KMOD) \
modules
$(MAKE) $(MAKEFLAGS_KMOD) MOD_NAME="_mimo" \
modules
# Compile wlc
$(MAKE) -C $(PKG_BUILD_DIR)/wlc \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="-I$(PKG_BUILD_DIR)/wlc/include $(TARGET_CFLAGS)" \
all
endef
define wl_template
install -d -m0755 $(1)/etc/modules.d
echo "wl$(2)" > $(1)/etc/modules.d/20-wl$(2)
install -d -m0755 $(1)/lib/modules/$(LINUX_VERSION)
install -m0644 $(PKG_BUILD_DIR)/kmod/wl$(2).o $(PKG_BUILD_DIR)/kmod/wl$(2).o.patch $(1)/lib/modules/$(LINUX_VERSION)/
endef
define Package/kmod-brcm-wl/install
$(call wl_template,$(1))
endef
define Package/kmod-brcm-wl-mimo/install
$(call wl_template,$(1),_mimo)
endef
define Package/wlc/install
$(CP) ./files/* $(1)/
install -d -m0755 $(1)/sbin
install -m0755 $(PKG_BUILD_DIR)/wlc/wlc $(1)/sbin/
endef
define Package/wl/install
install -d -m0755 $(1)/usr/sbin
install -m0755 $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/
endef
define Package/nas/install
install -d -m0755 $(1)/usr/lib
install -m0755 $(PKG_BUILD_DIR)/libbcmcrypto.so $(1)/usr/lib/
install -d -m0755 $(1)/usr/sbin
install -m0755 $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/
ln -sf nas $(1)/usr/sbin/nas4not
ln -sf nas $(1)/usr/sbin/nas4wds
endef
$(eval $(call BuildPackage,kmod-brcm-wl))
$(eval $(call BuildPackage,kmod-brcm-wl-mimo))
$(eval $(call BuildPackage,wlc))
$(eval $(call BuildPackage,wl))
$(eval $(call BuildPackage,nas))

View file

@ -0,0 +1,177 @@
bridge_interface() {
(
. /etc/functions.sh
include network
scan_interfaces
cfg="$(find_config "$1")"
[ -z "$cfg" ] && return 0
config_get iftype "$cfg" type
[ "$iftype" = bridge ] && config_get "$iftype" bridge
)
}
scan_broadcom() {
local device="$1"
config_get vifs "$device" vifs
for vif in $vifs; do
config_get mode "$vif" mode
case "$mode" in
adhoc)
adhoc=1
adhoc_if="$vif"
;;
sta)
sta=1
sta_if="$vif"
;;
ap)
ap=1
ap_if="${ap_if:+$ap_if }$vif"
;;
*) echo "$device($vif): Invalid mode";;
esac
done
local _c=
for vif in ${adhoc_if:-$sta_if $ap_if}; do
config_set "$vif" ifname "wl0${_c:+.$_c}"
_c=$((${_c:-0} + 1))
done
ifdown="down"
for vif in 0 1 2 3; do
append ifdown "vif $vif" "$N"
append ifdown "enabled 0" "$N"
done
ap=1
infra=1
mssid=1
apsta=0
radio=1
case "$adhoc:$sta:$ap" in
1*)
ap=0
mssid=0
infra=0
;;
:1:1)
apsta=1
wet=1
;;
:1:)
wet=1
ap=0
mssid=0
;;
::)
radio=0
;;
esac
}
setup_broadcom() {
local _c
config_get channel "$device" channel
config_get country "$device" country
config_get maxassoc "$device" maxassoc
_c=0
nas="$(which nas)"
nas_cmd=
if_up=
for vif in ${adhoc_if:-$sta_if $ap_if}; do
append vif_pre_up "vif $_c" "$N"
append vif_post_up "vif $_c" "$N"
[ "$vif" = "$sta_if" ] || {
config_get_bool hidden "$vif" hidden 1
append vif_pre_up "closed $hidden" "$N"
config_get_bool isolate "$vif" isolate
append vif_pre_up "ap_isolate $hidden" "$N"
}
wsec_r=0
eap_r=0
wsec=0
auth=0
nasopts=
config_get enc "$vif" encryption
case "$enc" in
WEP|wep)
wsec_r=1
;;
*psk*|*PSK*)
wsec_r=1
config_get key "$vif" key
case "$enc" in
wpa2*|WPA2*|PSK2*|psk2*) auth=128; wsec=4;;
*) auth=4; crypto=2;;
esac
eval "${vif}_key=\"\$key\""
nasopts="-k \"\$${vif}_key\""
;;
*wpa*|*WPA*)
wsec_r=1
eap_r=1
config_get key "$vif" key
config_get server "$vif" server
config_get port "$vif" port
case "$enc" in
wpa2*|WPA2*) auth=64; wsec=4;;
*) auth=2; crypto=2;;
esac
eval "${vif}_key=\"\$key\""
nasopts="-r \"\$${vif}_key\" -h $server -p $port"
;;
esac
append vif_post_up "wsec $wsec" "$N"
append vif_post_up "wpa_auth $auth" "$N"
append vif_post_up "wsec_restrict $wsec_r" "$N"
append vif_post_up "eap_restrict $eap_r" "$N"
config_get ssid "$vif" ssid
append vif_post_up "vlan_mode 0"
append vif_post_up "ssid $ssid" "$N"
append vif_post_up "enabled 1" "$N"
config_get ifname "$vif" ifname
append if_up "ifconfig $ifname up" ";$N"
[ -z "$nasopts" ] || {
bridge="$(bridge_interface "$ifname")"
eval "${vif}_ssid=\"\$ssid\""
mode="-A"
[ "$vif" = "$sta_if" ] && mode="-S"
[ -z "$nas" ] || nas_cmd="${nas_cmd:+$nas_cmd$N}$nas -P /var/run/nas.$ifname.pid -H 34954 ${bridge:+ -l $bridge} -i $ifname $mode -m $auth -w $crypto -s \"\$${vif}_ssid\" -g 3600 $nasopts &"
}
_c=$(($_c + 1))
done
killall -KILL nas >&- 2>&-
wlc stdin <<EOF
$ifdown
mssid $mssid
ap $ap
apsta $apsta
infra $infra
${wet:+wet 1}
radio ${radio:-1}
macfilter 0
maclist none
wds none
channel ${channel:-0}
country ${country:-IL0}
maxassoc ${maxassoc:-128}
$vif_pre_up
up
$vif_post_up
EOF
eval "$nas_cmd"
eval "$if_up"
}

View file

@ -0,0 +1,31 @@
#
# Makefile for the Broadcom wl driver
#
# Copyright 2004, Broadcom Corporation
# All Rights Reserved.
#
# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
#
# $Id: Makefile,v 1.2 2005/03/29 03:32:18 mbm Exp $
EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
O_TARGET := wl$(MOD_NAME).o
obj-y := wl_mod$(MOD_NAME).o
obj-y += bcmutils.o hnddma.o linux_osl.o
obj-m := $(O_TARGET)
wl_mod$(MOD_NAME).o: wl_apsta$(MOD_NAME).o
perl -ne 's,eth%d,wl%d\x00,g,print' < $< > $@
wl$(MOD_NAME).o.patch: wl$(MOD_NAME).o
$(OBJDUMP) -d $< | perl patchtable.pl > $@
modules: wl$(MOD_NAME).o.patch
include $(TOPDIR)/Rules.make

View file

@ -0,0 +1,101 @@
/*
* Copyright 2006, Broadcom Corporation
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
*
* Fundamental constants relating to IP Protocol
*
* $Id: bcmip.h,v 1.1.1.3 2006/02/27 03:43:16 honor Exp $
*/
#ifndef _bcmip_h_
#define _bcmip_h_
/* IPV4 and IPV6 common */
#define IP_VER_OFFSET 0x0 /* offset to version field */
#define IP_VER_MASK 0xf0 /* version mask */
#define IP_VER_SHIFT 4 /* version shift */
#define IP_VER_4 4 /* version number for IPV4 */
#define IP_VER_6 6 /* version number for IPV6 */
#define IP_VER(ip_body) \
((((uint8 *)(ip_body))[IP_VER_OFFSET] & IP_VER_MASK) >> IP_VER_SHIFT)
#define IP_PROT_ICMP 0x1 /* ICMP protocol */
#define IP_PROT_TCP 0x6 /* TCP protocol */
#define IP_PROT_UDP 0x11 /* UDP protocol type */
/* IPV4 field offsets */
#define IPV4_VER_HL_OFFSET 0 /* version and ihl byte offset */
#define IPV4_TOS_OFFSET 1 /* type of service offset */
#define IPV4_PROT_OFFSET 9 /* protocol type offset */
#define IPV4_CHKSUM_OFFSET 10 /* IP header checksum offset */
#define IPV4_SRC_IP_OFFSET 12 /* src IP addr offset */
#define IPV4_DEST_IP_OFFSET 16 /* dest IP addr offset */
/* IPV4 field decodes */
#define IPV4_VER_MASK 0xf0 /* IPV4 version mask */
#define IPV4_VER_SHIFT 4 /* IPV4 version shift */
#define IPV4_HLEN_MASK 0x0f /* IPV4 header length mask */
#define IPV4_HLEN(ipv4_body) (4 * (((uint8 *)(ipv4_body))[IPV4_VER_HL_OFFSET] & IPV4_HLEN_MASK))
#define IPV4_ADDR_LEN 4 /* IPV4 address length */
#define IPV4_ADDR_NULL(a) ((((uint8 *)(a))[0] | ((uint8 *)(a))[1] | \
((uint8 *)(a))[2] | ((uint8 *)(a))[3]) == 0)
#define IPV4_TOS_DSCP_MASK 0xfc /* DiffServ codepoint mask */
#define IPV4_TOS_DSCP_SHIFT 2 /* DiffServ codepoint shift */
#define IPV4_TOS(ipv4_body) (((uint8 *)(ipv4_body))[IPV4_TOS_OFFSET])
#define IPV4_TOS_PREC_MASK 0xe0 /* Historical precedence mask */
#define IPV4_TOS_PREC_SHIFT 5 /* Historical precedence shift */
#define IPV4_TOS_LOWDELAY 0x10 /* Lowest delay requested */
#define IPV4_TOS_THROUGHPUT 0x8 /* Best throughput requested */
#define IPV4_TOS_RELIABILITY 0x4 /* Most reliable delivery requested */
#define IPV4_PROT(ipv4_body) (((uint8 *)(ipv4_body))[IPV4_PROT_OFFSET])
#define IPV4_ADDR_STR_LEN 16 /* Max IP address length in string format */
/* IPV6 field offsets */
#define IPV6_PAYLOAD_LEN_OFFSET 4 /* payload length offset */
#define IPV6_NEXT_HDR_OFFSET 6 /* next header/protocol offset */
#define IPV6_HOP_LIMIT_OFFSET 7 /* hop limit offset */
#define IPV6_SRC_IP_OFFSET 8 /* src IP addr offset */
#define IPV6_DEST_IP_OFFSET 24 /* dst IP addr offset */
/* IPV6 field decodes */
#define IPV6_TRAFFIC_CLASS(ipv6_body) \
(((((uint8 *)(ipv6_body))[0] & 0x0f) << 4) | \
((((uint8 *)(ipv6_body))[1] & 0xf0) >> 4))
#define IPV6_FLOW_LABEL(ipv6_body) \
(((((uint8 *)(ipv6_body))[1] & 0x0f) << 16) | \
(((uint8 *)(ipv6_body))[2] << 8) | \
(((uint8 *)(ipv6_body))[3]))
#define IPV6_PAYLOAD_LEN(ipv6_body) \
((((uint8 *)(ipv6_body))[IPV6_PAYLOAD_LEN_OFFSET + 0] << 8) | \
((uint8 *)(ipv6_body))[IPV6_PAYLOAD_LEN_OFFSET + 1])
#define IPV6_NEXT_HDR(ipv6_body) \
(((uint8 *)(ipv6_body))[IPV6_NEXT_HDR_OFFSET])
#define IPV6_PROT(ipv6_body) IPV6_NEXT_HDR(ipv6_body)
#define IPV6_ADDR_LEN 16 /* IPV6 address length */
/* IPV4 TOS or IPV6 Traffic Classifier or 0 */
#define IP_TOS(ip_body) \
(IP_VER(ip_body) == IP_VER_4 ? IPV4_TOS(ip_body) : \
IP_VER(ip_body) == IP_VER_6 ? IPV6_TRAFFIC_CLASS(ip_body) : 0)
#endif /* _bcmip_h_ */

View file

@ -0,0 +1,857 @@
/*
* Misc useful OS-independent routines.
*
* Copyright 2006, Broadcom Corporation
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
* $Id: bcmutils.c,v 1.1.1.12 2006/02/27 03:43:16 honor Exp $
*/
#include <typedefs.h>
#include <bcmdefs.h>
#include <stdarg.h>
#include <osl.h>
#include "linux_osl.h"
#include "pktq.h"
#include <bcmutils.h>
#include <sbutils.h>
#include <bcmnvram.h>
#include <bcmendian.h>
#include <bcmdevs.h>
#include "bcmip.h"
#define ETHER_TYPE_8021Q 0x8100
#define ETHER_TYPE_IP 0x0800
#define VLAN_PRI_SHIFT 13
#define VLAN_PRI_MASK 7
struct ether_header {
uint8 ether_dhost[6];
uint8 ether_shost[6];
uint16 ether_type;
} __attribute__((packed));
struct ethervlan_header {
uint8 ether_dhost[6];
uint8 ether_shost[6];
uint16 vlan_type; /* 0x8100 */
uint16 vlan_tag; /* priority, cfi and vid */
uint16 ether_type;
};
/* copy a pkt buffer chain into a buffer */
uint
pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf)
{
uint n, ret = 0;
if (len < 0)
len = 4096; /* "infinite" */
/* skip 'offset' bytes */
for (; p && offset; p = PKTNEXT(osh, p)) {
if (offset < (uint)PKTLEN(osh, p))
break;
offset -= PKTLEN(osh, p);
}
if (!p)
return 0;
/* copy the data */
for (; p && len; p = PKTNEXT(osh, p)) {
n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
bcopy(PKTDATA(osh, p) + offset, buf, n);
buf += n;
len -= n;
ret += n;
offset = 0;
}
return ret;
}
/* return total length of buffer chain */
uint
pkttotlen(osl_t *osh, void *p)
{
uint total;
total = 0;
for (; p; p = PKTNEXT(osh, p))
total += PKTLEN(osh, p);
return (total);
}
/* return the last buffer of chained pkt */
void *
pktlast(osl_t *osh, void *p)
{
for (; PKTNEXT(osh, p); p = PKTNEXT(osh, p))
;
return (p);
}
/*
* osl multiple-precedence packet queue
* hi_prec is always >= the number of the highest non-empty queue
*/
void *
pktq_penq(struct pktq *pq, int prec, void *p)
{
struct pktq_prec *q;
ASSERT(prec >= 0 && prec < pq->num_prec);
ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */
ASSERT(!pktq_full(pq));
ASSERT(!pktq_pfull(pq, prec));
q = &pq->q[prec];
if (q->head)
PKTSETLINK(q->tail, p);
else
q->head = p;
q->tail = p;
q->len++;
pq->len++;
if (pq->hi_prec < prec)
pq->hi_prec = (uint8)prec;
return p;
}
void *
pktq_penq_head(struct pktq *pq, int prec, void *p)
{
struct pktq_prec *q;
ASSERT(prec >= 0 && prec < pq->num_prec);
ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */
ASSERT(!pktq_full(pq));
ASSERT(!pktq_pfull(pq, prec));
q = &pq->q[prec];
if (q->head == NULL)
q->tail = p;
PKTSETLINK(p, q->head);
q->head = p;
q->len++;
pq->len++;
if (pq->hi_prec < prec)
pq->hi_prec = (uint8)prec;
return p;
}
void *
pktq_pdeq(struct pktq *pq, int prec)
{
struct pktq_prec *q;
void *p;
ASSERT(prec >= 0 && prec < pq->num_prec);
q = &pq->q[prec];
if ((p = q->head) == NULL)
return NULL;
if ((q->head = PKTLINK(p)) == NULL)
q->tail = NULL;
q->len--;
pq->len--;
PKTSETLINK(p, NULL);
return p;
}
void *
pktq_pdeq_tail(struct pktq *pq, int prec)
{
struct pktq_prec *q;
void *p, *prev;
ASSERT(prec >= 0 && prec < pq->num_prec);
q = &pq->q[prec];
if ((p = q->head) == NULL)
return NULL;
for (prev = NULL; p != q->tail; p = PKTLINK(p))
prev = p;
if (prev)
PKTSETLINK(prev, NULL);
else
q->head = NULL;
q->tail = prev;
q->len--;
pq->len--;
return p;
}
void
pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir)
{
struct pktq_prec *q;
void *p;
q = &pq->q[prec];
p = q->head;
while (p) {
q->head = PKTLINK(p);
PKTSETLINK(p, NULL);
PKTFREE(osh, p, dir);
q->len--;
pq->len--;
p = q->head;
}
ASSERT(q->len == 0);
q->tail = NULL;
}
bool
pktq_pdel(struct pktq *pq, void *pktbuf, int prec)
{
struct pktq_prec *q;
void *p;
ASSERT(prec >= 0 && prec < pq->num_prec);
if (!pktbuf)
return FALSE;
q = &pq->q[prec];
if (q->head == pktbuf) {
if ((q->head = PKTLINK(pktbuf)) == NULL)
q->tail = NULL;
} else {
for (p = q->head; p && PKTLINK(p) != pktbuf; p = PKTLINK(p))
;
if (p == NULL)
return FALSE;
PKTSETLINK(p, PKTLINK(pktbuf));
if (q->tail == pktbuf)
q->tail = p;
}
q->len--;
pq->len--;
PKTSETLINK(pktbuf, NULL);
return TRUE;
}
void
pktq_init(struct pktq *pq, int num_prec, int max_len)
{
int prec;
ASSERT(num_prec > 0 && num_prec <= PKTQ_MAX_PREC);
bzero(pq, sizeof(*pq));
pq->num_prec = (uint16)num_prec;
pq->max = (uint16)max_len;
for (prec = 0; prec < num_prec; prec++)
pq->q[prec].max = pq->max;
}
void *
pktq_deq(struct pktq *pq, int *prec_out)
{
struct pktq_prec *q;
void *p;
int prec;
if (pq->len == 0)
return NULL;
while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL)
pq->hi_prec--;
q = &pq->q[prec];
if ((p = q->head) == NULL)
return NULL;
if ((q->head = PKTLINK(p)) == NULL)
q->tail = NULL;
q->len--;
pq->len--;
if (prec_out)
*prec_out = prec;
PKTSETLINK(p, NULL);
return p;
}
void *
pktq_deq_tail(struct pktq *pq, int *prec_out)
{
struct pktq_prec *q;
void *p, *prev;
int prec;
if (pq->len == 0)
return NULL;
for (prec = 0; prec < pq->hi_prec; prec++)
if (pq->q[prec].head)
break;
q = &pq->q[prec];
if ((p = q->head) == NULL)
return NULL;
for (prev = NULL; p != q->tail; p = PKTLINK(p))
prev = p;
if (prev)
PKTSETLINK(prev, NULL);
else
q->head = NULL;
q->tail = prev;
q->len--;
pq->len--;
if (prec_out)
*prec_out = prec;
PKTSETLINK(p, NULL);
return p;
}
void *
pktq_peek(struct pktq *pq, int *prec_out)
{
int prec;
if (pq->len == 0)
return NULL;
while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL)
pq->hi_prec--;
if (prec_out)
*prec_out = prec;
return (pq->q[prec].head);
}
void *
pktq_peek_tail(struct pktq *pq, int *prec_out)
{
int prec;
if (pq->len == 0)
return NULL;
for (prec = 0; prec < pq->hi_prec; prec++)
if (pq->q[prec].head)
break;
if (prec_out)
*prec_out = prec;
return (pq->q[prec].tail);
}
void
pktq_flush(osl_t *osh, struct pktq *pq, bool dir)
{
int prec;
for (prec = 0; prec < pq->num_prec; prec++)
pktq_pflush(osh, pq, prec, dir);
ASSERT(pq->len == 0);
}
/* Return sum of lengths of a specific set of precedences */
int
pktq_mlen(struct pktq *pq, uint prec_bmp)
{
int prec, len;
len = 0;
for (prec = 0; prec <= pq->hi_prec; prec++)
if (prec_bmp & (1 << prec))
len += pq->q[prec].len;
return len;
}
/* Priority dequeue from a specific set of precedences */
void *
pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out)
{
struct pktq_prec *q;
void *p;
int prec;
if (pq->len == 0)
return NULL;
while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL)
pq->hi_prec--;
while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL)
if (prec-- == 0)
return NULL;
q = &pq->q[prec];
if ((p = q->head) == NULL)
return NULL;
if ((q->head = PKTLINK(p)) == NULL)
q->tail = NULL;
q->len--;
if (prec_out)
*prec_out = prec;
pq->len--;
PKTSETLINK(p, NULL);
return p;
}
char*
bcmstrcat(char *dest, const char *src)
{
strcpy(&dest[strlen(dest)], src);
return (dest);
}
char*
bcm_ether_ntoa(struct ether_addr *ea, char *buf)
{
sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
ea->octet[0]&0xff, ea->octet[1]&0xff, ea->octet[2]&0xff,
ea->octet[3]&0xff, ea->octet[4]&0xff, ea->octet[5]&0xff);
return (buf);
}
/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
int
bcm_ether_atoe(char *p, struct ether_addr *ea)
{
int i = 0;
for (;;) {
ea->octet[i++] = (char) bcm_strtoul(p, &p, 16);
if (!*p++ || i == 6)
break;
}
return (i == 6);
}
/* Takes an Ethernet frame and sets out-of-bound PKTPRIO
* Also updates the inplace vlan tag if requested
*/
void
pktsetprio(void *pkt, bool update_vtag)
{
struct ether_header *eh;
struct ethervlan_header *evh;
uint8 *pktdata;
int priority = 0;
pktdata = (uint8 *) PKTDATA(NULL, pkt);
ASSERT(ISALIGNED((uintptr)pktdata, sizeof(uint16)));
eh = (struct ether_header *) pktdata;
if (ntoh16(eh->ether_type) == ETHER_TYPE_8021Q) {
uint16 vlan_tag;
int vlan_prio, dscp_prio = 0;
evh = (struct ethervlan_header *)eh;
vlan_tag = ntoh16(evh->vlan_tag);
vlan_prio = (int) (vlan_tag >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK;
if (ntoh16(evh->ether_type) == ETHER_TYPE_IP) {
uint8 *ip_body = pktdata + sizeof(struct ethervlan_header);
uint8 tos_tc = IP_TOS(ip_body);
dscp_prio = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT);
}
/* DSCP priority gets precedence over 802.1P (vlan tag) */
priority = (dscp_prio != 0) ? dscp_prio : vlan_prio;
/*
* If the DSCP priority is not the same as the VLAN priority,
* then overwrite the priority field in the vlan tag, with the
* DSCP priority value. This is required for Linux APs because
* the VLAN driver on Linux, overwrites the skb->priority field
* with the priority value in the vlan tag
*/
if (update_vtag && (priority != vlan_prio)) {
vlan_tag &= ~(VLAN_PRI_MASK << VLAN_PRI_SHIFT);
vlan_tag |= (uint16)priority << VLAN_PRI_SHIFT;
evh->vlan_tag = hton16(vlan_tag);
}
} else if (ntoh16(eh->ether_type) == ETHER_TYPE_IP) {
uint8 *ip_body = pktdata + sizeof(struct ether_header);
uint8 tos_tc = IP_TOS(ip_body);
priority = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT);
}
ASSERT(priority >= 0 && priority <= MAXPRIO);
PKTSETPRIO(pkt, priority);
}
static char bcm_undeferrstr[BCME_STRLEN];
static const char *bcmerrorstrtable[] = BCMERRSTRINGTABLE;
/* Convert the Error codes into related Error strings */
const char *
bcmerrorstr(int bcmerror)
{
int abs_bcmerror;
abs_bcmerror = ABS(bcmerror);
/* check if someone added a bcmerror code but forgot to add errorstring */
ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1));
if ((bcmerror > 0) || (abs_bcmerror > ABS(BCME_LAST))) {
sprintf(bcm_undeferrstr, "undefined Error %d", bcmerror);
return bcm_undeferrstr;
}
ASSERT((strlen((char*)bcmerrorstrtable[abs_bcmerror])) < BCME_STRLEN);
return bcmerrorstrtable[abs_bcmerror];
}
int
bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
{
int bcmerror = 0;
/* length check on io buf */
switch (vi->type) {
case IOVT_BOOL:
case IOVT_INT8:
case IOVT_INT16:
case IOVT_INT32:
case IOVT_UINT8:
case IOVT_UINT16:
case IOVT_UINT32:
/* all integers are int32 sized args at the ioctl interface */
if (len < (int)sizeof(int)) {
bcmerror = BCME_BUFTOOSHORT;
}
break;
case IOVT_BUFFER:
/* buffer must meet minimum length requirement */
if (len < vi->minlen) {
bcmerror = BCME_BUFTOOSHORT;
}
break;
case IOVT_VOID:
if (!set) {
/* Cannot return nil... */
bcmerror = BCME_UNSUPPORTED;
} else if (len) {
/* Set is an action w/o parameters */
bcmerror = BCME_BUFTOOLONG;
}
break;
default:
/* unknown type for length check in iovar info */
ASSERT(0);
bcmerror = BCME_UNSUPPORTED;
}
return bcmerror;
}
#define CRC_INNER_LOOP(n, c, x) \
(c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
static uint32 crc32_table[256] = {
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
uint32
hndcrc32(
uint8 *pdata, /* pointer to array of data to process */
uint nbytes, /* number of input data bytes to process */
uint32 crc /* either CRC32_INIT_VALUE or previous return value */
)
{
uint8 *pend;
#ifdef __mips__
uint8 tmp[4];
ulong *tptr = (ulong *)tmp;
/* in case the beginning of the buffer isn't aligned */
pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc);
nbytes -= (pend - pdata);
while (pdata < pend)
CRC_INNER_LOOP(32, crc, *pdata++);
/* handle bulk of data as 32-bit words */
pend = pdata + (nbytes & 0xfffffffc);
while (pdata < pend) {
*tptr = *(ulong *)pdata;
pdata += sizeof(ulong *);
CRC_INNER_LOOP(32, crc, tmp[0]);
CRC_INNER_LOOP(32, crc, tmp[1]);
CRC_INNER_LOOP(32, crc, tmp[2]);
CRC_INNER_LOOP(32, crc, tmp[3]);
}
/* 1-3 bytes at end of buffer */
pend = pdata + (nbytes & 0x03);
while (pdata < pend)
CRC_INNER_LOOP(32, crc, *pdata++);
#else
pend = pdata + nbytes;
while (pdata < pend)
CRC_INNER_LOOP(32, crc, *pdata++);
#endif /* __mips__ */
return crc;
}
/*
* Advance from the current 1-byte tag/1-byte length/variable-length value
* triple, to the next, returning a pointer to the next.
* If the current or next TLV is invalid (does not fit in given buffer length),
* NULL is returned.
* *buflen is not modified if the TLV elt parameter is invalid, or is decremented
* by the TLV paramter's length if it is valid.
*/
bcm_tlv_t *
bcm_next_tlv(bcm_tlv_t *elt, int *buflen)
{
int len;
/* validate current elt */
if (!bcm_valid_tlv(elt, *buflen))
return NULL;
/* advance to next elt */
len = elt->len;
elt = (bcm_tlv_t*)(elt->data + len);
*buflen -= (2 + len);
/* validate next elt */
if (!bcm_valid_tlv(elt, *buflen))
return NULL;
return elt;
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag
*/
bcm_tlv_t *
bcm_parse_tlvs(void *buf, int buflen, uint key)
{
bcm_tlv_t *elt;
int totlen;
elt = (bcm_tlv_t*)buf;
totlen = buflen;
/* find tagged parameter */
while (totlen >= 2) {
int len = elt->len;
/* validate remaining totlen */
if ((elt->id == key) && (totlen >= (len + 2)))
return (elt);
elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
totlen -= (len + 2);
}
return NULL;
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag. Stop parsing when we see an element whose ID is greater
* than the target key.
*/
bcm_tlv_t *
bcm_parse_ordered_tlvs(void *buf, int buflen, uint key)
{
bcm_tlv_t *elt;
int totlen;
elt = (bcm_tlv_t*)buf;
totlen = buflen;
/* find tagged parameter */
while (totlen >= 2) {
uint id = elt->id;
int len = elt->len;
/* Punt if we start seeing IDs > than target key */
if (id > key)
return (NULL);
/* validate remaining totlen */
if ((id == key) && (totlen >= (len + 2)))
return (elt);
elt = (bcm_tlv_t*)((uint8*)elt + (len + 2));
totlen -= (len + 2);
}
return NULL;
}
/* Initialization of bcmstrbuf structure */
void
bcm_binit(struct bcmstrbuf *b, char *buf, uint size)
{
b->origsize = b->size = size;
b->origbuf = b->buf = buf;
}
/* Buffer sprintf wrapper to guard against buffer overflow */
int
bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
{
va_list ap;
int r;
va_start(ap, fmt);
r = vsnprintf(b->buf, b->size, fmt, ap);
/* Non Ansi C99 compliant returns -1,
* Ansi compliant return r >= b->size,
* bcmstdlib returns 0, handle all
*/
if ((r == -1) || (r >= (int)b->size) || (r == 0))
{
b->size = 0;
}
else
{
b->size -= r;
b->buf += r;
}
va_end(ap);
return r;
}

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more