|
Electroneum
|
#include "util/locks.h"#include "util/alloc.h"#include "util/rbtree.h"#include "services/modstack.h"#include "libunbound/unbound.h"#include "libunbound/unbound-event.h"#include "util/data/packed_rrset.h"
Go to the source code of this file.
Classes | |
| struct | ub_ctx |
| struct | ctx_query |
Enumerations | |
| enum | ub_ctx_err { UB_NOERROR = 0, UB_SOCKET = -1, UB_NOMEM = -2, UB_SYNTAX = -3, UB_SERVFAIL = -4, UB_FORKFAIL = -5, UB_AFTERFINAL = -6, UB_INITFAIL = -7, UB_PIPE = -8, UB_READFILE = -9, UB_NOID = -10 } |
| enum | ub_ctx_cmd { UB_LIBCMD_QUIT = 0, UB_LIBCMD_NEWQUERY, UB_LIBCMD_CANCEL, UB_LIBCMD_ANSWER } |
This file contains the validator context structure.
Definition in file context.h.
| enum ub_ctx_cmd |
Command codes for libunbound pipe.
Serialization looks like this: o length (of remainder) uint32. o uint32 command code. o per command format.
| Enumerator | |
|---|---|
| UB_LIBCMD_QUIT | QUIT |
| UB_LIBCMD_NEWQUERY | New query, sent to bg worker |
| UB_LIBCMD_CANCEL | Cancel query, sent to bg worker |
| UB_LIBCMD_ANSWER | Query result, originates from bg worker |
Definition at line 210 of file context.h.
| enum ub_ctx_err |
The error constants
| Enumerator | |
|---|---|
| UB_NOERROR | no error |
| UB_SOCKET | socket operation. Set to -1, so that if an error from _fd() is passed (-1) it gives a socket error. |
| UB_NOMEM | alloc failure |
| UB_SYNTAX | syntax error |
| UB_SERVFAIL | DNS service failed |
| UB_FORKFAIL | fork() failed |
| UB_AFTERFINAL | cfg change after finalize() |
| UB_INITFAIL | initialization failed (bad settings) |
| UB_PIPE | error in pipe communication with async bg worker |
| UB_READFILE | error reading from file (resolv.conf) |
| UB_NOID | error async_id does not exist or result already been delivered |
Definition at line 176 of file context.h.
| struct ctx_query* context_deserialize_answer | ( | struct ub_ctx * | ctx, |
| uint8_t * | p, | ||
| uint32_t | len, | ||
| int * | err | ||
| ) |
Deserialize an answer buffer.
| ctx | context |
| p | buffer serialized. |
| len | length of buffer. |
| err | error code to be returned to client is passed. |
Deserialize a cancel buffer.
| ctx | context |
| p | buffer serialized. |
| len | length of buffer. |
Deserialize a new_query buffer.
| ctx | context |
| p | buffer serialized. |
| len | length of buffer. |
| int context_finalize | ( | struct ub_ctx * | ctx | ) |
finalize a context.
| ctx | context to finalize. creates shared data. |
Lookup query from new_query buffer.
| ctx | context |
| p | buffer serialized. |
| len | length of buffer. |
| struct ctx_query* context_new | ( | struct ub_ctx * | ctx, |
| const char * | name, | ||
| int | rrtype, | ||
| int | rrclass, | ||
| ub_callback_type | cb, | ||
| ub_event_callback_type | cb_event, | ||
| void * | cbarg | ||
| ) |
Create new query in context, add to querynum list.
| ctx | context |
| name | query name |
| rrtype | type |
| rrclass | class |
| cb | callback for async, or NULL for sync. |
| cb_event | event callback for async, or NULL for sync. |
| cbarg | user arg for async queries. |
| struct alloc_cache* context_obtain_alloc | ( | struct ub_ctx * | ctx, |
| int | locking | ||
| ) |
Get a new alloc. Creates a new one or uses a cached one.
| ctx | context |
| locking | if true, cfglock is locked while getting alloc. |
| int context_query_cmp | ( | const void * | a, |
| const void * | b | ||
| ) |
compare two ctx_query elements
| void context_query_delete | ( | struct ctx_query * | q | ) |
delete context query
| q | query to delete, including message packet and prealloc result |
| void context_release_alloc | ( | struct ub_ctx * | ctx, |
| struct alloc_cache * | alloc, | ||
| int | locking | ||
| ) |
Release an alloc. Puts it into the cache.
| ctx | context |
| locking | if true, cfglock is locked while releasing alloc. |
| alloc | alloc to relinquish. |
| enum ub_ctx_cmd context_serial_getcmd | ( | uint8_t * | p, |
| uint32_t | len | ||
| ) |
Obtain command code from serialized buffer
| p | buffer serialized. |
| len | length of buffer. |
| uint8_t* context_serialize_answer | ( | struct ctx_query * | q, |
| int | err, | ||
| struct sldns_buffer * | pkt, | ||
| uint32_t * | len | ||
| ) |
Serialize a context_query result to hand back to user. This serializes the query name, type, ..., and result. As well as command code 'answer'.
| q | context query |
| err | error code to pass to client. |
| pkt | the packet to add, can be NULL. |
| len | the length of the allocation is returned. |
Serialize a query cancellation. Serializes query async id as well as command code 'cancel'
| q | context query |
| len | the length of the allocation is returned. |
Serialize a context query that questions data. This serializes the query name, type, ... As well as command code 'new_query'.
| q | context query |
| len | the length of the allocation is returned. |