📄 transform.h
字号:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"LinkedList.h"
#ifndef TRAN_H
#define TRAN_H
typedef struct Message{
int type;
int serial;
char src[32];
char srcIp[32];
int srcPort;
char des[32];
int priority;
int length;
void* content;
}Message;
typedef struct DataMsgContent { // Access scope: public
int type; /* 0: direct, 1: indirect, 2: group */
int sendRange; /* 0: WO + SP, 1: WO, 2: SP */
int syn; /* true: Synchronous, false: Asynchronous */
int compulsory; /* If true, Unit always sends the message */
int state; /* The state of sender, 0: WO, 1: SP, 2: DO */
char src[32]; /* The source unit or group of the message */
int srcApp; /* The id of source application of the message */
char des[32]; /* The destination unit of the message */
int desApp; /* The id of destination application of the message */
int priority; /* 0: NORMAL, -1: LOW, 1: HIGH*/
int length; /* The byte-size of data */
char* data; /* The data of the message. */
}DataMsgContent;
typedef struct CI{
LinkedList * sendBuffer;
LinkedList * receiveBuffer;
Message * sendMsg;
Message * receiveMsg;
int listenPort;
}CI;
typedef struct DmtRegRequest { // Access scope: public
int index;
char dmt[32]; /* The DMT name */
}DmtRegRequest;
typedef struct MapRequestContent { // Access scope: public
char target[32]; /* The requested DMT name */
}MapRequestContent;
typedef struct MapRespondContent { // Access scope: public
int result;
int state0; /* The state of DMT0 */
char ip0[32]; /* The IP of DMT0 */
int state1; /* The state of DMT1 */
char ip1[32]; /* The IP of DMT1 */
}MapRespondContent;
typedef struct AppRegContent { // Access scope: public
char appName[32]; /* The name of Application */
int appId; /* The ID of Application */
char Group[32];
int port; /* The group that Application asks the DMT to join*/
}AppRegContent;
typedef struct CommonRespondContent { // Access scope: public
int result; /* Result of the action, 1: successful, 0: failed*/
char description[32]; /* The description of the result */
}CommonRespondContent;
typedef struct MonitorContent { // Access scope: public
int count;
int state; /* The state of DMT */
}MonitorContent;
typedef struct Buffer{
char* bytes;
int length;
}Buffer;
/*This struct is used as the node value of the CI queue*/
typedef struct SendPack
{
Message *msg;
char ip[32];
int port;
}SendPack;
void init(Message *message);
/**
* Transform bytes stream to Message.
* @param buffer Buffer object used for saving bytestream and its length
* @return Message which is transform from the bytestream.
*/
Message* byteToStruct(Buffer *buffer);
/**
* Transform MessageMessage to Message.
* @param message The Message object which is to transform into bytestream.
* @param buffer The Buffer object which is used for saving bytestream and its length.
* @return void
*/
void strToByte(Message *message,Buffer *buffer);
Buffer * createBuffer();
CI * createCI(int a);
void destroyBuffer(Buffer * buffer);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -