/*	stub.inc - Simulated shim and managment channel commands and data.
*
*******************************************************************************
* Copyright (c) 1996-97 Digi International Inc., All Rights Reserved          *
*                                                                             *
* This  software  contains  proprietary  and  confidential   information   of *
* Digi International  Inc.   By  accepting  transfer  of this copy, Recipient *
* agrees to retain this software in  confidence,  to  prevent  disclosure  to *
* others,  and  to make no  use of this software other than that for which it *
* was delivered.  This is an unpublished copyright work  Digi   International *
* Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is *
* strictly prohibited.                                                        *
*                                                                             *
* Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc. *
* Confidential  when   combined   with   the   aggregated  modules  for  this *
* product) OBJECT CODE ONLY SOURCE MATERIALS                                  *
*                                                                             *
* (C) COPYRIGHT Digi International Inc. 1996-97                               *
*                                                                             *
* All Rights Reserved                                                         *
*                                                                             *
* US   Government   Users   Restricted   Rights   -   Use,   duplication   or *
* disclosure  restricted by GSA ADP Schedule Contract with Digi International *
* Inc.                                                                        *
*                                                                             *
*******************************************************************************
*
*/

#include <string.h>
#include "triglbl.h"
#include "mgmthlc.h"
#include "hou2.h"

uint32 MGMT_DECL
stub_Trace (
		uint32	BoardNumber,	/* 1 to total boards or ignored if not applicable */
		uint16	Command,		/* obvious */
		void	*mpkt,			/* msg packet.  This is the data portion of the ioctl. */
		uint16	mpktlen,		/* need to know its length */
		void	*rpkt,			/* response packet.  This is the data portion of the ioctl response */
		uint16	rpktlen,		/* I hate access violations. */
		TRC_DATACOPY_CB	cb,				/* This is the function I call when traces come in. */
		TRCARG			handle )		/* cb functions "handle" */
{
    return(BAD_COMMAND);
}

uint32 MGMT_DECL
stub_Command (
		uint32	BoardNumber,	/* 1 to total boards or ignored if not applicable */
		uint16	Command,		/* obvious */
		void	*mpkt,			/* msg packet.  This is the data portion of the ioctl. */
		uint16	mpktlen,		/* need to know its length */
		void	*rpkt,			/* response packet.  This is the data portion of the ioctl response */
		uint16	rpktlen)		/* I hate access violations. */
{
	uint32 nResult = MGMT_OK;

	switch (Command)
	{
		case GET_MGMT_SHIM_VER:
		{
			((get_mgmt_shim_ver_response_t *)rpkt)->ver = MGMT_SHIM_VERSION;
			break;
	    }

		case GET_MGMT_BOARD_NO:
		{
			((get_mgmt_board_no_response_t *)rpkt)->NumberOfBoards = 3;
			break;
	    }
    
		case GET_MGMT_BOARD_INFO:
		{
			get_mgmt_board_info_response_t *response;

			response = (get_mgmt_board_info_response_t *)rpkt;

			if (BoardNumber == 1) {
				response->BoardInfo.BoardNo = 1;
				response->BoardInfo.BrdId = 0xFF;
				response->BoardInfo.BoardType = POST_TYPE_LONDON_U;
				response->BoardInfo.TotalPorts = 4;
				response->BoardInfo.TotalChannels = 4 * 2;
			}
			else if (BoardNumber == 2) {
				response->BoardInfo.BoardNo = 2;
				response->BoardInfo.BrdId = 0xFF;
				response->BoardInfo.BoardType = POST_TYPE_CHASKA;
				response->BoardInfo.TotalPorts = 8;
				response->BoardInfo.TotalChannels = 8 * 1;
			}
			else if (BoardNumber == 3) {
				response->BoardInfo.BoardNo = 3;
				response->BoardInfo.BrdId = 0xFF;
				response->BoardInfo.BoardType = POST_TYPE_HOUSTON_T1;
				response->BoardInfo.TotalPorts = 2;
				response->BoardInfo.TotalChannels = 2 * 24;
			}
			else
			{
				nResult = MGMT_SHIM_ERROR_BAD_DEVICE;
			}

			break;
	    }
    
		case GET_MGMT_PROTOCOL_VERSION:
		{
			get_mgmt_protocol_ver_response_t *response = rpkt;

			response->mgmt_protocol_version = MGMT_SHIM_VERSION;

			break;
		}
    
		case GET_ADAPTER_INFO:
		{
			get_adapter_info_response_t *response;

			response = (get_adapter_info_response_t *)rpkt;

			if (BoardNumber == 1) {
				response->info.board_type = ADAPTER_LONU;
				response->info.port_count = 4;
				response->info.channels_per_port = 2;
				response->info.memory_size = 1;
				response->info.fep_version = 2;
				response->info.csc_version = 3;
				response->info.pump_version = 4;
				response->info.main_board_revision = 5;
				strcpy((char *)&response->info.main_board_serial[0],
				   "1234567");
				response->info.daughter_card_revision = 6;
				strcpy((char *)&response->info.daughter_card_serial[0],
				   "1234567");
				strcpy((char *)&response->info.part_number[0],
				   "1234567");
			}
			else if (BoardNumber == 2) {
				response->info.board_type = ADAPTER_CHASKA8;
				response->info.port_count = 8;
				response->info.channels_per_port = 1;
				response->info.memory_size = 1;
				response->info.fep_version = 2;
				response->info.csc_version = 3;
				response->info.pump_version = 4;
				response->info.main_board_revision = 5;
				strcpy((char *)&response->info.main_board_serial[0],
				   "2234567");
				response->info.daughter_card_revision = 6;
				strcpy((char *)&response->info.daughter_card_serial[0],
				   "2234567");
				strcpy((char *)&response->info.part_number[0],
				   "2234567");
			}
			else if (BoardNumber == 3) {
				response->info.board_type = ADAPTER_HOU48;
				response->info.port_count = 2;
				response->info.channels_per_port = 24;
				response->info.memory_size = 1;
				response->info.fep_version = 2;
				response->info.csc_version = 3;
				response->info.pump_version = 4;
				response->info.main_board_revision = 5;
				strcpy((char *)&response->info.main_board_serial[0],
				   "3234567");
				response->info.daughter_card_revision = 6;
				strcpy((char *)&response->info.daughter_card_serial[0],
				   "3234567");
				strcpy((char *)&response->info.part_number[0],
				   "3234567");
			}
			else
			{
				nResult = MGMT_SHIM_ERROR_BAD_DEVICE;
			}

			break;
		}

		case GET_MODEM_NATIONALITY:
		{
			modem_nationality_t *response;

			response = (modem_nationality_t *)rpkt;
			response->country_code = COUNTRY_CODE_UNITED_STATES;

			break;
		}

		case GET_MGMT_DRV_VERS:
		{
			get_mgmt_drv_vers_response_t *response;

			response = (get_mgmt_drv_vers_response_t *)rpkt;
			response->versions.driverCount = 2;
			response->versions.drivers[0].type = MGMT_DXB_DRV_VER;
			strcpy((char *)&response->versions.drivers[0].name[0],
				   "bob's yer uncle");
			strcpy((char *)&response->versions.drivers[0].version[0],
				   "enter date & time here");
			response->versions.drivers[1].type = MGMT_MGMT_DRV_VER;
			strcpy((char *)&response->versions.drivers[1].name[0],
				   "aaron's a goof");
			strcpy((char *)&response->versions.drivers[1].version[0],
				   "1998/11/25/14:05");

			break;
		}
    
		case GET_ADAPTER_STATE:
		{
			get_adapter_state_response_t *response;

			response = (get_adapter_state_response_t *)rpkt;
			response->state.memory_usage = 10;
			response->state.cpu_usage = 11;
			response->state.dxb_h2a_count = 12;
			response->state.dxb_a2h_count = 13;
			response->state.uptime.seconds = 14;
			response->state.uptime.mseconds = 15;

			break;
	    }

		case GET_DS1_CONFIG:
		{
			get_ds1_config_response_t *response;

			response = (get_ds1_config_response_t *)rpkt;
			response->config.coding = LINE_CODE_B8ZS;
			response->config.framing = FRAME_ESF;
			response->config.if_type = LONG_HAUL;
			response->config.long_haul_lbo = LBO_00_0_DB;
			response->config.short_haul_len = SH_0_133;
			response->config.signalling = PRI_NI2;
			response->config.wink_digits = 1;
			response->config.clocking = TIMING_LOOP;
			response->config.jitter_atten = 1;
			response->config.eq_gain_limit = 1;
			response->config.leased_mask = 1;

			break;
	    }

		case GET_DS1_EXT_CONFIG:
		{
			get_ds1_ext_config_response_t *response;

			response = (get_ds1_ext_config_response_t *)rpkt;

			response->config.tx_special = 1;
			response->config.auto_config = 1;
			response->config.loopback = 1;

			break;
	    }

		case GET_DS1_STATUS:
		{
			get_ds1_status_response_t *response;

			response = (get_ds1_status_response_t *)rpkt;

			response->status.rx_special = 1;
			response->status.alarm = 1;
			response->status.loopback = 1;

			break;
	    }

		case GET_DS1_EXT_STATUS:
		{
			get_ds1_ext_status_response_t *response;

			response = (get_ds1_ext_status_response_t *)rpkt;

			response->status.errored_seconds  = 1;
			response->status.unavailable_seconds  = 1;
			response->status.bursty_seconds  = 1;
			response->status.severe_seconds  = 1;
			response->status.severe_framing_seconds  = 1;
			response->status.controlled_slip_seconds  = 1;
			response->status.loss_of_frame_count  = 1;
			response->status.degraded_minutes  = 1;
			response->status.line_errored_seconds  = 1;
			response->status.line_code_violations  = 1;
			response->status.crc_error_count  = 1;

			break;
	    }

		case GET_DS1_CT1_SIG_STATUS:
		{
			get_ds1_ct1_sig_status_response_t *response;

			response = (get_ds1_ct1_sig_status_response_t *)rpkt;

			break;
	    }

		case GET_BRI_CONFIG:
		{
			get_bri_config_response_t *response;

			response = (get_bri_config_response_t *)rpkt;
			response->config.switch_type = 1 ;
			response->config.auto_spid = 2 ;
			strcpy((char *)&response->config.directory[0].number[0],
				   "1234567");
			strcpy((char *)&response->config.directory[0].sub_address[0],
				   "1234567");
			strcpy((char *)&response->config.directory[0].spid[0],
				   "1234567");

			response->config.directory[1].number[0] = '\0';
			response->config.directory[1].sub_address[0] = '\0';
			response->config.directory[1].spid[0] = '\0';

			break;
	    }     

		case GET_BRI_STATUS:
		{
			get_bri_status_response_t *response;

			response = (get_bri_status_response_t *)rpkt;

			response->status.power  = 1;
			response->status.activation_state  = 1;
			response->status.rx_info_state  = 1;
			response->status.tx_info_state  = 1;
			response->status.loss_of_sync  = 1;
			response->status.collisions  = 1;

			break;
	    }

		case GET_DCHAN_EXT_CONFIG:
		{
			get_dchan_ext_config_response_t *response;

			response = (get_dchan_ext_config_response_t *)rpkt;

			response->config.mode = 1;
			response->config.address_type = 1;
			response->config.numbering_plan = 1;
			response->config.subaddress_type = 1;

			break;
	    }

		case GET_DCHAN_EXT_STATUS:
		{
			get_dchan_ext_status_response_t *response;

			response = (get_dchan_ext_status_response_t *)rpkt;

			response->status.tei_state = 1;

			response->status.hdlc.tx_bytes = 1;
			response->status.hdlc.rx_bytes = 1;
			response->status.hdlc.tx_frames = 1;
			response->status.hdlc.rx_frames = 1;
			response->status.hdlc.rx_bad_frames = 1;
			response->status.hdlc.rx_short_frames = 1;
			response->status.hdlc.rx_long_frames = 1;
			response->status.hdlc.rx_aborts = 1;
			response->status.hdlc.rx_overruns = 1;
			response->status.hdlc.rx_crc_errors = 1;
			response->status.hdlc.rx_buffer_overflows = 1;
			response->status.hdlc.tx_underruns = 1;

			response->status.lapd.RR_rx_cmd = 1;
			response->status.lapd.RR_rx_rsp = 1;
			response->status.lapd.RR_tx_cmd = 1;
			response->status.lapd.RR_tx_rsp = 1;
			response->status.lapd.RR_tx_cmd_p = 1;
			response->status.lapd.RNR_rx_cmd = 1;
			response->status.lapd.RNR_rx_rsp = 1;
			response->status.lapd.RNR_tx_cmd = 1;
			response->status.lapd.RNR_tx_rsp = 1;
			response->status.lapd.RNR_tx_cmd_p = 1;
			response->status.lapd.REJ_rx_cmd = 1;
			response->status.lapd.REJ_rx_rsp = 1;
			response->status.lapd.REJ_tx_cmd = 1;
			response->status.lapd.REJ_tx_rsp = 1;
			response->status.lapd.REJ_tx_cmd_p = 1;
			response->status.lapd.I_tx_cmd = 1;
			response->status.lapd.I_rx_cmd = 1;
			response->status.lapd.SABME_rx_cmd = 1;
			response->status.lapd.SABME_tx_cmd = 1;
			response->status.lapd.DISC_rx_cmd = 1;
			response->status.lapd.DISC_tx_cmd = 1;
			response->status.lapd.UA_rx_rsp = 1;
			response->status.lapd.UA_tx_rsp = 1;
			response->status.lapd.DM_rx_rsp = 1;
			response->status.lapd.DM_tx_rsp = 1;
			response->status.lapd.UI_rx_cmd = 1;
			response->status.lapd.UI_tx_cmd = 1;
			response->status.lapd.FRMR_rx_rsp = 1;
			response->status.lapd.FRMR_tx_rsp = 1;
			response->status.lapd.XID_rx_cmd = 1;
			response->status.lapd.XID_rx_rsp = 1;
			response->status.lapd.XID_tx_cmd = 1;
			response->status.lapd.XID_tx_rsp = 1;
			response->status.lapd.rx_badlen = 1;
			response->status.lapd.rx_unknown = 1;
			response->status.lapd.rx_bad = 1;
			response->status.lapd.rx_dud = 1;
			response->status.lapd.rx_ign = 1;
			response->status.lapd.tx_rtr = 1;
			response->status.lapd.tx_ign = 1;
			response->status.lapd.T200_exp = 1;
			response->status.lapd.T200_N200_exp = 1;
			response->status.lapd.rx_mgmt_dud = 1;
			response->status.lapd.rx_mgmt_badlen = 1;
			response->status.lapd.rx_mgmt_ign = 1;
			response->status.lapd.rx_mgmt_unknown = 1;
			response->status.lapd.rx_tei_assigned = 1;
			response->status.lapd.rx_tei_denied = 1;
			response->status.lapd.rx_tei_check = 1;
			response->status.lapd.rx_tei_remove = 1;

			break;
	    }

		case GET_CALL_STATUS:
		{
			get_call_status_response_t *response;

			response = (get_call_status_response_t *)rpkt;

			response->status.call_state  = 1;
			response->status.call_type  = 1;
			response->status.index  = 1;
			response->status.timeslot  = 1;

			break;
	    }

		case GET_ALL_CALL_STATUS:
		{
			int temp, pc;
			get_all_call_status_response_t *response;

			response = (get_all_call_status_response_t *)rpkt;

			if (BoardNumber == 1)
				pc = 2;
			else if (BoardNumber == 2)
				pc = 1;
			else 
				pc = 23;

			response->count  = pc;
			for (temp = 0; temp < pc; temp++) {
				response->status[temp].call_state  = 1;
				response->status[temp].call_type  = 1;
				response->status[temp].index  = 1;
				response->status[temp].timeslot  = 1;
			}

			break;
	    }

		case GET_MODEM_CONFIG:
		{
			get_modem_config_response_t *response;

			response = (get_modem_config_response_t *)rpkt;

			response->config.answer_rings = 1;
			response->config.clid_enable = 1;
			response->config.max_rate = 1;
			response->config.min_rate = 1;
			response->config.hangup = 0;
			response->config.reset = 0;

			break;
		}

		case GET_MODEM_EXT_CONFIG:
		{
			get_modem_ext_config_response_t *response;

			response = (get_modem_ext_config_response_t *)rpkt;

			response->config.busy_out = 1;
			response->config.leased_line = 1;
			response->config.audio_level_rx = 1;
			response->config.audio_level_tx = 1;

			break;
	    }
    
		case GET_MODEM_STATUS:
		{
			get_modem_status_response_t *response;

			response = (get_modem_status_response_t *)rpkt;

			response->status.mode = 1;
			response->status.dte_tx_rate = 1;
			response->status.dte_rx_rate = 1;
			response->status.port = 1;
			response->status.index = 1;
			response->status.connect_time = 1;
			response->status.initial_tx_rate = 1;
			response->status.initial_rx_rate = 1;
			response->status.current_tx_rate = 1;
			response->status.current_rx_rate = 1;
			response->status.modulation = 1;
			response->status.compression = 1;
			response->status.error_correction = 1;
			response->status.page_number = 1;
			response->status.last_disconnect = 1;

			strcpy((char *)&response->status.clid[0], "1234567");
			strcpy((char *)&response->status.local_dn[0], "1234567");
			strcpy((char *)&response->status.remote_dn[0], "1234567");

			break;
	    }

		case GET_MODEM_EXT_STATUS:
		{
			get_modem_ext_status_response_t *response;

			response = (get_modem_ext_status_response_t *)rpkt;

			response->status.symbol_rate = 1;
			response->status.carrier_freq = 1;
			response->status.estimated_snr = 1;
			response->status.estimated_rtt = 1;
			response->status.tx_signal_level = 1;
			response->status.rx_signal_level = 1;
			response->status.local_retrains = 1;
			response->status.remote_retrains = 1;
			response->status.manual_retrains = 1;
			response->status.renegotiate_count = 1;
			response->status.mean_square_error = 1;
			response->status.trellis_size = 1;
			response->status.block_errors = 1;
			response->status.resends = 1;
			response->status.dictionary_size = 1;
			response->status.max_string_length = 1;

			break;
	    }

		case GET_BCHAN_EXT_CONFIG:
		{
			get_bchan_ext_config_response_t *response;

			response = (get_bchan_ext_config_response_t *)rpkt;

			response->config.hangup = 1;
			response->config.cause_code = 1;

			break;
	    }

		case GET_BCHAN_STATUS:
		{
			get_bchan_status_response_t *response;

			response = (get_bchan_status_response_t *)rpkt;

			response->status.mode = 1;
			response->status.dte_tx_rate = 1;
			response->status.dte_rx_rate = 1;
			response->status.port = 1;
			response->status.index = 1;
			response->status.connect_time = 1;
			response->status.channel_rate = 1;
			response->status.compression = 1;
			response->status.last_disconnect = 1;

			strcpy((char *)&response->status.local_dn[0], "1234567");
			strcpy((char *)&response->status.remote_dn[0], "1234567");

			break;
	    }

		case GET_BCHAN_EXT_STATUS:
		{
			get_bchan_ext_status_response_t *response;

			response = (get_bchan_ext_status_response_t *)rpkt;

			response->status.hdlc.tx_bytes = 1;
			response->status.hdlc.rx_bytes = 1;
			response->status.hdlc.tx_frames = 1;
			response->status.hdlc.rx_frames = 1;
			response->status.hdlc.rx_bad_frames = 1;
			response->status.hdlc.rx_short_frames = 1;
			response->status.hdlc.rx_long_frames = 1;
			response->status.hdlc.rx_aborts = 1;
			response->status.hdlc.rx_overruns = 1;
			response->status.hdlc.rx_crc_errors = 1;
			response->status.hdlc.rx_buffer_overflows = 1;
			response->status.hdlc.tx_underruns = 1;

			break;
	    }

		case GET_SERIAL_STATUS:
		{
			get_serial_status_response_t *response;

			response = (get_serial_status_response_t *)rpkt;

			response->status.port_state = 1;
			response->status.frame_mode = 1;

			response->status.in_flow_type[0] = 1;
			response->status.in_flow_type[1] = 0;
			response->status.in_flow_type[2] = 0;

			response->status.out_flow_type[0] = 0; 
			response->status.out_flow_type[1] = 0; 
			response->status.out_flow_type[2] = 0; 

			response->status.in_flow_state[0] = 0; 
			response->status.in_flow_state[1] = 0; 
			response->status.in_flow_state[2] = 0; 

			response->status.out_flow_state[0] = 0; 
			response->status.out_flow_state[1] = 0; 
			response->status.out_flow_state[2] = 0; 

			response->status.mdm_sig_state[0] = 1;
			response->status.mdm_sig_state[1] = 1;
			response->status.mdm_sig_state[2] = 1;
			response->status.mdm_sig_state[3] = 1;
			response->status.mdm_sig_state[4] = 1;
			response->status.mdm_sig_state[5] = 1;

			response->status.in_speed = 1;
			response->status.out_speed = 1;
			response->status.autobaud = 1;

			response->status.data_bits = 1;
			response->status.stop_bits = 1;
			response->status.parity = 1;

			break;
		}

		case GET_SERIAL_EXT_STATUS:
		{
			get_serial_ext_status_response_t *response;

			response = (get_serial_ext_status_response_t *)rpkt;

			response->status.tx_bytes = 1;
			response->status.rx_bytes = 1;
			response->status.tx_frames = 1;
			response->status.rx_frames = 1;
			response->status.rx_bad_frames = 1;
			response->status.rx_short_frames = 1;
			response->status.rx_long_frames = 1;
			response->status.rx_aborts = 1;
			response->status.rx_overruns = 1;
			response->status.rx_crc_errors = 1;
			response->status.rx_buffer_overflows = 1;
			response->status.tx_underruns = 1;

			response->status.interrupted_frames = 1;

			response->status.breaks_received = 1;
			response->status.parity_errs = 1;
			response->status.framing_errs = 1;
			response->status.overrun_errs = 1;

			response->status.rxaccm = 1;
			response->status.txaccm = 1;

			break;
	    }

		case GET_SERIAL_CONFIG:
		{
			get_serial_config_response_t *response;

			response = (get_serial_config_response_t *)rpkt;

			response->config.port_type = 1;
			response->config.clock_source = 1;
			response->config.alt_pin = 1;

			break;
	    }

		case GET_SERIAL_EXT_CONFIG:
		{
			get_serial_ext_config_response_t *response;

			response = (get_serial_ext_config_response_t *)rpkt;

			response->config.unpause_rx = 0;
			response->config.unpause_tx = 0;

			break;
	    }

		default:
		{
			nResult = MGMT_SHIM_ERROR_BAD_COMMAND;
			break;
		}
	}

    return nResult;
}
