File: val_parse.h

package info (click to toggle)
dnssec-tools 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 16,064 kB
  • sloc: perl: 44,399; ansic: 31,547; cpp: 21,306; sh: 15,813; xml: 2,113; makefile: 1,390; pascal: 836; python: 290; csh: 11
file content (90 lines) | stat: -rw-r--r-- 2,623 bytes parent folder | download
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Copyright 2005-2012 SPARTA, Inc.  All rights reserved.
 * See the COPYING file distributed with this software for details.
 *
 * Author: Abhijit Hayatnagarkar
 *
 * This is a header file for data structures and functions for parsing
 * DNSSEC Resource Records.
 */

#ifndef VAL_PARSE_H
#define VAL_PARSE_H

/*
 * Parse a domain name 
 */
int             val_parse_dname(const u_char *buf, size_t buflen,
                                size_t offset, char *dname, size_t *namelen);

/*
 * Parse the rdata portion of a DNSKEY resource record 
 */
int             val_parse_dnskey_rdata(const u_char *buf,
                                       size_t buflen,
                                       val_dnskey_rdata_t * rdata);
/*
 * Parse the dnskey from the string. The string contains the flags, 
 * protocol, algorithm and the base64 key delimited by spaces.
 */
int             val_parse_dnskey_string(char *keystr, size_t keystrlen,
                                        val_dnskey_rdata_t **
                                        dnskey_rdata);
/*
 * Parse the ds from the string. 
 */
int             val_parse_ds_string(char *dsstr, size_t dsstrlen,
                                    val_ds_rdata_t ** ds_rdata);

/*
 * Parse the rdata portion of an RRSIG resource record 
 */
int             val_parse_rrsig_rdata(const u_char *buf, size_t buflen,
                                      val_rrsig_rdata_t * rdata);

/*
 * Parse the rdata portion of an DS resource record 
 */
int             val_parse_ds_rdata(const u_char *buf, size_t buflen,
                                   val_ds_rdata_t * rdata);

#ifdef LIBVAL_NSEC3
val_nsec3_rdata_t *val_parse_nsec3_rdata(u_char * rr_rdata,
                                         size_t rdatalen,
                                         val_nsec3_rdata_t * nd);
#endif


/*
 * Parse the ETC_HOSTS file 
 */
#define ETC_HOSTS      "/etc/hosts"
#define MAXLINE 4096
#define MAX_ALIAS_COUNT 2048
struct hosts {
    char           *address;
    char           *canonical_hostname;
    char          **aliases;    /* An array.  The last element is NULL */
    struct hosts   *next;
};

/*
 * A macro to free memory allocated for hosts 
 */
#define FREE_HOSTS(hentry) do { \
	if (hentry) { \
	    int i = 0; \
	    if (hentry->address) free (hentry->address); \
	    if (hentry->canonical_hostname) free (hentry->canonical_hostname); \
	    if (hentry->aliases) { \
		for (i=0; hentry->aliases[i] != 0; i++) { \
		    if (hentry->aliases[i]) free (hentry->aliases[i]); \
		} \
		free (hentry->aliases); \
	    } \
	    free (hentry); \
	} \
} while (0)


#endif