... | ... |
@@ -2,7 +2,7 @@ $Id$ |
2 | 2 |
|
3 | 3 |
Installation Notes |
4 | 4 |
|
5 |
-Supported architectures: Linux, FreeBSD, Solaris |
|
5 |
+Supported architectures: Linux, FreeBSD, Solaris, Win* (CYGWIN) |
|
6 | 6 |
(for other architectures the Makefile must be edited) |
7 | 7 |
|
8 | 8 |
Requirements: |
... | ... |
@@ -17,6 +17,10 @@ Arhitecture Notes: |
17 | 17 |
|
18 | 18 |
- FreeBSD: make sure gmake, bison & flex are installed |
19 | 19 |
- Solaris: as above; you can use Solaris's yacc instead of bison |
20 |
+- Windows: it works in windows but you must install a recent cygwin version |
|
21 |
+ (http://www.cygwin.com/) and also install a newer regex library version |
|
22 |
+ (>=0.12). |
|
23 |
+ |
|
20 | 24 |
|
21 | 25 |
Compile: |
22 | 26 |
|
... | ... |
@@ -3,14 +3,13 @@ |
3 | 3 |
# sip_router makefile |
4 | 4 |
# |
5 | 5 |
# WARNING: requires gmake (GNU Make) |
6 |
-# Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6) |
|
6 |
+# Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6), WinNT |
|
7 | 7 |
|
8 |
-lex_f=lex.yy.c |
|
9 |
-yacc_f=cfg.tab.c |
|
10 |
-sources= $(filter-out $(lex_f) $(yacc_f), $(wildcard *.c)) $(lex_f) \ |
|
11 |
-$(yacc_f) |
|
12 |
-objs= $(sources:.c=.o) |
|
13 |
-depends= $(sources:.c=.d) |
|
8 |
+auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc |
|
9 |
+sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen) |
|
10 |
+objs=$(sources:.c=.o) |
|
11 |
+depends=$(sources:.c=.d) |
|
12 |
+modules=$(wildcard modules/*) |
|
14 | 13 |
|
15 | 14 |
NAME=ser |
16 | 15 |
|
... | ... |
@@ -26,10 +25,11 @@ DEFS=-DNOCR -DMACROEATER |
26 | 25 |
|
27 | 26 |
ARCH = $(shell uname -s) |
28 | 27 |
|
29 |
-ifeq ($(ARCH), Linux) |
|
30 |
- |
|
28 |
+#common |
|
31 | 29 |
CC=gcc |
30 |
+LD=gcc |
|
32 | 31 |
CFLAGS=-O2 -Wcast-align #-Wmissing-prototypes |
32 |
+LDFLAGS=-Wl,-O2 -Wl,-E |
|
33 | 33 |
LEX=flex |
34 | 34 |
YACC=bison |
35 | 35 |
YACC_FLAGS=-d -b cfg |
... | ... |
@@ -37,60 +37,48 @@ YACC_FLAGS=-d -b cfg |
37 | 37 |
# on solaris add -lxnet (e.g. LIBS= -lxnet) |
38 | 38 |
LIBS=-lfl -ldl |
39 | 39 |
|
40 |
-endif |
|
40 |
+ |
|
41 |
+ifeq ($(ARCH), Linux) |
|
42 |
+ |
|
43 |
+endif |
|
41 | 44 |
ifeq ($(ARCH), SunOS) |
42 | 45 |
|
43 | 46 |
MAKE=gmake |
44 |
-CC=gcc |
|
45 |
-CFLAGS=-O2 -Wcast-align |
|
46 |
-LEX=flex |
|
47 | 47 |
YACC=yacc |
48 |
-YACC_FLAGS=-d -b cfg |
|
49 |
-LIBS=-lfl -ldl -L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ? |
|
48 |
+LIBS=$(LIBS) -L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ? |
|
50 | 49 |
|
51 | 50 |
endif |
52 | 51 |
ifeq ($(ARCH), FreeBSD) |
53 | 52 |
|
54 | 53 |
MAKE=gmake |
55 |
-CC=gcc |
|
56 |
-CFLAGS=-O2 -Wcast-align |
|
57 |
-LEX=flex |
|
58 | 54 |
YACC=yacc |
59 |
-YACC_FLAGS=-d -b cfg |
|
60 |
-LIBS=-lfl -ldl |
|
61 | 55 |
|
62 | 56 |
endif |
57 |
+ifneq (,$(findstring CYGWIN, $(ARCH))) |
|
63 | 58 |
|
64 |
-ifeq ($(ARCH), CYGWIN_NT-4.0) |
|
65 |
- |
|
66 |
-CC=gcc |
|
67 |
-CFLAGS=-O2 -Wcast-align #-Wmissing-prototypes -Wall |
|
68 |
-LEX=flex |
|
69 |
-YACC=bison |
|
70 |
-YACC_FLAGS=-d -b cfg |
|
71 |
-# on linux and freebsd keep it empty (e.g. LIBS= ) |
|
72 |
-# on solaris add -lxnet (e.g. LIBS= -lxnet) |
|
73 |
-LIBS=-lfl -ldl |
|
59 |
+#cygwin is the same as common |
|
74 | 60 |
|
75 | 61 |
endif |
76 | 62 |
|
77 | 63 |
|
78 |
-MKDEP=gcc -M $(DEFS) |
|
64 |
+MKDEP=gcc -M |
|
79 | 65 |
|
80 | 66 |
ALLDEP=Makefile |
81 | 67 |
|
82 |
-#implicit rules |
|
68 |
+export #export all variables for the sub-makes |
|
83 | 69 |
|
84 | 70 |
|
71 |
+#implicit rules |
|
85 | 72 |
%.o:%.c $(ALLDEP) |
86 | 73 |
$(CC) $(CFLAGS) $(DEFS) -c $< -o $@ |
87 | 74 |
|
88 | 75 |
%.d: %.c |
89 | 76 |
$(MKDEP) $< >$@ |
90 | 77 |
|
78 |
+ |
|
91 | 79 |
# normal rules |
92 | 80 |
$(NAME): $(objs) |
93 |
- $(CC) $(CFLAGS) $(objs) -o $(NAME) $(LIBS) |
|
81 |
+ $(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME) |
|
94 | 82 |
|
95 | 83 |
lex.yy.c: cfg.lex $(ALLDEP) |
96 | 84 |
$(LEX) $< |
... | ... |
@@ -99,8 +87,9 @@ cfg.tab.c: cfg.y $(ALLDEP) |
99 | 87 |
$(YACC) $(YACC_FLAGS) $< |
100 | 88 |
|
101 | 89 |
|
90 |
+ |
|
102 | 91 |
.PHONY: all |
103 |
-all: $(NAME) |
|
92 |
+all: $(NAME) modules |
|
104 | 93 |
|
105 | 94 |
.PHONY: dep |
106 | 95 |
dep: $(depends) |
... | ... |
@@ -108,10 +97,19 @@ dep: $(depends) |
108 | 97 |
.PHONY: clean |
109 | 98 |
clean: |
110 | 99 |
-rm $(objs) $(NAME) |
100 |
+ -for r in $(modules); do $(MAKE) -C $$r clean ; done |
|
101 |
+ |
|
102 |
+.PHONY: modules |
|
103 |
+modules: |
|
104 |
+ -for r in $(modules); do \ |
|
105 |
+ $(MAKE) -C $$r ; \ |
|
106 |
+ done |
|
107 |
+ |
|
111 | 108 |
|
112 | 109 |
.PHONY: proper |
113 |
-proper: clean |
|
110 |
+proper: clean |
|
114 | 111 |
-rm $(depends) |
112 |
+ -for r in $(modules); do $(MAKE) -C $$r proper ; done |
|
115 | 113 |
|
116 | 114 |
include $(depends) |
117 | 115 |
|
... | ... |
@@ -209,7 +209,7 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
209 | 209 |
| error EQUAL { yyerror("unknown config variable"); } |
210 | 210 |
; |
211 | 211 |
|
212 |
-module_stm: LOADMODULE STRING { DBG("loading module %s", $2); |
|
212 |
+module_stm: LOADMODULE STRING { DBG("loading module %s\n", $2); |
|
213 | 213 |
if (load_module($2)!=0){ |
214 | 214 |
yyerror("failed to load module"); |
215 | 215 |
} |
... | ... |
@@ -554,8 +554,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
554 | 554 |
| SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); } |
555 | 555 |
| SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
556 | 556 |
"string expected"); } |
557 |
- | ID LPAREN STRING RPAREN { DBG(" %s - doing nothing", $1); |
|
558 |
- f_tmp=find_export($1); |
|
557 |
+ | ID LPAREN STRING RPAREN { f_tmp=find_export($1); |
|
559 | 558 |
if (f_tmp==0){ |
560 | 559 |
yyerror("unknown command %s, missing" |
561 | 560 |
" loadmodule?\n"); |
... | ... |
@@ -159,13 +159,11 @@ struct lump* anchor_lump(struct lump** list, int offset, int len, int type) |
159 | 159 |
tmp->u.offset=offset; |
160 | 160 |
tmp->len=len; |
161 | 161 |
prev=0; |
162 |
- DBG("anchor: new tmp=%x\n", tmp); |
|
163 | 162 |
for (t=*list;t; prev=t, t=t->next){ |
164 | 163 |
/* insert it sorted after offset */ |
165 | 164 |
if (((t->op==LUMP_DEL)||(t->op==LUMP_NOP))&&(t->u.offset>offset)) |
166 | 165 |
break; |
167 | 166 |
} |
168 |
- DBG("anchor: inserting it between %x and %x (*list=%x)\n", prev, t,*list); |
|
169 | 167 |
tmp->next=t; |
170 | 168 |
|
171 | 169 |
if (prev) prev->next=tmp; |
... | ... |
@@ -177,13 +175,11 @@ struct lump* anchor_lump(struct lump** list, int offset, int len, int type) |
177 | 175 |
|
178 | 176 |
void free_lump(struct lump* lmp) |
179 | 177 |
{ |
180 |
- DBG("- free_lump(%x), op=%d\n", lmp, lmp->op); |
|
181 | 178 |
if (lmp && (lmp->op==LUMP_ADD)){ |
182 | 179 |
if (lmp->u.value) free(lmp->u.value); |
183 | 180 |
lmp->u.value=0; |
184 | 181 |
lmp->len=0; |
185 | 182 |
} |
186 |
- DBG("- exiting free_lump(%x)\n", lmp); |
|
187 | 183 |
} |
188 | 184 |
|
189 | 185 |
|
... | ... |
@@ -192,19 +188,14 @@ void free_lump_list(struct lump* l) |
192 | 188 |
{ |
193 | 189 |
struct lump* t, *crt; |
194 | 190 |
t=l; |
195 |
- DBG("+ free_lump_list(%x)\n", l); |
|
196 | 191 |
while(t){ |
197 | 192 |
crt=t; |
198 | 193 |
t=t->next; |
199 |
- DBG("free_lump_list: freeing %x\n", crt); |
|
200 | 194 |
/* dangerous recursive clean*/ |
201 | 195 |
if (crt->before) free_lump_list(crt->before); |
202 | 196 |
if (crt->after) free_lump_list(crt->after); |
203 |
- DBG("free_lump_list: back from recursive calls (%x) \n", crt); |
|
204 | 197 |
/*clean current elem*/ |
205 | 198 |
free_lump(crt); |
206 | 199 |
free(crt); |
207 |
- DBG("after free_lump_list: %x\n", crt); |
|
208 | 200 |
} |
209 |
- DBG("+ exiting free_lump_list(%x)\n", l); |
|
210 | 201 |
} |
... | ... |
@@ -116,7 +116,6 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
116 | 116 |
|
117 | 117 |
/* add via header to the list */ |
118 | 118 |
/* try to add it before msg. 1st via */ |
119 |
- DBG("forward_request: before via\n"); |
|
120 | 119 |
/*add first via, as an anchor for second via*/ |
121 | 120 |
anchor=anchor_lump(&(msg->add_rm), msg->via1.hdr-buf, 0, HDR_VIA); |
122 | 121 |
if (anchor==0) goto error; |
... | ... |
@@ -124,7 +123,6 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
124 | 123 |
goto error; |
125 | 124 |
/* if received needs to be added, add anchor after host and add it */ |
126 | 125 |
if (received_len){ |
127 |
- DBG("forward_request: adding received\n"); |
|
128 | 126 |
if (msg->via1.params){ |
129 | 127 |
size= msg->via1.params-msg->via1.hdr-1; /*compensate for ';' */ |
130 | 128 |
}else{ |
... | ... |
@@ -142,11 +140,8 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
142 | 140 |
|
143 | 141 |
/* compute new msg len*/ |
144 | 142 |
new_len=len; |
145 |
- DBG("forward_request: computing new_len\n"); |
|
146 | 143 |
for(t=msg->add_rm;t;t=t->next){ |
147 |
- DBG("forward_request: in for t.(%x)..\n", t); |
|
148 | 144 |
for(r=t->before;r;r=r->before){ |
149 |
- DBG("- forward_request: in for r...\n"); |
|
150 | 145 |
switch(r->op){ |
151 | 146 |
case LUMP_ADD: |
152 | 147 |
new_len+=r->len; |
... | ... |
@@ -172,7 +167,6 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
172 | 167 |
" op for data lump (%x)\n", r->op); |
173 | 168 |
} |
174 | 169 |
for (r=t->after;r;r=r->after){ |
175 |
- DBG("- forward_request: in for2 r...\n"); |
|
176 | 170 |
switch(r->op){ |
177 | 171 |
case LUMP_ADD: |
178 | 172 |
new_len+=r->len; |
... | ... |
@@ -190,7 +184,6 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
190 | 184 |
uri_len=strlen(msg->new_uri); |
191 | 185 |
new_len=new_len-strlen(msg->first_line.u.request.uri)+uri_len; |
192 | 186 |
} |
193 |
- DBG("forward_request: new_len=%d\n",new_len); |
|
194 | 187 |
new_buf=(char*)malloc(new_len+1); |
195 | 188 |
if (new_buf==0){ |
196 | 189 |
LOG(L_ERR, "ERROR: forward_request: out of memory\n"); |
... | ... |
@@ -211,7 +204,6 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
211 | 204 |
} |
212 | 205 |
/* copy msg adding/removing lumps */ |
213 | 206 |
for (t=msg->add_rm;t;t=t->next){ |
214 |
- DBG("adding/rming %x, op=%x, offset=%d\n", t, t->op, t->u.offset); |
|
215 | 207 |
switch(t->op){ |
216 | 208 |
case LUMP_ADD: |
217 | 209 |
/* just add it here! */ |