edns.h
Go to the documentation of this file.
/*
* Copyright (c) 2011 NLNet Labs. All rights reserved.
*
* Taken from NSD3 and adjusted for OpenDNSSEC, NLnet Labs.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef WIRE_EDNS_H
#define WIRE_EDNS_H
#include "config.h"
#include "status.h"
#include "wire/buffer.h"
#include <ldns/ldns.h>
#define OPT_LEN 9U /* length of the NSD EDNS response record minus 2 */
#define OPT_RDATA 2 /* holds the rdata length comes after OPT_LEN */
#define DNSSEC_OK_MASK 0x8000U /* do bit mask */
#define EDNS_MAX_MESSAGE_LEN 4096
typedef struct edns_data_struct edns_data_type;
struct edns_data_struct {
unsigned char ok[OPT_LEN];
unsigned char error[OPT_LEN];
unsigned char rdata_none[OPT_RDATA];
};
enum edns_status_enum {
EDNS_NOT_PRESENT,
EDNS_OK,
EDNS_ERROR
};
typedef enum edns_status_enum edns_status;
typedef struct edns_rr_struct edns_rr_type;
struct edns_rr_struct {
edns_status status;
size_t position;
size_t maxlen;
int dnssec_ok;
};
extern void edns_init(edns_data_type* data, uint16_t max_length);
extern edns_rr_type* edns_rr_create(void);
extern void edns_rr_reset(edns_rr_type* err);
extern int edns_rr_parse(edns_rr_type* err, buffer_type* buffer);
extern size_t edns_rr_reserved_space(edns_rr_type* err);
extern void edns_rr_cleanup(edns_rr_type* err);
#endif /* WIRE_EDNS_H */
buffer.h
buffer_type
struct buffer_struct buffer_type
Definition buffer.h:111
edns_rr_cleanup
void edns_rr_cleanup(edns_rr_type *err)
Definition edns.c:172
edns_init
void edns_init(edns_data_type *data, uint16_t max_length)
Definition edns.c:64
OPT_RDATA
#define OPT_RDATA
Definition edns.h:44
edns_status_enum
edns_status_enum
Definition edns.h:64
EDNS_NOT_PRESENT
@ EDNS_NOT_PRESENT
Definition edns.h:65
EDNS_ERROR
@ EDNS_ERROR
Definition edns.h:67
EDNS_OK
@ EDNS_OK
Definition edns.h:66
edns_rr_reserved_space
size_t edns_rr_reserved_space(edns_rr_type *err)
Definition edns.c:162
edns_rr_create
edns_rr_type * edns_rr_create(void)
Definition edns.c:50
edns_rr_reset
void edns_rr_reset(edns_rr_type *err)
Definition edns.c:90
edns_data_type
struct edns_data_struct edns_data_type
Definition edns.h:53
OPT_LEN
#define OPT_LEN
Definition edns.h:43
edns_status
enum edns_status_enum edns_status
Definition edns.h:69
edns_rr_parse
int edns_rr_parse(edns_rr_type *err, buffer_type *buffer)
Definition edns.c:107
edns_rr_type
struct edns_rr_struct edns_rr_type
Definition edns.h:75
edns_data_struct
Definition edns.h:54
edns_data_struct::ok
unsigned char ok[OPT_LEN]
Definition edns.h:55
edns_data_struct::error
unsigned char error[OPT_LEN]
Definition edns.h:56
edns_data_struct::rdata_none
unsigned char rdata_none[OPT_RDATA]
Definition edns.h:57
edns_rr_struct
Definition edns.h:76
edns_rr_struct::dnssec_ok
int dnssec_ok
Definition edns.h:80
edns_rr_struct::status
edns_status status
Definition edns.h:77
edns_rr_struct::position
size_t position
Definition edns.h:78
edns_rr_struct::maxlen
size_t maxlen
Definition edns.h:79