---
name: "inet_cidr"
section: "3bind"
platform: "linux"
package: "bind-dev"
version: "1:8.4.7-1"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/inet_cidr"
---

# inet\_cidr(3bind)

network translation routines

## NAME

**inet\_cidr\_ntop**, **inet\_cidr\_pton** – network translation routines

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/socket.h\>**

**#include \<netinet/in.h\>**

**#include \<arpa/inet.h\>**

**inet\_cidr\_ntop**(*int af*, *const void \*src*, *int bits*, *char \*dst*, *size\_t size*);

**inet\_cidr\_pton**(*int af*, *const char \*src*, *void \*dst*, *int \*bits*);

## DESCRIPTION

These routines are used for converting addresses to and from network and presentation forms with CIDR (Classless Inter-Domain Routing) representation, embedded net mask.

```
		130.155.16.1/20
```

**inet\_cidr\_ntop**() converts an address from network to presentation format.

*af* describes the type of address that is being passed in *src*. Currently only AF\_INET is supported.

*src* is an address in network byte order, its length is determined from *af*.

*bits* specifies the number of bits in the netmask unless it is -1 in which case the CIDR representation is omitted.

*dst* is a caller supplied buffer of at least *size* bytes.

**inet\_cidr\_ntop**() returns  *dst* on success or NULL. Check errno for reason.

**inet\_cidr\_pton**() converts and address from presentation format, with optional CIDR reperesentation, to network format. The resulting address is zero filled if there were insufficint bits in *src*.

*af* describes the type of address that is being passed in via  *src* and determines the size of  *dst*.

*src* is an address in presentation format.

*bits* returns the number of bits in the netmask or -1 if a CIDR representation was not supplied.

**inet\_cidr\_pton**() returns 0 on succces or -1 on error. Check errno for reason. ENOENT indicates an invalid netmask.

## SEE ALSO

[intro(2)](/intro/2.md)
