init ems server code

This commit is contained in:
2024-09-27 15:39:34 +08:00
parent 9d4009aaca
commit 9930e4e58f
1551 changed files with 110216 additions and 102864 deletions

View File

@@ -0,0 +1,88 @@
#ifndef _M2UA__H
#define _M2UA__H
typedef struct _m2ua_up_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed));
BYTE sio __attribute__((packed));
union
{
struct
{
BYTE content[256] __attribute__((packed));
}mtp3 __attribute__((packed));
struct
{
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}lm __attribute__((packed));
}msg __attribute__((packed));
}m2ua_up_msg_t;
void m2ua_init(BYTE);
void m2ua_timer(void);
int get_m2ua_msg(m2ua_up_msg_t **data_ptr);
int put_m2ua_msg(m2ua_up_msg_t *data_ptr);
int set_m2ua_link(BYTE link, BYTE *data_ptr);
int set_m2ua_sg(WORD sg, BYTE *data_ptr);
int m2ua_restart();
//add by yizane
typedef struct _xua_lm_lk
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len = 3 */
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}xua_lm_lk;
typedef struct _xua_iua_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len for content */
BYTE content[256] __attribute__((packed));
}xua_iua_msg;
typedef struct _xua_m2ua_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len for content */
BYTE content[256] __attribute__((packed));
}xua_m2ua_msg;
typedef struct _xua_up_msg
{
BYTE msg_class __attribute__((packed));
union
{
xua_lm_lk lm_lk __attribute__((packed));
xua_m2ua_msg m2ua __attribute__((packed));
xua_iua_msg iua __attribute__((packed));
}msg __attribute__((packed));
}xua_up_msg_t;
int get_xua_msg(BYTE xUA_type, xua_up_msg_t **data_ptr);
int put_xua_msg(xua_up_msg_t *data_ptr);
#define XUAHEADOFFSET 3
#define RESERVE_FOR_IUAHEAD (28 - XUAHEADOFFSET)
#define RESERVE_FOR_M2UAHEAD (20 - XUAHEADOFFSET)
//msg_class
#define IUA_QPTM_MSG 0x05
#define M2UA_MAUP_MSG 0x06
#define IUA_MGMT_CMD 0xA5
#define M2UA_MGMT_CMD 0xA6
#define IUA_APP 1
#define M2UA_APP 0
//add by yizane
#endif

View File

@@ -0,0 +1,330 @@
#ifndef _M2UA_CONST__H
#define _M2UA_CONST__H
#define M2UA_MAX_LK_NUM 256
#define M2UA_MAX_MSG_LEN 256
#define M2UA_MAX_SG_NUM 512
#define M2UA_LISTEN_SG_NUM_0 512
#define IUA_LISTEN_SG_NUM_0 513
#define IUA_PORT_0 9900
#define M2UA_PORT_0 2904
#define M2UA_LISTEN_SG_NUM_1 514
#define IUA_LISTEN_SG_NUM_1 515
#define IUA_PORT_1 9901
#define M2UA_PORT_1 2905
#define M2UA_MAX_SG_FSM_NUM (512+4)//for listen m2ua*2,iua*2
#define M2UA_MAX_M3MSG_NUM 2048
#define M2UA_MAX_M3MSG_NUM_1 2047
#define M2UA_SCTP_CMD_BUFSIZE 5*1024
#define M2UA_SCTP_DAT_BUFSIZE 5*1024
#define M2UA_FAILURE -1
#define M2UA_SUCCESS 0
#define M2UA_CMD_IDLEW 0xEEEE
// M2UA Message Class
#define M2UA_MCLASS_MGMT 0
#define M2UA_MCLASS_ASPSM 3
#define M2UA_MCLASS_ASPTM 4
#define M2UA_MCLASS_MAUP 6
#define M2UA_MCLASS_IIM 10
//add by yizane
#define xUA_MCLASS_MGMT 0
#define xUA_MCLASS_TRMSG 1
#define xUA_MCLASS_SSNM 2
#define xUA_MCLASS_ASPSM 3
#define xUA_MCLASS_ASPTM 4
#define xUA_MCLASS_QPTM 5
#define xUA_MCLASS_MAUP 6
#define xUA_MCLASS_IIM 10
//add by yizane
// M2UA ASPSM Message Type
#define ASP_UP 1
#define ASP_DOWN 2
#define HEARTBEAT 3
#define ASP_UP_ACK 4
#define ASP_DOWN_ACK 5
#define HEARTBEAT_ACK 6
// M2UA ASPSM Combined Message Type
#define M2UA_ASPSM_ASP_UP (M2UA_MCLASS_ASPSM << 8) + ASP_UP
#define M2UA_ASPSM_ASP_DOWN (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN
#define M2UA_ASPSM_HEARTBEAT (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT
#define M2UA_ASPSM_ASP_UP_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define M2UA_ASPSM_ASP_DOWN_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define M2UA_ASPSM_HEARTBEAT_ACK (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
//add by yizane
#define xUA_ASPSM_ASP_UP (xUA_MCLASS_ASPSM << 8) + ASP_UP
#define xUA_ASPSM_ASP_DOWN (xUA_MCLASS_ASPSM << 8) + ASP_DOWN
#define xUA_ASPSM_HEARTBEAT (xUA_MCLASS_ASPSM << 8) + HEARTBEAT
#define xUA_ASPSM_ASP_UP_ACK (xUA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define xUA_ASPSM_ASP_DOWN_ACK (xUA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define xUA_ASPSM_HEARTBEAT_ACK (xUA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
//add by yizane
#define ASP_ACTIVE 1
#define ASP_INACTIVE 2
#define ASP_ACTIVE_ACK 3
#define ASP_INACTIVE_ACK 4
#define M2UA_ASPTM_ASP_ACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define M2UA_ASPTM_ASP_INACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define M2UA_ASPTM_ASP_ACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define M2UA_ASPTM_ASP_INACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
//add by yizane
#define xUA_ASPTM_ASP_ACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define xUA_ASPTM_ASP_INACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define xUA_ASPTM_ASP_ACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define xUA_ASPTM_ASP_INACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
//add by yizane
//for MAUP
#define DATA 1
#define ESTABLISH_REQ 2
#define ESTABLISH_CFM 3
#define RELEASE_REQ 4
#define RELEASE_CFM 5
#define RELEASE_IND 6
#define STATE_REQ 7
#define STATE_CFM 8
#define STATE_IND 9
#define DATA_RETIEVE_REQ 10
#define DATA_RETIEVE_CFM 11
#define DATA_RETIEVE_IND 12
#define DATA_RETIEVE_CMP 13
#define CONGESTION_IND 14
#define DATA_ACK 15
#define M2UA_MAUP_DATA (M2UA_MCLASS_MAUP << 8) + DATA
#define M2UA_MAUP_ESTABLISH_REQ (M2UA_MCLASS_MAUP << 8) + ESTABLISH_REQ
#define M2UA_MAUP_ESTABLISH_CFM (M2UA_MCLASS_MAUP << 8) + ESTABLISH_CFM
#define M2UA_MAUP_RELEASE_REQ (M2UA_MCLASS_MAUP << 8) + RELEASE_REQ
#define M2UA_MAUP_RELEASE_CFM (M2UA_MCLASS_MAUP << 8) + RELEASE_CFM
#define M2UA_MAUP_RELEASE_IND (M2UA_MCLASS_MAUP << 8) + RELEASE_IND
#define M2UA_MAUP_STATE_REQ (M2UA_MCLASS_MAUP << 8) + STATE_REQ
#define M2UA_MAUP_STATE_CFM (M2UA_MCLASS_MAUP << 8) + STATE_CFM
#define M2UA_MAUP_STATE_IND (M2UA_MCLASS_MAUP << 8) + STATE_IND
#define M2UA_MAUP_DATA_RETIEVE_REQ (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_REQ
#define M2UA_MAUP_DATA_RETIEVE_CFM (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CFM
#define M2UA_MAUP_DATA_RETIEVE_IND (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_IND
#define M2UA_MAUP_DATA_RETIEVE_CMP (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CMP
#define M2UA_MAUP_CONGESTION_IND (M2UA_MCLASS_MAUP << 8) + CONGESTION_IND
#define M2UA_MAUP_DATA_ACK (M2UA_MCLASS_MAUP << 8) + DATA_ACK
//add by yizane
//for QPTM
#define IUA_DATA_REQ 1
#define IUA_DATA_IND 2
#define IUA_UDATA_REQ 3
#define IUA_UDATA_IND 4
#define IUA_ESTABLISH_REQ 5
#define IUA_ESTABLISH_CFM 6
#define IUA_ESTABLISH_IND 7
#define IUA_RELEASE_REQ 8
#define IUA_RELEASE_CFM 9
#define IUA_RELEASE_IND 10
#define IUA_QPTM_DATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_DATA_REQ
#define IUA_QPTM_DATA_IND (xUA_MCLASS_QPTM << 8) + IUA_DATA_IND
#define IUA_QPTM_UDATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_UDATA_REQ
#define IUA_QPTM_UDATA_IND (xUA_MCLASS_QPTM << 8) + IUA_UDATA_IND
#define IUA_QPTM_ESTABLISH_REQ (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_REQ
#define IUA_QPTM_ESTABLISH_CFM (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_CFM
#define IUA_QPTM_ESTABLISH_IND (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_IND
#define IUA_QPTM_RELEASE_REQ (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_REQ
#define IUA_QPTM_RELEASE_CFM (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_CFM
#define IUA_QPTM_RELEASE_IND (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_IND
//add by yizane
#define ERROR 0
#define NOTIFY 1
//add by yizane
#define TEI_S_REQ 2
#define TEI_S_CFM 3
#define TEI_S_IND 4
//add by yizane
#define M2UA_MGMT_ERROR (M2UA_MCLASS_MGMT << 8) + ERROR
#define M2UA_MGMT_NOTIFY (M2UA_MCLASS_MGMT << 8) + NOTIFY
//add by yizane
#define xUA_MGMT_ERROR (xUA_MCLASS_MGMT << 8) + ERROR
#define xUA_MGMT_NOTIFY (xUA_MCLASS_MGMT << 8) + NOTIFY
#define xUA_MGMT_TEI_S_REQ (xUA_MCLASS_MGMT << 8) + TEI_S_REQ
#define xUA_MGMT_TEI_S_CFM (xUA_MCLASS_MGMT << 8) + TEI_S_CFM
#define xUA_MGMT_TEI_S_IND (xUA_MCLASS_MGMT << 8) + TEI_S_IND
//add by yizane
#define M2UA_IIM_REG_REQ 1
#define M2UA_IIM_REG_RSP 2
#define M2UA_IIM_DEREG_REQ 3
#define M2UA_IIM_DEREG_RSP 4
#define M2UA_PAR_INTERFACE_ID_INT 0x0001
#define M2UA_PAR_INTERFACE_ID_TXT 0x0003
#define M2UA_PAR_TRAFFIC_MODE 0x000B
#define M2UA_PAR_ASP_IDENTIFIER 0x0011
#define M2UA_PAR_PROTO_DATA_1 0x0300
#define M2UA_PAR_CORRELATION_ID 0x0013
#define M2UA_PAR_STATE 0x0302
#define M2UA_PAR_STATUS 0x000D
#define M2UA_PAR_ERR_CODE 0x000C
//add by yizane
#define xUA_PAR_DLCI 0x0005
#define xUA_PAR_PROTOCOL_DATA 0x000E
#define xUA_PAR_REL_REASON 0x000F
#define xUA_PAR_TEI_STATUS 0x0010
//add by yizane
#define M2UA_STATUS_LPO_SET 0x0
#define M2UA_STATUS_LPO_CLEAR 0x1
#define M2UA_STATUS_EMER_SET 0x2
#define M2UA_STATUS_EMER_CLEAR 0x3
#define M2UA_STATUS_FLUSH_BUFFERS 0x4
#define M2UA_STATUS_CONTINUE 0x5
#define M2UA_STATUS_CLEAR_RTB 0x6
#define M2UA_STATUS_AUDIT 0x7
#define M2UA_STATUS_CONG_CLEAR 0x8
#define M2UA_STATUS_CONG_ACCEPT 0x9
#define M2UA_STATUS_CONG_DISCARD 0xa
#define M2UA_STATUS_TYPE_AS_STATE_CHG 1
#define M2UA_STATUS_TYPE_OTHER 2
#define M2UA_STATUS_INFO_AS_RESERVED 1
#define M2UA_STATUS_INFO_AS_INACTIVE 2
#define M2UA_STATUS_INFO_AS_ACTIVE 3
#define M2UA_STATUS_INFO_AS_PENDING 4
#define M2UA_ERR_INVALID_VERSION 0x1
#define M2UA_ERR_INVALID_IID 0x2
#define M2UA_ERR_UNSUPPORTED_MSG_CLASS 0x3
#define M2UA_ERR_UNSUPPORTED_MSG_TYPE 0x4
#define M2UA_ERR_UNSUPPORTED_TRA_HDL_MODE 0x5
#define M2UA_ERR_UNEXPECTED_MSG 0x6
#define M2UA_ERR_PROTOCOL_ERROR 0x7
#define M2UA_ERR_UNSUPPORTED_IIT 0x8
#define M2UA_ERR_INVALID_SID 0x9
#define M2UA_ERR_REFUSED_MGMT_BLOCK 0xd
#define M2UA_ERR_ASP_ID_REQUIRED 0xe
#define M2UA_ERR_INVALID_ASP_ID 0xf
#define M2UA_ERR_ASP_ACTIVE_FOR_IID 0x10
#define M2UA_ERR_INVALID_PARA_VAL 0x11
#define M2UA_ERR_PARA_FIELD_ERROR 0x12
#define M2UA_ERR_UNEXPECTED_PARA 0x13
#define M2UA_ERR_MISSING_PARA 0x16
//add by yizane
#define IUA_TEI_ASSIGNED 0x0
#define IUA_TEI_UNASSIGNED 0x1
#define IUA_RELEASE_MGMT 0x00
#define IUA_RELEASE_PHYS 0x01
#define IUA_RELEASE_DM 0x02
#define IUA_RELEASE_OTHER 0x03
//add by yizane
#define M2UA_TRAFFIC_MODE_OVERRIDE 1
#define M2UA_TRAFFIC_MODE_LOADSHARE 2
#define M2UA_TRAFFIC_MODE_BROADCAST 3
#define M2UA_LK_IDLE 0
#define M2UA_LK_DOWN 1
#define M2UA_LK_UP 5
#define M2UA_LK_PO 6
#define M2UA_MCLASS_MTP3 1
#define M2UA_MCLASS_LM 2
#define M2UA_MTP3_SIO_CMD 0xFF
#define M2UA_SIO_CMD 0xEF
#define M2UA_MTP3_SIO_MSG 0x80
#define M2UA_LK_ATTR_SIGTRAN 1
#define M2UA_MTP3_MAX_LS_NUM 128
#define M2UA_MTP3_CMD_ACTIVE_LK 1
#define M2UA_MTP3_CMD_DEACTIVE_LK 2
#define M2UA_MTP3_CMD_STOP_L2 3
#define M2UA_MTP3_CMD_EMERG_ALIGN 4
#define M2UA_T_ACK 100 // 2 seconds = 100 * 20ms
#define M2UA_T_R 100 // 2 seconds
#define M2UA_T_LK_ESTAB 4 // 10 seconds = 4 * 2.56s
#define M2UA_T_SG_ESTAB_1 500 // 10 seconds
#define M2UA_T_SG_ESTAB_2 6000 // 120 seconds
#define M2UA_T_SG_ESTAB_3 1500 // 30 seconds
#define M2UA_T_SG_WAIT 100 // 2 seconds
#define M2UA_CMD_IDLE 0
#define M2UA_CMD_PARA_SAVE 1
#define M2UA_CMD_PARA_INIT 2
#define M2UA_CMD_STATUS_INIT 3
#define M2UA_MGMT_CMD_LK_LOCK 1
//add by yizane
#define IUA_MGMT_CMD_LK_LOCK 2
//add by yizane
#define MAX_ASCIIIN_LEN 4096
#define MAX_ASCIIOUT_LEN 4096
#define MAX_ASCITMP_LEN 4096
#define MONITOR_NONE 0x0000
#define MONITOR_MTP3 0x0001
#define MONITOR_M2UA 0x0002
#define MONITOR_MAUP 0x0004
#define MONITOR_SCTP 0x0008
#define MONITOR_ERROR 0x0010
#define MONITOR_ALL 0xffff
#define M2UA_MAX_RETRANS 10
#define M2UA_STOP_M2UA_LINK 6
#define M2UA_ENABLE_M2UA_LINK 7
//add by yizane
#define xUA_STOP_xUA_LINK 6
#define xUA_ENABLE_xUA_LINK 7
//add by yizane
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_UP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_LOST & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_SHUTDOWN_COMP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_RESTART ((SCTP_ASSOC_CHANGE << 16) | (SCTP_RESTART & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC ((SCTP_ASSOC_CHANGE << 16) | (SCTP_CANT_STR_ASSOC & 0xFFFF))
#define M2UA_LKSCTP_SEND_FAILED (SCTP_SEND_FAILED << 16)
#define M2UA_LKSCTP_PEER_ADDR_CHANGE (SCTP_PEER_ADDR_CHANGE << 16)
#define M2UA_LKSCTP_REMOTE_ERROR (SCTP_REMOTE_ERROR << 16)
#define M2UA_LKSCTP_SHUTDOWN_EVENT (SCTP_SHUTDOWN_EVENT << 16)
#define M2UA_LKSCTP_DATA_IND 0x7FFFFFFE
#define M2UA_LKSCTP_UNKNOWN_EVENT 0x7FFFFFFF
#define M2UA_ALARM_CODE_NORMAL 0
#define M2UA_ALARM_CODE_SCTP_FAILURE 1
#define M2UA_ALARM_CODE_REMOTE_AS_DOWN 2
#define M2UA_ALARM_CODE_REMOTE_LINK_RELEASE 3
#define M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN 4
#define M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE 5
#define M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE 6
#endif

View File

@@ -0,0 +1,10 @@
#ifndef _M2UA_DEBUG__H
#define _M2UA_DEBUG__H
void m2ua_mon(void);
int m2ua_debug_set(void);
int m2ua_asciout_proc(BYTE *out_str);
int m2ua_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc);
int m2ua_log_err(WORD sg_id, BYTE *err_msg);
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _M2UA_DEF__H
#define _M2UA_DEF__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
//const BYTE m2ua_ver[3] = {10, 0, 6};
BYTE m2ua_command = 0;
m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];//for listen m2ua*2,iua*2
m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
m2ua_sctp_addr_t m2ua_sctp_addr;
m2ua_sctp_cmd_t m2ua_sctp_cmd;
BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE];
int m2ua_sctp_cmd_len;
int m2ua_sctp_dat_len;
#ifndef _LKSCTP
struct strbuf m2ua_sctp_ctrl = {M2UA_SCTP_CMD_BUFSIZE, 0, m2ua_sctp_cmd.cbuf};
struct strbuf m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#else
m2ua_sctp_data_t m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#endif
m2ua_para_t m2ua_para;
BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD m2ua_mtp3_sd_h;
WORD m2ua_mtp3_sd_t;
//add by yizane
BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD iua_q931_sd_h;
WORD iua_q931_sd_t;
//add by yizane
DWORD x256[M2UA_MAX_M3MSG_NUM];
char hostip[20];
char hostname[50];
DWORD host_ip;
BYTE plat_id;
m2ua_sctp_addr_t m2ua_sctp_server_addr;
m2ua_csta_t m2ua_csta;
BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
WORD moniter_fg;
BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
WORD m2ua_sg_mon_count;
WORD m2ua_lk_mon_count;
DWORD err[64];
BYTE init_flag;
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _M2UA_EXT__H
#define _M2UA_EXT__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
//extern const BYTE m2ua_ver[3];
extern BYTE m2ua_command;
extern m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];
extern m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
extern m2ua_sctp_addr_t m2ua_sctp_addr;
extern m2ua_sctp_cmd_t m2ua_sctp_cmd;
extern BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE];
extern int m2ua_sctp_cmd_len;
extern int m2ua_sctp_dat_len;
#ifndef _LKSCTP
extern struct strbuf m2ua_sctp_ctrl;
extern struct strbuf m2ua_sctp_data;
#else
extern m2ua_sctp_data_t m2ua_sctp_data;
#endif
extern m2ua_para_t m2ua_para;
extern BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD m2ua_mtp3_sd_h;
extern WORD m2ua_mtp3_sd_t;
//add by yizane
extern BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD iua_q931_sd_h;
extern WORD iua_q931_sd_t;
//add by yizane
extern DWORD x256[M2UA_MAX_M3MSG_NUM];
extern char hostip[20];
extern char hostname[50];
extern DWORD host_ip;
extern BYTE plat_id;
extern m2ua_sctp_addr_t m2ua_sctp_server_addr;
extern m2ua_csta_t m2ua_csta;
extern BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
extern BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
extern BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
extern WORD moniter_fg;
extern BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
extern BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
extern WORD m2ua_sg_mon_count;
extern WORD m2ua_lk_mon_count;
extern DWORD err[64];
extern BYTE init_flag;
#endif

View File

@@ -0,0 +1,9 @@
#ifndef _M2UA_FSM__H
#define _M2UA_FSM__H
int m2ua_sg_fsm(WORD sg_id);
int m2ua_fsm(WORD sg_id);
int rel_sid(WORD sg, BYTE lk);
#endif

View File

@@ -0,0 +1,53 @@
#ifndef _M2UA_MSG__H
#define _M2UA_MSG__H
#define COMBO_W(par_class,par_type) ((par_class << 8) + par_type)
int m2ua_sctp_close(int fd, WORD sg_id);
int m2ua_dec_msg(WORD sg_id);
int m2ua_send_msg(WORD sg_id, WORD msg);
int m2ua_sd_mtp3_primi(BYTE lk, BYTE primi);
int m2ua_sd_mtp3_msg(WORD sg, BYTE lk);
//add by yizane
int iua_sd_q931_primi(BYTE lk, BYTE primi);
int iua_sd_q931_msg(WORD sg, BYTE lk);
//add by yizane
int m2ua_sg_init(WORD id);
int m2ua_lk_init(BYTE id);
int enable_sg(WORD sg);
int rm_sg_lk(WORD sg, BYTE lk);
char *dec_sctp_primi(long sctp_primi);
#ifndef _LKSCTP
int m2ua_sctp_t_open(WORD sg);
int expect(int fd, int sg, int *msg, int want);
int m2ua_sctp_optmgmt_req(int fd, int sg, DWORD flags);
int m2ua_sctp_bind_req(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_conn_res(int fd, int fd2, int sg, long seq);
int m2ua_sctp_ordrel_req(int fd, int sg);
int m2ua_sctp_discon_req(int fd, int sg, DWORD seq);
int m2ua_sctp_conn_req(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_optdata_req(int fd, int sg, BYTE len);
#else
int m2ua_sctp_optmgmt_req_lksctp(int fd, int sg);
int m2ua_sctp_optmgmt_req_lksctp_ext(int fd, int sg);
int m2ua_sctp_bind_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_open_lksctp(WORD sg);
int m2ua_sctp_conn_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_get_msg_lksctp(int fd, WORD sg);
int expect_lksctp(int fd, int sg, int *msg, int want);
int m2ua_sctp_discon_req_lksctp(int fd, int sg, int flag);
int m2ua_sctp_put_msg_lksctp(int fd, int sg);
int m2ua_sctp_optdata_req_lksctp(int fd, int sg, int len);
#endif
#endif

View File

@@ -0,0 +1,63 @@
#ifndef _M2UA_PUB__H
#define _M2UA_PUB__H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <netdb.h>
#include <setjmp.h>
#include <unistd.h>
#include <signal.h>
#include <stropts.h>
#include <time.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/io.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <sys/select.h>
#ifndef _LKSCTP
#include <sys/tpi.h>
#include <sys/tpi_sctp.h>
#include <sys/xti_ip.h>
#include <sys/xti_sctp.h>
#else
#include <netinet/sctp.h>
#endif
#ifndef _T_BYTE
#define _T_BYTE
typedef unsigned char BYTE;
#endif
#ifndef _T_WORD
#define _T_WORD
typedef unsigned short WORD;
#endif
#ifndef _T_DWORD
#define _T_DWORD
typedef unsigned int DWORD;
#endif
#endif

View File

@@ -0,0 +1,240 @@
#ifndef _M2UA_STRUCT__H
#define _M2UA_STRUCT__H
#include "m2ua_const.h"
#ifndef _LKSCTP
typedef union _m2ua_sctp_cmd
{
union T_primitives tpi;
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE];
}m2ua_sctp_cmd_t;
// Data Options
typedef struct _m2ua_sctp_opt_data
{
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
}m2ua_sctp_opt_data_t;
// Connect Options
typedef struct _m2ua_sctp_opt_conn
{
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
}m2ua_sctp_opt_conn_t;
// Management Options
typedef struct _m2ua_sctp_opt_optm
{
struct t_opthdr nod_hdr __attribute__((packed));
t_scalar_t nod_val __attribute__((packed));
struct t_opthdr crk_hdr __attribute__((packed));
t_scalar_t crk_val __attribute__((packed));
struct t_opthdr ppi_hdr __attribute__((packed));
t_scalar_t ppi_val __attribute__((packed));
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
struct t_opthdr rcv_hdr __attribute__((packed));
t_scalar_t rcv_val __attribute__((packed));
struct t_opthdr ckl_hdr __attribute__((packed));
t_scalar_t ckl_val __attribute__((packed));
struct t_opthdr skd_hdr __attribute__((packed));
t_scalar_t skd_val __attribute__((packed));
struct t_opthdr prt_hdr __attribute__((packed));
t_scalar_t prt_val __attribute__((packed));
struct t_opthdr art_hdr __attribute__((packed));
t_scalar_t art_val __attribute__((packed));
struct t_opthdr irt_hdr __attribute__((packed));
t_scalar_t irt_val __attribute__((packed));
struct t_opthdr hbi_hdr __attribute__((packed));
t_scalar_t hbi_val __attribute__((packed));
struct t_opthdr rin_hdr __attribute__((packed));
t_scalar_t rin_val __attribute__((packed));
struct t_opthdr rmn_hdr __attribute__((packed));
t_scalar_t rmn_val __attribute__((packed));
struct t_opthdr rmx_hdr __attribute__((packed));
t_scalar_t rmx_val __attribute__((packed));
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
struct t_opthdr cin_hdr __attribute__((packed));
t_scalar_t cin_val __attribute__((packed));
struct t_opthdr tin_hdr __attribute__((packed));
t_scalar_t tin_val __attribute__((packed));
struct t_opthdr mac_hdr __attribute__((packed));
t_scalar_t mac_val __attribute__((packed));
struct t_opthdr dbg_hdr __attribute__((packed));
t_scalar_t dbg_val __attribute__((packed));
}m2ua_sctp_opt_optm_t;
#else
typedef union _m2ua_sctp_cmd
{
struct cmsghdr cmsg __attribute__((packed));
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE] __attribute__((packed));
}m2ua_sctp_cmd_t;
typedef struct _m2ua_sctp_data
{
int len __attribute__((packed));
int sid __attribute__((packed));
BYTE *buf __attribute__((packed));
}m2ua_sctp_data_t;
#endif
typedef struct _m2ua_sctp_addr
{
uint16_t port __attribute__((packed));
struct in_addr addr __attribute__((packed));
}m2ua_sctp_addr_t;
typedef struct _m2ua_lk_info
{
BYTE enable __attribute__((packed));
BYTE lk_st __attribute__((packed));
WORD sid __attribute__((packed));
DWORD lk_timer __attribute__((packed));
BYTE alarm_code __attribute__((packed));
BYTE lk_act __attribute__((packed));
}m2ua_lk_info_t;
typedef struct _m2ua_sg_info
{
BYTE enable __attribute__((packed));
BYTE sctp_state __attribute__((packed));
BYTE sctp_state_1 __attribute__((packed));
BYTE m2ua_state __attribute__((packed));
DWORD sctp_cmd __attribute__((packed));
WORD m2ua_cmd __attribute__((packed));
WORD mtp3_cmd __attribute__((packed));
WORD mgmt_cmd __attribute__((packed));
WORD fd __attribute__((packed));
WORD iid __attribute__((packed));
DWORD sid_st[8] __attribute__((packed));
BYTE *msg __attribute__((packed));
WORD msg_len __attribute__((packed));
WORD rem_ostrs __attribute__((packed));
WORD T_ack __attribute__((packed));
WORD T_r __attribute__((packed));
BYTE con_sg __attribute__((packed));
BYTE state __attribute__((packed));
BYTE err_code __attribute__((packed));
BYTE tra_hdl_mode __attribute__((packed));
WORD act_lks __attribute__((packed));
WORD istrs __attribute__((packed));
WORD ostrs __attribute__((packed));
DWORD status __attribute__((packed));
DWORD seq __attribute__((packed));
DWORD cor_id __attribute__((packed));
WORD up_lks_pre __attribute__((packed));
WORD up_lks_cur __attribute__((packed));
DWORD sg_timer __attribute__((packed));
BYTE retrans_times __attribute__((packed));
WORD rem_port __attribute__((packed));
BYTE alarm_code __attribute__((packed));
//add by yizane
BYTE rel_reason __attribute__((packed));
BYTE tei_state __attribute__((packed));
BYTE dlci __attribute__((packed));
//add by yizane
}m2ua_sg_info_t;
typedef struct _m2ua_comhdr
{
BYTE version __attribute__((packed));
BYTE spare __attribute__((packed));
BYTE msg_class __attribute__((packed));
BYTE msg_type __attribute__((packed));
DWORD len __attribute__((packed));
}m2ua_comhdr_t;
typedef struct _m2ua_par_hdr
{
WORD tag __attribute__((packed));
WORD len __attribute__((packed));
}m2ua_par_hdr_t;
typedef struct _m2ua_var_par
{
m2ua_par_hdr_t hdr __attribute__((packed));
BYTE val[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_var_par_t;
typedef struct _m2ua_msg
{
m2ua_comhdr_t comhdr __attribute__((packed));
BYTE msg[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_msg_t;
typedef struct _sg_para
{
BYTE enable __attribute__((packed));
BYTE server __attribute__((packed));
BYTE xUA_ack __attribute__((packed)); //BIT 1-7:xUA_type,0/1:M2UA/IUA ,Bit 0: ACK
DWORD ip __attribute__((packed));
WORD plat_port[2] __attribute__((packed));
}sg_para_t;
typedef struct _lk_para
{
BYTE enable __attribute__((packed));
WORD lk_sg __attribute__((packed));
BYTE iid __attribute__((packed));
WORD dlci __attribute__((packed));
}lk_para_t;
typedef struct _m2ua_para
{
sg_para_t sg_para[M2UA_MAX_SG_NUM] __attribute__((packed));
lk_para_t lk_para[M2UA_MAX_LK_NUM] __attribute__((packed));
BYTE cmd __attribute__((packed));
}m2ua_para_t;
typedef struct _m2ua_lk_pro
{
BYTE e1_to_linkset __attribute__((packed));
BYTE e1_to_slc __attribute__((packed));
DWORD e1_to_mtp3 __attribute__((packed));
BYTE e1_lk_type __attribute__((packed));
BYTE e1_to_sg __attribute__((packed));
BYTE e1_to_iid __attribute__((packed));
DWORD remote_ip __attribute__((packed));
BYTE inactive __attribute__((packed));
BYTE inactive_tm __attribute__((packed));
DWORD e1_to_alterMTP3 __attribute__((packed));
}m2ua_lk_pro_t;
typedef struct _m2ua_sg_csta
{
DWORD timestamp __attribute__((packed));
DWORD sg_out_msg __attribute__((packed));
DWORD sg_in_msg __attribute__((packed));
DWORD sg_out_bytes __attribute__((packed));
DWORD sg_in_bytes __attribute__((packed));
DWORD sg_asp_dn_times __attribute__((packed));
}m2ua_sg_csta_t;
typedef struct _m2ua_lk_csta
{
DWORD timestamp __attribute__((packed));
DWORD lk_out_msg __attribute__((packed));
DWORD lk_in_msg __attribute__((packed));
DWORD lk_out_bytes __attribute__((packed));
DWORD lk_in_bytes __attribute__((packed));
DWORD lk_dn_times __attribute__((packed));
}m2ua_lk_csta_t;
typedef struct _m2ua_csta
{
m2ua_sg_csta_t sg_csta[M2UA_MAX_SG_NUM] __attribute__((packed));
m2ua_lk_csta_t lk_csta[M2UA_MAX_LK_NUM] __attribute__((packed));
}m2ua_csta_t;
#endif

View File

@@ -0,0 +1,655 @@
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2004
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
*
* This file is part of the SCTP kernel reference Implementation
*
* This header represents the structures and constants needed to support
* the SCTP Extension to the Sockets API.
*
* The SCTP reference implementation 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, or (at your option)
* any later version.
*
* The SCTP reference implementation 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 GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Please send any bug reports or fixes you make to the
* email address(es):
* lksctp developers <lksctp-developers@lists.sourceforge.net>
*
* Or submit a bug report through the following website:
* http://www.sf.net/projects/lksctp
*
* Written or modified by:
* La Monte H.P. Yarroll <piggy@acm.org>
* R. Stewart <randall@sctp.chicago.il.us>
* K. Morneau <kmorneau@cisco.com>
* Q. Xie <qxie1@email.mot.com>
* Karl Knutson <karl@athena.chicago.il.us>
* Jon Grimm <jgrimm@austin.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Inaky Perez-Gonzalez <inaky.gonzalez@intel.com>
* Sridhar Samudrala <sri@us.ibm.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
*/
#ifndef __linux_sctp_h__
#define __linux_sctp_h__
#include <stdint.h>
#include <linux/types.h>
#include <sys/socket.h>
__BEGIN_DECLS
typedef void * sctp_assoc_t;
/* Socket option layer for SCTP */
#ifndef SOL_SCTP
#define SOL_SCTP 132
#endif
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
/* 9. Preprocessor constants */
#define HAVE_SCTP
#define HAVE_KERNEL_SCTP
#define HAVE_SCTP_MULTIBUF
#define HAVE_SCTP_NOCONNECT
/* The following symbols come from the Sockets API Extensions for
* SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
*/
enum sctp_optname {
SCTP_RTOINFO,
#define SCTP_RTOINFO SCTP_RTOINFO
SCTP_ASSOCINFO,
#define SCTP_ASSOCINFO SCTP_ASSOCINFO
SCTP_INITMSG,
#define SCTP_INITMSG SCTP_INITMSG
SCTP_NODELAY, /* Get/set nodelay option. */
#define SCTP_NODELAY SCTP_NODELAY
SCTP_AUTOCLOSE,
#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
SCTP_SET_PEER_PRIMARY_ADDR,
#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
SCTP_PRIMARY_ADDR,
#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
SCTP_ADAPTION_LAYER,
#define SCTP_ADAPTION_LAYER SCTP_ADAPTION_LAYER
SCTP_DISABLE_FRAGMENTS,
#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
SCTP_PEER_ADDR_PARAMS,
#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
SCTP_DEFAULT_SEND_PARAM,
#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
SCTP_EVENTS,
#define SCTP_EVENTS SCTP_EVENTS
SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */
#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
SCTP_MAXSEG, /* Get/set maximum fragment. */
#define SCTP_MAXSEG SCTP_MAXSEG
SCTP_STATUS,
#define SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO,
#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
/* Internal Socket Options. Some of the sctp library functions are
* implemented using these socket options.
*/
SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
#define SCTP_SOCKOPT_BINDX_ADD SCTP_SOCKOPT_BINDX_ADD
SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
SCTP_SOCKOPT_PEELOFF, /* peel off association. */
#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
SCTP_GET_PEER_ADDRS_NUM, /* Get number of peer addresss. */
#define SCTP_GET_PEER_ADDRS_NUM SCTP_GET_PEER_ADDRS_NUM
SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */
#define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS
SCTP_GET_LOCAL_ADDRS_NUM, /* Get number of local addresss. */
#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM
SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */
#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS
};
/*
* 5.2.1 SCTP Initiation Structure (SCTP_INIT)
*
* This cmsghdr structure provides information for initializing new
* SCTP associations with sendmsg(). The SCTP_INITMSG socket option
* uses this same data structure. This structure is not used for
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
*
*/
struct sctp_initmsg {
__u16 sinit_num_ostreams;
__u16 sinit_max_instreams;
__u16 sinit_max_attempts;
__u16 sinit_max_init_timeo;
};
/*
* 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
*
* This cmsghdr structure specifies SCTP options for sendmsg() and
* describes SCTP header information about a received message through
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
*
*/
struct sctp_sndrcvinfo {
__u16 sinfo_stream;
__u16 sinfo_ssn;
__u16 sinfo_flags;
__u32 sinfo_ppid;
__u32 sinfo_context;
__u32 sinfo_timetolive;
__u32 sinfo_tsn;
__u32 sinfo_cumtsn;
sctp_assoc_t sinfo_assoc_id;
};
/*
* sinfo_flags: 16 bits (unsigned integer)
*
* This field may contain any of the following flags and is composed of
* a bitwise OR of these values.
*/
enum sctp_sinfo_flags {
MSG_UNORDERED = 1, /* Send/receive message unordered. */
MSG_ADDR_OVER = 2, /* Override the primary destination. */
MSG_ABORT=4, /* Send an ABORT message to the peer. */
MSG_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
};
typedef union {
__u8 raw;
struct sctp_initmsg init;
struct sctp_sndrcvinfo sndrcv;
} sctp_cmsg_data_t;
/* These are cmsg_types. */
typedef enum sctp_cmsg_type {
SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
} sctp_cmsg_t;
/*
* 5.3.1.1 SCTP_ASSOC_CHANGE
*
* Communication notifications inform the ULP that an SCTP association
* has either begun or ended. The identifier for a new association is
* provided by this notificaion. The notification information has the
* following format:
*
*/
struct sctp_assoc_change {
__u16 sac_type;
__u16 sac_flags;
__u32 sac_length;
__u16 sac_state;
__u16 sac_error;
__u16 sac_outbound_streams;
__u16 sac_inbound_streams;
sctp_assoc_t sac_assoc_id;
};
/*
* sac_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the association. They include:
*
* Note: The following state names deviate from the API draft as
* the names clash too easily with other kernel symbols.
*/
enum sctp_sac_state {
SCTP_COMM_UP,
SCTP_COMM_LOST,
SCTP_RESTART,
SCTP_SHUTDOWN_COMP,
SCTP_CANT_STR_ASSOC,
};
/*
* 5.3.1.2 SCTP_PEER_ADDR_CHANGE
*
* When a destination address on a multi-homed peer encounters a change
* an interface details event is sent. The information has the
* following structure:
*/
struct sctp_paddr_change {
__u16 spc_type;
__u16 spc_flags;
__u32 spc_length;
struct sockaddr_storage spc_aaddr;
int spc_state;
int spc_error;
sctp_assoc_t spc_assoc_id;
};
/*
* spc_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the address. They include:
*/
enum sctp_spc_state {
SCTP_ADDR_AVAILABLE,
SCTP_ADDR_UNREACHABLE,
SCTP_ADDR_REMOVED,
SCTP_ADDR_ADDED,
SCTP_ADDR_MADE_PRIM,
};
/*
* 5.3.1.3 SCTP_REMOTE_ERROR
*
* A remote peer may send an Operational Error message to its peer.
* This message indicates a variety of error conditions on an
* association. The entire error TLV as it appears on the wire is
* included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP
* specification [SCTP] and any extensions for a list of possible
* error formats. SCTP error TLVs have the format:
*/
struct sctp_remote_error {
__u16 sre_type;
__u16 sre_flags;
__u32 sre_length;
__u16 sre_error;
sctp_assoc_t sre_assoc_id;
__u8 sre_data[0];
};
/*
* 5.3.1.4 SCTP_SEND_FAILED
*
* If SCTP cannot deliver a message it may return the message as a
* notification.
*/
struct sctp_send_failed {
__u16 ssf_type;
__u16 ssf_flags;
__u32 ssf_length;
__u32 ssf_error;
struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id;
__u8 ssf_data[0];
};
/*
* ssf_flags: 16 bits (unsigned integer)
*
* The flag value will take one of the following values
*
* SCTP_DATA_UNSENT - Indicates that the data was never put on
* the wire.
*
* SCTP_DATA_SENT - Indicates that the data was put on the wire.
* Note that this does not necessarily mean that the
* data was (or was not) successfully delivered.
*/
enum sctp_ssf_flags {
SCTP_DATA_UNSENT,
SCTP_DATA_SENT,
};
/*
* 5.3.1.5 SCTP_SHUTDOWN_EVENT
*
* When a peer sends a SHUTDOWN, SCTP delivers this notification to
* inform the application that it should cease sending data.
*/
struct sctp_shutdown_event {
__u16 sse_type;
__u16 sse_flags;
__u32 sse_length;
sctp_assoc_t sse_assoc_id;
};
/*
* 5.3.1.6 SCTP_ADAPTION_INDICATION
*
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application
* that of the peers requested adaption layer.
*/
struct sctp_adaption_event {
__u16 sai_type;
__u16 sai_flags;
__u32 sai_length;
__u32 sai_adaption_ind;
sctp_assoc_t sai_assoc_id;
};
/*
* 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
*
* When a reciever is engaged in a partial delivery of a
* message this notification will be used to inidicate
* various events.
*/
struct sctp_pdapi_event {
__u16 pdapi_type;
__u16 pdapi_flags;
__u32 pdapi_length;
__u32 pdapi_indication;
sctp_assoc_t pdapi_assoc_id;
};
enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
/*
* Described in Section 7.3
* Ancillary Data and Notification Interest Options
*/
struct sctp_event_subscribe {
__u8 sctp_data_io_event;
__u8 sctp_association_event;
__u8 sctp_address_event;
__u8 sctp_send_failure_event;
__u8 sctp_peer_error_event;
__u8 sctp_shutdown_event;
__u8 sctp_partial_delivery_event;
__u8 sctp_adaption_layer_event;
};
/*
* 5.3.1 SCTP Notification Structure
*
* The notification structure is defined as the union of all
* notification types.
*
*/
union sctp_notification {
struct {
__u16 sn_type; /* Notification type. */
__u16 sn_flags;
__u32 sn_length;
} sn_header;
struct sctp_assoc_change sn_assoc_change;
struct sctp_paddr_change sn_paddr_change;
struct sctp_remote_error sn_remote_error;
struct sctp_send_failed sn_send_failed;
struct sctp_shutdown_event sn_shutdown_event;
struct sctp_adaption_event sn_adaption_event;
struct sctp_pdapi_event sn_pdapi_event;
};
/* Section 5.3.1
* All standard values for sn_type flags are greater than 2^15.
* Values from 2^15 and down are reserved.
*/
enum sctp_sn_type {
SCTP_SN_TYPE_BASE = (1<<15),
SCTP_ASSOC_CHANGE,
SCTP_PEER_ADDR_CHANGE,
SCTP_SEND_FAILED,
SCTP_REMOTE_ERROR,
SCTP_SHUTDOWN_EVENT,
SCTP_PARTIAL_DELIVERY_EVENT,
SCTP_ADAPTION_INDICATION,
};
/* Notification error codes used to fill up the error fields in some
* notifications.
* SCTP_PEER_ADDRESS_CHAGE : spc_error
* SCTP_ASSOC_CHANGE : sac_error
* These names should be potentially included in the draft 04 of the SCTP
* sockets API specification.
*/
typedef enum sctp_sn_error {
SCTP_FAILED_THRESHOLD,
SCTP_RECEIVED_SACK,
SCTP_HEARTBEAT_SUCCESS,
SCTP_RESPONSE_TO_USER_REQ,
SCTP_INTERNAL_ERROR,
SCTP_SHUTDOWN_GUARD_EXPIRES,
SCTP_PEER_FAULTY,
} sctp_sn_error_t;
/*
* 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
*
* The protocol parameters used to initialize and bound retransmission
* timeout (RTO) are tunable. See [SCTP] for more information on how
* these parameters are used in RTO calculation.
*/
struct sctp_rtoinfo {
sctp_assoc_t srto_assoc_id;
__u32 srto_initial;
__u32 srto_max;
__u32 srto_min;
};
/*
* 7.1.2 Association Parameters (SCTP_ASSOCINFO)
*
* This option is used to both examine and set various association and
* endpoint parameters.
*/
struct sctp_assocparams {
sctp_assoc_t sasoc_assoc_id;
__u16 sasoc_asocmaxrxt;
__u16 sasoc_number_peer_destinations;
__u32 sasoc_peer_rwnd;
__u32 sasoc_local_rwnd;
__u32 sasoc_cookie_life;
};
/*
* 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
*
* Requests that the peer mark the enclosed address as the association
* primary. The enclosed address must be one of the association's
* locally bound addresses. The following structure is used to make a
* set primary request:
*/
struct sctp_setpeerprim {
sctp_assoc_t sspp_assoc_id;
struct sockaddr_storage sspp_addr;
};
/*
* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
*
* Requests that the local SCTP stack use the enclosed peer address as
* the association primary. The enclosed address must be one of the
* association peer's addresses. The following structure is used to
* make a set peer primary request:
*/
struct sctp_prim {
sctp_assoc_t ssp_assoc_id;
struct sockaddr_storage ssp_addr;
};
/*
* 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
*
* Requests that the local endpoint set the specified Adaption Layer
* Indication parameter for all future INIT and INIT-ACK exchanges.
*/
struct sctp_setadaption {
__u32 ssb_adaption_ind;
};
/*
* 7.1.13 Peer Address Parameters (SCTP_PEER_ADDR_PARAMS)
*
* Applications can enable or disable heartbeats for any peer address
* of an association, modify an address's heartbeat interval, force a
* heartbeat to be sent immediately, and adjust the address's maximum
* number of retransmissions sent before an address is considered
* unreachable. The following structure is used to access and modify an
* address's parameters:
*/
struct sctp_paddrparams {
sctp_assoc_t spp_assoc_id;
struct sockaddr_storage spp_address;
__u32 spp_hbinterval;
__u16 spp_pathmaxrxt;
};
/*
* 7.2.2 Peer Address Information
*
* Applications can retrieve information about a specific peer address
* of an association, including its reachability state, congestion
* window, and retransmission timer values. This information is
* read-only. The following structure is used to access this
* information:
*/
struct sctp_paddrinfo {
sctp_assoc_t spinfo_assoc_id;
struct sockaddr_storage spinfo_address;
__s32 spinfo_state;
__u32 spinfo_cwnd;
__u32 spinfo_srtt;
__u32 spinfo_rto;
__u32 spinfo_mtu;
};
/* Peer addresses's state. */
enum sctp_spinfo_state {
SCTP_INACTIVE,
SCTP_ACTIVE,
};
/*
* 7.2.1 Association Status (SCTP_STATUS)
*
* Applications can retrieve current status information about an
* association, including association state, peer receiver window size,
* number of unacked data chunks, and number of data chunks pending
* receipt. This information is read-only. The following structure is
* used to access this information:
*/
struct sctp_status {
sctp_assoc_t sstat_assoc_id;
__s32 sstat_state;
__u32 sstat_rwnd;
__u16 sstat_unackdata;
__u16 sstat_penddata;
__u16 sstat_instrms;
__u16 sstat_outstrms;
__u32 sstat_fragmentation_point;
struct sctp_paddrinfo sstat_primary;
};
/*
* 8.3, 8.5 get all peer/local addresses on a socket
* This parameter struct is for getsockopt
*/
struct sctp_getaddrs {
sctp_assoc_t assoc_id;
int addr_num;
struct sockaddr *addrs;
};
/* These are bit fields for msghdr->msg_flags. See section 5.1. */
/* On user space Linux, these live in <bits/socket.h> as an enum. */
enum sctp_msg_flags {
MSG_NOTIFICATION = 0x8000,
#define MSG_NOTIFICATION MSG_NOTIFICATION
};
/*
* 8.1 sctp_bindx()
*
* The flags parameter is formed from the bitwise OR of zero or more of the
* following currently defined flags:
*/
#define SCTP_BINDX_ADD_ADDR 0x01
#define SCTP_BINDX_REM_ADDR 0x02
/* This is the structure that is passed as an argument(optval) to
* getsockopt(SCTP_SOCKOPT_PEELOFF).
*/
typedef struct {
sctp_assoc_t associd;
int sd;
} sctp_peeloff_arg_t;
int sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags);
int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
/* Prototype for the library function sctp_opt_info defined in
* API 7. Socket Options.
*/
int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size);
/* Get all peer address on a socket. This is a new SCTP API
* described in the section 8.3 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getpaddrs(). This is a new SCTP API
* described in the section 8.4 of the Sockets API Extensions for SCTP.
*/
int sctp_freepaddrs(struct sockaddr *addrs);
/* Get all locally bound address on a socket. This is a new SCTP API
* described in the section 8.5 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getladdrs(). This is a new SCTP API
* described in the section 8.6 of the Sockets API Extensions for SCTP.
*/
int sctp_freeladdrs(struct sockaddr *addrs);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.7 of the
* Sockets API Extensions for SCTP. This is implemented using the
* sendmsg() interface.
*/
int sctp_sendmsg(int s, const void *msg, size_t len, struct sockaddr *to,
socklen_t tolen, uint32_t ppid, uint32_t flags,
uint16_t stream_no, uint32_t timetolive, uint32_t context);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.8 of the
* Sockets API Extensions for SCTP. This is implemented using the
* recvmsg() interface.
*/
int sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from,
socklen_t *fromlen, struct sctp_sndrcvinfo *sinfo,
int *msg_flags);
__END_DECLS
#endif /* __linux_sctp_h__ */