Changeset 10 for trunk

Show
Ignore:
Timestamp:
02/09/06 18:15:36 (17 years ago)
Author:
andreu
Message:

prefix v6 ok

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/rules_mgmt.c

    r8 r10  
    292292    if ( strspn(line, "#") == 0 ) { 
    293293      strcpy(lineCopy, line); 
     294      fprintf(stderr,"ligne en cours : %d\n", cptLine); 
    294295      if (strncmp("N", lineCopy, 1) == 0){ 
    295296        if (sscanf(line, "%1s %s\n", 
     
    352353      } 
    353354      cptLine++; 
     355      fprintf(stderr,"ligne : %d\n", cptLine); 
    354356    } 
    355357  } 
     
    441443    static unsigned short ft; 
    442444    char operator[2]; 
    443     char value[30]; 
     445    char value[42]; 
    444446    tmp = (RuleDefPtr) malloc(sizeof(struct RuleDef)); 
    445447    if (tmp==NULL) { 
     
    447449      exit(1); 
    448450    } else {  
    449       if (sscanf(fields, " %hu %1s %s ", &ft, operator, value) == 0) { 
     451      if (sscanf(fields, " %hu %1s %s", &ft, operator, value)==0) { 
    450452        syslog(LOG_ERR, "Errors in Tests definition : wrong syntax"); 
    451453        exit(1); 
     
    496498  unsigned short v0, v1, v2, v3; 
    497499  unsigned char buffer4[4]; 
    498  
     500/*   static unsigned short mask; */ 
    499501  tmp = (ValuesPtr) malloc(sizeof(struct Values)); 
    500502  if (tmp==NULL) { 
     
    512514    tmp->valueLength = 4; 
    513515    tmp->stor.lvalue = *((unsigned long*)(&buffer4)); 
     516    tmp->mask = 32; 
    514517    tmp->next = vPtr; 
    515518  } 
     
    524527  char netw_form[16]; 
    525528  int result; 
    526  
     529  static char value[30]; 
     530  static char mask[4]; 
     531  static char *token; 
     532  int lg = 0; 
     533  int lgMask = 0; 
    527534  tmp = (ValuesPtr) malloc(sizeof(struct Values)); 
    528535  if (tmp==NULL) { 
     
    530537    exit(1); 
    531538  } else { 
    532     result = inet_pton(AF_INET6, val, netw_form); 
    533     switch(result) { 
    534     case 0 :  
    535       syslog(LOG_ERR," inet_pton : Invalid IPv6 Address"); 
    536       exit(1); 
    537       break; 
    538     case -1:  
    539       syslog(LOG_ERR," inet_pton : AF unknown"); 
    540       exit(1); 
    541       break; 
    542     } 
    543     memcpy(&v6addr, netw_form, sizeof(netw_form)); 
    544     tmp->valueLength = 16; 
    545     tmp->stor.tabAdd6[0] = v6addr.s6_addr32[0]; 
    546     tmp->stor.tabAdd6[1] = v6addr.s6_addr32[1]; 
    547     tmp->stor.tabAdd6[2] = v6addr.s6_addr32[2]; 
    548     tmp->stor.tabAdd6[3] = v6addr.s6_addr32[3]; 
    549     tmp->next = vPtr; 
     539    if ( (token=memccpy(value, val, '/', strlen(val)))==NULL) { 
     540      /* address case */ 
     541      fprintf(stderr,"address case\n"); 
     542      result = inet_pton(AF_INET6, val, netw_form); 
     543      switch(result) { 
     544      case 0 :  
     545        syslog(LOG_ERR," inet_pton : Invalid IPv6 Address"); 
     546        exit(1); 
     547        break; 
     548      case -1:  
     549        syslog(LOG_ERR," inet_pton : AF unknown"); 
     550        exit(1); 
     551        break; 
     552      } 
     553      memcpy(&v6addr, netw_form, sizeof(netw_form)); 
     554      tmp->valueLength = 16; 
     555      tmp->mask = 128; 
     556      tmp->stor.tabAdd6[0] = v6addr.s6_addr32[0]; 
     557      tmp->stor.tabAdd6[1] = v6addr.s6_addr32[1]; 
     558      tmp->stor.tabAdd6[2] = v6addr.s6_addr32[2]; 
     559      tmp->stor.tabAdd6[3] = v6addr.s6_addr32[3]; 
     560      tmp->next = vPtr; 
     561    } else { 
     562      fprintf(stderr,"prefix case\n"); 
     563      lg = strlen(value); 
     564      lgMask = strlen(token); 
     565      value[lg-1-lgMask] = '\0'; 
     566      strcpy( mask, strchr(val,'/')+1); 
     567      fprintf(stderr,"apres strcpy: %s et %d\n", value, atoi(mask)); 
     568      result = inet_pton(AF_INET6, value, netw_form); 
     569      switch(result) { 
     570      case 0 : 
     571        syslog(LOG_ERR," inet_pton : Invalid IPv6 Address"); 
     572        exit(1); 
     573        break; 
     574      case -1: 
     575        syslog(LOG_ERR," inet_pton : AF unknown"); 
     576        exit(1); 
     577        break; 
     578      } 
     579      memcpy(&v6addr, netw_form, sizeof(netw_form)); 
     580      tmp->valueLength = 16; 
     581      fprintf(stderr,"ici\n"); 
     582      tmp->mask = atoi(mask); 
     583      fprintf(stderr,"la %hu\n",  tmp->mask); 
     584      tmp->stor.tabAdd6[0] = v6addr.s6_addr32[0]; 
     585      tmp->stor.tabAdd6[1] = v6addr.s6_addr32[1]; 
     586      tmp->stor.tabAdd6[2] = v6addr.s6_addr32[2]; 
     587      tmp->stor.tabAdd6[3] = v6addr.s6_addr32[3]; 
     588      tmp->next = vPtr; 
     589      fprintf(stderr,"plus la\n"); 
     590    } 
    550591  } 
    551592  return tmp; 
  • trunk/src/rules_mgmt.h

    r2 r10  
    5151    uint32_t tabAdd6[4];   /* 16 */ 
    5252  } stor; 
     53  unsigned short mask; 
    5354  ValuesPtr next; 
    5455} ValuesType;