---
name: "ipsec_subnetof"
section: "3"
platform: "linux"
package: "openswan"
version: "1:2.6.37-3+deb7u1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/ipsec_subnetof"
---

# ipsec\_subnetof(3)

given Internet address and subnet mask return subnet number, host part, broadcast address

## NAME

ipsec\_subnetof, ipsec\_hostof, ipsec\_broadcastof - given Internet address and subnet mask return subnet number, host part, broadcast address

## SYNOPSIS

**#include \<freeswan.h\>**

**struct in\_addr subnetof(struct in\_addr addr,** **struct in\_addr mask);**\
 **struct in\_addr hostof(struct in\_addr addr,** **struct in\_addr mask);**\
 **struct in\_addr broadcastof(struct in\_addr addr,** **struct in\_addr mask);**

## DESCRIPTION

These functions are obsolete; see [*ipsec\_networkof*(3)](/ipsec_networkof/3.md) for their replacements.

*Subnetof* takes an Internet *address* and a subnet *mask* and returns the network part of the address (all in network byte order). *Hostof* similarly returns the host part, and *broadcastof* returns the broadcast address (all-1s convention) for the network.

These functions are provided to hide the Internet bit-munging inside an API, in hopes of easing the eventual transition to IPv6.

## SEE ALSO

[inet(3)](/inet/3.md), [ipsec\_atosubnet(3)](/ipsec_atosubnet/3.md)

## HISTORY

Written for the FreeS/WAN project by Henry Spencer.

## BUGS

Calling functions for this is more costly than doing it yourself.
