Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F173878235
D30465.id89889.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D30465.id89889.diff
View Options
Index: sbin/ipfw/Makefile
===================================================================
--- sbin/ipfw/Makefile
+++ sbin/ipfw/Makefile
@@ -4,6 +4,9 @@
PACKAGE=ipfw
PROG= ipfw
+
+LINKS= ${BINDIR}/ipfw ${BINDIR}/dnctl
+
SRCS= ipfw2.c dummynet.c ipv6.c main.c nat.c tables.c
SRCS+= nat64clat.c nat64lsn.c nat64stl.c nptv6.c
Index: sbin/ipfw/ipfw2.h
===================================================================
--- sbin/ipfw/ipfw2.h
+++ sbin/ipfw/ipfw2.h
@@ -20,6 +20,11 @@
* $FreeBSD$
*/
+enum cmdline_prog {
+ cmdline_prog_ipfw,
+ cmdline_prog_dnctl
+};
+
/*
* Options that can be set on the command line.
* When reading commands from a file, a subset of the options can also
@@ -54,8 +59,11 @@
uint32_t use_set; /* work with specified set number */
/* 0 means all sets, otherwise apply to set use_set - 1 */
+ enum cmdline_prog prog; /* Are we ipfw or dnctl? */
};
+int is_ipfw(void);
+
enum {
TIMESTAMP_NONE = 0,
TIMESTAMP_STRING,
Index: sbin/ipfw/ipfw2.c
===================================================================
--- sbin/ipfw/ipfw2.c
+++ sbin/ipfw/ipfw2.c
@@ -411,6 +411,12 @@
static char *object_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx,
uint16_t type);
+int
+is_ipfw(void)
+{
+ return (g_co.prog == cmdline_prog_ipfw);
+}
+
/*
* Simple string buffer API.
* Used to simplify buffer passing between function and for
Index: sbin/ipfw/main.c
===================================================================
--- sbin/ipfw/main.c
+++ sbin/ipfw/main.c
@@ -36,7 +36,8 @@
static void
help(void)
{
- fprintf(stderr,
+ if (is_ipfw()) {
+ fprintf(stderr,
"ipfw syntax summary (but please do read the ipfw(8) manpage):\n\n"
"\tipfw [-abcdefhnNqStTv] <command>\n\n"
"where <command> is one of the following:\n\n"
@@ -76,6 +77,17 @@
" setup | {tcpack|tcpseq|tcpwin} NN | tcpflags SPEC | tcpoptions SPEC |\n"
" tcpdatalen LIST | verrevpath | versrcreach | antispoof\n"
);
+ } else {
+ fprintf(stderr,
+"dnctl syntax summary (but please do read the dnctl(8) manpage):\n\n"
+"\tdnctl [-hnsv] <command>\n\n"
+"where <command> is one of the following:\n\n"
+"{pipe|queue} N config PIPE-BODY\n"
+"[pipe|queue] {zero|delete|show} [N{,N}]\n"
+"show\n"
+"\n"
+);
+ }
exit(0);
}
@@ -231,7 +243,8 @@
g_co.do_force = !isatty(STDIN_FILENO);
#ifdef EMULATE_SYSCTL /* sysctl emulation */
- if ( ac >= 2 && !strcmp(av[1], "sysctl")) {
+ if (is_ipfw() && ac >= 2 &&
+ !strcmp(av[1], "sysctl")) {
char *s;
int i;
@@ -263,87 +276,115 @@
save_av = av;
optind = optreset = 1; /* restart getopt() */
- while ((ch = getopt(ac, av, "abcdDefhinNp:qs:STtv")) != -1)
- switch (ch) {
- case 'a':
- do_acct = 1;
- break;
+ if (is_ipfw()) {
+ while ((ch = getopt(ac, av, "abcdDefhinNp:qs:STtv")) != -1)
+ switch (ch) {
+ case 'a':
+ do_acct = 1;
+ break;
- case 'b':
- g_co.comment_only = 1;
- g_co.do_compact = 1;
- break;
+ case 'b':
+ g_co.comment_only = 1;
+ g_co.do_compact = 1;
+ break;
- case 'c':
- g_co.do_compact = 1;
- break;
+ case 'c':
+ g_co.do_compact = 1;
+ break;
- case 'd':
- g_co.do_dynamic = 1;
- break;
+ case 'd':
+ g_co.do_dynamic = 1;
+ break;
- case 'D':
- g_co.do_dynamic = 2;
- break;
+ case 'D':
+ g_co.do_dynamic = 2;
+ break;
- case 'e':
- /* nop for compatibility */
- break;
+ case 'e':
+ /* nop for compatibility */
+ break;
- case 'f':
- g_co.do_force = 1;
- break;
+ case 'f':
+ g_co.do_force = 1;
+ break;
- case 'h': /* help */
- free(save_av);
- help();
- break; /* NOTREACHED */
+ case 'h': /* help */
+ free(save_av);
+ help();
+ break; /* NOTREACHED */
- case 'i':
- g_co.do_value_as_ip = 1;
- break;
+ case 'i':
+ g_co.do_value_as_ip = 1;
+ break;
- case 'n':
- g_co.test_only = 1;
- break;
+ case 'n':
+ g_co.test_only = 1;
+ break;
- case 'N':
- g_co.do_resolv = 1;
- break;
+ case 'N':
+ g_co.do_resolv = 1;
+ break;
- case 'p':
- errx(EX_USAGE, "An absolute pathname must be used "
- "with -p option.");
- /* NOTREACHED */
+ case 'p':
+ errx(EX_USAGE, "An absolute pathname must be used "
+ "with -p option.");
+ /* NOTREACHED */
- case 'q':
- g_co.do_quiet = 1;
- break;
+ case 'q':
+ g_co.do_quiet = 1;
+ break;
- case 's': /* sort */
- g_co.do_sort = atoi(optarg);
- break;
+ case 's': /* sort */
+ g_co.do_sort = atoi(optarg);
+ break;
- case 'S':
- g_co.show_sets = 1;
- break;
+ case 'S':
+ g_co.show_sets = 1;
+ break;
- case 't':
- g_co.do_time = TIMESTAMP_STRING;
- break;
+ case 't':
+ g_co.do_time = TIMESTAMP_STRING;
+ break;
- case 'T':
- g_co.do_time = TIMESTAMP_NUMERIC;
- break;
+ case 'T':
+ g_co.do_time = TIMESTAMP_NUMERIC;
+ break;
- case 'v': /* verbose */
- g_co.verbose = 1;
- break;
+ case 'v': /* verbose */
+ g_co.verbose = 1;
+ break;
- default:
- free(save_av);
- return 1;
- }
+ default:
+ free(save_av);
+ return 1;
+ }
+ } else {
+ while ((ch = getopt(ac, av, "hns:v")) != -1)
+ switch (ch) {
+
+ case 'h': /* help */
+ free(save_av);
+ help();
+ break; /* NOTREACHED */
+
+ case 'n':
+ g_co.test_only = 1;
+ break;
+
+ case 's': /* sort */
+ g_co.do_sort = atoi(optarg);
+ break;
+
+ case 'v': /* verbose */
+ g_co.verbose = 1;
+ break;
+
+ default:
+ free(save_av);
+ return 1;
+ }
+
+ }
ac -= optind;
av += optind;
@@ -367,7 +408,7 @@
g_co.do_nat = 0;
g_co.do_pipe = 0;
g_co.use_set = 0;
- if (!strncmp(*av, "nat", strlen(*av)))
+ if (is_ipfw() && !strncmp(*av, "nat", strlen(*av)))
g_co.do_nat = 1;
else if (!strncmp(*av, "pipe", strlen(*av)))
g_co.do_pipe = 1;
@@ -377,7 +418,7 @@
g_co.do_pipe = 2;
else if (_substrcmp(*av, "sched") == 0)
g_co.do_pipe = 3;
- else if (!strncmp(*av, "set", strlen(*av))) {
+ else if (is_ipfw() && !strncmp(*av, "set", strlen(*av))) {
if (ac > 1 && isdigit(av[1][0])) {
g_co.use_set = strtonum(av[1], 0, resvd_set_number,
&errstr);
@@ -407,7 +448,7 @@
}
if (g_co.use_set == 0) {
- if (_substrcmp(*av, "add") == 0)
+ if (is_ipfw() && _substrcmp(*av, "add") == 0)
ipfw_add(av);
else if (g_co.do_nat && _substrcmp(*av, "show") == 0)
ipfw_show_nat(ac, av);
@@ -415,19 +456,19 @@
ipfw_config_pipe(ac, av);
else if (g_co.do_nat && _substrcmp(*av, "config") == 0)
ipfw_config_nat(ac, av);
- else if (_substrcmp(*av, "set") == 0)
+ else if (is_ipfw() && _substrcmp(*av, "set") == 0)
ipfw_sets_handler(av);
- else if (_substrcmp(*av, "table") == 0)
+ else if (is_ipfw() && _substrcmp(*av, "table") == 0)
ipfw_table_handler(ac, av);
- else if (_substrcmp(*av, "enable") == 0)
+ else if (is_ipfw() && _substrcmp(*av, "enable") == 0)
ipfw_sysctl_handler(av, 1);
- else if (_substrcmp(*av, "disable") == 0)
+ else if (is_ipfw() && _substrcmp(*av, "disable") == 0)
ipfw_sysctl_handler(av, 0);
else
try_next = 1;
}
- if (g_co.use_set || try_next) {
+ if (is_ipfw() && (g_co.use_set || try_next)) {
if (_substrcmp(*av, "delete") == 0)
ipfw_delete(av);
else if (!strncmp(*av, "nat64clat", strlen(*av)))
@@ -620,12 +661,22 @@
}
}
#endif
+
+ if (strcmp(av[0], "dnctl") == 0)
+ g_co.prog = cmdline_prog_dnctl;
+ else
+ g_co.prog = cmdline_prog_ipfw;
+
/*
* If the last argument is an absolute pathname, interpret it
* as a file to be preprocessed.
*/
if (ac > 1 && av[ac - 1][0] == '/') {
+ if (! is_ipfw())
+ errx(EX_USAGE, "usage: dnctl [options]\n"
+ "do \"dnctl -h\" for details");
+
if (access(av[ac - 1], R_OK) == 0)
ipfw_readfile(ac, av);
else
@@ -633,8 +684,9 @@
} else {
if (ipfw_main(ac, av)) {
errx(EX_USAGE,
- "usage: ipfw [options]\n"
- "do \"ipfw -h\" or \"man ipfw\" for details");
+ "usage: %s [options]\n"
+ "do \"%s -h\" or \"man %s\" for details", av[0],
+ av[0], av[0]);
}
}
return EX_OK;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 30, 1:53 AM (2 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39915169
Default Alt Text
D30465.id89889.diff (7 KB)
Attached To
Mode
D30465: ipfw: Introduce dnctl
Attached
Detach File
Event Timeline
Log In to Comment