maintidi.c

来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 2,112 行 · 第 1/5 页

C
2,112
字号
					"Statistics\\B-Layer1\\R-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b1.R_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer1\\R-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b1.R_Errors;	/*		B-Layer2		*/	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\X-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.X_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\X-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.X_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\X-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.X_Errors;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\R-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.R_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\R-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.R_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\B-Layer2\\R-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.b2.R_Errors;	/*		D-Layer1		*/	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\X-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.X_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\X-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.X_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\X-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.X_Errors;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\R-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.R_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\R-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.R_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer1\\R-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d1.R_Errors;	/*		D-Layer2		*/	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\X-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.X_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\X-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.X_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\X-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.X_Errors;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\R-Frames");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.R_Frames;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\R-Bytes");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.R_Bytes;	strcpy (pLib->parse_table[pLib->cur_parse_entry].path,					"Statistics\\D-Layer2\\R-Errors");	pLib->parse_table[pLib->cur_parse_entry++].variable = \																		&pLib->InterfaceStat.d2.R_Errors;	pLib->statistic_parse_last  = pLib->cur_parse_entry - 1;}static void diva_trace_error (diva_strace_context_t* pLib,															int error, const char* file, int line) {	if (pLib->user_proc_table.error_notify_proc) {		(*(pLib->user_proc_table.error_notify_proc))(\																						pLib->user_proc_table.user_context,																						&pLib->instance, pLib->Adapter,																						error, file, line);	}}/*	Delivery notification to user	*/static void diva_trace_notify_user (diva_strace_context_t* pLib,														 int Channel,														 int notify_subject) {	if (pLib->user_proc_table.notify_proc) {		(*(pLib->user_proc_table.notify_proc))(pLib->user_proc_table.user_context,																					 &pLib->instance,																					 pLib->Adapter,																					 &pLib->lines[Channel],																					 notify_subject);	}}/*	Read variable value to they destination based on the variable type	*/static int diva_trace_read_variable (diva_man_var_header_t* pVar,																		 void* variable) {	switch (pVar->type) {		case 0x03: /* MI_ASCIIZ - syting                               */			return (diva_strace_read_asz  (pVar, (char*)variable));		case 0x04: /* MI_ASCII  - string                               */			return (diva_strace_read_asc  (pVar, (char*)variable));		case 0x05: /* MI_NUMBER - counted sequence of bytes            */			return (diva_strace_read_ie  (pVar, (diva_trace_ie_t*)variable));		case 0x81: /* MI_INT    - signed integer                       */			return (diva_strace_read_int (pVar, (int*)variable));		case 0x82: /* MI_UINT   - unsigned integer                     */			return (diva_strace_read_uint (pVar, (dword*)variable));		case 0x83: /* MI_HINT   - unsigned integer, hex representetion */			return (diva_strace_read_uint (pVar, (dword*)variable));		case 0x87: /* MI_BITFLD - unsigned integer, bit representation */			return (diva_strace_read_uint (pVar, (dword*)variable));	}	/*		This type of variable is not handled, indicate error		Or one problem in management interface, or in application recodeing		table, or this application should handle it.		*/	return (-1);}/*	Read signed integer to destination	*/static int diva_strace_read_int  (diva_man_var_header_t* pVar, int* var) {	byte* ptr = (char*)&pVar->path_length;	int value;	ptr += (pVar->path_length + 1);	switch (pVar->value_length) {		case 1:			value = *(char*)ptr;			break;		case 2:			value = (short)READ_WORD(ptr);			break;		case 4:			value = (int)READ_DWORD(ptr);			break;		default:			return (-1);	}	*var = value;	return (0);}static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var) {	byte* ptr = (char*)&pVar->path_length;	dword value;	ptr += (pVar->path_length + 1);	switch (pVar->value_length) {		case 1:			value = (byte)(*ptr);			break;		case 2:			value = (word)READ_WORD(ptr);			break;		case 3:			value  = (dword)READ_DWORD(ptr);			value &= 0x00ffffff;			break;		case 4:			value = (dword)READ_DWORD(ptr);			break;		default:			return (-1);	}	*var = value;	return (0);}/*	Read zero terminated ASCII string	*/static int diva_strace_read_asz  (diva_man_var_header_t* pVar, char* var) {	char* ptr = (char*)&pVar->path_length;	int length;	ptr += (pVar->path_length + 1);	if (!(length = pVar->value_length)) {		length = strlen (ptr);	}	memcpy (var, ptr, length);	var[length] = 0;	return (0);}/*	Read counted (with leading length byte) ASCII string	*/static int diva_strace_read_asc  (diva_man_var_header_t* pVar, char* var) {	char* ptr = (char*)&pVar->path_length;	ptr += (pVar->path_length + 1);	memcpy (var, ptr+1, *ptr);	var[(int)*ptr] = 0;	return (0);}/*		Read one information element - i.e. one string of byte values with		one length byte in front	*/static int  diva_strace_read_ie  (diva_man_var_header_t* pVar,																	diva_trace_ie_t* var) {	char* ptr = (char*)&pVar->path_length;	ptr += (pVar->path_length + 1);	var->length = *ptr;	memcpy (&var->data[0], ptr+1, *ptr);	return (0);}static int SuperTraceSetAudioTap  (void* hLib, int Channel, int on) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	if ((Channel < 1) || (Channel > pLib->Channels)) {		return (-1);	}	Channel--;	if (on) {		pLib->audio_tap_mask |=  (1L << Channel);	} else {		pLib->audio_tap_mask &= ~(1L << Channel);	}  /*    EYE patterns have TM_M_DATA set as additional    condition    */  if (pLib->audio_tap_mask) {    pLib->trace_event_mask |= TM_M_DATA;  } else {    pLib->trace_event_mask &= ~TM_M_DATA;  }	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceSetBChannel  (void* hLib, int Channel, int on) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	if ((Channel < 1) || (Channel > pLib->Channels)) {		return (-1);	}	Channel--;	if (on) {		pLib->bchannel_trace_mask |=  (1L << Channel);	} else {		pLib->bchannel_trace_mask &= ~(1L << Channel);	}	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceSetDChannel  (void* hLib, int on) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	if (on) {		pLib->trace_event_mask |= (TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1);	} else {		pLib->trace_event_mask &= ~(TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1);	}	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceSetInfo (void* hLib, int on) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	if (on) {		pLib->trace_event_mask |= TM_STRING;	} else {		pLib->trace_event_mask &= ~TM_STRING;	}	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceClearCall (void* hLib, int Channel) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	if ((Channel < 1) || (Channel > pLib->Channels)) {		return (-1);	}	Channel--;	pLib->clear_call_command |= (1L << Channel);	return (ScheduleNextTraceRequest (pLib));}/*	Parse and update cumulative statistice	*/static int diva_ifc_statistics (diva_strace_context_t* pLib,																diva_man_var_header_t* pVar) {	diva_man_var_header_t* cur;	int i, one_updated = 0, mdm_updated = 0, fax_updated = 0;	for (i  = pLib->statistic_parse_first; i <= pLib->statistic_parse_last; i++) {		if ((cur = find_var (pVar, pLib->parse_table[i].path))) {			if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) {				diva_trace_error (pLib, -3 , __FILE__, __LINE__);				return (-1);			}			one_updated = 1;      if ((i >= pLib->mdm_statistic_parse_first) && (i <= pLib->mdm_statistic_parse_last)) {        mdm_updated = 1;      }      if ((i >= pLib->fax_statistic_parse_first) && (i <= pLib->fax_statistic_parse_last)) {        fax_updated = 1;      }		}	}	/*		We do not use first event to notify user - this is the event that is		generated as result of EVENT ON operation and is used only to initialize		internal variables of application		*/  if (mdm_updated) {		diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE);  } else if (fax_updated) {		diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE);  } else if (one_updated) {		diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE);	}	return (one_updated ? 0 : -1);}static int SuperTraceGetOutgoingCallStatistics (void* hLib) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	pLib->outgoing_ifc_stats = 1;	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceGetIncomingCallStatistics (void* hLib) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	pLib->incoming_ifc_stats = 1;	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceGetModemStatistics (void* hLib) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	pLib->modem_ifc_stats = 1;	return (ScheduleNextTraceRequest (pLib));}static int SuperTraceGetFaxStatistics (void* hLib) {	diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;	pLib->fax_ifc_

⌨️ 快捷键说明

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