#include #include #include #include #include #include #include #include #include #include #include #include typedef struct sockaddr_in Sockaddr; # define DISPATCHER_PORT 1300 # define AGENT_START_PORT 1302 # define USER_NAME_SIZE 20 # define MACHINE_NAME_SIZE 40 # define AGENT_NAME_SIZE 20 # define ALIAS_NAME_SIZE 20 # define PACKET_MAX_SIZE 1024 # define PACKET_TYPE_REGISTER 1 # define PACKET_TYPE_SEARCH_AGENT 2 # define PACKET_TYPE_MESSAGE 3 # define PACKET_TYPE_UNREGISTER 4 # define PACKET_TYPE_UNKNOWN_AGENT 5 # define PACKET_TYPE_AGENT_INFO 6 # define DEBUG_PRINT_AGENTS 100 /* Network message header. */ typedef struct { unsigned long msg_type; char from_machine[MACHINE_NAME_SIZE]; char from_user[USER_NAME_SIZE]; char from_agent[AGENT_NAME_SIZE]; char to_machine[MACHINE_NAME_SIZE]; char to_user[USER_NAME_SIZE]; char to_agent[AGENT_NAME_SIZE]; unsigned long data_length; Sockaddr agent_addr; } netMsgHeader; typedef struct { netMsgHeader header; char *data; } netMsg; /* Function Declarations. */ extern int netInit(char *user_name); extern int getSocketNum(); extern void sendNetMessage(char msg_type, char *from_agent, char *to_machine, char *to_user, char *to_agent, char *data, int data_length); extern netMsg *recieveNetMessage(); extern void dispalyPacket(netMsgHeader *header, char *data);