# ol.client-ip.cidr

## cidr-parts

```clojure
(cidr-parts cidr)
```

Parse an ip network string into its prefix and signifcant bits

`cidr` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1)

Returns a vector of [^InetAddress prefix ^Integer bits]

[source,window=_blank](https://github.com/outskirtslabs/client-ip/blob/main/src/ol/client_ip/cidr.clj#L26-L39)

---

## contains?

```clojure
(contains? cidr ip)
(contains? cidr-ip cidr-mask ip)
```

Check if the given CIDR contains the given IP address.
 
 Arguments:
   cidr - CIDR notation string (e.g. "192.168.0.0/24" or "2001:db8::/32")
   ip   - IP address to check (can be InetAddress or string)

[source,window=_blank](https://github.com/outskirtslabs/client-ip/blob/main/src/ol/client_ip/cidr.clj#L41-L61)

---

## reserved-ranges

[source,window=_blank](https://github.com/outskirtslabs/client-ip/blob/main/src/ol/client_ip/cidr.clj#L66-L93)

---

## reserved?

```clojure
(reserved? ip)
```

Check if an IP is in a reserved range (loopback or private network).

[source,window=_blank](https://github.com/outskirtslabs/client-ip/blob/main/src/ol/client_ip/cidr.clj#L95-L98)
