/[radius]/radius/lib/ascend.c
ViewVC logotype

Diff of /radius/lib/ascend.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gray, Fri Aug 2 11:18:43 2002 UTC revision 1.4 by gray, Wed Apr 30 08:38:29 2003 UTC
# Line 1  Line 1 
1  /* This file is part of GNU RADIUS.  /* This file is part of GNU Radius.
2     Copyright (C) 2000,2001 Sergey Poznyakoff     Copyright (C) 2002,2003 Sergey Poznyakoff
3        
4     This program is free software; you can redistribute it and/or modify     GNU Radius is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.     (at your option) any later version.
8        
9     This program is distributed in the hope that it will be useful,     GNU Radius is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.     GNU General Public License for more details.
13        
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software Foundation,     along with GNU Radius; if not, write to the Free Software Foundation,
16     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17    
18  /* Support for ascend binary filters. */  /* Support for ascend binary filters. */
# Line 139  static int _ascend_parse(struct ascend_p Line 139  static int _ascend_parse(struct ascend_p
139  #define _moreinput(pb) ((pb)->tokn < (pb)->tokc)  #define _moreinput(pb) ((pb)->tokn < (pb)->tokc)
140    
141  static char *  static char *
142  _get_token(pb, require)  _get_token(struct ascend_parse_buf *pb, int require)
         struct ascend_parse_buf *pb;  
         int require;  
143  {  {
144    
145          if (!_moreinput(pb)) {          if (!_moreinput(pb)) {
# Line 155  _get_token(pb, require) Line 153  _get_token(pb, require)
153  }  }
154    
155  static char *  static char *
156  _lookahead(pb)  _lookahead(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
157  {  {
158          if (_moreinput(pb))          if (_moreinput(pb))
159                  return pb->tokv[pb->tokn];                  return pb->tokv[pb->tokn];
# Line 164  _lookahead(pb) Line 161  _lookahead(pb)
161  }  }
162    
163  static int  static int
164  _get_type(pb)  _get_type(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
165  {  {
166          char *tok = _get_token(pb, 1);          char *tok = _get_token(pb, 1);
167          if (!tok)          if (!tok)
# Line 185  _get_type(pb) Line 181  _get_type(pb)
181  }  }
182    
183  static int  static int
184  _get_dir(pb)  _get_dir(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
185  {  {
186          char *tok;          char *tok;
187          if ((tok = _get_token(pb, 1)) == NULL)          if ((tok = _get_token(pb, 1)) == NULL)
# Line 203  _get_dir(pb) Line 198  _get_dir(pb)
198  }  }
199    
200  static int  static int
201  _get_action(pb)  _get_action(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
202  {  {
203          char *tok;          char *tok;
204          if ((tok = _get_token(pb, 1)) == NULL)          if ((tok = _get_token(pb, 1)) == NULL)
# Line 225  _get_action(pb) Line 219  _get_action(pb)
219  /* GENERIC filter parsing */  /* GENERIC filter parsing */
220    
221  int  int
222  _get_hex_string(pb, buf)  _get_hex_string(struct ascend_parse_buf *pb, u_char *buf)
         struct ascend_parse_buf *pb;  
         u_char *buf;  
223  {  {
224          u_char tmp[2*ASCEND_MAX_CMP_LENGTH], *p;          u_char tmp[2*ASCEND_MAX_CMP_LENGTH], *p;
225          char *tok = _get_token(pb, 1);          char *tok = _get_token(pb, 1);
# Line 277  _get_hex_string(pb, buf) Line 269  _get_hex_string(pb, buf)
269          mask and value are hex strings */          mask and value are hex strings */
270        
271  int  int
272  _ascend_parse_generic(pb)  _ascend_parse_generic(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
273  {  {
274          char *p;          char *p;
275          int num;          int num;
# Line 337  _ascend_parse_generic(pb) Line 328  _ascend_parse_generic(pb)
328  /* ************************************************************************* */  /* ************************************************************************* */
329  /* IP filter parsing */  /* IP filter parsing */
330  int  int
331  _get_protocol(pb)  _get_protocol(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
332  {  {
333          char *tok = _get_token(pb, 1);          char *tok = _get_token(pb, 1);
334          char *p;          char *p;
# Line 366  _get_protocol(pb) Line 356  _get_protocol(pb)
356  #define ASCEND_DIR_DST 1  #define ASCEND_DIR_DST 1
357    
358  int  int
359  _get_direction_type(pb, suffix, lookahead)  _get_direction_type(struct ascend_parse_buf *pb, char *suffix, int lookahead)
         struct ascend_parse_buf *pb;  
         char *suffix;  
         int lookahead;  
360  {  {
361          char *tok = lookahead ? _lookahead(pb) : _get_token(pb, 1);          char *tok = lookahead ? _lookahead(pb) : _get_token(pb, 1);
362    
# Line 388  _get_direction_type(pb, suffix, lookahea Line 375  _get_direction_type(pb, suffix, lookahea
375  }  }
376    
377  int  int
378  _get_ip(pb)  _get_ip(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
379  {  {
380          int dir = _get_direction_type(pb, "ip", 0);          int dir = _get_direction_type(pb, "ip", 0);
381          char *tok;          char *tok;
# Line 437  _get_ip(pb) Line 423  _get_ip(pb)
423  /* FIXME: if second {src|dst}ip is misspelled, the function returns  /* FIXME: if second {src|dst}ip is misspelled, the function returns
424     success, supposing it was a portspec */     success, supposing it was a portspec */
425  int  int
426  _ascend_parse_ip_clause(pb)  _ascend_parse_ip_clause(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
427  {  {
428          int n;          int n;
429    
# Line 459  _ascend_parse_ip_clause(pb) Line 444  _ascend_parse_ip_clause(pb)
444  }  }
445    
446  int  int
447  _get_op(pb)  _get_op(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
448  {  {
449          char *s = _get_token(pb, 1);          char *s = _get_token(pb, 1);
450          if (!s)          if (!s)
# Line 481  _get_op(pb) Line 465  _get_op(pb)
465  }  }
466    
467  int  int
468  _get_port(pb)  _get_port(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
469  {  {
470          int dir = _get_direction_type(pb, "port", 0);          int dir = _get_direction_type(pb, "port", 0);
471          char *tok;          char *tok;
# Line 539  _get_port(pb) Line 522  _get_port(pb)
522  }  }
523    
524  int  int
525  _ascend_parse_port_clause(pb)  _ascend_parse_port_clause(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
526  {  {
527          int n = _get_port(pb);          int n = _get_port(pb);
528    
# Line 574  _ascend_parse_port_clause(pb) Line 556  _ascend_parse_port_clause(pb)
556           PORT   is either the port number or its name from /etc/services */           PORT   is either the port number or its name from /etc/services */
557    
558  int  int
559  _ascend_parse_ip(pb)  _ascend_parse_ip(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
560  {  {
561          if (!_moreinput(pb))          if (!_moreinput(pb))
562                  return 0;                  return 0;
# Line 616  _ascend_parse_ip(pb) Line 597  _ascend_parse_ip(pb)
597                      [ "dstipxnet" NETADDR "dstipxnode" NODE                      [ "dstipxnet" NETADDR "dstipxnode" NODE
598                       [ "dstipxsoc" cmp HEXNUM ]] */                       [ "dstipxsoc" cmp HEXNUM ]] */
599  int  int
600  _ascend_parse_ipx(pb)  _ascend_parse_ipx(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
601  {  {
602          asprintf(pb->errmsg, "IPX filters are not yet supported");          asprintf(pb->errmsg, "IPX filters are not yet supported");
603          return 1;          return 1;
604  }  }
605    
606  int  int
607  _ascend_parse(pb)  _ascend_parse(struct ascend_parse_buf *pb)
         struct ascend_parse_buf *pb;  
608  {  {
609          memset(pb->flt, 0, sizeof(pb->flt[0]));          memset(pb->flt, 0, sizeof(pb->flt[0]));
610                    
# Line 649  _ascend_parse(pb) Line 628  _ascend_parse(pb)
628     Return !0 and return diagnostics in errp otherwise.     Return !0 and return diagnostics in errp otherwise.
629     NOTE: errp is malloced and should be freed using usual free() */     NOTE: errp is malloced and should be freed using usual free() */
630  int  int
631  _ascend_parse_filter(input, flt, errp)  _ascend_parse_filter(const char *input, ASCEND_FILTER *flt, char **errp)
         const char *input;  
         ASCEND_FILTER *flt;  
         char **errp;  
632  {  {
633          struct ascend_parse_buf pb;          struct ascend_parse_buf pb;
634          int rc;          int rc;
# Line 673  _ascend_parse_filter(input, flt, errp) Line 649  _ascend_parse_filter(input, flt, errp)
649  }  }
650    
651  int  int
652  ascend_parse_filter(pair, errp)  ascend_parse_filter(VALUE_PAIR *pair, char **errp)
         VALUE_PAIR *pair;  
         char **errp;  
653  {  {
654          ASCEND_FILTER flt;          ASCEND_FILTER flt;
655                    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26