OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orpmon/] [services/] [net.c] - Diff between revs 833 and 1312

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 833 Rev 1312
Line 640... Line 640...
    ip_to_string(x, tmp);
    ip_to_string(x, tmp);
 
 
    printf(tmp);
    printf(tmp);
}
}
 
 
 
static unsigned int i2a(char* dest,unsigned int x) {
 
  register unsigned int tmp=x;
 
  register unsigned int len=0;
 
  if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; }
 
  if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; }
 
  *dest++=tmp+'0';
 
  return len+1;
 
}
 
 
 
char *inet_ntoa(unsigned long in) {
 
  static char buf[20];
 
  unsigned int len;
 
  unsigned char *ip=(unsigned char*)∈
 
 
 
  len=i2a(buf,ip[0]); buf[len]='.'; ++len;
 
  len+=i2a(buf+ len,ip[1]); buf[len]='.'; ++len;
 
  len+=i2a(buf+ len,ip[2]); buf[len]='.'; ++len;
 
  len+=i2a(buf+ len,ip[3]); buf[len]=0;
 
  return buf;
 
}
 
 
 
unsigned long inet_aton(const char *cp)
 
{
 
  unsigned long a[4];
 
  unsigned long ret;
 
  char *p = (char *)cp;
 
  int i,d;
 
  if (strcmp(cp, "255.255.255.255") == 0)
 
    return -1;
 
 
 
  for(i = 0; i < 4; i++) {
 
    a[i] = strtoul(p, 0, 0);
 
    for(d=1; (p[d] != '.') && (i < 3); d++);
 
    p = &p[d+1];
 
  }
 
 
 
  ret = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
 
  return ret;
 
}
 
 
#endif
#endif
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.