📄 main.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/router/main.c,v 1.3 2003/01/15 14:04:49 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** * Copyright 1994-1997 Epilogue Technology Corporation. * Copyright 1998-1999 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: main.c,v $ * Revision 1.3 2003/01/15 14:04:49 josh * directory structure shifting * * Revision 1.2 2001/11/09 21:06:50 josh * demo router path modification * * Revision 1.1.1.1 2001/11/05 17:49:09 tneale * Tornado shuffle * * Revision 2.112 2001/05/24 18:43:51 paul * Consolidated copyright notice in startup banner. * * Revision 2.111 2001/02/16 21:44:47 paul * Conditionalized cmd_clean_nd(). * * Revision 2.110 2001/01/26 22:23:18 sar * Added commands to use set options for v6 global configuration information * also renamed some of the v6 print routines. * * Revision 2.109 2001/01/24 20:44:06 sar * Added commands to call the v6 print routines. These routines will print * out gloabl and table information about various parts of the v6 engine. * Also added a command to clean the v6 nd cache. * * Revision 2.108 2001/01/23 01:43:06 paul * Performed radical surgery on Bill's udp_handle/udp_endpoint goop. * * Revision 2.107 2001/01/19 22:24:38 paul * Update copyright. * * Revision 2.106 2000/10/16 19:21:57 paul * Restore sockets and mempool code. * * Revision 2.105 2000/03/17 00:14:18 meister * Update copyright message * * Revision 2.104 2000/03/13 21:22:18 paul * Removed some code that we are no longer working on. * * Revision 2.103 1999/11/28 03:49:28 mrf * Changes for new UDP listener API. * * Revision 2.102 1999/11/05 22:24:04 paul * Eliminate dependence on ancient backward-compatibility code. * * Revision 2.101 1999/04/29 22:31:23 wes * Beginnings of a test to exercise random dark corners/error cases in * the tcp API. * * Revision 2.100 1999/04/27 00:56:43 sra * Include firewall.h properly. * * Revision 2.99 1999/04/27 00:52:38 sra * Fix command indentation. * * Revision 2.98 1999/04/15 21:43:39 wes * Fix SNARK_ATTACHE_34_DNS_COMPAT to continue working.. * * Revision 2.97 1999/04/15 17:46:50 wes * Use new UDP api for both udp sink listens so address-specific binding actually *works* * * Revision 2.96 1999/04/14 19:45:15 wes * Use udp_endpoint abstractions consistantly * * Revision 2.95 1999/04/12 21:04:40 wes * Don't use uninitialized udp handle.. * * Revision 2.94 1999/04/09 20:48:42 wes * let it build without ATTACHE_DNS or ATTACHE_TCP * * Revision 2.93 1999/03/26 22:50:41 wes * catch up to udp API rename. * add "udp_sink" command * * Revision 2.92 1998/12/16 15:49:43 josh * break off Courier commands into separate file and eliminate * the warnings they were causing * * Revision 2.91 1998/12/12 20:56:43 sra * dcc noticed a bogus pointer range check in source_generator(). * * Revision 2.90 1998/12/12 17:59:19 sra * Slightly more useful chargen demo. * * Revision 2.89 1998/10/28 18:51:07 josh * marging in courier-sep98 branch * * Revision 2.88 1998/10/14 20:30:59 wes * Add UDP sink client * * Revision 2.87 1998/09/21 21:29:36 wes * Make alice optional (among other things, psos 2.5 doesn't have a getenv) * * Revision 2.86 1998/09/18 19:55:12 meister * timer call renaming; tm_ --> etc_tm_ * * Revision 2.85 1998/09/06 08:11:09 sra * Packet filtering hooks in Attache, rudimentary firewall * implementation in Snark. * * Revision 2.84.4.3 1998/09/12 19:27:34 sra * Minor kludges to make this development snapshot of snark compile with * the released versions of the Attache, Envoy, and Emissary products. * These changes will need to be un-done when this branch is merged back * into the main code base. * * Revision 2.84.4.2 1998/09/11 18:53:49 sra * Second batch of updates from Josh and Shukri. * * Revision 2.84.4.1 1998/09/11 05:50:34 sra * Initial commit on courier-sep98 branch. * * Revision 2.84 1998/07/04 01:31:34 sra * Fix some CAD-UL warnings. * * Revision 2.83 1998/07/02 06:55:42 sra * Make Snark restartable under pSOS, and other minor cleanups. * * Revision 2.82 1998/06/27 01:15:56 mrf * add delete-route command * * Revision 2.81 1998/06/25 21:31:13 wes * Add command to start/stop/abort DHCP from the command line * * Revision 2.80 1998/06/25 00:04:46 sar * Add call to SNMP_Config() to read the snmp configuration * * Revision 2.79 1998/06/24 18:12:52 wes * Let it build on NetBSD again. * * Revision 2.78 1998/06/23 20:48:21 meister * change that timer to a per chargen-cnxn timer. Add some dithering to avoid * one connection hogging all the memory resources and blocking others. * * Revision 2.77 1998/06/23 17:59:57 meister * Fixed bug in source_generator. Added a timer which schedules source_generator () * to be called again if it bails out due to tcp_alloc failing. Otherwise the * chargen service hangs completely; since it hadnt filled the send window, TCP * doesnt know to call our transmit upcall again. * * Revision 2.76 1998/05/13 21:22:05 meister * Changed a "struct route *" to a "route_entry_t *" * * Revision 2.75 1998/05/05 13:29:26 mrf * Fix typo in short help for add-route command * * Revision 2.74 1998/04/09 22:00:23 wes * Start splitting main.c into app-specific files; add netime client * * Revision 2.73 1998/03/16 16:39:27 mrf * Fix string constant which disturbed MSVC 1.52 * * Revision 2.72 1998/03/12 18:36:38 meister * convert all references to IPSEC_SA_{TRANSPORT,TUNNEL}_ONLY to * SA_FLAGS_{TRANSPORT,TUNNEL}_ONLY * * Revision 2.71 1998/03/12 18:22:19 meister * have printsa print out TRANSPORT_ONLY, TUNNEL_ONLY flags * * Revision 2.70 1998/03/10 19:06:01 meister * changed some "ipaddr.type" constructs to "GET_IPADDR_TYPE(&ipaddr)" * * Revision 2.69 1998/03/05 14:25:07 mrf * Added optional tag argument to add-routes, cleaned up help/usage messages. * * Revision 2.68 1998/03/04 21:35:42 mrf * Added add-route command. * * Revision 2.67 1998/03/04 21:19:04 meister * Checked-in version of this shouldnt have 30 second expires times on SA's ; * that was just for me testing... * * Revision 2.66 1998/03/04 21:00:42 meister * snark now knows about IPSEC_CREATE_FAIL_BADKEY * * Revision 2.65 1998/03/04 00:19:41 meister * #ifdef INSTALL_ATTACHE_IPSEC around ping check for IP_SEND_IPSEC_DENIED * was unnecessary * * Revision 2.64 1998/03/03 19:57:30 meister * separated out ipsec packet flags and ipsec policy flags * * Revision 2.63 1998/03/03 15:43:22 mrf * Correct misspelling in help message. * * Revision 2.62 1998/03/03 15:24:30 mrf * Clean up short help and add new features to compile-options command. * * Revision 2.61 1998/02/28 00:08:11 meister * deleted some #if 0'd code * * Revision 2.60 1998/02/27 22:15:29 meister * move ipsec glue to ips_glue.c. * * Revision 2.59 1998/02/26 23:44:10 meister * no more ipsecpol.h * * Revision 2.58 1998/02/26 03:05:01 mrf * Fixed usage messages for delsa and addsa * * Revision 2.57 1998/02/26 01:19:06 meister * Use party list access macros instead of direct access. * * Revision 2.56 1998/02/25 04:57:46 sra * Update copyrights. * * Revision 2.55 1998/02/25 00:37:52 meister * made cmd_printsat do help properly * * Revision 2.54 1998/02/24 05:40:16 sra * Fix uninitialized variable in cmd_blat(). * * Revision 2.53 1998/02/23 22:08:53 meister * call sa and policy access macros. * * Revision 2.52 1998/02/20 02:10:57 mrf * Convert Router Discovery code to use AVL tree structure. * * Revision 2.51 1998/02/17 19:53:16 sra * Turn off Attache 3.4 DNS compatability by default. * * Revision 2.50 1998/02/13 00:48:14 meister * added simple SA expiration handler * * Revision 2.49 1998/02/10 22:42:13 meister * more conditional IPSEC compilation stuff * * Revision 2.48 1998/02/10 18:19:13 meister * conditional compilation leftovers for IPSEC * * Revision 2.47 1998/02/07 00:36:46 meister * Added cmd_delpol () * * Revision 2.46 1998/02/03 23:29:20 meister * ipsec_iterate_{sa,policy}table functions now take cookies. * modify cmd_addsa for sa party lists. * * Revision 2.45 1998/01/30 21:52:08 meister * bumped ARGV_SIZE to 16 * * Revision 2.44 1998/01/28 20:25:51 meister * slight changes in cmd_addsa * * Revision 2.43 1998/01/21 23:16:07 meister * SA parties are now doing something real, updated cmd_addsa * to allow entry of them. * * Revision 2.42 1998/01/20 23:29:40 meister * Added test calls to ipsec policy engine * * Revision 2.41 1998/01/16 18:07:31 meister * reworked printsat to use avl iterators * * Revision 2.40 1998/01/15 22:19:47 meister * Added some ipsec test calls. * * Revision 2.39 1997/12/01 15:50:40 mrf * Add error messages when printing code was not built with PRINTF defined. * * Revision 2.38 1997/11/13 16:23:47 mrf * make dump-routes also print ipv6 routing table if installed * * Revision 2.37 1997/10/06 15:24:02 mrf * only compile dump-rdcache when the rd cache is present * * Revision 2.36 1997/10/06 04:13:43 mrf * add dump-rdcache command to dump router discovery cache * * Revision 2.35 1997/09/18 20:17:51 sra * Patch around version skew for Decorum 2.0 release. * * Revision 2.34 1997/09/17 20:48:06 josh * need decorum_init() for Decorum to work properly * * Revision 2.33 1997/07/27 01:40:43 sra * Make TELNET command IPv6-capable, fix Alice's Restaurant reference. * * Revision 2.32 1997/07/26 00:41:02 mrf * modified finger command to use new dns and tcp apis, in prep for ipv6 * * Revision 2.31 1997/07/25 05:23:39 sra * Preliminary DNS support for IPv6 (AAAA and IP6.INT DNS payloads). * * Revision 2.30 1997/07/09 18:00:52 mrf * add symbolic constants for tftp handler returns, fix typo in cnxn macro and * fix tftp short help layout for snark * * Revision 2.29 1997/06/15 01:46:18 mrf * changed IPADDR_* and related macros to use pointers instead of immediates * as arguments, also changed to GET/SET/PTR forms * * Revision 2.28 1997/06/09 22:53:29 lowell * fixes to match the documentation for TFTP sends * * Revision 2.27 1997/06/04 18:14:35 mrf * changed routing macros to GET/SET format and to take pointer args * * Revision 2.26 1997/06/03 04:35:52 sra * New ping API. * * Revision 2.25 1997/05/22 16:18:02 mrf * make dump-routes stop trying to dump v6 routes * * Revision 2.24 1997/05/19 22:42:18 lowell * add "send" subcommand for "tftp" * * Revision 2.23 1997/05/15 16:26:17 mrf * clean up unused variable warning in ipv4-only build * * Revision 2.22 1997/05/14 17:27:22 mrf * convert to new ip_conn structure and merge ipv4 and v6 send paths * * Revision 2.21 1997/05/07 19:01:06 mrf * pass buffer to ipaddr_to_string() instead of using dynamic memory * * Revision 2.20 1997/05/02 15:24:14 mrf * remove include of obsolete header file pingv6.h * * Revision 2.19 1997/04/19 02:51:02 mrf * added basic ipv6 stuff, configuable ipv6 address and ability to ping * using ipv6. lots more to come... * * Revision 2.18 1997/03/20 06:53:28 sra * DFARS-safe copyright text. Zap! * * Revision 2.17 1997/03/19 22:36:04 sra * Silence a gcc warning. * * Revision 2.16 1997/03/19 05:32:24 sra * Add copyright lines to banner(). * * Revision 2.15 1997/02/25 10:58:16 sra * Update copyright notice, dust under the bed. * * Revision 2.14 1997/02/19 08:10:29 sra * More fun merging snmptalk into snark, general snark cleanup. * * Revision 2.13 1997/02/15 21:25:18 sra * Buffer multiple ahead-of-seq segments in sink server. * * Revision 2.12 1996/11/15 20:44:07 josh * updated main.c with contents of test/main.c * router will now run decorum and tfftp * * Revision 2.11 1996/10/30 18:44:53 sra * Fix gcc warning about sscanf() format string type mismatch. * * Revision 2.10 1996/10/30 06:47:30 sra * Get rid of unused variable to silence compiler warning. * * Revision 2.9 1996/10/28 02:49:36 sra * Some of the stupid old DOS compilers only support rand(), so use that * instead of random(). * * Revision 2.8 1996/03/22 10:05:39 sra * Update copyrights prior to Attache 3.2 release. * * Revision 2.7 1996/03/09 09:25:34 sra * SunOS doesn't have strtoul(), use sscanf() instead, yuk. * * Revision 2.6 1996/03/09 09:13:45 sra * Make "ping" output more useful for automated testing. * * Revision 2.5 1996/02/22 21:02:06 sra * Add "blat" command. * * Revision 2.4 1996/02/13 21:09:00 sra * Add "dump-routes" command. * * Revision 2.3 1995/07/31 13:54:55 sra * OSPF now working well enough to let somebody else test it. * * Revision 2.2 1995/06/27 06:26:36 sra * Bring up OSPF on all interfaces, not just first found. * * Revision 2.1 1995/06/22 05:29:06 sra * Preliminary changes for multicast and OSPF. * * Revision 2.0 1995/05/10 22:38:15 sra * Attache release 3.0. * * Revision 1.7 1995/04/24 20:47:28 sra * Configurable prompt string. Gets confusing when you've got thirty of * these critters running at once and they all call themselves "snark". * * Revision 1.6 1995/04/23 01:07:59 sra * Reorder header files for new TELNET code. * * Revision 1.5 1995/04/19 07:30:31 sra * Don't free non-existant state block in source_close(. * * Revision 1.4 1995/01/06 00:52:48 sra * Update copyright notice for 2.1 release. * * Revision 1.3 1994/12/23 15:27:42 dab * Added compile-options command if Attache was compiled without routing * enabled it prints a message to this effect with the banner. * * Revision 1.2 1994/12/20 22:41:19 dab * Changed some strings and added some commands to hack interfaces. * * Revision 1.1 1994/11/23 18:31:00 dab * Initial revision * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*/#include <stdio.h>#include <stdlib.h>#include <wrn/wm/common/config.h>#include <wrn/wm/common/weakprng.h>#include <wrn/wm/common/glue.h>#include <wrn/wm/attache/config.h>#include <wrn/wm/attache/mib.h>#include <wrn/wm/attache/timer.h>#include <wrn/wm/attache/packet.h>#include <wrn/wm/attache/net.h>#include <wrn/wm/attache/route.h>#include <wrn/wm/attache/ip.h>#include <wrn/wm/attache/udp.h>#if INSTALL_ATTACHE_IPV6#include <wrn/wm/attache/ip6_cfg.h>#include <wrn/wm/attache/ip6_nd.h>#if INSTALL_ATTACHE_IPV6_RD#include <wrn/wm/attache/ip6_rd.h>#endif#if INSTALL_ATTACHE_IPV6_REDIRECT#include <wrn/wm/attache/ip6_rdrt.h>#endif#if INSTALL_ATTACHE_IPV6_FRAGMENTATION#include <wrn/wm/attache/ip6_frag.h>#endif#endif#if INSTALL_ATTACHE_IPSEC#include <wrn/wm/attache/ipsec.h>#endif#if INSTALL_ATTACHE_PING#include <wrn/wm/attache/icmp.h>#include <wrn/wm/attache/ping.h>#endif#if INSTALL_ATTACHE_IPV4_ROUTER_DISCOVERY#include <wrn/wm/attache/rd_cache.h>#endif#if INSTALL_ATTACHE_TCP#include <wrn/wm/attache/tcp.h>#endif#if INSTALL_ATTACHE_TELNET#include <wrn/wm/attache/tn.h>#endif#include <wrn/wm/attache/glue.h>#include "cmds.h"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -