6fbefa5d6d91cee68af8830d0c68ce5a8ffb8c54
[sip-router] / route.c
1 /*
2  * $Id$
3  *
4  * SIP routing engine
5  *
6  *
7  * Copyright (C) 2001-2003 Fhg Fokus
8  *
9  * This file is part of ser, a free SIP server.
10  *
11  * ser is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version
15  *
16  * For a license to use the ser software under conditions
17  * other than those described here, or to purchase support for this
18  * software, please contact iptel.org by e-mail at the following addresses:
19  *    info@iptel.org
20  *
21  * ser is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License 
27  * along with this program; if not, write to the Free Software 
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29  *
30  * History:
31  * --------
32  *  2003-01-28  scratchpad removed, src_port introduced (jiri)
33  *  2003-02-28  scratchpad compatibility abandoned (jiri)
34  *  2003-03-10  updated to the new module exports format (andrei)
35  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
36  *  2003-04-01  added dst_port, proto, af; renamed comp_port to comp_no,
37  *               inlined all the comp_* functions (andrei)
38  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
39  *  2003-05-23  comp_ip fixed, now it will resolve its operand and compare
40  *              the ip with all the addresses (andrei)
41  *  2003-10-10  added more operators support to comp_* (<,>,<=,>=,!=) (andrei)
42  */
43
44  
45 #include <stdlib.h>
46 #include <sys/types.h>
47 #include <regex.h>
48 #include <netdb.h>
49 #include <string.h>
50 #include <sys/socket.h>
51 #include <netinet/in.h>
52 #include <arpa/inet.h>
53 #include <netdb.h>
54
55 #include "route.h"
56 #include "forward.h"
57 #include "dprint.h"
58 #include "proxy.h"
59 #include "action.h"
60 #include "sr_module.h"
61 #include "ip_addr.h"
62 #include "resolve.h"
63 #include "parser/parse_uri.h"
64 #include "mem/mem.h"
65
66
67 /* main routing script table  */
68 struct action* rlist[RT_NO];
69 /* reply routing table */
70 struct action* onreply_rlist[ONREPLY_RT_NO];
71 struct action* failure_rlist[FAILURE_RT_NO];
72
73
74 static int fix_actions(struct action* a); /*fwd declaration*/
75
76
77 /* traverses an expr tree and compiles the REs where necessary) 
78  * returns: 0 for ok, <0 if errors */
79 static int fix_expr(struct expr* exp)
80 {
81         regex_t* re;
82         int ret;
83         
84         ret=E_BUG;
85         if (exp==0){
86                 LOG(L_CRIT, "BUG: fix_expr: null pointer\n");
87                 return E_BUG;
88         }
89         if (exp->type==EXP_T){
90                 switch(exp->op){
91                         case AND_OP:
92                         case OR_OP:
93                                                 if ((ret=fix_expr(exp->l.expr))!=0)
94                                                         return ret;
95                                                 ret=fix_expr(exp->r.expr);
96                                                 break;
97                         case NOT_OP:
98                                                 ret=fix_expr(exp->l.expr);
99                                                 break;
100                         default:
101                                                 LOG(L_CRIT, "BUG: fix_expr: unknown op %d\n",
102                                                                 exp->op);
103                 }
104         }else if (exp->type==ELEM_T){
105                         if (exp->op==MATCH_OP){
106                                 if (exp->subtype==STRING_ST){
107                                         re=(regex_t*)pkg_malloc(sizeof(regex_t));
108                                         if (re==0){
109                                                 LOG(L_CRIT, "ERROR: fix_expr: memory allocation"
110                                                                 " failure\n");
111                                                 return E_OUT_OF_MEM;
112                                         }
113                                         if (regcomp(re, (char*) exp->r.param,
114                                                                 REG_EXTENDED|REG_NOSUB|REG_ICASE) ){
115                                                 LOG(L_CRIT, "ERROR: fix_expr : bad re \"%s\"\n",
116                                                                         (char*) exp->r.param);
117                                                 pkg_free(re);
118                                                 return E_BAD_RE;
119                                         }
120                                         /* replace the string with the re */
121                                         pkg_free(exp->r.param);
122                                         exp->r.param=re;
123                                         exp->subtype=RE_ST;
124                                 }else if (exp->subtype!=RE_ST){
125                                         LOG(L_CRIT, "BUG: fix_expr : invalid type for match\n");
126                                         return E_BUG;
127                                 }
128                         }
129                         if (exp->l.operand==ACTION_O){
130                                 ret=fix_actions((struct action*)exp->r.param);
131                                 if (ret!=0){
132                                         LOG(L_CRIT, "ERROR: fix_expr : fix_actions error\n");
133                                         return ret;
134                                 }
135                         }
136                         ret=0;
137         }
138         return ret;
139 }
140
141
142
143 /* adds the proxies in the proxy list & resolves the hostnames */
144 /* returns 0 if ok, <0 on error */
145 static int fix_actions(struct action* a)
146 {
147         struct action *t;
148         struct proxy_l* p;
149         char *tmp;
150         int ret;
151         cmd_export_t* cmd;
152         struct sr_module* mod;
153         str s;
154         
155         if (a==0){
156                 LOG(L_CRIT,"BUG: fix_actions: null pointer\n");
157                 return E_BUG;
158         }
159         for(t=a; t!=0; t=t->next){
160                 switch(t->type){
161                         case FORWARD_T:
162                         case FORWARD_TLS_T:
163                         case FORWARD_TCP_T:
164                         case FORWARD_UDP_T:
165                         case SEND_T:
166                         case SEND_TCP_T:
167                                         switch(t->p1_type){
168                                                 case IP_ST: 
169                                                         tmp=strdup(ip_addr2a(
170                                                                                 (struct ip_addr*)t->p1.data));
171                                                         if (tmp==0){
172                                                                 LOG(L_CRIT, "ERROR: fix_actions:"
173                                                                                 "memory allocation failure\n");
174                                                                 return E_OUT_OF_MEM;
175                                                         }
176                                                         t->p1_type=STRING_ST;
177                                                         t->p1.string=tmp;
178                                                         /* no break */
179                                                 case STRING_ST:
180                                                         s.s = t->p1.string;
181                                                         s.len = strlen(s.s);
182                                                         p=add_proxy(&s, t->p2.number, 0); /* FIXME proto*/
183                                                         if (p==0) return E_BAD_ADDRESS;
184                                                         t->p1.data=p;
185                                                         t->p1_type=PROXY_ST;
186                                                         break;
187                                                 case URIHOST_ST:
188                                                         break;
189                                                 default:
190                                                         LOG(L_CRIT, "BUG: fix_actions: invalid type"
191                                                                         "%d (should be string or number)\n",
192                                                                                 t->type);
193                                                         return E_BUG;
194                                         }
195                                         break;
196                         case IF_T:
197                                 if (t->p1_type!=EXPR_ST){
198                                         LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
199                                                                 "%d for if (should be expr)\n",
200                                                                 t->p1_type);
201                                         return E_BUG;
202                                 }else if( (t->p2_type!=ACTIONS_ST)&&(t->p2_type!=NOSUBTYPE) ){
203                                         LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
204                                                                 "%d for if() {...} (should be action)\n",
205                                                                 t->p2_type);
206                                         return E_BUG;
207                                 }else if( (t->p3_type!=ACTIONS_ST)&&(t->p3_type!=NOSUBTYPE) ){
208                                         LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
209                                                                 "%d for if() {} else{...}(should be action)\n",
210                                                                 t->p3_type);
211                                         return E_BUG;
212                                 }
213                                 if (t->p1.data){
214                                         if ((ret=fix_expr((struct expr*)t->p1.data))<0)
215                                                 return ret;
216                                 }
217                                 if ( (t->p2_type==ACTIONS_ST)&&(t->p2.data) ){
218                                         if ((ret=fix_actions((struct action*)t->p2.data))<0)
219                                                 return ret;
220                                 }
221                                 if ( (t->p3_type==ACTIONS_ST)&&(t->p3.data) ){
222                                                 if ((ret=fix_actions((struct action*)t->p3.data))<0)
223                                                 return ret;
224                                 }
225                                 break;
226                         case MODULE_T:
227                                 if ((mod=find_module(t->p1.data, &cmd))!=0){
228                                         DBG("fixing %s %s\n", mod->path, cmd->name);
229                                         if (cmd->fixup){
230                                                 if (cmd->param_no>0){
231                                                         ret=cmd->fixup(&t->p2.data, 1);
232                                                         t->p2_type=MODFIXUP_ST;
233                                                         if (ret<0) return ret;
234                                                 }
235                                                 if (cmd->param_no>1){
236                                                         ret=cmd->fixup(&t->p3.data, 2);
237                                                         t->p3_type=MODFIXUP_ST;
238                                                         if (ret<0) return ret;
239                                                 }
240                                         }
241                                 }
242                         
243                 }
244         }
245         return 0;
246 }
247
248
249 inline static int comp_no( int port, void *param, int op, int subtype )
250 {
251         
252         if (subtype!=NUMBER_ST) {
253                 LOG(L_CRIT, "BUG: comp_no: number expected: %d\n", subtype );
254                 return E_BUG;
255         }
256         switch (op){
257                 case EQUAL_OP:
258                         return port==(long)param;
259                 case DIFF_OP:
260                         return port!=(long)param;
261                 case GT_OP:
262                         return port>(long)param;
263                 case LT_OP:
264                         return port<(long)param;
265                 case GTE_OP:
266                         return port>=(long)param;
267                 case LTE_OP:
268                         return port<=(long)param;
269                 default:
270                 LOG(L_CRIT, "BUG: comp_no: unknown operator: %d\n", op );
271                 return E_BUG;
272         }
273 }
274
275 /* eval_elem helping function, returns str op param */
276 inline static int comp_strstr(str* str, void* param, int op, int subtype)
277 {
278         int ret;
279         char backup;
280         
281         ret=-1;
282         switch(op){
283                 case EQUAL_OP:
284                         if (subtype!=STRING_ST){
285                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
286                                                 "string expected\n", subtype);
287                                 goto error;
288                         }
289                         ret=(strncasecmp(str->s, (char*)param, str->len)==0);
290                         break;
291                 case DIFF_OP:
292                         if (subtype!=STRING_ST){
293                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
294                                                 "string expected\n", subtype);
295                                 goto error;
296                         }
297                         ret=(strncasecmp(str->s, (char*)param, str->len)!=0);
298                         break;
299                 case MATCH_OP:
300                         if (subtype!=RE_ST){
301                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
302                                                 " RE expected\n", subtype);
303                                 goto error;
304                         }
305                 /* this is really ugly -- we put a temporary zero-terminating
306                  * character in the original string; that's because regexps
307          * take 0-terminated strings and our messages are not
308          * zero-terminated; it should not hurt as long as this function
309                  * is applied to content of pkg mem, which is always the case
310                  * with calls from route{}; the same goes for fline in reply_route{};
311          *
312          * also, the received function should always give us an extra
313          * character, into which we can put the 0-terminator now;
314          * an alternative would be allocating a new piece of memory,
315          * which might be too slow
316          * -jiri
317          */
318                         backup=str->s[str->len];str->s[str->len]=0;
319                         ret=(regexec((regex_t*)param, str->s, 0, 0, 0)==0);
320                         str->s[str->len]=backup;
321                         break;
322                 default:
323                         LOG(L_CRIT, "BUG: comp_str: unknown op %d\n", op);
324                         goto error;
325         }
326         return ret;
327         
328 error:
329         return -1;
330 }
331
332 /* eval_elem helping function, returns str op param */
333 inline static int comp_str(char* str, void* param, int op, int subtype)
334 {
335         int ret;
336         
337         ret=-1;
338         switch(op){
339                 case EQUAL_OP:
340                         if (subtype!=STRING_ST){
341                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
342                                                 "string expected\n", subtype);
343                                 goto error;
344                         }
345                         ret=(strcasecmp(str, (char*)param)==0);
346                         break;
347                 case DIFF_OP:
348                         if (subtype!=STRING_ST){
349                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
350                                                 "string expected\n", subtype);
351                                 goto error;
352                         }
353                         ret=(strcasecmp(str, (char*)param)!=0);
354                         break;
355                 case MATCH_OP:
356                         if (subtype!=RE_ST){
357                                 LOG(L_CRIT, "BUG: comp_str: bad type %d, "
358                                                 " RE expected\n", subtype);
359                                 goto error;
360                         }
361                         ret=(regexec((regex_t*)param, str, 0, 0, 0)==0);
362                         break;
363                 default:
364                         LOG(L_CRIT, "BUG: comp_str: unknown op %d\n", op);
365                         goto error;
366         }
367         return ret;
368         
369 error:
370         return -1;
371 }
372
373
374 /* check_self wrapper -- it checks also for the op */
375 inline static int check_self_op(int op, str* s, unsigned short p)
376 {
377         int ret;
378         
379         ret=check_self(s, p, 0);
380         switch(op){
381                 case EQUAL_OP:
382                         break;
383                 case DIFF_OP:
384                         if (ret>=0) ret=!ret;
385                         break;
386                 default:
387                         LOG(L_CRIT, "BUG: check_self_op: invalid operator %d\n", op);
388                         ret=-1;
389         }
390         return ret;
391 }
392
393
394 /* eval_elem helping function, returns an op param */
395 inline static int comp_ip(struct ip_addr* ip, void* param, int op, int subtype)
396 {
397         struct hostent* he;
398         char ** h;
399         int ret;
400         str tmp;
401
402         ret=-1;
403         switch(subtype){
404                 case NET_ST:
405                         switch(op){
406                                 case EQUAL_OP:
407                                         ret=(matchnet(ip, (struct net*) param)==1);
408                                         break;
409                                 case DIFF_OP:
410                                         ret=(matchnet(ip, (struct net*) param)!=1);
411                                         break;
412                                 default:
413                                         goto error_op;
414                         }
415                         break;
416                 case STRING_ST:
417                 case RE_ST:
418                         switch(op){
419                                 case EQUAL_OP:
420                                 case MATCH_OP:
421                                         /* 1: compare with ip2str*/
422                                         ret=comp_str(ip_addr2a(ip), param, op, subtype);
423                                         if (ret==1) break;
424                                         /* 2: resolve (name) & compare w/ all the ips */
425                                         if (subtype==STRING_ST){
426                                                 he=resolvehost((char*)param);
427                                                 if (he==0){
428                                                         DBG("comp_ip: could not resolve %s\n",
429                                                                         (char*)param);
430                                                 }else if (he->h_addrtype==ip->af){
431                                                         for(h=he->h_addr_list;(ret!=1)&& (*h); h++){
432                                                                 ret=(memcmp(ip->u.addr, *h, ip->len)==0);
433                                                         }
434                                                         if (ret==1) break;
435                                                 }
436                                         }
437                                         /* 3: (slow) rev dns the address
438                                         * and compare with all the aliases
439                                         * !!??!! review: remove this? */
440                                         he=rev_resolvehost(ip);
441                                         if (he==0){
442                                                 print_ip( "comp_ip: could not rev_resolve ip address:"
443                                                                         " ", ip, "\n");
444                                         ret=0;
445                                         }else{
446                                                 /*  compare with primary host name */
447                                                 ret=comp_str(he->h_name, param, op, subtype);
448                                                 /* compare with all the aliases */
449                                                 for(h=he->h_aliases; (ret!=1) && (*h); h++){
450                                                         ret=comp_str(*h, param, op, subtype);
451                                                 }
452                                         }
453                                         break;
454                                 case DIFF_OP:
455                                         ret=comp_ip(ip, param, EQUAL_OP, subtype);
456                                         if (ret>=0) ret=!ret;
457                                         break;
458                                 default:
459                                         goto error_op;
460                         }
461                         break;
462                 case MYSELF_ST: /* check if it's one of our addresses*/
463                         tmp.s=ip_addr2a(ip);
464                         tmp.len=strlen(tmp.s);
465                         ret=check_self_op(op, &tmp, 0);
466                         break;
467                 default:
468                         LOG(L_CRIT, "BUG: comp_ip: invalid type for "
469                                                 " src_ip or dst_ip (%d)\n", subtype);
470                         ret=-1;
471         }
472         return ret;
473 error_op:
474         LOG(L_CRIT, "BUG: comp_ip: invalid operator %d\n", op);
475         return -1;
476         
477 }
478
479
480
481 /* returns: 0/1 (false/true) or -1 on error, -127 EXPR_DROP */
482 static int eval_elem(struct expr* e, struct sip_msg* msg)
483 {
484
485         int ret;
486         ret=E_BUG;
487         
488         if (e->type!=ELEM_T){
489                 LOG(L_CRIT," BUG: eval_elem: invalid type\n");
490                 goto error;
491         }
492         switch(e->l.operand){
493                 case METHOD_O:
494                                 ret=comp_strstr(&msg->first_line.u.request.method, e->r.param,
495                                                                 e->op, e->subtype);
496                                 break;
497                 case URI_O:
498                                 if(msg->new_uri.s){
499                                         if (e->subtype==MYSELF_ST){
500                                                 if (parse_sip_msg_uri(msg)<0) ret=-1;
501                                                 else    ret=check_self_op(e->op, &msg->parsed_uri.host,
502                                                                         msg->parsed_uri.port_no?
503                                                                         msg->parsed_uri.port_no:SIP_PORT);
504                                         }else{
505                                                 ret=comp_strstr(&msg->new_uri, e->r.param,
506                                                                                 e->op, e->subtype);
507                                         }
508                                 }else{
509                                         if (e->subtype==MYSELF_ST){
510                                                 if (parse_sip_msg_uri(msg)<0) ret=-1;
511                                                 else    ret=check_self_op(e->op, &msg->parsed_uri.host,
512                                                                         msg->parsed_uri.port_no?
513                                                                         msg->parsed_uri.port_no:SIP_PORT);
514                                         }else{
515                                                 ret=comp_strstr(&msg->first_line.u.request.uri,
516                                                                                  e->r.param, e->op, e->subtype);
517                                         }
518                                 }
519                                 break;
520                 case SRCIP_O:
521                                 ret=comp_ip(&msg->rcv.src_ip, e->r.param, e->op, e->subtype);
522                                 break;
523                 case DSTIP_O:
524                                 ret=comp_ip(&msg->rcv.dst_ip, e->r.param, e->op, e->subtype);
525                                 break;
526                 case NUMBER_O:
527                                 ret=!(!e->r.intval); /* !! to transform it in {0,1} */
528                                 break;
529                 case ACTION_O:
530                                 ret=run_actions( (struct action*)e->r.param, msg);
531                                 if (ret<=0) ret=(ret==0)?EXPR_DROP:0;
532                                 else ret=1;
533                                 break;
534                 case SRCPORT_O:
535                                 ret=comp_no(msg->rcv.src_port, 
536                                         e->r.param, /* e.g., 5060 */
537                                         e->op, /* e.g. == */
538                                         e->subtype /* 5060 is number */);
539                                 break;
540                 case DSTPORT_O:
541                                 ret=comp_no(msg->rcv.dst_port, e->r.param, e->op, 
542                                                         e->subtype);
543                                 break;
544                 case PROTO_O:
545                                 ret=comp_no(msg->rcv.proto, e->r.param, e->op, e->subtype);
546                                 break;
547                 case AF_O:
548                                 ret=comp_no(msg->rcv.src_ip.af, e->r.param, e->op, e->subtype);
549                                 break;
550                 case MSGLEN_O:
551                                 ret=comp_no(msg->len, e->r.param, e->op, e->subtype);
552                                 break;
553                 default:
554                                 LOG(L_CRIT, "BUG: eval_elem: invalid operand %d\n",
555                                                         e->l.operand);
556         }
557         return ret;
558 error:
559         return -1;
560 }
561
562
563
564 /* ret= 0/1 (true/false) ,  -1 on error or EXPR_DROP (-127)  */
565 int eval_expr(struct expr* e, struct sip_msg* msg)
566 {
567         static int rec_lev=0;
568         int ret;
569         
570         rec_lev++;
571         if (rec_lev>MAX_REC_LEV){
572                 LOG(L_CRIT, "ERROR: eval_expr: too many expressions (%d)\n",
573                                 rec_lev);
574                 ret=-1;
575                 goto skip;
576         }
577         
578         if (e->type==ELEM_T){
579                 ret=eval_elem(e, msg);
580         }else if (e->type==EXP_T){
581                 switch(e->op){
582                         case AND_OP:
583                                 ret=eval_expr(e->l.expr, msg);
584                                 /* if error or false stop evaluating the rest */
585                                 if (ret!=1) break;
586                                 ret=eval_expr(e->r.expr, msg); /*ret1 is 1*/
587                                 break;
588                         case OR_OP:
589                                 ret=eval_expr(e->l.expr, msg);
590                                 /* if true or error stop evaluating the rest */
591                                 if (ret!=0) break;
592                                 ret=eval_expr(e->r.expr, msg); /* ret1 is 0 */
593                                 break;
594                         case NOT_OP:
595                                 ret=eval_expr(e->l.expr, msg);
596                                 if (ret<0) break;
597                                 ret= ! ret;
598                                 break;
599                         default:
600                                 LOG(L_CRIT, "BUG: eval_expr: unknown op %d\n", e->op);
601                                 ret=-1;
602                 }
603         }else{
604                 LOG(L_CRIT, "BUG: eval_expr: unknown type %d\n", e->type);
605                 ret=-1;
606         }
607
608 skip:
609         rec_lev--;
610         return ret;
611 }
612
613
614 /* adds an action list to head; a must be null terminated (last a->next=0))*/
615 void push(struct action* a, struct action** head)
616 {
617         struct action *t;
618         if (*head==0){
619                 *head=a;
620                 return;
621         }
622         for (t=*head; t->next;t=t->next);
623         t->next=a;
624 }
625
626
627
628
629 int add_actions(struct action* a, struct action** head)
630 {
631         int ret;
632
633         LOG(L_DBG, "add_actions: fixing actions...\n");
634         if ((ret=fix_actions(a))!=0) goto error;
635         push(a,head);
636         return 0;
637         
638 error:
639         return ret;
640 }
641
642
643
644 /* fixes all action tables */
645 /* returns 0 if ok , <0 on error */
646 int fix_rls()
647 {
648         int i,ret;
649         for(i=0;i<RT_NO;i++){
650                 if(rlist[i]){
651                         if ((ret=fix_actions(rlist[i]))!=0){
652                                 return ret;
653                         }
654                 }
655         }
656         for(i=0;i<ONREPLY_RT_NO;i++){
657                 if(onreply_rlist[i]){
658                         if ((ret=fix_actions(onreply_rlist[i]))!=0){
659                                 return ret;
660                         }
661                 }
662         }
663         for(i=0;i<FAILURE_RT_NO;i++){
664                 if(failure_rlist[i]){
665                         if ((ret=fix_actions(failure_rlist[i]))!=0){
666                                 return ret;
667                         }
668                 }
669         }
670         return 0;
671 }
672
673
674 /* debug function, prints main routing table */
675 void print_rl()
676 {
677         struct action* t;
678         int i,j;
679
680         for(j=0; j<RT_NO; j++){
681                 if (rlist[j]==0){
682                         if (j==0) DBG("WARNING: the main routing table is empty\n");
683                         continue;
684                 }
685                 DBG("routing table %d:\n",j);
686                 for (t=rlist[j],i=0; t; i++, t=t->next){
687                         print_action(t);
688                 }
689                 DBG("\n");
690         }
691         for(j=0; j<ONREPLY_RT_NO; j++){
692                 if (onreply_rlist[j]==0){
693                         continue;
694                 }
695                 DBG("onreply routing table %d:\n",j);
696                 for (t=onreply_rlist[j],i=0; t; i++, t=t->next){
697                         print_action(t);
698                 }
699                 DBG("\n");
700         }
701         for(j=0; j<FAILURE_RT_NO; j++){
702                 if (failure_rlist[j]==0){
703                         continue;
704                 }
705                 DBG("failure routing table %d:\n",j);
706                 for (t=failure_rlist[j],i=0; t; i++, t=t->next){
707                         print_action(t);
708                 }
709                 DBG("\n");
710         }
711 }
712
713