---
name: "subnetof"
section: "3"
platform: "linux"
package: "strongswan"
version: "4.2.4-5+lenny3"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/subnetof"
---

# subnetof(3)

given Internet address and subnet mask, return subnet number ipsec hostof - given Internet address and subnet mask, return host part ipsec broadcastof - given Internet address and subnet mask, return broadcast address

## NAME

ipsec subnetof - given Internet address and subnet mask, return subnet number\
 ipsec hostof - given Internet address and subnet mask, return host part\
 ipsec broadcastof - given Internet address and subnet mask, return 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.
