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

📄 diag_l3.h

📁 Freediag contains various drivers (ISO9141, ISO14230, SAEJ1850-VPW, SAEJ1850-PWM) for different adap
💻 H
字号:
/*
 *	freediag - Vehicle Diagnostic Utility
 *
 * CVSID $Id: diag_l3.h,v 1.2 2002/08/23 18:54:35 rpalmeida Exp $
 *
 * Copyright (C) 2001 Richard Almeida & Ibex Ltd (rpa@ibex.co.uk)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *************************************************************************
 *
 * L3 header.
 *
 */

#ifndef _DIAG_L3_H_
#define _DIAG_L3_H_

/*
 * Layer 3 connection info
 */
typedef struct diag_l3_conn
{
	diag_l2_conn_t	*d_l3l2_conn;
	int d_l3l2_flags;		/* Flags from L2 */
	int d_l3l1_flags;		/* Flags from L1 */
	
	int diag_l3_speed;		/* Speed */

	struct diag_l3_proto *d_l3_proto;

	/* Callback into next layer (which passed us the handle) */
	void (*callback)(void *handle, diag_msg_t *msg);
	void *handle;

	/* Data buffer, and offset into it */
	u_int8_t rxbuf[1024];	/* Receive data buffer */
	int	rxoffset;

	/* Received messages */
	diag_msg_t	*msg;

	/* General purpose timer */
	struct timeval	timer;

	/* Linked list held by main L3 code */
	struct diag_l3_conn	*next;


	/* Source address this connection is using */
	u_int8_t	src;

} diag_l3_conn_t;

/*
 * L3 Protocol look up table
 */
typedef struct diag_l3_proto
{
	char *proto_name;

	int (*diag_l3_proto_start)(diag_l3_conn_t *);
	int (*diag_l3_proto_stop)(diag_l3_conn_t *);
	int (*diag_l3_proto_send)(diag_l3_conn_t *, diag_msg_t *);
	int (*diag_l3_proto_recv)(diag_l3_conn_t *, int,
		void (* rcv_call_back)(void *handle ,diag_msg_t *) , void *);
	int (*diag_l3_proto_ioctl)(diag_l3_conn_t *, int cmd, void *data);

	/* Pretty text decode routine */
	char	*(*diag_l3_proto_decode)(diag_l3_conn_t *, diag_msg_t *);

	/* Timer */
	void (*diag_l3_proto_timer)(diag_l3_conn_t *, int ms);

} diag_l3_proto_t;


diag_l3_conn_t * diag_l3_start(char *protocol, diag_l2_conn_t *d_l2_conn);
int	diag_l3_stop(diag_l3_conn_t *d_l3_conn);
int	diag_l3_send(diag_l3_conn_t *d_l3_conn, diag_msg_t *msg);
int	diag_l3_recv(diag_l3_conn_t *d_l3_conn, int timeout,
	void (* rcv_call_back)(void *handle ,diag_msg_t *) , void *handle);
char * diag_l3_decode(diag_l3_conn_t *d_l3_conn, diag_msg_t *msg);

void diag_l3_timer();	/* Regular timer routine */

#endif

⌨️ 快捷键说明

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