⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snxcnfg.c

📁 VRTX 商用嵌入式实时操作系统
💻 C
字号:
/***************************************************************************
*
*		Copyright (c) 1993 MRI CORPORATION.
*
*	All rights reserved. MRI source code is an unpublished
*	work and the use of a copyright notice does not imply otherwise.
*	This source code contains confidential, trade secret material of
*	MRI. Any attempt or participation in deciphering, decoding,
*	reverse engineering or in any way altering the source code is
*	strictly prohibited, unless the prior written consent of
*	MRI is obtained.
*
*
*	Module Name:		snx.tpl
*
*	Identification:		 1.28 snx.tpl
*
*	Date:			10/25/94  14:41:25
*
****************************************************************************
*/


#include <syskind.h>
#include <vrtxil.h>
#include "sys/types.h"
#include "sys/sysnames.h"
#include "sys/kernel.h"
#include "kernel/swkconf.h"
#include "exec/device.h"
#include "sys/config.h"
#include "sys/stream.h"
#include "sys/tihdr.h"
#include "netinet/in.h"





























/*
 * Verbosity level (cmn_err())
 */
int	swk_dbgprt = 0;

/*
 * if no ldterm module present, tell serial driver to do a sub-set
 */
int	sio_no_ldterm = 1;

/*
 * Message passing library parameters
 */
int	swk_syscallq_id   = 1;
int	swk_syscallq_size = 16;
int	swk_sysintrq_id   = 2;
int	swk_sysintrq_size = 30;

int	swk_signalq_id 	  = 3;
int	swk_signalq_size  = 3;
int	swk_psignalq_id   = 4;
int	swk_psignalq_size = 30;
int     swk_intr_calls    = 1;

int	swk_ocq_id        = 5;
int	swk_ocq_size      = 30;

/*
 * Streams Tunable Parameters
 */
int 	nstrpush      = 8;
int 	strmsgsz      = 0;
int 	strctlsz      = 512;
int 	strthresh     = 0;
int     swk_max_mblks = 0;

int     swk_buf16     = 0;
int     swk_buf32     = 0;
int     swk_buf64     = 0;
int     swk_buf128    = 0;
int     swk_buf256    = 0;
int     swk_buf512    = 0;
int     swk_buf1024   = 0;
int     swk_buf2048   = 0;
int     swk_buf4560   = 0;

/*
 * Streams Timers Parameters
 */
unsigned long swk_timer_delta = 10;
int      swk_max_timers       = 100;

/*
 * Streams Main Task Parameters
 */
int     swk_max_msgs   = 10;
int     swk_max_stacks = 50;

/*
 * Streams Memory Parameters
 */
unsigned int swk_heap_size = 512*1024L;
unsigned int swk_mblk_weight = 100;    /* in bytes */
unsigned int swk_logio_bufs_pending = 0;
unsigned int tcp_recvspace = 32*1024L;

/*
 * Interface libraries
 */
int	swk_socket_lib = 1,
	swk_tli_lib    = 1;

/*
 * IP flag(s)
 */
int	initial_ip_forwarding = 0;

/*
 * Driver/Module declaration and configuration
 */
extern struct streamtab pipe_info; 
extern struct streamtab lo_info; 
extern struct streamtab ip_info; 
extern struct streamtab tcp_info; 
extern struct streamtab udp_info; 
extern struct streamtab icmp_info; 
extern struct streamtab rip_info; 
extern struct streamtab app_info; 
extern struct streamtab arp_info; 
extern struct streamtab ti_rwinfo; 
extern struct streamtab lg_info; 

extern struct streamtab sock_info; 
extern struct streamtab swk_loginfo; 






extern struct streamtab rte_info; 



struct sdev_tbl dmodsw[] =
{
	{ "__CLONE__", 0, 0, 0 },
	{ "pipe",	SDT_DRV|SDT_SVR4, 0, &pipe_info },
	{ "lo",	SDT_DRV|SDT_SVR3, 0, &lo_info },
	{ "ip",	SDT_DRV|SDT_SVR3, 0, &ip_info },
	{ "tcp",	SDT_DRV|SDT_SVR3, 0, &tcp_info },
	{ "udp",	SDT_DRV|SDT_SVR3, 0, &udp_info },
	{ "icmp",	SDT_DRV|SDT_SVR3, 0, &icmp_info },
	{ "rip",	SDT_DRV|SDT_SVR3, 0, &rip_info },
	{ "arpproc",	SDT_MOD|SDT_SVR3, 0, &app_info },
	{ "arp",	SDT_DRV|SDT_SVR3, 0, &arp_info },
	{ "tirdwr",	SDT_MOD|SDT_SVR4, 0, &ti_rwinfo },
	{ "lg",	SDT_DRV|SDT_SVR4, 0, &lg_info },

	{ "sockmod",	SDT_MOD|SDT_SVR4, 0, &sock_info },
	{ "log",	SDT_DRV|SDT_SVR4, 0, &swk_loginfo },






	{ "route",	SDT_DRV|SDT_SVR4, 0, &rte_info },


	{ 0, 0, 0, 0 }
};

/*
 * Driver/Module initialization functions called from swk_tcp_init
 */
extern void pipe_init(); 
extern void lo_init(); 
extern void ip_init(); 
extern void tcp_init(); 
extern void udp_init(); 
extern void icmp_init(); 
extern void rip_init(); 
 
extern void arp_init(); 
 
extern void lg_init(); 

extern void sockmod_init(); 
extern void swk_loginit(); 






extern void rte_init(); 



struct dmod_conf dmodconf[] =
{
	{ pipe_init },
	{ lo_init },
	{ ip_init },
	{ tcp_init },
	{ udp_init },
	{ icmp_init },
	{ rip_init },

	{ arp_init },

	{ lg_init },

	{ sockmod_init },
	{ swk_loginit },






	{ rte_init },


	{ 0 }
};

/*
 * Upper layer initialization functions called from swk_tcp_init
 * once SNX is initialized
 */




struct dmod_conf ulconf[] =
{

	
	
	
	{ 0 }
};

int	swk_maxmajor = sizeof(dmodsw)/sizeof(struct sdev_tbl) - 2;

/*
 * Network Interface table
 */
struct snx_net_interface snx_interface_table[] = {
	{ "lg0", "lg", "arpproc", "192.9.200.99", 1, 1, 0xffffff00, "DL_ETHERV2"  },
	{ "lo0", "lo", NULL, "127.0.0.1", 0, 0, 0xff000000, "DL_ETHERV2"  },

	{ "", NULL, NULL, NULL, 0, 0, 0 }
};

/*
 * SNX devices
 */
extern int lg_intr_srv(struct swk_irq_req *);
extern void lg_logio_snx_hdlr1(), lg_logio_snx_hdlr2();
struct  lg_logio_dev lg_logio_dev[] = {
{ "VDEV_ETHER_1", lg_logio_snx_hdlr1, { 0, 0, lg_intr_srv } },
{ "VDEV_ETHER_2", lg_logio_snx_hdlr2, { 0, 1, lg_intr_srv } }
};

/*
 * Local host info
 */
unsigned char snx_local_host[HOST_NAME_LEN];
unsigned char x_snx_local_host[HOST_NAME_LEN] = "suzhou";
unsigned char snx_domain_name[DOMAIN_NAME_LEN] = "mri.com";

/*
 * Host table (/etc/hosts)
 */
struct snx_host snx_host_table[] = {
	{ "localhost",  "127.0.0.1",    1 },
	{ "suzhou",	"192.9.200.99",	1 },
	{ "mripc",	"192.9.200.55",	1 },
	{ "slj",	"192.9.200.205",	1 },

	{ "",	"",	0 }
};

/*
 * Name server table (/etc/resolv.conf)
 */
struct snx_nameserv snx_nameservers[] = {

	{ "" }
};

/*
 * Gateway table (/etc/gateways)
 */
struct snx_gw_entry snx_gw_table[] = {

	{ 0, 0, 0, 0, 0 }
};

/*
 * RARP parameters
 */
int     snx_rarp_enable = 1;
int     snx_rarp_timeout = 5000;
int     snx_rarp_retries = -1;

int	swk_tid      = 1;		/* Streams server TID */
int	swk_priority = 255;	/* Streams server priority */
int	swk_request_weight = 5;	/* weighted count for message interface */

int	swk_nfile = 256;		/* Max number of files */
dev_t	swk_ftbl[256];		/* File table */
int	open_fdtbl[256];		

int	swk_sig_tid = 0;		/* Signal server TID */
int	swk_sig_prio = 1;	/* Signal server PRIO */

extern int sys_sc_tcreates();
int	(*sys_tcreate_fctp)() = (int (*)())sc_tcreate;

/*
 * RPC parameters
 */


int sca_lenbad;
int gethostname_first;
int snx_stats_enabled;
int snx_gratuitous_arp_enabled;
int snx_print_mem_err;

/*
 * TFTP parameters
 */
int	max_tftp_clients = 20;
char	tftp_homedir[] = "";

/*
 * TCP (keepalive) configuration parameters
 */
int	tcptv_keep_idle = 7200;
int	tcptv_keepintvl = 75;
int	tcptv_keepcnt   = 8;
int	tcp_maxrxtshift = 12;

/* 
 * IP and LOGIO Interface trace parameters
 */

unsigned char sw_trace_ip_in            = FALSE ;
unsigned char sw_trace_ip_out           = FALSE ;
unsigned char sw_trace_lgif_in          = FALSE ;
unsigned char sw_trace_lgif_out         = FALSE ;

unsigned char sw_trace_ip_not_for_us_include = FALSE ;

unsigned char sw_trace_lgif_not_bound_include = FALSE ;

unsigned long counter_trace_ip_in       = 0;
unsigned long counter_trace_ip_out      = 0;
unsigned long counter_trace_lgif_in     = 0;
unsigned long counter_trace_lgif_out    = 0;

unsigned short size_trace_ip_in         = 0;
unsigned short size_trace_ip_out        = 0;
unsigned short size_trace_lgif_in       = 0;
unsigned short size_trace_lgif_out      = 0;


struct struct_trace_ip_in       array_trace_ip_in [1];
struct struct_trace_ip_out      array_trace_ip_out [1];
struct struct_trace_lgif_in     array_trace_lgif_in [1];
struct struct_trace_lgif_out    array_trace_lgif_out [1];

/*
** Load function stubs for rtlsnx. Applications using
** rtlsnx continue to work as it is, w/o linking
** with snx libraries. This function pulls the rtlsnx
** functions into snx image.
*/
snx_app_func_load()
{
        snx_dummy_loadfunc();
} 


/*
 * SNX initialization
 */
void 
sys_initialize_snx()
{
	int		i, err;
	extern int	swk_main_task();
	extern void	swk_signal_server(),
			swk_tcp_init(),
			swk_timeout_init();
	struct dmod_conf *p;

	/*
	 * global variables
	 */
	gethostname_first = 1;
	sca_lenbad = 0;
	snx_stats_enabled = 0;
	snx_gratuitous_arp_enabled = 0;
	snx_print_mem_err = 1;


	/* Initializetion of structures, variables and arrays used for
	   SNX statistics. 
	*/
	snx_init_stats();
	/*
	 * open/close requests to be handle by a separate thread
	 */
        sc_qcreate(swk_ocq_id, swk_ocq_size, &err);
        if (err)
            (*sys_message_handler)(USECONSOLE | VSYSLIBID | FATALTYPE | SYS_ESNXREQ, err); 


	if (swk_init_msgqueue() == -1)
            (*sys_message_handler)(USECONSOLE | VSYSLIBID | FATALTYPE | SYS_ESNXMSGQ, NULL); 

	/* Initialize global file table */
	for (i = 0; i < swk_nfile; i++)
	{
		swk_ftbl[i] = NODEV;
		open_fdtbl[i] = 0;
	}
	/* Initialize SwK globol data */
	swk_start();

	/* Initialize global timeout data */
	swk_timeout_init();

	/* swk_main_task() has to run with kernel privileges */
	(*sys_tcreate_fctp)(swk_main_task, swk_tid, swk_priority, &err);
        if (err)
            (*sys_message_handler)(USECONSOLE | VSYSLIBID | FATALTYPE | SYS_ESNXTASK, err); 

	/* The signal server only needs user privileges */
	sc_tcreate(swk_signal_server, swk_sig_tid, swk_sig_prio, &err);
        if (err)
            (*sys_message_handler)(USECONSOLE | VSYSLIBID | FATALTYPE | SYS_ESNXSIGTASK, err); 

	/*
	 * Initialize all Streams modules.
         */ 

	for (p = dmodconf; p->initf; ++p)
       		(void) (*p->initf)();

	/* TCP/IP stack initialization */
	sc_tcreate(swk_tcp_init, 0, 
		   (swk_priority == 255) ? swk_priority : swk_priority + 1,
		   &err);
        if (err)
            (*sys_message_handler)(USECONSOLE | VSYSLIBID | FATALTYPE | SYS_ESNXTCPINIT, err); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -