Diff for /libelwix/src/net.c between versions 1.6.4.1 and 1.8.12.1

version 1.6.4.1, 2013/07/08 01:11:34 version 1.8.12.1, 2014/01/29 14:11:45
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013Copyright 2004 - 2014
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 76  e_link_ntoa(const struct sockaddr_dl *sdl) Line 76  e_link_ntoa(const struct sockaddr_dl *sdl)
                         firsttime ^= firsttime;                          firsttime ^= firsttime;
                 else                  else
                         *out++ = ':';                          *out++ = ':';
   
                 i = *in++;                  i = *in++;
                 if (i > 0xf) {                  if (i > 0xf) {
                         out[1] = hexlist[i & 0xf];                          out[1] = hexlist[i & 0xf];
                         i >>= 4;                          i >>= 4;
                } else                } else {
                        out[1] = hexlist[0];                        out[1] = hexlist[i];
                         i = 0;
                 }
   
                 out[0] = hexlist[i];                  out[0] = hexlist[i];
                 out += 2;                  out += 2;
Line 100  e_link_ntoa(const struct sockaddr_dl *sdl) Line 103  e_link_ntoa(const struct sockaddr_dl *sdl)
  * return: NULL error or !=NULL string a   * return: NULL error or !=NULL string a
  */   */
 char *  char *
e_ether_ntoa(const struct e_ether_addr *n, char * __restrict a, int len)e_ether_ntoa(const ether_addr_t * __restrict n, char * __restrict a, int len)
 {  {
         if (!n || !a)          if (!n || !a)
                 return NULL;                  return NULL;
   
         memset(a, 0, len);          memset(a, 0, len);
        if (snprintf(a, len, "%02x:%02x:%02x:%02x:%02x:%02x",         if (snprintf(a, len, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", 
                         n->ether_addr_octet[0], n->ether_addr_octet[1],                           n->ether_addr_octet[0], n->ether_addr_octet[1], 
                         n->ether_addr_octet[2], n->ether_addr_octet[3],                           n->ether_addr_octet[2], n->ether_addr_octet[3], 
                         n->ether_addr_octet[4], n->ether_addr_octet[5]) < 17)                          n->ether_addr_octet[4], n->ether_addr_octet[5]) < 17)
Line 122  e_ether_ntoa(const struct e_ether_addr *n, char * __re Line 125  e_ether_ntoa(const struct e_ether_addr *n, char * __re
  * @e = ethernet address structure, like struct ether_addr   * @e = ethernet address structure, like struct ether_addr
  * return: NULL error or !=NULL ethernet address structure   * return: NULL error or !=NULL ethernet address structure
  */   */
struct e_ether_addr *ether_addr_t *
e_ether_aton(const char *a, struct e_ether_addr *e)e_ether_aton(const char *a, ether_addr_t * __restrict e)
 {                         {                       
         int i;          int i;
         u_int o0, o1, o2, o3, o4, o5;  
   
         if (!a || !e)          if (!a || !e)
                 return NULL;                  return NULL;
   
        i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5);        i = sscanf(a, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", 
                         &e->ether_addr_octet[0], 
                         &e->ether_addr_octet[1], 
                         &e->ether_addr_octet[2], 
                         &e->ether_addr_octet[3], 
                         &e->ether_addr_octet[4], 
                         &e->ether_addr_octet[5]);
         if (i != 6)          if (i != 6)
                 return NULL;                  return NULL;
   
         e->ether_addr_octet[0] = o0;  
         e->ether_addr_octet[1] = o1;  
         e->ether_addr_octet[2] = o2;  
         e->ether_addr_octet[3] = o3;  
         e->ether_addr_octet[4] = o4;  
         e->ether_addr_octet[5] = o5;  
   
         return e;          return e;
 }  }
   
Line 462  e_ether_addr(const char *ifname, ether_addr_t * __rest Line 463  e_ether_addr(const char *ifname, ether_addr_t * __rest
                 memset(a, 0, sizeof(ether_addr_t));                  memset(a, 0, sizeof(ether_addr_t));
   
         getifaddrs(&ifa);          getifaddrs(&ifa);
        for (p = ifa; p; p++)        for (p = ifa; p && p->ifa_name; p++)
                if (!strcmp(p->ifa_name, ifname) && p->ifa_addr &&                 if (p->ifa_name && !strcmp(p->ifa_name, ifname) && p->ifa_addr && 
                                 p->ifa_addr->sa_family == AF_LINK) {                                  p->ifa_addr->sa_family == AF_LINK) {
                         memcpy(a, LLADDR((struct sockaddr_dl*) p->ifa_addr), sizeof(ether_addr_t));                          memcpy(a, LLADDR((struct sockaddr_dl*) p->ifa_addr), sizeof(ether_addr_t));
                         break;                          break;

Removed from v.1.6.4.1  
changed lines
  Added in v.1.8.12.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>