/* Common routines for ip4 addresses. */

#include <arpa/inet.h>
#include "ip4addr.h"

/* parse ip4 address in `s' */

int ip4addr(const char *s, ip4addr_t *ap) {
  /* don't reinvent already existing routine, use inet_aton() */
  struct in_addr ia;
  if (inet_aton(s, &ia)) {
    *ap = ntohl(ia.s_addr);
    return 1;
  }
  else
    return 0;
}
