我需要使用libmmtp.dll与服务器的mmtp协议进行通信。 我使用c#来调用dll方法,这个lib的必须复杂结构之一是MMTPMsg
#ifndef _LIBPGA_H
# define _LIBPGA_H
# ifndef _UNUSED_
# ifdef __GNUC__
# define _UNUSED_ __attribute__ ((__unused__))
# else
# define _UNUSED_
# endif
# endif
;
static char const* LibPga_h_Rev _UNUSED_="@(#) $Name: LIV_MMTP_SDK_V2_15_00 $ $Header: /cvs/DTM/LIB/libpga/libpga.h,v 1.86 2004/10/22 10:45:40 fred Exp $";
# if defined(_LIBPGA_COMPILATION_) && defined(_USRDLL)
# define ExportApi __declspec(dllexport)
# define ExportClass __declspec(dllexport)
# else
# define ExportApi extern
# define ExportClass
# endif
# if !defined(BOOL) && !defined(BOOL_DEF)
typedef int BOOL;
# define BOOL BOOL
# endif
# ifndef FALSE
# define FALSE 0
# endif
# ifndef TRUE
# define TRUE 1
# endif
# include <sys/types.h>
# include <sys/timeb.h>
# ifdef UNIX
# include <netinet/in.h>
# endif
# ifndef _TICKS
# define _TICKS
# ifdef NT
typedef __int64 Ticks;
# else
typedef long long Ticks;
# endif
# define UPPER_LONG_LONG ((Ticks)~0)
# endif
# ifndef _LLONG
# define _LLONG
# ifdef NT
typedef signed __int64 llong;
typedef unsigned __int64 ullong;
# else
typedef signed long long llong;
typedef unsigned long long ullong;
# endif
# endif
# ifdef NT
typedef unsigned int in_addr_t;
# endif
# ifdef __cplusplus
extern "C"
{
# endif
# ifndef STX
# define STX 2
# endif
# ifndef ETX
# define ETX 3
# endif
# define MMTP_IN 0
# define MMTP_OUT 1
// Type of protocol messages.
# define MSG_EMPTY 0
# define CONX_REQ 10
# define CONX_ACK 11
# define CONX_NACK 12
# define DCNX_REQ 13
# define DCNX_ACK 14
# define DSPTCH_MSG 15
# define START_REQ 20
# define START_ACK 21
# define START_NACK 22
# define DATA_MSG 23
# define SYNC_REQ 24
# define SYNC_ACK 25
# define ERR_IND 90
# define SRVC_MSG 93
# define CONX_REQ_STR "10"
# define CONX_ACK_STR "11"
# define CONX_NACK_STR "12"
# define DCNX_REQ_STR "13"
# define DCNX_ACK_STR "14"
# define DSPTCH_MSG_STR "15"
# define START_REQ_STR "20"
# define START_ACK_STR "21"
# define START_NACK_STR "22"
# define DATA_MSG_STR "23"
# define SYNC_REQ_STR "24"
# define SYNC_ACK_STR "25"
# define ERR_IND_STR "90"
# define SRVC_MSG_STR "93"
// MMTP options index.
typedef enum
{
MMTPOptCrypt=0, // 0 : Cryptage.
MMTPOptCheckSeqNb, // 1 : Vérification du numéro de séquence.
MMTPOptCheckCrypt, // 2 : Vérification de la validité du décryptage.
MMTPOptCompression, // 3 : Compression des messages.
// -------------------
MMTP_MAX_OPT
} MMTPCnxOption;
// MMTP connection nack reason.
typedef enum
{
MMTPCnxNckRsn_NoAnswer=-2, // Pas d'envoi de réponse (pour MmtpBaseSession).
MMTPCnxNckRsn_SendError=-1, // Envoi d'une erreur OutOfContext (pour MmtpBaseSession).
MMTPCnxNckRsn_Ok=0, // 0 : Connexion acceptée (pour MmtpBaseSession).
MMTPCnxNckRsn_InvalidMember, // 1 : Abonné invalide.
MMTPCnxNckRsn_HubNotReady, // 2 : Programme pas prêt.
MMTPCnxNckRsn_UnknownMember, // 3 : Membre (abonné) inconnu.
MMTPCnxNckRsn_LastCnxTooRecent, // 4 : Dernière connexion trop récente.
MMTPCnxNckRsn_InvalidVersion, // 5 : Versions de librairies incompatibles.
MMTPCnxNckRsn_InvalidOptions, // 6 : Options de connexion invalides.
MMTPCnxNckRsn_TooManyCnx // 7 : Trop de connexions simultanées.
} MMTPCnxNckRsn;
// MMTP disconnection reason
typedef enum
{
MMTPDcnxRsn_NoAnswer=-2, // Pas d'envoi de réponse (pour MmtpBaseSession).
MMTPDcnxRsn_Normal=1, // 1 : Déconnexion normale.
MMTPDcnxRsn_AskedByHub, // 2 : Déconnexion demandée par lr programme.
MMTPDcnxRsn_Abnormal, // 3 : Déconnexion anormale.
MMTPDcnxRsn_SessionBroken, // 4 : Session interrompue.
MMTPDcnxRsn_InvalidStartAck, // 5 : Déconnexion due à un Start-Ack invalide.
MMTPDcnxRsn_LastMsgSent, // 6 : Déconnexion due à l'envoi du dernier message.
MMTPDcnxRsn_InvalidKey, // 7 : Clé de cryptage invalide.
MMTPDcnxRsn_InvalidAdminData, // 8 : Données administratives invalides.
MMTPDcnxRsn_AclViolation, // 9 : ???
MMTPDcnxRsn_EncryptionUnavailable=10, // 10 : Cryptage indisponible.
MMTPDcnxRsn_Last=99
} MMTPDcnxRsn;
// MMTP start nack reason
typedef enum
{
MMTPStrtNckRsn_NoAnswer=-2, // Pas d'envoi de réponse (pour MmtpBaseSession).
MMTPStrtNckRsn_SendError=-1, // Envoi d'une erreur OutOfContext (pour MmtpBaseSession).
MMTPStrtNckRsn_Ok=0, // 0 : Start-req accepté (pour MmtpBaseSession).
MMTPStrtNckRsn_StartReqInProgress, // 1 : Déjà un start-req en cours.
MMTPStrtNckRsn_NoHubCnx, // 2 : Connexion avec programme distant pas établie.
MMTPStrtNckRsn_MsgIdNotFound // 3 : Message demandé pas trouvé.
} MMTPStrtNckRsn;
// MMTP Err-Ind error
typedef enum
{
MMTPErrIndErr_MsgLost=1, // 1 : Message perdu (trou dans les numéros de séquence).
MMTPErrIndErr_MsgDuplicate, // 2 : Message dupliqués (numéro de séquence déjà reçu).
MMTPErrIndErr_InvalidField, // 3 : Champ invalide.
MMTPErrIndErr_OutOfContext, // 4 : Message hors de son contexte.
MMTPErrIndErr_InvalidMsg, // 5 : Message invalide.
MMTPErrIndErr_AclViolation=9, // 9 : ???
MMTPErrInd_Last=99
} MMTPErrIndErr;
// Admin data types.
# define NO_ADMIN_DATA 0
# define ADMIN_DATA_UNKNOWN 1
# define ADMIN_DATA_E1 2
# define ADMIN_DATA_RR 3
# define ADMIN_DATA_E0 4
# define ADMIN_DATA_A1 5
# define ADMIN_DATA_A2 6
# define ADMIN_DATA_M0 7
# define ADMIN_DATA_G0 8
// Size of protocol message fields.
# define FIELD_SIZE_SEQNB 8
# define FIELD_SIZE_SUBS_ID 11
# define FIELD_SIZE_VERSION 4
# define FIELD_SIZE_OPTIONS 16
# define FIELD_SIZE_AUTH_DATA 8
# define FIELD_SIZE_REASON 2
# define FIELD_SIZE_LENGTH 4
# define FIELD_SIZE_TYPE 2
# define FIELD_SIZE_ADMIN_TYPE 2
# define FIELD_SIZE_ERROR 2
# define FIELD_SIZE_ADMIN 256
# define FIELD_SIZE_DATA 9500
# define FIELD_SIZE_SERVICE 4
# define FIELD_SIZE_TIME 12
# define FIELD_SIZE_MSGID 24
# define FIELD_SIZE_FILLER_E0 5
# define FIELD_SIZE_FILLER_E1 8
# define FIELD_SIZE_FILLER_A1 11
# define FIELD_SIZE_FILLER_A2 5
# define FIELD_SIZE_FILLER_M0 41
# define FIELD_SIZE_FILLER_G0 29
# define FIELD_SIZE_TIMEOUT 6
# define FIELD_SIZE_ROUTE_DATA 11
# define FIELD_SIZE_MEMBER_ID 8
# define FIELD_SIZE_DOMAIN 1
# define FIELD_SIZE_IPADDR 10
# define FIELD_SIZE_PORT 5
# define FIELD_SIZE_FREE_SESSIONS 2
# define FIELD_SIZE_SERVER_ID 10
# define FIELD_SIZE_SERVER_DATA 32
# define FIELD_SIZE_SUBS_SEQ 8
# define FIELD_SIZE_SERV_TIME 6
# define FIELD_SIZE_NBHOP 1
# define FIELD_SIZE_CLASSID 4
# define FIELD_SIZE_ETT 128
# define FIELD_SIZE_IV 8
# define FIELD_SIZE_CONX_ACK_FILLER 100
# define FIELD_SIZE_ERROR_BODY (FIELD_SIZE_DATA+FIELD_SIZE_ADMIN+24)
// E0-type administrative data.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char DeliveryTimeOut[FIELD_SIZE_TIMEOUT+1];
char RouteData[FIELD_SIZE_ROUTE_DATA+1];
char Filler[FIELD_SIZE_FILLER_E0+1];
} MMTPAdminDataE0;
// E1-type administrative data.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char DeliveryTimeOut[FIELD_SIZE_TIMEOUT+1];
char Filler[FIELD_SIZE_FILLER_E1+1];
} MMTPAdminDataE1;
// A1-type administrative data.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char DeliveryTimeOut[FIELD_SIZE_TIMEOUT+1];
char ReceiveTime[FIELD_SIZE_TIME+1];
char SubsId[FIELD_SIZE_SUBS_ID+1];
char MemberId[FIELD_SIZE_MEMBER_ID+1];
char Domain[FIELD_SIZE_DOMAIN+1];
char Dest[FIELD_SIZE_SUBS_ID+1];
unsigned int SubsSeq;
unsigned int ServTime;
char ClassId[FIELD_SIZE_CLASSID+1];
char Filler[FIELD_SIZE_FILLER_A1+1];
} MMTPAdminDataA1;
// A2-type administrative data.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char DeliveryTimeOut[FIELD_SIZE_TIMEOUT+1];
char ReceiveTime[FIELD_SIZE_TIME+1];
char OnSubscriber[FIELD_SIZE_SUBS_ID+1];
char OnMember[FIELD_SIZE_MEMBER_ID+1];
char OnMsgId[FIELD_SIZE_MSGID+1];
char Domain[FIELD_SIZE_DOMAIN+1];
char Dest[FIELD_SIZE_SUBS_ID+1];
char Filler[FIELD_SIZE_FILLER_A2+1];
} MMTPAdminDataA2;
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char DeliveryTimeOut[FIELD_SIZE_TIMEOUT+1];
char RouteData[FIELD_SIZE_ROUTE_DATA+1];
char OnMember[FIELD_SIZE_MEMBER_ID+1];
char Domain[FIELD_SIZE_DOMAIN+1];
char Dest[FIELD_SIZE_SUBS_ID+1];
char Filler[FIELD_SIZE_FILLER_M0+1];
} MMTPAdminDataM0;
// Generic administrative data.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
} MMTPAdminGeneric;
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
char SendTime[FIELD_SIZE_TIME+1];
char ReceiptTime[FIELD_SIZE_TIME+1];
char OnSubscriber[FIELD_SIZE_SUBS_ID+1];
char OnMember[FIELD_SIZE_MEMBER_ID+1];
char Domain[FIELD_SIZE_DOMAIN+1];
char ClassId[FIELD_SIZE_CLASSID+1];
char Dest[FIELD_SIZE_SUBS_ID+1];
char NbHop[FIELD_SIZE_NBHOP+1];
char ReceiveTime[FIELD_SIZE_TIME+1];
char Filler[FIELD_SIZE_FILLER_G0+1];
int EttType;
int EttSize;
union
{
MMTPAdminDataA1 A1;
MMTPAdminDataA2 A2;
MMTPAdminDataE0 E0;
MMTPAdminDataE1 E1;
MMTPAdminDataM0 M0;
char Unknown[FIELD_SIZE_ETT];
} Ett;
} MMTPAdminDataG0;
// RR-type administrative data.
# define FIELD_SIZE_RR_SPFID 8
# define FIELD_SIZE_RR_TYPE_TD 2
typedef struct
{
long RelativeNumber;
long Timestamp;
unsigned short TD;
char SpfId[FIELD_SIZE_RR_SPFID+1];
char TypeTD[FIELD_SIZE_RR_TYPE_TD+1];
} MMTPAdminDataRR;
// Administrative data.
typedef struct
{
int Type;
int Size;
union
{
MMTPAdminDataA1 A1;
MMTPAdminDataA2 A2;
MMTPAdminDataE0 E0;
MMTPAdminDataE1 E1;
MMTPAdminDataG0 G0;
MMTPAdminDataM0 M0;
MMTPAdminDataRR RR;
MMTPAdminGeneric Generic;
} Data;
char Unknown[FIELD_SIZE_ADMIN];
} MMTPAdminData;
# define FIELD_RECEIPT_TIME_POS (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME)
// Size of administrative data.
# define ADMIN_A1_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME*3+FIELD_SIZE_TIMEOUT+FIELD_SIZE_MEMBER_ID+FIELD_SIZE_DOMAIN+FIELD_SIZE_SUBS_ID*2+FIELD_SIZE_SUBS_SEQ+FIELD_SIZE_SERV_TIME+FIELD_SIZE_CLASSID+FIELD_SIZE_FILLER_A1)
# define ADMIN_A2_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID*2+FIELD_SIZE_TIME*3+FIELD_SIZE_TIMEOUT+FIELD_SIZE_SUBS_ID*2+FIELD_SIZE_DOMAIN+FIELD_SIZE_MEMBER_ID+FIELD_SIZE_FILLER_A2)
# define ADMIN_E0_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME*2+FIELD_SIZE_TIMEOUT+FIELD_SIZE_ROUTE_DATA+FIELD_SIZE_FILLER_E0)
# define ADMIN_E1_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME*2+FIELD_SIZE_TIMEOUT+FIELD_SIZE_FILLER_E1)
# define ADMIN_G0_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME*3+FIELD_SIZE_SUBS_ID*2+FIELD_SIZE_MEMBER_ID+FIELD_SIZE_DOMAIN+FIELD_SIZE_CLASSID+FIELD_SIZE_NBHOP+FIELD_SIZE_FILLER_G0+FIELD_SIZE_ETT)
# define ADMIN_M0_SIZE (FIELD_SIZE_ADMIN_TYPE+FIELD_SIZE_MSGID+FIELD_SIZE_TIME*2+FIELD_SIZE_TIMEOUT+FIELD_SIZE_ROUTE_DATA+FIELD_SIZE_MEMBER_ID+FIELD_SIZE_DOMAIN+FIELD_SIZE_SUBS_ID+FIELD_SIZE_FILLER_M0)
# define ADMIN_RR_SIZE (FIELD_SIZE_ADMIN_TYPE+sizeof(long)*2+sizeof(short)+FIELD_SIZE_RR_SPFID+FIELD_SIZE_RR_TYPE_TD)
// Contents of CONX-REQ message.
typedef struct
{
char SubsId[FIELD_SIZE_SUBS_ID+1];
int Level;
char Options[FIELD_SIZE_OPTIONS+1];
char AuthData[FIELD_SIZE_AUTH_DATA+1];
} MMTPConxReq;
// Contents of CONX-ACK message.
typedef struct
{
char Options[FIELD_SIZE_OPTIONS+1];
} MMTPConxAck;
// Contents of CONX-NACK message.
typedef struct
{
MMTPCnxNckRsn Reason;
} MMTPConxNack;
// Contents of START-REQ message.
typedef struct
{
char MsgId[FIELD_SIZE_MSGID+1];
} MMTPStartReq;
// Contents of START-ACK message.
typedef struct
{
int SeqNb;
char MsgId[FIELD_SIZE_MSGID+1];
} MMTPStartAck;
// Contents of START-NACK message.
typedef struct
{
MMTPStrtNckRsn Reason;
char MsgId[FIELD_SIZE_MSGID+1];
} MMTPStartNack;
// Contents of DATA-MSG message.
typedef struct
{
int SeqNb;
int DataSize;
MMTPAdminData AD;
char Data[FIELD_SIZE_DATA+1];
} MMTPDataMsg;
// Contents of SYNC-ACK message.
typedef struct
{
int SeqNb;
char MsgId[FIELD_SIZE_MSGID+1];
} MMTPSyncAck;
// Contents of DCNX-REQ.
typedef struct
{
MMTPDcnxRsn Reason;
int SeqNb;
} MMTPDcnxReq;
// Contents of DCNX-ACK.
typedef struct
{
int SeqNb;
} MMTPDcnxAck;
// Contents of ERR-IND.
typedef struct
{
MMTPErrIndErr Error;
int SubError;
int SeqNb;
int Length;
char Body[FIELD_SIZE_ERROR_BODY+1];
} MMTPErrInd;
// Contents of SRVC-MSG
typedef struct
{
char Type[FIELD_SIZE_SERVICE+1];
int Size;
char Data[FIELD_SIZE_DATA+1];
} MMTPSrvcMsg;
// Contents of DSPTCH-MSG.
typedef struct
{
char ServerId[FIELD_SIZE_SERVER_ID+1];
char ServerData[FIELD_SIZE_SERVER_DATA+1];
in_addr_t IpAddr;
unsigned short Port;
int FreeSessions;
} MMTPDsptchMsg;
// Contents of RCNX-REQ.
typedef struct
{
in_addr_t IpAddr;
int Port;
char SubsId[FIELD_SIZE_SUBS_ID+1];
char Options[FIELD_SIZE_OPTIONS+1];
char AuthData[FIELD_SIZE_AUTH_DATA+1];
} MMTPRcnxReq;
typedef struct
{
long Length;
short Type;
union
{
MMTPConxReq ConxReq;
MMTPConxAck ConxAck;
MMTPConxNack ConxNack;
MMTPErrInd ErrInd;
MMTPDcnxReq DcnxReq;
MMTPDcnxAck DcnxAck;
MMTPDataMsg DataMsg;
MMTPSyncAck SyncAck;
MMTPStartReq StartReq;
MMTPStartAck StartAck;
MMTPStartNack StartNack;
MMTPSrvcMsg SrvcMsg;
MMTPDsptchMsg DsptchMsg;
MMTPRcnxReq RcnxReq;
} Data;
Ticks TimeStamp;
} MMTPMsg;
typedef void* MMTPSESSION;
typedef void* MMTPLPL;
# define MMTPLPL_DEFAULT ((void*)~0)
// MMTP options which can be set by the MMTPSetOption function.
typedef enum
{
MMTPOption_CheckAliveTimeout,
MMTPOption_WriteTimeout,
MMTPOption_AutoGetTicks,
MMTPOption_NoDelay,
MMTPOption_DumpGap,
MMTPOption_Progress,
MMTPOption_SendHeartBeat,
MMTPOption_ZeroSeqNbAllowed,
MMTPOption_LogDataMsg,
MMTPOption_CompressionLevel,
MMTPOption_AutoFlush,
MMTPOption_SndBufferSize,
MMTPOption_RcvBufferSize
} MMTPOption;
# define MMTP_NO_CHECK_ALIVE 0
# define MMTP_MIN_CHECK_ALIVE_TIMEOUT 10
# define MMTP_MAX_CHECK_ALIVE_TIMEOUT 60*60*2
# define MMTP_INFINITE_WRITE_DELAY -1
# define MMTP_AUTO_GET_TICKS_ENABLED 1
# define MMTP_AUTO_GET_TICKS_DISABLED 0
# define MMTP_SEND_HEARTBEAT_ENABLED 1
# define MMTP_SEND_HEARTBEAT_DISABLED 0
# define MMTP_AUTO_FLUSH_ENABLED 1
# define MMTP_AUTO_FLUSH_DISABLED 0
# define MMTP_NO_DELAY_ENABLED 1
# define MMTP_NO_DELAY_DISABLED 0
# define MMTP_ZERO_SEQNB_ENABLED 1
# define MMTP_ZERO_SEQNB_DISABLED 0
# define MMTP_LOG_DATAMSG_ENABLED 1
# define MMTP_LOG_DATAMSG_DISABLED 0
# define MMTP_NO_WRITE_DELAY 0
# define MMTP_DEF_DUMP_GAP 300 // En secondes
# define MMTP_MIN_DUMP_GAP 1 // En secondes
# define MMTP_MAX_DUMP_GAP 7200 // En secondes
# define MMTP_DEF_SOCKET_BUFFER_SIZE (20*1024)
# define MMTP_MIN_SOCKET_BUFFER_SIZE (1024)
# define MMTP_MAX_SOCKET_BUFFER_SIZE (10*1024*1024)
// Modes disponibles pour la fonction MMTPAddInput();
typedef enum
{
MmtpInput_Read=0,
MmtpInput_Write,
MmtpInput_Error
} MmtpInputMode;
typedef enum
{
// 0 : No error
MMTP_OK=0,
// 1 : Logical connection not established.
MMTP_NOT_CONNECTED,
// 2 : Invalid IP address.
MMTP_INVALID_ADDRESS,
// 3 : Physical connection lost.
MMTP_CNX_LOST,
// 4 : No message received.
MMTP_NO_MESSAGE,
// 5 : Invalid argument.
MMTP_INVALID_ARG,
// 6 : Session open in server mode and the requested function is
// reserved for sessions open in client mode.
MMTP_CLIENT_FCT,
// 7 : Session open in client mode and the requested function is
// reserved for sessions open in server mode.
MMTP_SERVER_FCT,
// 8 : Invalid session.
MMTP_INVALID_SESSION,
// 9 : A message of the same type is still awaiting acceptance.
MMTP_ALREADY_IN_PROGRESS,
// 10 : Logical connection already established.
MMTP_ALREADY_CONNECTED,
// 11 : Library already initialized.
MMTP_ALREADY_INITIALIZED,
// 12 : Library not initialized.
MMTP_NOT_INITIALIZED,
// 13 : Encryption/decryption error.
MMTP_CRYPT_ERROR,
// 14 : Unable to open socket.
MMTP_CANNOT_INIT_SOCKET, // UNUSED
// 15 : Insufficient memory.
MMTP_NOT_ENOUGH_MEMORY,
// 16 : Maximum number of sessions open.
MMTP_TOO_MUCH_SESSIONS,
// 17 : Impossible to open the protocol transfer log file.
MMTP_CANNOT_OPEN_LOGFILE,
// 18 : Protocol transfer log file not open.
MMTP_LOGFILE_NOT_OPENED,
// 19 : Socket full.
MMTP_SOCKET_FULL,
// 20 : Socket system error.
MMTP_SOCKET_ERROR,
// 21 : Write buffer full. Use MMTPWriteTerminate to empty it.
MMTP_BUFFER_FULL,
// 22 : Pending action to be interrupted does not exist.
MMTP_NOT_IN_PROGRESS,
// 23 : Too many listen ports open.
MMTP_TOO_MUCH_LISTEN_PORTS,
// 24 : Encryption feature not available.
MMTP_ENCRYPTION_UNAVAILABLE,
// 25 : Encryption library invalid.
MMTP_INVALID_ENCRYPTION_LIB,
// 26 : System exception trapped.
MMTP_SYSTEM_EXCEPTION,
// 27 : System error.
MMTP_SYSTEM_ERROR,
// 28 : Bad encryption/decryption key.
MMTP_BAD_KEY,
// 29 : The first argument is invalid.
MMTP_INVALID_ARG1,
// 30 : The second argument is invalid.
MMTP_INVALID_ARG2,
// 31 : The third argument is invalid.
MMTP_INVALID_ARG3,
// 32 : The fourth argument is invalid.
MMTP_INVALID_ARG4,
// 33 : The fifth argument is invalid.
MMTP_INVALID_ARG5,
// 34 : The sixth argument is invalid.
MMTP_INVALID_ARG6,
// 35 : The seventh argument is invalid.
MMTP_INVALID_ARG7,
// 36 : The eighth argument is invalid.
MMTP_INVALID_ARG8,
// 37 : The ninth argument is invalid.
MMTP_INVALID_ARG9,
// 38 : No key defined.
MMTP_NO_KEY_DEFINED,
// 39 : An exception occurs in an handler.
MMTP_EXCEPTION_TRAPPED,
// 40 : Too many waiting sockets defined.
MMTP_TOO_MANY_WAITING_SOCKETS,
// 41 : Listen port list invalid.
MMTP_INVALID_LPL,
// 42 : Socket error occured during wait. A port is removed.
MMTP_LPL_SOCKET_ERROR,
// 43 : The current message does not contains the requested member.
MMTP_INVALID_MEMBER,
// 44 : Error in dispatcher managment.
MMTP_DISPATCHER_ERROR,
// 45 : The server is unavailable.
MMTP_SERVER_UNAVAILABLE,
// 46 : No dispatcher defined.
MMTP_NO_DISPATCHER_DEFINED,
// 47 : Dispatcher already defined.
MMTP_DISPATCHER_ALREADY_DEFINED,
// 48 : The library is busy.
MMTP_LIBRARY_BUSY,
// 49 : Compression error.
MMTP_COMPRESSION_ERROR,
// 50 : Invalid administative data.
MMTP_INVALID_AD,
// 51 : Exception raised in ModifyMsg user function given using MMTPSetModifyMsgFct API.
MMTP_MODIFYMSG_FUNCTION_EXCEPTION,
// Insert new error before this line.
// Notify the end of the error list.
MMTP_MAX_NUM_ERROR
} MMTPError;
任何人都可以在这个过程中帮助我吗? 任何存在的c#代码或链接为这个结构准备好代码? 罐
答案 0 :(得分:0)
您可以通过显式指定每个项目的偏移量来实现Union。我不确定你的情况下是否有4或8个字节。
[StructLayout(LayoutKind.Explicit)]
struct MMTPMsg
{
[FieldOffset(0)]
public long length;
[FieldOffset(8)]
public short Type;
[FieldOffset(10)]
public MMTPConxReq ConxReq;
[FieldOffset(10)]
public MMTPConxAck ConxAck;
[FieldOffset(10)]
public MMTPConxNack ConxNack;
[FieldOffset(10)]
public MMTPErrInd ErrInd;
[FieldOffset(10)]
public MMTPDcnxReq DcnxReq;
[FieldOffset(10)]
public MMTPDcnxAck DcnxAck;
[FieldOffset(10)]
public MMTPDataMsg DataMsg;
[FieldOffset(10)]
public MMTPSyncAck SyncAck;
[FieldOffset(10)]
public MMTPStartReq StartReq;
[FieldOffset(10)]
public MMTPStartAck StartAck;
[FieldOffset(10)]
public MMTPStartNack StartNack;
[FieldOffset(10)]
public MMTPSrvcMsg SrvcMsg;
[FieldOffset(10)]
public MMTPDsptchMsg DsptchMsg;
[FieldOffset(10)]
public MMTPRcnxReq RcnxReq;
[FieldOffset(FIELD_SIZE_OPTIONS+1+8+2)]
public Ticks TimeStamp;
}