---
name: "dns_ip4_packet"
section: "3diet"
platform: "linux"
package: "libowfat-dev"
version: "0.28-2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/dns_ip4_packet/3diet"
---

# dns\_ip4\_packet(3diet)

extract IPv4 address from DNS answer packet

## NAME

dns\_ip4\_packet - extract IPv4 address from DNS answer packet

## SYNTAX

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

int **dns\_ip4\_packet**(stralloc\* *out*,const char\* *buf*,\
                    unsigned int *len*);

## DESCRIPTION

dns\_ip4\_packet is a low-level component of dns\_ip4, designed to support asynchronous DNS lookups. It reads a DNS packet of length *len* from *buf*, extracts IP addresses from the answer section of the packet, puts the addresses into *out*, and returns 0 or -1 the same way as dns\_ip4.

## SEE ALSO

[dns\_ip4(3)](/dns_ip4/3.md), [dns\_ip6\_packet(3)](/dns_ip6_packet/3.md)
