-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpacket.h
executable file
·57 lines (46 loc) · 1.32 KB
/
packet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* CSci 4061 F2014 Assignment 3
* Section 3
* Date: 10/10/2014
* Name: Jialun Jiang, Yaozhang Xu, Shang Ju
* ID: 4467970, 4944346, 4455103
*/
#ifndef PACKET_H
#define PACKET_H
#define INTERVAL 0
// Interval for timer. Interval you need to send the packets to the receiver
#define INTERVAL_USEC 500000
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include "mm.h"
#define MAX_PACKETS 10 /* Max packets allowed in the message */
#define PACKET_SIZE 3
#define MSGSIZE 128
#define key 4061 /* key which will be used for identifying the queue */
#define QUEUE_MSG_TYPE 1 /* message type for queue messages. Send receive only these types of messages from the queue */
typedef char data_t[PACKET_SIZE];
typedef struct {
int how_many; /* number of packets in the message */
int which; /* which packet in the message */
data_t data; /* packet data */
} packet_t;
/* Keeps track of packets that have arrived for the message */
typedef struct {
int num_packets;
void *data[MAX_PACKETS];
} message_t;
/* The queue message used to send the pid */
typedef struct {
long mtype;
int pid;
} pid_queue_msg;
/* The queue message used to send the packets */
typedef struct {
long mtype;
packet_t pkt;
} packet_queue_msg;
#endif