Revision dfeef5d8 lib/ipv4.c

View differences:

lib/ipv4.c
8 8

  
9 9
#ifndef IPV6
10 10

  
11
#include <string.h>
12
#include <stdlib.h>
13

  
11 14
#include "nest/bird.h"
12 15
#include "lib/ip.h"
13 16
#include "lib/string.h"
......
65 68
	return m;
66 69
}
67 70

  
71
int
72
ip_pton(char *a, ip_addr *o)
73
{
74
  int i,j;
75
  unsigned long int l;
76
  u32 ia = 0;
77

  
78
  i=4;
79
  while (i--)
80
    {
81
      char *d, *c = strchr(a, '.');
82
      if (!c != !i)
83
	return 0;
84
      if (c)
85
	*c++ = 0;
86
      l = strtoul(a, &d, 10);
87
      if (d && *d || l > 255)
88
	return 0;
89
      ia = (ia << 8) | l;
90
      a = c;
91
    }
92
  *o = ipa_from_u32(ia);
93
  return 1;
94
}
95

  
68 96
#endif

Also available in: Unified diff