Lines Matching +full:no +full:- +full:srv +full:- +full:ipv4 +full:- +full:single +full:- +full:target
1 /* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
39 /* options which don't have a one-char version */
86 {"no-hosts", 0, 0, 'h'},
87 {"no-poll", 0, 0, 'n'},
89 {"no-daemon", 0, 0, 'd'},
90 {"log-queries", 0, 0, 'q'},
93 {"resolv-file", 2, 0, 'r'},
94 {"mx-host", 1, 0, 'm'},
95 {"mx-target", 1, 0, 't'},
96 {"cache-size", 2, 0, 'c'},
98 {"dhcp-leasefile", 2, 0, 'l'},
99 {"dhcp-lease", 1, 0, 'l'},
100 {"dhcp-host", 1, 0, 'G'},
101 {"dhcp-range", 1, 0, 'F'},
102 {"dhcp-option", 1, 0, 'O'},
103 {"dhcp-boot", 1, 0, 'M'},
105 {"domain-suffix", 1, 0, 's'},
107 {"listen-address", 1, 0, 'a'},
108 {"bogus-priv", 0, 0, 'b'},
109 {"bogus-nxdomain", 1, 0, 'B'},
112 {"pid-file", 2, 0, 'x'},
113 {"strict-order", 0, 0, 'o'},
117 {"conf-file", 2, 0, 'C'},
118 {"no-resolv", 0, 0, 'R'},
119 {"expand-hosts", 0, 0, 'E'},
121 {"local-ttl", 1, 0, 'T'},
122 {"no-negcache", 0, 0, 'N'},
123 {"addn-hosts", 1, 0, 'H'},
124 {"query-port", 1, 0, 'Q'},
125 {"except-interface", 1, 0, 'I'},
126 {"no-dhcp-interface", 1, 0, '2'},
127 {"domain-needed", 0, 0, 'D'},
128 {"dhcp-lease-max", 1, 0, 'X'},
129 {"bind-interfaces", 0, 0, 'z'},
131 {"dhcp-vendorclass", 1, 0, 'U'},
132 {"dhcp-userclass", 1, 0, 'j'},
133 {"dhcp-ignore", 1, 0, 'J'},
134 {"edns-packet-max", 1, 0, 'P'},
135 {"keep-in-foreground", 0, 0, 'k'},
136 {"dhcp-authoritative", 0, 0, 'K'},
137 {"srv-host", 1, 0, 'W'},
138 {"localise-queries", 0, 0, 'y'},
139 {"txt-record", 1, 0, 'Y'},
140 {"enable-dbus", 0, 0, '1'},
141 {"bootp-dynamic", 2, 0, '3'},
142 {"dhcp-mac", 1, 0, '4'},
143 {"no-ping", 0, 0, '5'},
144 {"dhcp-script", 1, 0, '6'},
145 {"conf-dir", 1, 0, '7'},
146 {"log-facility", 1, 0, '8'},
147 {"leasefile-ro", 0, 0, '9'},
148 {"dns-forward-max", 1, 0, '0'},
149 {"clear-on-reload", 0, 0, LOPT_RELOAD},
150 {"dhcp-ignore-names", 2, 0, LOPT_NO_NAMES},
151 {"enable-tftp", 0, 0, LOPT_TFTP},
152 {"tftp-secure", 0, 0, LOPT_SECURE},
153 {"tftp-unique-root", 0, 0, LOPT_APREF},
154 {"tftp-root", 1, 0, LOPT_PREFIX},
155 {"tftp-max", 1, 0, LOPT_TFTP_MAX},
156 {"ptr-record", 1, 0, LOPT_PTR},
157 {"naptr-record", 1, 0, LOPT_NAPTR},
158 {"bridge-interface", 1, 0, LOPT_BRIDGE},
159 {"dhcp-option-force", 1, 0, LOPT_FORCE},
160 {"tftp-no-blocksize", 0, 0, LOPT_NOBLOCK},
161 {"log-dhcp", 0, 0, LOPT_LOG_OPTS},
162 {"log-async", 2, 0, LOPT_MAX_LOGS},
163 {"dhcp-circuitid", 1, 0, LOPT_CIRCUIT},
164 {"dhcp-remoteid", 1, 0, LOPT_REMOTE},
165 {"dhcp-subscrid", 1, 0, LOPT_SUBSCR},
166 {"interface-name", 1, 0, LOPT_INTNAME},
167 {"dhcp-hostsfile", 1, 0, LOPT_DHCP_HOST},
168 {"dhcp-optsfile", 1, 0, LOPT_DHCP_OPTS},
169 {"dhcp-no-override", 0, 0, LOPT_OVERRIDE},
170 {"tftp-port-range", 1, 0, LOPT_TFTPPORTS},
171 {"stop-dns-rebind", 0, 0, LOPT_REBIND},
172 {"all-servers", 0, 0, LOPT_NOLAST},
173 {"dhcp-match", 1, 0, LOPT_MATCH},
174 {"dhcp-broadcast", 1, 0, LOPT_BROADCAST},
175 {"neg-ttl", 1, 0, LOPT_NEGTTL},
176 {"dhcp-alternate-port", 2, 0, LOPT_ALTPORT},
177 {"dhcp-scriptuser", 1, 0, LOPT_SCRIPTUSR},
178 {"min-port", 1, 0, LOPT_MINPORT},
179 {"dhcp-fqdn", 0, 0, LOPT_DHCP_FQDN},
181 {"pxe-prompt", 1, 0, LOPT_PXE_PROMT},
182 {"pxe-service", 1, 0, LOPT_PXE_SERV},
184 {"listen-mark", 1, 0, LOPT_LISTNMARK},
214 … {'D', OPT_NODOTS_LOCAL, NULL, gettext_noop("Do NOT forward queries with no domain part."), NULL},
215 {'e', OPT_SELFMX, NULL, gettext_noop("Return self-pointing MX records for local hosts."), NULL},
216 {'E', OPT_EXPAND, NULL, gettext_noop("Expand simple names in /etc/hosts with domain-suffix."),
234 … {LOPT_CIRCUIT, ARG_DUP, "<tag>,<circuit>", gettext_noop("Map RFC3046 circuit-id to tag."), NULL},
235 {LOPT_REMOTE, ARG_DUP, "<tag>,<remote>", gettext_noop("Map RFC3046 remote-id to tag."), NULL},
236 {LOPT_SUBSCR, ARG_DUP, "<tag>,<remote>", gettext_noop("Map RFC3993 subscriber-id to tag."),
248 {'m', ARG_DUP, "host_name,target,pref", gettext_noop("Specify an MX record."), NULL},
274 {'t', ARG_ONE, "host_name", gettext_noop("Specify default target in an MX record."), NULL},
276 gettext_noop("Specify time-to-live in seconds for replies from /etc/hosts."), NULL},
278 gettext_noop("Specify time-to-live in seconds for negative caching."), NULL},
284 gettext_noop("Translate IPv4 addresses from upstream servers."), NULL},
285 {'W', ARG_DUP, "name,target,...", gettext_noop("Specify a SRV record."), NULL},
286 {'w', 0, NULL, gettext_noop("Display this message. Use --help dhcp for known DHCP options."),
294 {LOPT_PTR, ARG_DUP, "name,target", gettext_noop("Specify PTR DNS record."), NULL},
296 gettext_noop("Give DNS name to IPv4 address of interface."), NULL},
324 {LOPT_TFTP, OPT_TFTP, NULL, gettext_noop("Enable integrated read-only TFTP server."), NULL},
327 {LOPT_APREF, OPT_TFTP_APREF, NULL, gettext_noop("Add client IP address to tftp-root."), NULL},
346 {LOPT_SCRIPTUSR, ARG_ONE, "<username>", gettext_noop("Run lease-change script as this user."),
353 {LOPT_CNAME, ARG_DUP, "<alias>,<target>",
365 /* DHCP-internal options, for logging. not valid in config file */
373 {"time-offset", 2, 4},
375 {"dns-server", 6, OT_ADDR_LIST},
376 {"log-server", 7, OT_ADDR_LIST},
377 {"lpr-server", 9, OT_ADDR_LIST},
379 {"boot-file-size", 13, 2},
380 {"domain-name", 15, OT_NAME},
381 {"swap-server", 16, OT_ADDR_LIST},
382 {"root-path", 17, 0},
383 {"extension-path", 18, 0},
384 {"ip-forward-enable", 19, 1},
385 {"non-local-source-routing", 20, 1},
386 {"policy-filter", 21, OT_ADDR_LIST},
387 {"max-datagram-reassembly", 22, 2},
388 {"default-ttl", 23, 1},
390 {"all-subnets-local", 27, 1},
392 {"router-discovery", 31, 1},
393 {"router-solicitation", 32, OT_ADDR_LIST},
394 {"static-route", 33, OT_ADDR_LIST},
395 {"trailer-encapsulation", 34, 1},
396 {"arp-timeout", 35, 4},
397 {"ethernet-encap", 36, 1},
398 {"tcp-ttl", 37, 1},
399 {"tcp-keepalive", 38, 4},
400 {"nis-domain", 40, 0},
401 {"nis-server", 41, OT_ADDR_LIST},
402 {"ntp-server", 42, OT_ADDR_LIST},
403 {"vendor-encap", 43, OT_INTERNAL},
404 {"netbios-ns", 44, OT_ADDR_LIST},
405 {"netbios-dd", 45, OT_ADDR_LIST},
406 {"netbios-nodetype", 46, 1},
407 {"netbios-scope", 47, 0},
408 {"x-windows-fs", 48, OT_ADDR_LIST},
409 {"x-windows-dm", 49, OT_ADDR_LIST},
410 {"requested-address", 50, OT_INTERNAL | OT_ADDR_LIST},
411 {"lease-time", 51, OT_INTERNAL},
412 {"option-overload", 52, OT_INTERNAL},
414 "message-type",
418 {"server-identifier", 54, OT_INTERNAL | OT_ADDR_LIST},
419 {"parameter-request", 55, OT_INTERNAL},
421 {"max-message-size", 57, OT_INTERNAL},
424 {"vendor-class", 60, 0},
425 {"client-id", 61, OT_INTERNAL},
426 {"nis+-domain", 64, 0},
427 {"nis+-server", 65, OT_ADDR_LIST},
428 {"tftp-server", 66, 0},
429 {"bootfile-name", 67, 0},
430 {"mobile-ip-home", 68, OT_ADDR_LIST},
431 {"smtp-server", 69, OT_ADDR_LIST},
432 {"pop3-server", 70, OT_ADDR_LIST},
433 {"nntp-server", 71, OT_ADDR_LIST},
434 {"irc-server", 74, OT_ADDR_LIST},
435 {"user-class", 77, 0},
437 {"agent-id", 82, OT_INTERNAL},
438 {"client-arch", 93, 2},
439 {"client-interface-id", 94, 0},
440 {"client-machine-id", 97, 0},
441 {"subnet-select", 118, OT_INTERNAL},
442 {"domain-search", 119, 0},
443 {"sip-server", 120, 0},
444 {"classless-static-route", 121, 0},
445 {"server-ip-address", 255, OT_ADDR_LIST}, /* special, internal only, sets siaddr */
470 --dhcp-option=3, string
472 --dhcp-option=3," string"
481 for (i = 0; i < (sizeof(meta) - 1); i++) in hide_meta()
490 if (c < (sizeof(meta) - 1)) cr = meta[c]; in unhide_meta()
540 for (; (p >= s) && isspace((int) *p); p--) *p = 0; in split_chr()
590 r->name = opt_string_alloc(name); in add_txt()
591 r->next = daemon->txt; in add_txt()
592 daemon->txt = r; in add_txt()
593 r->class = C_CHAOS; in add_txt()
594 r->txt = opt_malloc(len + 1); in add_txt()
595 r->len = len + 1; in add_txt()
596 *(r->txt) = len; in add_txt()
597 memcpy((r->txt) + 1, txt, len); in add_txt()
626 sprintf(buff, "-%c, ", usage[i].opt); in do_usage()
630 sprintf(buff + 4, "--%s%s%s", opts[j].name, eq, desc); in do_usage()
631 printf("%-36.36s", buff); in do_usage()
653 /* This is too insanely large to keep in-line in the switch */
662 new->len = 0; in parse_dhcp_opt()
663 new->flags = flags; in parse_dhcp_opt()
664 new->netid = NULL; in parse_dhcp_opt()
665 new->val = NULL; in parse_dhcp_opt()
666 new->opt = 0; in parse_dhcp_opt()
675 new->opt = atoi(arg); in parse_dhcp_opt()
683 new->opt = opttab[i].val; in parse_dhcp_opt()
690 new->u.vendor_class = (unsigned char*) opt_string_alloc(arg + 7); in parse_dhcp_opt()
691 new->flags |= DHOPT_VENDOR; in parse_dhcp_opt()
693 new->u.encap = atoi(arg + 6); in parse_dhcp_opt()
694 new->flags |= DHOPT_ENCAPSULATE; in parse_dhcp_opt()
696 new->netid = opt_malloc(sizeof(struct dhcp_netid)); in parse_dhcp_opt()
699 new->netid->net = opt_string_alloc(arg + 4); in parse_dhcp_opt()
701 new->netid->net = opt_string_alloc(arg); in parse_dhcp_opt()
702 new->netid->next = np; in parse_dhcp_opt()
703 np = new->netid; in parse_dhcp_opt()
709 if (new->opt == 0) in parse_dhcp_opt()
710 problem = _("bad dhcp-option"); in parse_dhcp_opt()
731 } else if (c == '-') in parse_dhcp_opt()
755 new->len = digs; in parse_dhcp_opt()
756 new->val = opt_malloc(new->len); in parse_dhcp_opt()
757 parse_hex(comma, new->val, digs, (flags & DHOPT_MATCH) ? &new->u.wildcard_mask : NULL, in parse_dhcp_opt()
759 new->flags |= DHOPT_HEX; in parse_dhcp_opt()
766 new->len = opt_len; in parse_dhcp_opt()
768 new->len = 4; in parse_dhcp_opt()
770 new->len = 2; in parse_dhcp_opt()
772 new->len = 1; in parse_dhcp_opt()
775 new->len = 1; in parse_dhcp_opt()
777 new->len = 2; in parse_dhcp_opt()
779 new->len = 4; in parse_dhcp_opt()
781 new->val = opt_malloc(new->len); in parse_dhcp_opt()
782 for (i = 0; i < new->len; i++) new->val[i] = val >> ((new->len - i - 1) * 8); in parse_dhcp_opt()
789 new->val = op = opt_malloc((5 * addrs) + 1); in parse_dhcp_opt()
790 new->flags |= DHOPT_ADDR; in parse_dhcp_opt()
792 if (!(new->flags& DHOPT_ENCAPSULATE) && new->opt == 120) { in parse_dhcp_opt()
794 new->flags &= ~DHOPT_ADDR; in parse_dhcp_opt()
796 while (addrs--) { in parse_dhcp_opt()
812 new->flags &= ~DHOPT_ADDR; /* cannot re-write descriptor format */ in parse_dhcp_opt()
815 new->len = op - new->val; in parse_dhcp_opt()
818 if ((new->opt == 119 || new->opt == 120) && !(new->flags& DHOPT_ENCAPSULATE)) { in parse_dhcp_opt()
823 int header_size = (new->opt == 119) ? 0 : 1; in parse_dhcp_opt()
831 problem = _("bad domain in dhcp-option"); in parse_dhcp_opt()
852 /* Now tail-compress using earlier names. */ in parse_dhcp_opt()
853 newlen = q - p; in parse_dhcp_opt()
855 for (r = p; r - p < (int) len; r += (*r) + 1) in parse_dhcp_opt()
857 PUTSHORT((r - p) | 0xc000, tail); in parse_dhcp_opt()
858 newlen = tail - p; in parse_dhcp_opt()
869 if (new->opt == 120) m[0] = 0; in parse_dhcp_opt()
870 new->len = (int) len + header_size; in parse_dhcp_opt()
871 new->val = m; in parse_dhcp_opt()
873 new->len = strlen(comma); in parse_dhcp_opt()
875 new->val = (unsigned char*) opt_string_alloc(comma); in parse_dhcp_opt()
876 new->flags |= DHOPT_STRING; in parse_dhcp_opt()
881 if ((new->len > 255) || (new->len > 253 && (new->flags&(DHOPT_VENDOR | DHOPT_ENCAPSULATE)))) in parse_dhcp_opt()
882 problem = _("dhcp-option too long"); in parse_dhcp_opt()
886 if ((new->flags&(DHOPT_ENCAPSULATE | DHOPT_VENDOR)) || !new->netid || new->netid->next) in parse_dhcp_opt()
887 problem = _("illegal dhcp-match"); in parse_dhcp_opt()
889 new->next = daemon->dhcp_match; in parse_dhcp_opt()
890 daemon->dhcp_match = new; in parse_dhcp_opt()
893 new->next = daemon->dhcp_opts; in parse_dhcp_opt()
894 daemon->dhcp_opts = new; in parse_dhcp_opt()
925 daemon->options |= rept; in one_opt()
933 case 'C': /* --conf-file */ in one_opt()
943 case '7': /* --conf-dir */ in one_opt()
959 li->next = ignore_suffix; in one_opt()
962 li->suffix = opt_string_alloc(arg); in one_opt()
969 size_t len = strlen(ent->d_name); in one_opt()
973 if (len == 0 || ent->d_name[len - 1] == '~' || in one_opt()
974 (ent->d_name[0] == '#' && ent->d_name[len - 1] == '#') || ent->d_name[0] == '.') in one_opt()
977 for (li = ignore_suffix; li; li = li->next) { in one_opt()
979 size_t ls = strlen(li->suffix); in one_opt()
980 if (len > ls && strcmp(li->suffix, &ent->d_name[len - ls]) == 0) break; in one_opt()
987 strcat(path, ent->d_name); in one_opt()
989 if (stat(path, &buf) == -1) die(_("cannot access %s: %s"), path, EC_FILE); in one_opt()
1001 li = ignore_suffix->next; in one_opt()
1002 free(ignore_suffix->suffix); in one_opt()
1009 case '8': /* --log-facility */ in one_opt()
1012 daemon->log_file = opt_string_alloc(arg); in one_opt()
1021 daemon->log_fac = facilitynames[i].c_val; in one_opt()
1028 case 'x': /* --pid-file */ in one_opt()
1029 daemon->runfile = opt_string_alloc(arg); in one_opt()
1032 case LOPT_DHCP_HOST: /* --dhcp-hostfile */ in one_opt()
1033 if (daemon->dhcp_hosts_file) in one_opt()
1034 problem = _("only one dhcp-hostsfile allowed"); in one_opt()
1036 daemon->dhcp_hosts_file = opt_string_alloc(arg); in one_opt()
1039 case LOPT_DHCP_OPTS: /* --dhcp-optsfile */ in one_opt()
1040 if (daemon->dhcp_opts_file) in one_opt()
1041 problem = _("only one dhcp-optsfile allowed"); in one_opt()
1043 daemon->dhcp_opts_file = opt_string_alloc(arg); in one_opt()
1046 case 'r': /* --resolv-file */ in one_opt()
1049 struct resolvc* new, *list = daemon->resolv_files; in one_opt()
1051 if (list && list->is_default) { in one_opt()
1052 /* replace default resolv file - possibly with nothing */ in one_opt()
1054 list->is_default = 0; in one_opt()
1055 list->name = name; in one_opt()
1060 new->next = list; in one_opt()
1061 new->name = name; in one_opt()
1062 new->is_default = 0; in one_opt()
1063 new->mtime = 0; in one_opt()
1064 new->logged = 0; in one_opt()
1067 daemon->resolv_files = list; in one_opt()
1071 case 'm': /* --mx-host */ in one_opt()
1075 char *name, *target = NULL; in one_opt() local
1083 if (!(name = canonicalise_opt(arg)) || (comma && !(target = canonicalise_opt(comma)))) in one_opt()
1087 new->next = daemon->mxnames; in one_opt()
1088 daemon->mxnames = new; in one_opt()
1089 new->issrv = 0; in one_opt()
1090 new->name = name; in one_opt()
1091 new->target = target; /* may be NULL */ in one_opt()
1092 new->weight = pref; in one_opt()
1096 case 't': /* --mx-target */ in one_opt()
1097 if (!(daemon->mxtarget = canonicalise_opt(arg))) problem = _("bad MX target"); in one_opt()
1101 case 'l': /* --dhcp-leasefile */ in one_opt()
1102 daemon->lease_file = opt_string_alloc(arg); in one_opt()
1105 case '6': /* --dhcp-script */ in one_opt()
1109 problem = _("recompile with HAVE_SCRIPT defined to enable lease-change scripts"); in one_opt()
1111 daemon->lease_change_command = opt_string_alloc(arg); in one_opt()
1116 case 'H': /* --addn-hosts */ in one_opt()
1120 new->fname = opt_string_alloc(arg); in one_opt()
1121 new->index = hosts_index++; in one_opt()
1122 new->flags = 0; in one_opt()
1123 new->next = daemon->addn_hosts; in one_opt()
1124 daemon->addn_hosts = new; in one_opt()
1128 case 's': /* --domain */ in one_opt()
1130 daemon->options |= OPT_RESOLV_DOMAIN; in one_opt()
1142 if ((new->start.s_addr = inet_addr(comma)) == (in_addr_t) -1 || in one_opt()
1146 mask = (1 << (32 - mask)) - 1; in one_opt()
1147 new->start.s_addr = ntohl(htonl(new->start.s_addr) & ~mask); in one_opt()
1148 new->end.s_addr = new->start.s_addr | htonl(mask); in one_opt()
1151 if ((new->start.s_addr = inet_addr(comma)) == (in_addr_t) -1 || in one_opt()
1152 (new->end.s_addr = inet_addr(arg)) == (in_addr_t) -1) in one_opt()
1154 } else if ((new->start.s_addr = new->end.s_addr = inet_addr(comma)) == in one_opt()
1155 (in_addr_t) -1) in one_opt()
1158 new->domain = d; in one_opt()
1159 new->next = daemon->cond_domain; in one_opt()
1160 daemon->cond_domain = new; in one_opt()
1162 daemon->domain_suffix = d; in one_opt()
1167 case 'u': /* --user */ in one_opt()
1168 daemon->username = opt_string_alloc(arg); in one_opt()
1171 case 'g': /* --group */ in one_opt()
1172 daemon->groupname = opt_string_alloc(arg); in one_opt()
1173 daemon->group_set = 1; in one_opt()
1177 case LOPT_SCRIPTUSR: /* --scriptuser */ in one_opt()
1178 daemon->scriptuser = opt_string_alloc(arg); in one_opt()
1182 case 'i': /* --interface */ in one_opt()
1186 new->next = daemon->if_names; in one_opt()
1187 daemon->if_names = new; in one_opt()
1188 /* new->name may be NULL if someone does in one_opt()
1190 new->name = opt_string_alloc(arg); in one_opt()
1191 new->isloop = new->used = 0; in one_opt()
1196 case 'I': /* --except-interface */ in one_opt()
1197 case '2': /* --no-dhcp-interface */ in one_opt()
1201 new->name = opt_string_alloc(arg); in one_opt()
1203 new->next = daemon->if_except; in one_opt()
1204 daemon->if_except = new; in one_opt()
1206 new->next = daemon->dhcp_except; in one_opt()
1207 daemon->dhcp_except = new; in one_opt()
1213 case 'B': /* --bogus-nxdomain */ in one_opt()
1217 if (arg && (addr.s_addr = inet_addr(arg)) != (in_addr_t) -1) { in one_opt()
1219 baddr->next = daemon->bogus_addr; in one_opt()
1220 daemon->bogus_addr = baddr; in one_opt()
1221 baddr->addr = addr; in one_opt()
1227 case 'a': /* --listen-address */ in one_opt()
1232 new->next = daemon->if_addrs; in one_opt()
1233 if (arg && parse_addr(AF_INET, arg, &new->addr) != 0 && in one_opt()
1234 parse_addr(AF_INET6, arg, &new->addr) != 0) { in one_opt()
1239 daemon->if_addrs = new; in one_opt()
1244 case 'S': /* --server */ in one_opt()
1245 case LOPT_LOCAL: /* --local */ in one_opt()
1246 case 'A': /* --address */ in one_opt()
1264 serv->next = newlist; in one_opt()
1266 serv->domain = domain; in one_opt()
1267 serv->flags = domain ? SERV_HAS_DOMAIN : SERV_FOR_NODOTS; in one_opt()
1281 newlist->flags |= SERV_LITERAL_ADDRESS; in one_opt()
1282 if (!(newlist->flags & SERV_TYPE)) option = '?'; in one_opt()
1286 newlist->flags |= SERV_NO_ADDR; /* no server */ in one_opt()
1287 if (newlist->flags & SERV_LITERAL_ADDRESS) option = '?'; in one_opt()
1296 if ((portno = split_chr(arg, '#')) && /* is there a port no. */ in one_opt()
1300 if (parse_addr(AF_INET, arg, &newlist->addr) == 0) { in one_opt()
1301 newlist->addr.in.sin_port = htons(serv_port); in one_opt()
1303 newlist->flags |= SERV_HAS_SOURCE; in one_opt()
1304 if (parse_addr(AF_INET, source, &newlist->addr) != 0) { in one_opt()
1306 newlist->source_addr.in.sin_addr.s_addr = INADDR_ANY; in one_opt()
1307 strncpy(newlist->interface, source, IF_NAMESIZE); in one_opt()
1313 newlist->source_addr.in.sin_addr.s_addr = INADDR_ANY; in one_opt()
1315 newlist->source_addr.in.sin_port = htons(source_port); in one_opt()
1316 newlist->source_addr.sa.sa_family = AF_INET; in one_opt()
1319 else if (parse_addr(AF_INET6, arg, &newlist->addr) == 0) { in one_opt()
1320 newlist->addr.in6.sin6_port = htons(serv_port); in one_opt()
1322 newlist->flags |= SERV_HAS_SOURCE; in one_opt()
1323 if (parse_addr(AF_INET6, source, &newlist->source_addr) != 0) { in one_opt()
1325 newlist->source_addr.in6.sin6_addr = in6addr_any; in one_opt()
1326 strncpy(newlist->interface, source, IF_NAMESIZE); in one_opt()
1332 newlist->source_addr.in6.sin6_addr = in6addr_any; in one_opt()
1334 newlist->source_addr.in6.sin6_port = htons(source_port); in one_opt()
1335 newlist->source_addr.sa.sa_family = AF_INET6; in one_opt()
1343 while (serv->next) { in one_opt()
1344 serv->next->flags = serv->flags; in one_opt()
1345 serv->next->addr = serv->addr; in one_opt()
1346 serv->next->source_addr = serv->source_addr; in one_opt()
1347 serv = serv->next; in one_opt()
1349 serv->next = daemon->servers; in one_opt()
1350 daemon->servers = newlist; in one_opt()
1354 case 'c': /* --cache-size */ in one_opt()
1361 /* zero is OK, and means no caching. */ in one_opt()
1368 daemon->cachesize = size; in one_opt()
1373 case 'p': /* --port */ in one_opt()
1374 if (!atoi_check16(arg, &daemon->port)) option = '?'; in one_opt()
1377 case LOPT_MINPORT: /* --min-port */ in one_opt()
1378 if (!atoi_check16(arg, &daemon->min_port)) option = '?'; in one_opt()
1381 case '0': /* --dns-forward-max */ in one_opt()
1382 if (!atoi_check(arg, &daemon->ftabsize)) option = '?'; in one_opt()
1385 case LOPT_MAX_LOGS: /* --log-async */ in one_opt()
1386 daemon->max_logs = LOG_MAX; /* default */ in one_opt()
1387 if (arg && !atoi_check(arg, &daemon->max_logs)) in one_opt()
1389 else if (daemon->max_logs > 100) in one_opt()
1390 daemon->max_logs = 100; in one_opt()
1393 case 'P': /* --edns-packet-max */ in one_opt()
1397 daemon->edns_pktsz = (unsigned short) i; in one_opt()
1401 case 'Q': /* --query-port */ in one_opt()
1402 if (!atoi_check16(arg, &daemon->query_port)) option = '?'; in one_opt()
1403 /* if explicitly set to zero, use single OS ephemeral port in one_opt()
1405 if (daemon->query_port == 0) daemon->osport = 1; in one_opt()
1408 case 'T': /* --local-ttl */ in one_opt()
1409 case LOPT_NEGTTL: /* --neg-ttl */ in one_opt()
1415 daemon->neg_ttl = (unsigned long) ttl; in one_opt()
1417 daemon->local_ttl = (unsigned long) ttl; in one_opt()
1422 case 'X': /* --dhcp-lease-max */ in one_opt()
1423 if (!atoi_check(arg, &daemon->dhcp_max)) option = '?'; in one_opt()
1427 case LOPT_BRIDGE: /* --bridge-interface */ in one_opt()
1431 problem = _("bad bridge-interface"); in one_opt()
1435 strncpy(new->iface, arg, IF_NAMESIZE); in one_opt()
1436 new->alias = NULL; in one_opt()
1437 new->next = daemon->bridges; in one_opt()
1438 daemon->bridges = new; in one_opt()
1445 b->next = new->alias; in one_opt()
1446 new->alias = b; in one_opt()
1447 strncpy(b->iface, arg, IF_NAMESIZE); in one_opt()
1455 case 'F': /* --dhcp-range */ in one_opt()
1461 new->next = daemon->dhcp; in one_opt()
1462 new->lease_time = DEFLEASE; in one_opt()
1463 new->addr_epoch = 0; in one_opt()
1464 new->netmask.s_addr = 0; in one_opt()
1465 new->broadcast.s_addr = 0; in one_opt()
1466 new->router.s_addr = 0; in one_opt()
1467 new->netid.net = NULL; in one_opt()
1468 new->filter = NULL; in one_opt()
1469 new->flags = 0; in one_opt()
1471 gen_prob = _("bad dhcp-range"); in one_opt()
1485 tt->net = opt_string_alloc(arg + 4); in one_opt()
1486 tt->next = new->filter; in one_opt()
1487 new->filter = tt; in one_opt()
1489 if (new->netid.net) in one_opt()
1492 new->netid.net = opt_string_alloc(arg); in one_opt()
1502 if (!(a[k] = split(a[k - 1]))) break; in one_opt()
1504 if ((k < 2) || ((new->start.s_addr = inet_addr(a[0])) == (in_addr_t) -1)) in one_opt()
1507 new->end = new->start; in one_opt()
1508 new->flags |= CONTEXT_STATIC; in one_opt()
1510 new->end = new->start; in one_opt()
1511 new->flags |= CONTEXT_PROXY; in one_opt()
1512 } else if ((new->end.s_addr = inet_addr(a[1])) == (in_addr_t) -1) in one_opt()
1515 if (ntohl(new->start.s_addr) > ntohl(new->end.s_addr)) { in one_opt()
1516 struct in_addr tmp = new->start; in one_opt()
1517 new->start = new->end; in one_opt()
1518 new->end = tmp; in one_opt()
1522 ((new->netmask.s_addr = inet_addr(a[2])) != (in_addr_t) -1)) { in one_opt()
1523 new->flags |= CONTEXT_NETMASK; in one_opt()
1525 if (!is_same_net(new->start, new->end, new->netmask)) in one_opt()
1528 daemon->dhcp = new; in one_opt()
1531 ((new->broadcast.s_addr = inet_addr(a[3])) != (in_addr_t) -1)) { in one_opt()
1532 new->flags |= CONTEXT_BRDCAST; in one_opt()
1538 new->lease_time = 0xffffffff; in one_opt()
1542 switch (a[leasepos][strlen(a[leasepos]) - 1]) { in one_opt()
1557 a[leasepos][strlen(a[leasepos]) - 1] = 0; in one_opt()
1560 new->lease_time = atoi(a[leasepos]) * fac; in one_opt()
1563 if (new->lease_time < 120) new->lease_time = 120; in one_opt()
1571 case 'G': /* --dhcp-host */ in one_opt()
1580 new->next = daemon->dhcp_conf; in one_opt()
1581 new->flags = (option == LOPT_BANK) ? CONFIG_BANK : 0; in one_opt()
1582 new->hwaddr = NULL; in one_opt()
1586 if (!(a[k] = split(a[k - 1]))) break; in one_opt()
1596 new->flags |= CONFIG_NOCLID; in one_opt()
1601 len = parse_hex(arg, (unsigned char*) arg, -1, NULL, NULL); in one_opt()
1607 if ((new->clid = opt_malloc(len))) { in one_opt()
1608 new->flags |= CONFIG_CLID; in one_opt()
1609 new->clid_len = len; in one_opt()
1610 memcpy(new->clid, arg, len); in one_opt()
1615 if ((new->netid.net = opt_malloc(len))) { in one_opt()
1616 new->flags |= CONFIG_NETID; in one_opt()
1617 strcpy(new->netid.net, arg + 4); in one_opt()
1618 unhide_metas(new->netid.net); in one_opt()
1622 newhw->next = new->hwaddr; in one_opt()
1623 new->hwaddr = newhw; in one_opt()
1624 newhw->hwaddr_len = parse_hex(a[j], newhw->hwaddr, DHCP_CHADDR_MAX, in one_opt()
1625 &newhw->wildcard_mask, &newhw->hwaddr_type); in one_opt()
1627 } else if (strchr(a[j], '.') && (in.s_addr = inet_addr(a[j])) != (in_addr_t) -1) { in one_opt()
1628 new->addr = in; in one_opt()
1629 new->flags |= CONFIG_ADDR; in one_opt()
1635 lastp = a[j] + strlen(a[j]) - 1; in one_opt()
1662 new->lease_time = 0xffffffff; in one_opt()
1663 new->flags |= CONFIG_TIME; in one_opt()
1665 new->flags |= CONFIG_DISABLE; in one_opt()
1667 if (!(new->hostname = canonicalise_opt(a[j])) || in one_opt()
1668 !legal_hostname(new->hostname)) in one_opt()
1671 new->flags |= CONFIG_NAME; in one_opt()
1672 new->domain = NULL; in one_opt()
1675 new->lease_time = atoi(a[j]) * fac; in one_opt()
1678 if (new->lease_time < 120) new->lease_time = 120; in one_opt()
1679 new->flags |= CONFIG_TIME; in one_opt()
1683 daemon->dhcp_conf = new; in one_opt()
1687 case 'O': /* --dhcp-option */ in one_opt()
1688 case LOPT_FORCE: /* --dhcp-option-force */ in one_opt()
1690 case LOPT_MATCH: /* --dhcp-match */ in one_opt()
1698 case 'M': /* --dhcp-boot */ in one_opt()
1703 newid->next = id; in one_opt()
1706 newid->net = opt_string_alloc(arg + 4); in one_opt()
1724 if ((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t) -1) in one_opt()
1730 new->file = dhcp_file; in one_opt()
1731 new->sname = dhcp_sname; in one_opt()
1732 new->next_server = dhcp_next_server; in one_opt()
1733 new->netid = id; in one_opt()
1734 new->next = daemon->boot_config; in one_opt()
1735 daemon->boot_config = new; in one_opt()
1742 case LOPT_PXE_PROMT: /* --pxe-prompt */ in one_opt()
1747 new->netid = NULL; in one_opt()
1748 new->opt = 10; /* PXE_MENU_PROMPT */ in one_opt()
1753 nn->next = new->netid; in one_opt()
1754 new->netid = nn; in one_opt()
1755 nn->net = opt_string_alloc(arg + 4); in one_opt()
1764 new->len = strlen(arg) + 1; in one_opt()
1765 new->val = opt_malloc(new->len); in one_opt()
1766 memcpy(new->val + 1, arg, new->len - 1); in one_opt()
1768 new->u.vendor_class = (unsigned char*) "PXEClient"; in one_opt()
1769 new->flags = DHOPT_VENDOR; in one_opt()
1772 *(new->val) = timeout; in one_opt()
1774 *(new->val) = 255; in one_opt()
1776 new->next = daemon->dhcp_opts; in one_opt()
1777 daemon->dhcp_opts = new; in one_opt()
1778 daemon->enable_pxe = 1; in one_opt()
1784 case LOPT_PXE_SERV: /* --pxe-service */ in one_opt()
1789 "IA32_EFI", "BC_EFI", "Xscale_EFI", "x86-64_EFI", NULL}; in one_opt()
1792 new->netid = NULL; in one_opt()
1793 new->server.s_addr = 0; in one_opt()
1798 nn->next = new->netid; in one_opt()
1799 new->netid = nn; in one_opt()
1800 nn->net = opt_string_alloc(arg + 4); in one_opt()
1812 new->CSA = i; in one_opt()
1813 new->menu = opt_string_alloc(arg); in one_opt()
1819 new->type = i; in one_opt()
1820 new->basename = NULL; in one_opt()
1822 new->type = boottype++; in one_opt()
1823 new->basename = opt_string_alloc(arg); in one_opt()
1826 if (comma && (new->server.s_addr = inet_addr(comma)) == (in_addr_t) -1) in one_opt()
1830 new->next = NULL; in one_opt()
1831 if (!daemon->pxe_services) in one_opt()
1832 daemon->pxe_services = new; in one_opt()
1835 for (s = daemon->pxe_services; s->next; s = s->next) in one_opt()
1837 s->next = new; in one_opt()
1840 daemon->enable_pxe = 1; in one_opt()
1850 case '4': /* --dhcp-mac */ in one_opt()
1857 new->netid.net = opt_string_alloc(arg + 4); in one_opt()
1859 new->netid.net = opt_string_alloc(arg); in one_opt()
1861 new->hwaddr_len = in one_opt()
1862 parse_hex(comma, new->hwaddr, DHCP_CHADDR_MAX, &new->mask, &new->hwaddr_type); in one_opt()
1863 new->next = daemon->dhcp_macs; in one_opt()
1864 daemon->dhcp_macs = new; in one_opt()
1868 case 'U': /* --dhcp-vendorclass */ in one_opt()
1869 case 'j': /* --dhcp-userclass */ in one_opt()
1870 case LOPT_CIRCUIT: /* --dhcp-circuitid */ in one_opt()
1871 case LOPT_REMOTE: /* --dhcp-remoteid */ in one_opt()
1872 case LOPT_SUBSCR: /* --dhcp-subscrid */ in one_opt()
1881 new->netid.net = opt_string_alloc(arg + 4); in one_opt()
1883 new->netid.net = opt_string_alloc(arg); in one_opt()
1884 /* check for hex string - must digits may include : must not have nothing else, in one_opt()
1885 only allowed for agent-options. */ in one_opt()
1893 new->len = strlen(comma); in one_opt()
1894 new->data = opt_malloc(new->len); in one_opt()
1895 memcpy(new->data, comma, new->len); in one_opt()
1897 new->len = parse_hex(comma, (unsigned char*) comma, strlen(comma), NULL, NULL); in one_opt()
1898 new->data = opt_malloc(new->len); in one_opt()
1899 memcpy(new->data, comma, new->len); in one_opt()
1904 new->match_type = MATCH_USER; in one_opt()
1907 new->match_type = MATCH_VENDOR; in one_opt()
1910 new->match_type = MATCH_CIRCUIT; in one_opt()
1913 new->match_type = MATCH_REMOTE; in one_opt()
1916 new->match_type = MATCH_SUBSCRIBER; in one_opt()
1919 new->next = daemon->dhcp_vendors; in one_opt()
1920 daemon->dhcp_vendors = new; in one_opt()
1925 case LOPT_ALTPORT: /* --dhcp-alternate-port */ in one_opt()
1927 daemon->dhcp_server_port = DHCP_SERVER_ALTPORT; in one_opt()
1928 daemon->dhcp_client_port = DHCP_CLIENT_ALTPORT; in one_opt()
1931 if (!atoi_check16(arg, &daemon->dhcp_server_port) || in one_opt()
1932 (comma && !atoi_check16(comma, &daemon->dhcp_client_port))) in one_opt()
1934 if (!comma) daemon->dhcp_client_port = daemon->dhcp_server_port + 1; in one_opt()
1938 case 'J': /* --dhcp-ignore */ in one_opt()
1939 case LOPT_NO_NAMES: /* --dhcp-ignore-names */ in one_opt()
1940 case LOPT_BROADCAST: /* --dhcp-broadcast */ in one_opt()
1941 case '3': /* --bootp-dynamic */ in one_opt()
1946 new->next = daemon->dhcp_ignore; in one_opt()
1947 daemon->dhcp_ignore = new; in one_opt()
1949 new->next = daemon->force_broadcast; in one_opt()
1950 daemon->force_broadcast = new; in one_opt()
1952 new->next = daemon->bootp_dynamic; in one_opt()
1953 daemon->bootp_dynamic = new; in one_opt()
1955 new->next = daemon->dhcp_ignore_names; in one_opt()
1956 daemon->dhcp_ignore_names = new; in one_opt()
1962 member->next = list; in one_opt()
1965 member->net = opt_string_alloc(arg + 4); in one_opt()
1967 member->net = opt_string_alloc(arg); in one_opt()
1971 new->list = list; in one_opt()
1976 case 'V': /* --alias */ in one_opt()
1981 new->next = daemon->doctors; in one_opt()
1982 daemon->doctors = new; in one_opt()
1983 new->mask.s_addr = 0xffffffff; in one_opt()
1984 new->end.s_addr = 0; in one_opt()
1988 if (!(a[k] = split(a[k - 1]))) break; in one_opt()
1992 dash = split_chr(a[0], '-'); in one_opt()
1994 if ((k < 2) || ((new->in.s_addr = inet_addr(a[0])) == (in_addr_t) -1) || in one_opt()
1995 ((new->out.s_addr = inet_addr(a[1])) == (in_addr_t) -1)) in one_opt()
1998 if (k == 3) new->mask.s_addr = inet_addr(a[2]); in one_opt()
2000 if (dash && ((new->end.s_addr = inet_addr(dash)) == (in_addr_t) -1 || in one_opt()
2001 !is_same_net(new->in, new->end, new->mask) || in one_opt()
2002 ntohl(new->in.s_addr) > ntohl(new->end.s_addr))) in one_opt()
2008 case LOPT_INTNAME: /* --interface-name */ in one_opt()
2018 new->next = NULL; in one_opt()
2021 for (up = &daemon->int_names; *up; up = &((*up)->next)) in one_opt()
2024 new->name = domain; in one_opt()
2025 new->intr = opt_string_alloc(comma); in one_opt()
2029 case LOPT_CNAME: /* --cname */ in one_opt()
2037 char* target = canonicalise_opt(comma); in one_opt() local
2039 if (!alias || !target) in one_opt()
2042 for (new = daemon->cnames; new; new = new->next) in one_opt()
2043 if (hostname_isequal(new->alias, arg)) problem = _("duplicate CNAME"); in one_opt()
2045 new->next = daemon->cnames; in one_opt()
2046 daemon->cnames = new; in one_opt()
2047 new->alias = alias; in one_opt()
2048 new->target = target; in one_opt()
2054 case LOPT_PTR: /* --ptr-record */ in one_opt()
2057 char *dom, *target = NULL; in one_opt() local
2061 if (!(dom = canonicalise_opt(arg)) || (comma && !(target = canonicalise_opt(comma)))) in one_opt()
2065 new->next = daemon->ptr; in one_opt()
2066 daemon->ptr = new; in one_opt()
2067 new->name = dom; in one_opt()
2068 new->ptr = target; in one_opt()
2073 case LOPT_NAPTR: /* --naptr-record */ in one_opt()
2083 if (!(a[k] = split(a[k - 1]))) break; in one_opt()
2090 new->next = daemon->naptr; in one_opt()
2091 daemon->naptr = new; in one_opt()
2092 new->name = name; in one_opt()
2093 new->flags = opt_string_alloc(a[3]); in one_opt()
2094 new->services = opt_string_alloc(a[4]); in one_opt()
2095 new->regexp = opt_string_alloc(a[5]); in one_opt()
2096 new->replace = replace; in one_opt()
2097 new->order = order; in one_opt()
2098 new->pref = pref; in one_opt()
2103 case 'Y': /* --txt-record */ in one_opt()
2108 if ((comma = split(arg))) comma--; in one_opt()
2116 if ((len = p - q - 1) > 255) option = '?'; in one_opt()
2128 new->next = daemon->txt; in one_opt()
2129 daemon->txt = new; in one_opt()
2130 new->class = C_IN; in one_opt()
2132 new->len = q - ((unsigned char*) comma); in one_opt()
2133 new->txt = opt_malloc(new->len); in one_opt()
2134 memcpy(new->txt, comma, new->len); in one_opt()
2137 new->len = 1; in one_opt()
2138 new->txt = empty; in one_opt()
2144 if (!(new->name = canonicalise_opt(arg))) { in one_opt()
2152 case 'W': /* --srv-host */ in one_opt()
2155 char *name, *target = NULL; in one_opt() local
2160 if (!(name = canonicalise_opt(arg))) problem = _("bad SRV record"); in one_opt()
2165 if (!(target = canonicalise_opt(arg))) problem = _("bad SRV target"); in one_opt()
2187 new->next = daemon->mxnames; in one_opt()
2188 daemon->mxnames = new; in one_opt()
2189 new->issrv = 1; in one_opt()
2190 new->name = name; in one_opt()
2191 new->target = target; in one_opt()
2192 new->srvport = port; in one_opt()
2193 new->priority = priority; in one_opt()
2194 new->weight = weight; in one_opt()
2198 case LOPT_LISTNMARK: /* --listen-mark */ in one_opt()
2202 // my_syslog(LOG_WARNING, "passed-in mark: %s", arg); in one_opt()
2204 daemon->listen_mark = mark; in one_opt()
2207 … // my_syslog(LOG_WARNING, "daemon->listen_mark: 0x%x, *endptr=%d", daemon->listen_mark, *endptr); in one_opt()
2226 char *p, *arg, *start, *buff = daemon->namebuff; in one_file()
2238 for (r = filesread; r; r = r->next) in one_file()
2239 if (r->dev == statbuf.st_dev && r->ino == statbuf.st_ino) return; in one_file()
2242 r->next = filesread; in one_file()
2244 r->dev = statbuf.st_dev; in one_file()
2245 r->ino = statbuf.st_ino; in one_file()
2252 return; /* No conffile, all done. */ in one_file()
2301 lastquote = p - buff; in one_file()
2316 while (strlen(buff) > lastquote && isspace((int) unhide_meta(buff[strlen(buff) - 1]))) in one_file()
2317 buff[strlen(buff) - 1] = 0; in one_file()
2326 for (; p >= buff && (isspace((int) *p) || *p == '='); p--) *p = 0; in one_file()
2375 if (daemon->dhcp_hosts_file) { in reread_dhcp()
2379 for (up = &daemon->dhcp_conf, configs = daemon->dhcp_conf; configs; configs = cp) { in reread_dhcp()
2380 cp = configs->next; in reread_dhcp()
2382 if (configs->flags & CONFIG_BANK) { in reread_dhcp()
2385 for (mac = configs->hwaddr; mac; mac = tmp) { in reread_dhcp()
2386 tmp = mac->next; in reread_dhcp()
2389 if (configs->flags & CONFIG_CLID) free(configs->clid); in reread_dhcp()
2390 if (configs->flags & CONFIG_NETID) free(configs->netid.net); in reread_dhcp()
2391 if (configs->flags & CONFIG_NAME) free(configs->hostname); in reread_dhcp()
2393 *up = configs->next; in reread_dhcp()
2396 up = &configs->next; in reread_dhcp()
2399 one_file(daemon->dhcp_hosts_file, 1, LOPT_BANK); in reread_dhcp()
2400 my_syslog(MS_DHCP | LOG_INFO, _("read %s"), daemon->dhcp_hosts_file); in reread_dhcp()
2403 if (daemon->dhcp_opts_file) { in reread_dhcp()
2407 for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp) { in reread_dhcp()
2408 cp = opts->next; in reread_dhcp()
2410 if (opts->flags & DHOPT_BANK) { in reread_dhcp()
2411 if ((opts->flags & DHOPT_VENDOR)) free(opts->u.vendor_class); in reread_dhcp()
2412 free(opts->val); in reread_dhcp()
2413 for (id = opts->netid; id; id = next) { in reread_dhcp()
2414 next = id->next; in reread_dhcp()
2415 free(id->net); in reread_dhcp()
2418 *up = opts->next; in reread_dhcp()
2421 up = &opts->next; in reread_dhcp()
2424 one_file(daemon->dhcp_opts_file, 1, LOPT_OPTS); in reread_dhcp()
2425 my_syslog(MS_DHCP | LOG_INFO, _("read %s"), daemon->dhcp_opts_file); in reread_dhcp()
2439 daemon->namebuff = buff; in read_opts()
2441 /* Set defaults - everything else is zero or NULL */ in read_opts()
2442 daemon->cachesize = CACHESIZ; in read_opts()
2443 daemon->ftabsize = FTABSIZ; in read_opts()
2444 daemon->port = NAMESERVER_PORT; in read_opts()
2445 daemon->dhcp_client_port = DHCP_CLIENT_PORT; in read_opts()
2446 daemon->dhcp_server_port = DHCP_SERVER_PORT; in read_opts()
2447 daemon->default_resolv.is_default = 1; in read_opts()
2448 daemon->default_resolv.name = RESOLVFILE; in read_opts()
2449 daemon->resolv_files = &daemon->default_resolv; in read_opts()
2450 daemon->username = CHUSER; in read_opts()
2451 daemon->runfile = RUNFILE; in read_opts()
2452 daemon->dhcp_max = MAXLEASES; in read_opts()
2453 daemon->edns_pktsz = EDNS_PKTSZ; in read_opts()
2454 daemon->log_fac = -1; in read_opts()
2455 add_txt("version.bind", "dnsmasq-" VERSION); in read_opts()
2466 if (option == -1) break; in read_opts()
2471 buff[MAXDNAME - 1] = 0; in read_opts()
2476 /* command-line only stuff */ in read_opts()
2489 printf(_("This software comes with ABSOLUTELY NO WARRANTY.\n")); in read_opts()
2498 errmess = one_opt(option, arg, _("try --help"), 0); in read_opts()
2500 errmess = one_opt(option, arg, _("try -w"), 0); in read_opts()
2508 /* port might not be known when the address is parsed - fill in here */ in read_opts()
2509 if (daemon->servers) { in read_opts()
2511 for (tmp = daemon->servers; tmp; tmp = tmp->next) in read_opts()
2512 if (!(tmp->flags & SERV_HAS_SOURCE)) { in read_opts()
2513 if (tmp->source_addr.sa.sa_family == AF_INET) in read_opts()
2514 tmp->source_addr.in.sin_port = htons(daemon->query_port); in read_opts()
2516 else if (tmp->source_addr.sa.sa_family == AF_INET6) in read_opts()
2517 tmp->source_addr.in6.sin6_port = htons(daemon->query_port); in read_opts()
2522 if (daemon->if_addrs) { in read_opts()
2524 for (tmp = daemon->if_addrs; tmp; tmp = tmp->next) in read_opts()
2525 if (tmp->addr.sa.sa_family == AF_INET) tmp->addr.in.sin_port = htons(daemon->port); in read_opts()
2527 else if (tmp->addr.sa.sa_family == AF_INET6) in read_opts()
2528 tmp->addr.in6.sin6_port = htons(daemon->port); in read_opts()
2532 /* only one of these need be specified: the other defaults to the host-name */ in read_opts()
2533 if ((daemon->options & OPT_LOCALMX) || daemon->mxnames || daemon->mxtarget) { in read_opts()
2536 if (gethostname(buff, MAXDNAME) == -1) die(_("cannot get host-name: %s"), NULL, EC_MISC); in read_opts()
2538 for (mx = daemon->mxnames; mx; mx = mx->next) in read_opts()
2539 if (!mx->issrv && hostname_isequal(mx->name, buff)) break; in read_opts()
2541 if ((daemon->mxtarget || (daemon->options & OPT_LOCALMX)) && !mx) { in read_opts()
2543 mx->next = daemon->mxnames; in read_opts()
2544 mx->issrv = 0; in read_opts()
2545 mx->target = NULL; in read_opts()
2546 mx->name = opt_string_alloc(buff); in read_opts()
2547 daemon->mxnames = mx; in read_opts()
2550 if (!daemon->mxtarget) daemon->mxtarget = opt_string_alloc(buff); in read_opts()
2552 for (mx = daemon->mxnames; mx; mx = mx->next) in read_opts()
2553 if (!mx->issrv && !mx->target) mx->target = daemon->mxtarget; in read_opts()
2556 if (!(daemon->options & OPT_NO_RESOLV) && daemon->resolv_files && daemon->resolv_files->next && in read_opts()
2557 (daemon->options & OPT_NO_POLL)) in read_opts()
2558 die(_("only one resolv.conf file allowed in no-poll mode."), NULL, EC_BADCONF); in read_opts()
2560 if (daemon->options & OPT_RESOLV_DOMAIN) { in read_opts()
2564 if ((daemon->options & OPT_NO_RESOLV) || !daemon->resolv_files || in read_opts()
2565 (daemon->resolv_files)->next) in read_opts()
2568 if (!(f = fopen((daemon->resolv_files)->name, "r"))) in read_opts()
2569 die(_("failed to read %s: %s"), (daemon->resolv_files)->name, EC_FILE); in read_opts()
2577 (daemon->domain_suffix = canonicalise_opt(token))) in read_opts()
2583 if (!daemon->domain_suffix) in read_opts()
2584 die(_("no search directive found in %s"), (daemon->resolv_files)->name, EC_MISC); in read_opts()
2587 if (daemon->domain_suffix) { in read_opts()
2588 /* add domain for any srv record without one. */ in read_opts()
2589 struct mx_srv_record* srv; in read_opts() local
2591 for (srv = daemon->mxnames; srv; srv = srv->next) in read_opts()
2592 if (srv->issrv && strchr(srv->name, '.') && in read_opts()
2593 strchr(srv->name, '.') == strrchr(srv->name, '.')) { in read_opts()
2594 strcpy(buff, srv->name); in read_opts()
2596 strcat(buff, daemon->domain_suffix); in read_opts()
2597 free(srv->name); in read_opts()
2598 srv->name = opt_string_alloc(buff); in read_opts()
2600 } else if (daemon->options & OPT_DHCP_FQDN) in read_opts()
2601 die(_("there must be a default domain when --dhcp-fqdn is set"), NULL, EC_BADCONF); in read_opts()