1 /* 2 * verify.h 3 * 4 * Copyright (c) 2020, NLnet Labs. All rights reserved. 5 * 6 * See LICENSE for the license. 7 */ 8 #ifndef VERIFY_H 9 #define VERIFY_H 10 11 #ifndef USE_MINI_EVENT 12 # ifdef HAVE_EVENT_H 13 # include <event.h> 14 # else 15 # include <event2/event.h> 16 # include "event2/event_struct.h" 17 # include "event2/event_compat.h" 18 # endif 19 #else 20 # include "mini_event.h" 21 #endif 22 23 /* 24 * Track position in zone to feed verifier more data as the input descriptor 25 * becomes available. 26 */ 27 struct verifier_zone_feed { 28 FILE *fh; 29 struct event event; 30 zone_rr_iter_type rriter; 31 struct state_pretty_rr *rrprinter; 32 struct region *region; 33 struct buffer *buffer; 34 }; 35 36 /* 40 is (estimated) space already used on each logline. 37 * (time, pid, priority, etc) 38 */ 39 #define LOGLINELEN (MAXSYSLOGMSGLEN-40) 40 41 #define LOGBUFSIZE (LOGLINELEN * 2) 42 43 /* 44 * STDOUT and STDERR are logged per line. Lines that exceed LOGLINELEN, are 45 * split over multiple entries. Line breaks are indicated with "..." in the log 46 * before and after the break. 47 */ 48 struct verifier_stream { 49 int fd; 50 struct event event; 51 int priority; 52 int cut; 53 char buf[LOGBUFSIZE+1]; 54 size_t cnt; 55 size_t off; 56 }; 57 58 struct verifier { 59 struct nsd *nsd; 60 struct zone *zone; 61 pid_t pid; 62 int was_ok; 63 struct timeval timeout; 64 struct event timeout_event; 65 struct verifier_zone_feed zone_feed; 66 struct verifier_stream output_stream; 67 struct verifier_stream error_stream; 68 }; 69 70 struct zone *verify_next_zone(struct nsd *nsd, struct zone *zone); 71 72 void verify_zone(struct nsd *nsd, struct zone *zone); 73 74 void verify_handle_signal(int sig, short event, void *arg); 75 76 void verify_handle_exit(int fd, short event, void *arg); 77 78 void verify_handle_command(int fd, short event, void *arg); 79 80 #endif /* VERIFY_H */ 81