44 else if (*
sp ==
'"' || *
sp ==
'\\')
58 *(
const unsigned char *)
sp);
60 }
else if (*
sp ==
'"' || *
sp ==
'\\') {
78 for (
i = 0;
i < len;
i++) {
83 else if (
s [
i] ==
'"' ||
s [
i] ==
'\\')
100 for (
i = 0;
i < len;
i++) {
106 }
else if (
s [
i] ==
'"' ||
s [
i] ==
'\\') {
128 static char to64 [] =
129 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
131 bl = ((len * 4 + 2) / 3) + 1;
148 val = (
extra << 8) + buf [
i++];
157 val = (
extra << 8) + buf [
i++];
174 const unsigned char *data;
176 static char habuf [49];
184 for (
i = 0;
i < hlen;
i++) {
211 if (
lease -> hardware_addr.hlen)
214 lease -> hardware_addr.hlen - 1,
215 &
lease -> hardware_addr.hbuf [1]));
217 lease -> host ?
lease -> host -> name :
"<none>");
220#if defined (DEBUG_PACKET)
230 const char *name, *
dot;
246 ds.data,
ds.len, 1, 1));
256 log_debug (
"packet length %d",
tp -> packet_length);
257 log_debug (
"op = %d htype = %d hlen = %d hops = %d",
259 log_debug (
"xid = %x secs = %ld flags = %x",
265 log_debug (
"chaddr = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
274 if (
tp -> options_valid) {
294 const unsigned char *buf;
310 for (
i = 0;
i < len;
i++) {
323 }
else if ((
i & 7) == 0)
353 for (
i = 0;
i < table -> hash_count;
i++) {
354 if (!table -> buckets [
i])
393 if (((
len == 0) || ((
len * 3) > limit))) {
426 if ((buf ==
NULL) || (limit < 3))
429 for (
i = 0; (
i < (limit - 3)) && (
i <
len);
i++) {
512 data [
i], data [
i + 1], data [
i + 2], data [
i + 3]);
527 static char vbuf [32];
535 static char vbuf [32];
540static unsigned print_subexpression (
struct expression *,
char *,
unsigned);
542static unsigned print_subexpression (expr, buf,
len)
550 switch (expr ->
op) {
579 buf +
rv, len -
rv - 2);
582 buf +
rv, len -
rv - 1);
594 buf +
rv, len -
rv - 2);
597 buf +
rv, len -
rv - 1);
609 buf +
rv, len -
rv - 2);
612 buf +
rv, len -
rv - 1);
624 buf +
rv, len -
rv - 3);
626 rv += print_subexpression
628 buf +
rv, len -
rv - 2);
631 buf +
rv, len -
rv - 1);
643 buf +
rv, len -
rv - 2);
647 buf +
rv, len -
rv - 1);
660 buf +
rv, len -
rv - 1);
672 buf +
rv, len -
rv - 1);
684 buf +
rv, len -
rv - 2);
687 buf +
rv, len -
rv - 1);
697 strcpy (buf,
"(pick1st ");
698 rv += print_subexpression
700 buf +
rv, len -
rv - 2);
702 rv += print_subexpression
704 buf +
rv, len -
rv - 1);
714 sprintf (buf,
"(dns-lookup %s)",
729 rv += print_subexpression (expr ->
data.
and [0],
730 buf +
rv, len -
rv - 2);
732 rv += print_subexpression (expr ->
data.
and [1],
733 buf +
rv, len -
rv - 1);
780 rv += print_subexpression (expr ->
data.
not,
781 buf +
rv, len -
rv - 1);
798 sprintf (buf,
"(option %s.%s)",
807 strcpy (buf,
"(hardware)");
817 buf +
rv, len -
rv - 2);
820 buf +
rv, len -
rv - 1);
839 strcpy (buf,
"(encapsulate ");
854 buf +
rv, len -
rv - 1);
866 buf +
rv, len -
rv - 1);
878 buf +
rv, len -
rv - 1);
888 strcpy (buf,
"(to-int8 ");
890 buf +
rv, len -
rv - 1);
900 strcpy (buf,
"(to-int16 ");
902 buf +
rv, len -
rv - 1);
912 strcpy (buf,
"(to-int32 ");
914 buf +
rv, len -
rv - 1);
934 sprintf (buf,
"(exists %s.%s)",
968 s =
"leased-address";
976 s =
"host-decl-name";
998 strcpy (buf,
"(reverse ");
1000 buf +
rv, len -
rv - 2);
1003 buf +
rv, len -
rv - 1);
1015 buf +
rv, len -
rv - 4);
1018 buf +
rv, len -
rv - 3);
1021 buf +
rv, len -
rv - 2);
1024 buf +
rv, len -
rv - 1);
1035 strcpy (&buf [1],
"ns-update ");
1036 while (len <
rv + 2) {
1037 rv += print_subexpression
1039 buf +
rv, len -
rv - 2);
1085 rv += print_subexpression
1090 rv += print_subexpression
1095 rv += print_subexpression
1113 strcpy (buf,
"(funcall ");
1116 rv += print_subexpression
1126 rv = print_subexpression (expr ->
data.
arg.
val, buf, len);
1141 strcpy (buf,
"(function");
1142 for (foo = expr -> data.func -> args;
1143 foo; foo = foo ->
next) {
1144 if (len >
rv + 2 +
strlen (foo ->
string)) {
1158 strcpy(buf,
"(gethostname)");
1164 log_fatal(
"Impossible case at %s:%d (undefined expression "
1165 "%d).",
MDL, expr->
op);
1177 print_subexpression (expr, buf,
sizeof buf);
1183 const char *suffix, ...)
1200 log_fatal (
"token_print_indent: no memory for copy buffer");
1220 const char *prefix,
const char *suffix,
1228 for (
i = 0;
i <
data -> len;
i++)
1234 if (
i ==
data -> len) {
1239 buf [
data -> len + 1] =
'"';
1240 buf [
data -> len + 2] = 0;
1242 prefix, suffix, buf);
1248 for (
i = 0;
i <
data -> len;
i++) {
1251 i == 0 ? prefix :
"",
1252 (
i + 1 ==
data -> len
1255 if (
i + 1 !=
data -> len)
1257 prefix, suffix,
":");
1264 const char *suffix,
const char *buf)
1272 if (
col + len > 79) {
1278 col = len > 79 ? 0 : 79 - len - 1;
1280 }
else if (prefix && *prefix) {
1284 if ((buf !=
NULL) && (*buf != 0)) {
1288 if (suffix && *suffix) {
1314 static char buf[
sizeof(
"epoch 9223372036854775807; "
1315 "# Wed Jun 30 21:49:08 2147483647")];
1316 static char buf1[
sizeof(
"# Wed Jun 30 21:49:08 2147483647")];
1333#if (MAX_TIME > 0x7fffffffffffffff)
1334 if (
t > 0x7fffffffffffffff)
1341 "# %a %b %d %H:%M:%S %Y",
1343 (
snprintf(buf,
sizeof(buf),
"epoch %lu; %s",
1351 if (
strftime(buf,
sizeof(buf),
"%w %Y/%m/%d %H:%M:%S;",
1428 int format,
const char *
file,
int line) {
1464 log_fatal(
"Failed to get realpath for %s: %s",
1471 log_fatal(
"No memory for filename:%s\n",
void data_string_forget(struct data_string *data, const char *file, int line)
const char * pretty_print_option(struct option *option, const unsigned char *data, unsigned len, int emit_commas, int emit_quotes)
void option_space_foreach(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
char * format_lease_id(const unsigned char *s, unsigned len, int format, const char *file, int line)
int token_indent_data_string(FILE *file, int col, int indent, const char *prefix, const char *suffix, struct data_string *data)
char * print_dec_1(unsigned long val)
int token_print_indent_concat(FILE *file, int col, int indent, const char *prefix, const char *suffix,...)
void print_expression(char *name, struct expression *expr) const
char * quotify_string(const char *s, const char *file, int line)
char * print_dotted_quads(unsigned len, const u_int8_t *data)
char * print_hex(unsigned len, const u_int8_t *data, unsigned limit, unsigned buf_num)
void indent_spaces(FILE *file, int indent)
void hash_dump(struct hash_table *table)
char * print_dec_2(unsigned long val)
char * buf_to_hex(const unsigned char *s, unsigned len, const char *file, int line)
char * print_base64(const unsigned char *buf, unsigned len, const char *file, int line)
void print_lease(struct lease *lease)
void print_hex_or_string(unsigned len, const u_int8_t *data, unsigned limit, char *buf)
char * quotify_buf(const unsigned char *s, unsigned len, char enclose_char, const char *file, int line)
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
char * absolute_path(const char *orgpath)
const char * print_time(TIME t)
int token_print_indent(FILE *file, int col, int indent, const char *prefix, const char *suffix, const char *buf)
void print_hex_only(unsigned len, const u_int8_t *data, unsigned limit, char *buf)
void dump_raw(unsigned char *buf, unsigned len) const
#define DEFAULT_TIME_FORMAT
void dump_packet_option(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *)
void dump_packet(struct packet *)
#define LOCAL_TIME_FORMAT
struct universe dhcp_universe
#define print_hex_1(len, data, limit)
struct iaddr ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address)
const char * piaddr(const struct iaddr addr)
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
const unsigned char * data
unsigned char options[DHCP_MAX_OPTION_LEN]
char sname[DHCP_SNAME_LEN]
union expression::expr_union data
struct hash_bucket * next
const unsigned char * name
struct string_list * next
struct universe ** universes
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
struct binding_scope * global_scope
@ expr_variable_reference
struct expression * rrname
struct dns_host_entry * host_lookup
struct expression::expr_union::@22 dns_transaction
struct expression * extract_int
struct expression * ucase
struct expression::expr_union::@25 arg
struct expression * rrdata
struct collection * check
struct expression * arglist
struct expression::expr_union::@19 b2a
struct expression * encode_int
struct expression::expr_union::@20 reverse
struct data_string encapsulate
struct expression * and[2]
struct expression * separator
struct expression::expr_union::@17 suffix
struct expression::expr_union::@16 substring
struct expression * lcase
struct expression::expr_union::@18 packet
struct expression::expr_union::@21 pick_first_value
struct data_string const_data
struct expression::expr_union::@23 ns_add
struct expression * offset
struct expression * width
struct expression * buffer
struct expression * concat[2]
struct expression * equal[2]
struct expression::expr_union::@26 funcall