Changeset 539


Ignore:
Timestamp:
02/05/10 11:59:17 (2 years ago)
Author:
eagle
Message:

pointer dereferences recoded in respect to strict alias checking of compiler

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ocat.h

    r538 r539  
    524524void set_select_timeout(struct timeval *); 
    525525void set_nonblock(int); 
     526void set_tunheader(char *, uint32_t); 
     527uint32_t get_tunheader(char *); 
    526528 
    527529/* ocatthread.c */ 
  • trunk/src/ocateth.c

    r510 r539  
    250250 
    251251   // tunnel header 
    252    *((uint32_t*) buf) = htonl(CNF(fhd_key[IPV6_KEY])); 
     252   set_tunheader(buf, htonl(CNF(fhd_key[IPV6_KEY]))); 
    253253 
    254254   // ethernet header 
    255    *((uint16_t*) ndp6->eth.ether_dhost) = 0x3333; 
     255   ndp6->eth.ether_dhost[0] = 0x33; 
     256   ndp6->eth.ether_dhost[1] = 0x33; 
    256257   memcpy(&ndp6->eth.ether_dhost[2], ((char*) &mcastd) + 12, 4); 
    257258   memcpy(ndp6->eth.ether_shost, CNF(ocat_hwaddr), ETHER_ADDR_LEN); 
     
    449450 
    450451   // check ethernet destination 
    451    if ((*((uint16_t*) &ndp6->eth.ether_dhost) != 0x3333) && memcmp(ndp6->eth.ether_dhost, CNF(ocat_hwaddr), ETHER_ADDR_LEN)) 
     452   if ((ndp6->eth.ether_dhost[0] != 0x33) && (ndp6->eth.ether_dhost[1] != 0x33) && memcmp(ndp6->eth.ether_dhost, CNF(ocat_hwaddr), ETHER_ADDR_LEN)) 
    452453   { 
    453454      log_debug("unknown destination MAC"); 
  • trunk/src/ocatroute.c

    r535 r539  
    265265 
    266266 
     267void set_tunheader(char *buf, uint32_t tunhdr) 
     268{ 
     269   uint32_t *ibuf = (uint32_t*) buf; 
     270   *ibuf = tunhdr; 
     271} 
     272 
     273 
     274uint32_t get_tunheader(char *buf) 
     275{ 
     276   uint32_t *ibuf = (uint32_t*) buf; 
     277   return *ibuf; 
     278} 
     279 
     280 
    267281void *socket_receiver(void *p) 
    268282{ 
     
    512526                  else 
    513527                  { 
    514                      *((uint32_t*) buf) = *peer->tunhdr; 
     528                     set_tunheader(buf, *peer->tunhdr); 
    515529                     memcpy(buf + 4 + sizeof(struct ether_header), peer->fragbuf, len); 
    516530                     memcpy(eh->ether_shost, CNF(ocat_hwaddr), ETHER_ADDR_LEN); 
     
    864878      } 
    865879 
    866       if (*((uint32_t*) buf) == CNF(fhd_key[IPV6_KEY])) 
     880      if (get_tunheader(buf) == CNF(fhd_key[IPV6_KEY])) 
    867881      { 
    868882         if (((rlen - 4) < IP6HLEN)) 
     
    883897            dest = &((struct ip6_hdr*) &buf[4])->ip6_dst; 
    884898      } 
    885       else if (*((uint32_t*) buf) == CNF(fhd_key[IPV4_KEY])) 
     899      else if (get_tunheader(buf) == CNF(fhd_key[IPV4_KEY])) 
    886900      { 
    887901         if (((rlen - 4) < IPHDLEN)) 
     
    904918      else 
    905919      { 
    906          log_msg(LOG_ERR, "protocol 0x%08x not supported. dropping frame.", ntohl(*((uint32_t*) buf))); 
     920         log_msg(LOG_ERR, "protocol 0x%08x not supported. dropping frame.", ntohl(get_tunheader(buf))); 
    907921         continue; 
    908922      } 
Note: See TracChangeset for help on using the changeset viewer.