📄 sdla_ppp.h
字号:
/*****************************************************************************
* sdla_ppp.h Sangoma PPP firmware API definitions.
*
* Author: Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-1997 Sangoma Technologies Inc.
*
* 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.
* ============================================================================
* Feb 24, 2000 Nenad Corbic v2.1.2
* Jan 06, 1997 Gene Kozin v2.0
* Apr 11, 1996 Gene Kozin Initial version.
*****************************************************************************/
#ifndef _SDLA_PPP_H
#define _SDLA_PPP_H
/*----------------------------------------------------------------------------
* Notes:
* ------
* 1. All structures defined in this file are byte-alined.
*
* Compiler Platform
* -------- --------
* GNU C Linux
*/
#ifndef PACKED
# define PACKED __attribute__((packed))
#endif /* PACKED */
/* Adapter memory layout and important constants */
#define PPP508_MB_VECT 0xE000 /* mailbox window vector */
#define PPP508_MB_OFFS 0 /* mailbox offset */
#define PPP508_FLG_OFFS 0x1000 /* status flags offset */
#define PPP508_BUF_OFFS 0x1100 /* buffer info block offset */
#define PPP514_MB_OFFS 0xE000 /* mailbox offset */
#define PPP514_FLG_OFFS 0xF000 /* status flags offset */
#define PPP514_BUF_OFFS 0xF100 /* buffer info block offset */
#define PPP_MAX_DATA 1008 /* command block data buffer length */
/****** Data Structures *****************************************************/
/*----------------------------------------------------------------------------
* PPP Command Block.
*/
typedef struct ppp_cmd{
unsigned char command PACKED; /* command code */
unsigned short length PACKED; /* length of data buffer */
unsigned char result PACKED; /* return code */
unsigned char rsrv[11] PACKED; /* reserved for future use */
} ppp_cmd_t;
typedef struct cblock{
unsigned char opp_flag PACKED;
unsigned char command PACKED; /* command code */
unsigned short length PACKED; /* length of data buffer */
unsigned char result PACKED; /* return code */
unsigned char rsrv[11] PACKED; /* reserved for future use */
} cblock_t;
typedef struct ppp_udp_pkt{
ip_pkt_t ip_pkt PACKED;
udp_pkt_t udp_pkt PACKED;
wp_mgmt_t wp_mgmt PACKED;
cblock_t cblock PACKED;
unsigned char data[MAX_LGTH_UDP_MGNT_PKT] PACKED;
} ppp_udp_pkt_t;
typedef struct {
unsigned char status PACKED;
unsigned char data_avail PACKED;
unsigned short real_length PACKED;
unsigned short time_stamp PACKED;
unsigned char data[1] PACKED;
} trace_pkt_t;
typedef struct {
unsigned char opp_flag PACKED;
unsigned char trace_type PACKED;
unsigned short trace_length PACKED;
unsigned short trace_data_ptr PACKED;
unsigned short trace_time_stamp PACKED;
} trace_element_t;
/* 'command' field defines */
#define PPP_READ_CODE_VERSION 0x10 /* configuration commands */
#define PPP_SET_CONFIG 0x05
#define PPP_READ_CONFIG 0x06
#define PPP_SET_INTR_FLAGS 0x20
#define PPP_READ_INTR_FLAGS 0x21
#define PPP_SET_INBOUND_AUTH 0x30
#define PPP_SET_OUTBOUND_AUTH 0x31
#define PPP_GET_CONNECTION_INFO 0x32
#define PPP_COMM_ENABLE 0x03 /* operational commands */
#define PPP_COMM_DISABLE 0x04
#define PPP_SEND_SIGN_FRAME 0x23
#define PPP_READ_SIGN_RESPONSE 0x24
#define PPP_DATALINE_MONITOR 0x33
#define PPP_READ_STATISTICS 0x07 /* statistics commands */
#define PPP_FLUSH_STATISTICS 0x08
#define PPP_READ_ERROR_STATS 0x09
#define PPP_FLUSH_ERROR_STATS 0x0A
#define PPP_READ_PACKET_STATS 0x12
#define PPP_FLUSH_PACKET_STATS 0x13
#define PPP_READ_LCP_STATS 0x14
#define PPP_FLUSH_LCP_STATS 0x15
#define PPP_READ_LPBK_STATS 0x16
#define PPP_FLUSH_LPBK_STATS 0x17
#define PPP_READ_IPCP_STATS 0x18
#define PPP_FLUSH_IPCP_STATS 0x19
#define PPP_READ_IPXCP_STATS 0x1A
#define PPP_FLUSH_IPXCP_STATS 0x1B
#define PPP_READ_PAP_STATS 0x1C
#define PPP_FLUSH_PAP_STATS 0x1D
#define PPP_READ_CHAP_STATS 0x1E
#define PPP_FLUSH_CHAP_STATS 0x1F
/* 'result' field defines */
#define PPPRES_OK 0x00 /* command executed successfully */
#define PPPRES_INVALID_STATE 0x09 /* invalid command in this context */
/*----------------------------------------------------------------------------
* PPP Mailbox.
* This structure is located at offset PPP???_MB_OFFS into PPP???_MB_VECT
*/
typedef struct ppp_mbox
{
unsigned char flag PACKED; /* 00h: command execution flag */
ppp_cmd_t cmd PACKED; /* 01h: command block */
unsigned char data[1] PACKED; /* 10h: variable length data buffer */
} ppp_mbox_t;
/*----------------------------------------------------------------------------
* PPP Status Flags.
* This structure is located at offset PPP???_FLG_OFFS into
* PPP???_MB_VECT.
*/
typedef struct ppp_flags
{
unsigned char iflag PACKED; /* 00: interrupt flag */
unsigned char imask PACKED; /* 01: interrupt mask */
unsigned char resrv PACKED;
unsigned char mstatus PACKED; /* 03: modem status */
unsigned char lcp_state PACKED; /* 04: LCP state */
unsigned char ppp_phase PACKED; /* 05: PPP phase */
unsigned char ip_state PACKED; /* 06: IPCP state */
unsigned char ipx_state PACKED; /* 07: IPXCP state */
unsigned char pap_state PACKED; /* 08: PAP state */
unsigned char chap_state PACKED; /* 09: CHAP state */
unsigned short disc_cause PACKED; /* 0A: disconnection cause */
} ppp_flags_t;
/* 'iflag' defines */
#define PPP_INTR_RXRDY 0x01 /* Rx ready */
#define PPP_INTR_TXRDY 0x02 /* Tx ready */
#define PPP_INTR_MODEM 0x04 /* modem status change (DCD, CTS) */
#define PPP_INTR_CMD 0x08 /* interface command completed */
#define PPP_INTR_DISC 0x10 /* data link disconnected */
#define PPP_INTR_OPEN 0x20 /* data link open */
#define PPP_INTR_DROP_DTR 0x40 /* DTR drop timeout expired */
#define PPP_INTR_TIMER 0x80 /* timer interrupt */
/* 'mstatus' defines */
#define PPP_MDM_DCD 0x08 /* mdm_status: DCD */
#define PPP_MDM_CTS 0x20 /* mdm_status: CTS */
/* 'disc_cause' defines */
#define PPP_LOCAL_TERMINATION 0x0001 /* Local Request by PPP termination phase */
#define PPP_DCD_CTS_DROP 0x0002 /* DCD and/or CTS dropped. Link down */
#define PPP_REMOTE_TERMINATION 0x0800 /* Remote Request by PPP termination phase */
/* 'misc_config_bits' defines */
#define DONT_RE_TX_ABORTED_I_FRAMES 0x01
#define TX_FRM_BYTE_COUNT_STATS 0x02
#define RX_FRM_BYTE_COUNT_STATS 0x04
#define TIME_STAMP_IN_RX_FRAMES 0x08
#define NON_STD_ADPTR_FREQ 0x10
#define INTERFACE_LEVEL_RS232 0x20
#define AUTO_LINK_RECOVERY 0x100
#define DONT_TERMINATE_LNK_MAX_CONFIG 0x200
/* 'authentication options' defines */
#define NO_AUTHENTICATION 0x00
#define INBOUND_AUTH 0x80
#define PAP_AUTH 0x01
#define CHAP_AUTH 0x02
/* 'ip options' defines */
#define L_AND_R_IP_NO_ASSIG 0x00
#define L_IP_LOCAL_ASSIG 0x01
#define L_IP_REMOTE_ASSIG 0x02
#define R_IP_LOCAL_ASSIG 0x04
#define R_IP_REMOTE_ASSIG 0x08
#define ENABLE_IP 0x80
/* 'ipx options' defines */
#define ROUTING_PROT_DEFAULT 0x20
#define ENABLE_IPX 0x80
#define DISABLE_IPX 0x00
/*----------------------------------------------------------------------------
* PPP Buffer Info.
* This structure is located at offset PPP508_BUF_OFFS into
* PPP508_MB_VECT.
*/
typedef struct ppp508_buf_info
{
unsigned short txb_num PACKED; /* 00: number of transmit buffers */
unsigned long txb_ptr PACKED; /* 02: pointer to the buffer ctl. */
unsigned long txb_nxt PACKED;
unsigned char rsrv1[22] PACKED;
unsigned short rxb_num PACKED; /* 20: number of receive buffers */
unsigned long rxb_ptr PACKED; /* 22: pointer to the buffer ctl. */
unsigned long rxb1_ptr PACKED; /* 26: pointer to the first buf.ctl. */
unsigned long rxb_base PACKED; /* 2A: pointer to the buffer base */
unsigned char rsrv2[2] PACKED;
unsigned long rxb_end PACKED; /* 30: pointer to the buffer end */
} ppp508_buf_info_t;
/*----------------------------------------------------------------------------
* Transmit/Receive Buffer Control Block.
*/
typedef struct ppp_buf_ctl
{
unsigned char flag PACKED; /* 00: 'buffer ready' flag */
unsigned short length PACKED; /* 01: length of data */
unsigned char reserved1[1] PACKED; /* 03: */
unsigned char proto PACKED; /* 04: protocol */
unsigned short timestamp PACKED; /* 05: time stamp (Rx only) */
unsigned char reserved2[5] PACKED; /* 07: */
union
{
unsigned short o_p[2]; /* 1C: buffer offset & page (S502) */
unsigned long ptr; /* 1C: buffer pointer (S508) */
} buf PACKED;
} ppp_buf_ctl_t;
/*----------------------------------------------------------------------------
* S508 Adapter Configuration Block (passed to the PPP_SET_CONFIG command).
*/
typedef struct ppp508_conf
{
unsigned long line_speed PACKED; /* 00: baud rate, bps */
unsigned short txbuf_percent PACKED; /* 04: % of Tx buffer */
unsigned short conf_flags PACKED; /* 06: configuration bits */
unsigned short mtu_local PACKED; /* 08: local MTU */
unsigned short mtu_remote PACKED; /* 0A: remote MTU */
unsigned short restart_tmr PACKED; /* 0C: restart timer */
unsigned short auth_rsrt_tmr PACKED; /* 0E: authentication timer */
unsigned short auth_wait_tmr PACKED; /* 10: authentication timer */
unsigned short mdm_fail_tmr PACKED; /* 12: modem failure timer */
unsigned short dtr_drop_tmr PACKED; /* 14: DTR drop timer */
unsigned short connect_tmout PACKED; /* 16: connection timeout */
unsigned short conf_retry PACKED; /* 18: max. retry */
unsigned short term_retry PACKED; /* 1A: max. retry */
unsigned short fail_retry PACKED; /* 1C: max. retry */
unsigned short auth_retry PACKED; /* 1E: max. retry */
unsigned char auth_options PACKED; /* 20: authentication opt. */
unsigned char ip_options PACKED; /* 21: IP options */
unsigned long ip_local PACKED; /* 22: local IP address */
unsigned long ip_remote PACKED; /* 26: remote IP address */
unsigned char ipx_options PACKED; /* 2A: IPX options */
unsigned char ipx_netno[4] PACKED; /* 2B: IPX net number */
unsigned char ipx_local[6] PACKED; /* 2F: local IPX node number*/
unsigned char ipx_remote[6] PACKED; /* 35: remote IPX node num.*/
unsigned char ipx_router[48] PACKED; /* 3B: IPX router name*/
unsigned long alt_cpu_clock PACKED; /* 6B: */
} ppp508_conf_t;
/*----------------------------------------------------------------------------
* S508 Adapter Read Connection Information Block
* Returned by the PPP_GET_CONNECTION_INFO command
*/
typedef struct ppp508_connect_info
{
unsigned short mru PACKED; /* 00-01 Remote Max Rec' Unit */
unsigned char ip_options PACKED; /* 02: Negotiated ip options */
unsigned long ip_local PACKED; /* 03-06: local IP address */
unsigned long ip_remote PACKED; /* 07-0A: remote IP address */
unsigned char ipx_options PACKED; /* 0B: Negotiated ipx options */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -