Skip to content

Commit ef47449

Browse files
committed
initial import
0 parents  commit ef47449

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+17118
-0
lines changed

Makefile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
DESTDIR=/usr/
2+
ROOTDIR=$(DESTDIR)
3+
LIBDIR=/usr/lib/
4+
SBINDIR=/sbin
5+
CONFDIR=/etc/iproute2
6+
DOCDIR=/share/doc/iproute2
7+
MANDIR=/share/man
8+
ARPDDIR=/var/lib/arpd
9+
10+
# Path to db_185.h include
11+
DBM_INCLUDE:=$(ROOTDIR)/usr/include
12+
13+
SHARED_LIBS = y
14+
15+
DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
16+
ifneq ($(SHARED_LIBS),y)
17+
DEFINES+= -DNO_SHARED_LIBS
18+
endif
19+
20+
#options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
21+
LDLIBS=-lresolv
22+
ADDLIB=
23+
24+
#options for decnet
25+
ADDLIB+=dnet_ntop.o dnet_pton.o
26+
27+
#options for ipx
28+
ADDLIB+=ipx_ntop.o ipx_pton.o
29+
30+
CC = gcc
31+
HOSTCC = gcc
32+
CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall
33+
CFLAGS = $(CCOPTS) -I../include $(DEFINES)
34+
YACCFLAGS = -d -t -v
35+
36+
LDLIBS += -L../lib -lnetlink -lutil
37+
38+
SUBDIRS=lib ip tc misc netem genl
39+
40+
LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
41+
42+
all: Config
43+
@set -e; \
44+
for i in $(SUBDIRS); \
45+
do $(MAKE) $(MFLAGS) -C $$i; done
46+
47+
Config:
48+
sh configure $(KERNEL_INCLUDE)
49+
50+
install: all
51+
install -m 0755 -d $(DESTDIR)$(SBINDIR)
52+
install -m 0755 -d $(DESTDIR)$(CONFDIR)
53+
install -m 0755 -d $(DESTDIR)$(ARPDDIR)
54+
install -m 0755 -d $(DESTDIR)$(DOCDIR)/examples
55+
install -m 0755 -d $(DESTDIR)$(DOCDIR)/examples/diffserv
56+
install -m 0644 README.iproute2+tc $(shell find examples -maxdepth 1 -type f) \
57+
$(DESTDIR)$(DOCDIR)/examples
58+
install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
59+
$(DESTDIR)$(DOCDIR)/examples/diffserv
60+
@for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
61+
install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
62+
install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
63+
install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
64+
ln -sf tc-bfifo.8 $(DESTDIR)$(MANDIR)/man8/tc-pfifo.8
65+
ln -sf lnstat.8 $(DESTDIR)$(MANDIR)/man8/rtstat.8
66+
ln -sf lnstat.8 $(DESTDIR)$(MANDIR)/man8/ctstat.8
67+
ln -sf rtacct.8 $(DESTDIR)$(MANDIR)/man8/nstat.8
68+
ln -sf routel.8 $(DESTDIR)$(MANDIR)/man8/routef.8
69+
install -m 0755 -d $(DESTDIR)$(MANDIR)/man3
70+
install -m 0644 $(shell find man/man3 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man3
71+
72+
snapshot:
73+
echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \
74+
> include/SNAPSHOT.h
75+
76+
clean:
77+
rm -f cscope.*
78+
@for i in $(SUBDIRS) doc; \
79+
do $(MAKE) $(MFLAGS) -C $$i clean; done
80+
81+
clobber:
82+
touch Config
83+
$(MAKE) $(MFLAGS) clean
84+
rm -f Config
85+
86+
distclean: clobber
87+
88+
cscope:
89+
cscope -b -q -R -Iinclude -sip -slib -smisc -snetem -stc
90+
91+
.EXPORT_ALL_VARIABLES:

configure

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#! /bin/bash
2+
# This is not an autconf generated configure
3+
#
4+
INCLUDE=${1:-"$PWD/include"}
5+
6+
TABLES=
7+
8+
check_atm()
9+
{
10+
cat >/tmp/atmtest.c <<EOF
11+
#include <atm.h>
12+
int main(int argc, char **argv) {
13+
struct atm_qos qos;
14+
(void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
15+
return 0;
16+
}
17+
EOF
18+
gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
19+
if [ $? -eq 0 ]
20+
then
21+
echo "TC_CONFIG_ATM:=y" >>Config
22+
echo yes
23+
else
24+
echo no
25+
fi
26+
rm -f /tmp/atmtest.c /tmp/atmtest
27+
}
28+
29+
check_xt()
30+
{
31+
#check if we have xtables from iptables >= 1.4.5.
32+
cat >/tmp/ipttest.c <<EOF
33+
#include <xtables.h>
34+
#include <linux/netfilter.h>
35+
static struct xtables_globals test_globals = {
36+
.option_offset = 0,
37+
.program_name = "tc-ipt",
38+
.program_version = XTABLES_VERSION,
39+
.orig_opts = NULL,
40+
.opts = NULL,
41+
.exit_err = NULL,
42+
};
43+
44+
int main(int argc, char **argv)
45+
{
46+
xtables_init_all(&test_globals, NFPROTO_IPV4);
47+
return 0;
48+
}
49+
50+
EOF
51+
52+
if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1
53+
then
54+
echo "TC_CONFIG_XT:=y" >>Config
55+
echo "using xtables"
56+
fi
57+
rm -f /tmp/ipttest.c /tmp/ipttest
58+
}
59+
60+
check_xt_old()
61+
{
62+
# bail if previous XT checks has already succeded.
63+
if grep TC_CONFIG_XT Config > /dev/null
64+
then
65+
return
66+
fi
67+
68+
#check if we need dont our internal header ..
69+
cat >/tmp/ipttest.c <<EOF
70+
#include <xtables.h>
71+
char *lib_dir;
72+
unsigned int global_option_offset = 0;
73+
const char *program_version = XTABLES_VERSION;
74+
const char *program_name = "tc-ipt";
75+
struct afinfo afinfo = {
76+
.libprefix = "libxt_",
77+
};
78+
79+
void exit_error(enum exittype status, const char *msg, ...)
80+
{
81+
}
82+
83+
int main(int argc, char **argv) {
84+
85+
return 0;
86+
}
87+
88+
EOF
89+
gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
90+
91+
if [ $? -eq 0 ]
92+
then
93+
echo "TC_CONFIG_XT_OLD:=y" >>Config
94+
echo "using old xtables (no need for xt-internal.h)"
95+
fi
96+
rm -f /tmp/ipttest.c /tmp/ipttest
97+
}
98+
99+
check_xt_old_internal_h()
100+
{
101+
# bail if previous XT checks has already succeded.
102+
if grep TC_CONFIG_XT Config > /dev/null
103+
then
104+
return
105+
fi
106+
107+
#check if we need our own internal.h
108+
cat >/tmp/ipttest.c <<EOF
109+
#include <xtables.h>
110+
#include "xt-internal.h"
111+
char *lib_dir;
112+
unsigned int global_option_offset = 0;
113+
const char *program_version = XTABLES_VERSION;
114+
const char *program_name = "tc-ipt";
115+
struct afinfo afinfo = {
116+
.libprefix = "libxt_",
117+
};
118+
119+
void exit_error(enum exittype status, const char *msg, ...)
120+
{
121+
}
122+
123+
int main(int argc, char **argv) {
124+
125+
return 0;
126+
}
127+
128+
EOF
129+
gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
130+
131+
if [ $? -eq 0 ]
132+
then
133+
echo "using old xtables with xt-internal.h"
134+
echo "TC_CONFIG_XT_OLD_H:=y" >>Config
135+
fi
136+
rm -f /tmp/ipttest.c /tmp/ipttest
137+
}
138+
139+
check_ipt()
140+
{
141+
if ! grep TC_CONFIG_XT Config > /dev/null
142+
then
143+
echo "using iptables"
144+
TABLES="iptables"
145+
else
146+
TABLES="xtables"
147+
fi
148+
}
149+
150+
check_ipt_lib_dir()
151+
{
152+
IPT_LIB_DIR=""
153+
for dir in /lib /usr/lib /usr/local/lib
154+
do
155+
for file in $dir/$TABLES/lib*t_*so ; do
156+
if [ -f $file ]; then
157+
echo $dir/$TABLES
158+
echo "IPT_LIB_DIR:=$dir/$TABLES" >> Config
159+
return
160+
fi
161+
done
162+
done
163+
echo "not found!"
164+
}
165+
166+
echo "# Generated config based on" $INCLUDE >Config
167+
168+
echo "TC schedulers"
169+
170+
echo -n " ATM "
171+
check_atm
172+
173+
echo -n " IPT "
174+
check_xt
175+
check_xt_old
176+
check_xt_old_internal_h
177+
check_ipt
178+
179+
echo -n "iptables modules directory: "
180+
check_ipt_lib_dir

include/SNAPSHOT.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
static const char SNAPSHOT[] = "110317";

include/dlfcn.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Stub dlfcn implementation for systems that lack shared library support
3+
* but obviously can still reference compiled-in symbols.
4+
*/
5+
6+
#ifndef NO_SHARED_LIBS
7+
#include_next <dlfcn.h>
8+
#else
9+
10+
#define RTLD_LAZY 0
11+
#define _FAKE_DLFCN_HDL (void *)0xbeefcafe
12+
13+
static inline void *dlopen(const char *file, int flag)
14+
{
15+
if (file == NULL)
16+
return _FAKE_DLFCN_HDL;
17+
else
18+
return NULL;
19+
}
20+
21+
extern void *_dlsym(const char *sym);
22+
static inline void *dlsym(void *handle, const char *sym)
23+
{
24+
if (handle != _FAKE_DLFCN_HDL)
25+
return NULL;
26+
return _dlsym(sym);
27+
}
28+
29+
static inline char *dlerror(void)
30+
{
31+
return NULL;
32+
}
33+
34+
static inline int dlclose(void *handle)
35+
{
36+
return (handle == _FAKE_DLFCN_HDL) ? 0 : 1;
37+
}
38+
39+
#endif

0 commit comments

Comments
 (0)