File: dns.h

package info (click to toggle)
radsecproxy 1.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,420 kB
  • sloc: ansic: 12,097; sh: 1,963; makefile: 84
file content (67 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright (c) 2021, SWITCH */
/* See LICENSE for licensing information. */

#ifndef _DNS_H
#define _DNS_H

#include <sys/types.h>
#include <arpa/nameser.h>
#include <stdlib.h>

/* maximum character string length in a DNS response, including null-terminator */
#define MAXCHARSTRLEN 256

struct naptr_record {
    uint32_t ttl;
    uint16_t order;
    uint16_t preference;
    char flags[MAXCHARSTRLEN];
    char services[MAXCHARSTRLEN];
    char regexp[MAXCHARSTRLEN];
    char replacement[NS_MAXDNAME];
};

struct srv_record {
    uint32_t ttl;
    uint16_t priority;
    uint16_t weight;
    uint16_t port;
    char host[NS_MAXDNAME];
    /* TODO add A and AAAA records from additional section */
};

/**
 * query DNS NAPTR record for name
 * caller must free memory by calling freenaptrresponse
 * 
 * @param name the name to query
 * @param timeout query timeout
 * @return null terminated array of struct naptr_record*
 */
struct naptr_record **querynaptr(const char *name, int timeout);

/**
 * free memory allocated by querynaptr
 * 
 * @param response the response to free
 */
void freenaptrresponse(struct naptr_record **response);

/** 
 * query a DNS SRV record for name.
 * caller must free memory by calling freesrvresponse.
 * 
 * @param name the name to query
 * @param timeout query timeout
 * @return null terminated array of struct srv_record*
 */
struct srv_record **querysrv(const char *name, int timeout);

/**
 * free memory allocated by querysrv
 * 
 * @param response the response to free
 */
void freesrvresponse(struct srv_record **response);

#endif /*_DNS_H*/