-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs.h
87 lines (77 loc) · 1.81 KB
/
args.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
enum do_operation
{
Doubly_Link_List = 1,
Multi_Threading = 2,
Fork = 3,
IPC = 4
};
struct MSG_fram_str
{
char *seq_num;
char *type; //tcp or udp
enum do_operation msg_code; //operation that neeeds to be performed
char *output_type; //tcp or udp
int payload; //payload
int payload1[100];
int payload_size; //size of payload
};
struct MSG_fram_str *inputs(int argc, char *argv[])
{
int choice = 0;
int count, select;
int Link_list[5];
struct MSG_fram_str *msg_ptr;
msg_ptr = (struct MSG_fram_str *)malloc(sizeof(struct MSG_fram_str));
while (1)
{
while ((choice = getopt(argc, argv, "t:u:")) != -1)
{
switch (choice)
{
case 't':
printf("[+]Perform TCP Operation\n");
(msg_ptr)->seq_num = argv[3];
(msg_ptr)->type = "tcp_prot";
(msg_ptr)->msg_code = atoi(optarg);
(msg_ptr)->output_type = "tcp_prot";
break;
case 'u':
printf("[+]Perform UDP operation\n");
(msg_ptr)->seq_num = argv[3];
(msg_ptr)->type = "udp_prot";
(msg_ptr)->msg_code = atoi(optarg);
(msg_ptr)->output_type = "udp_prot";
break;
default:
printf("Incorrect choice\n");
}
}
switch (msg_ptr->msg_code)
{
case 1:
printf("[+]ENTER DATA:");
for (count = 0; count < 5; count++)
{
scanf("%d", &Link_list[count]);
msg_ptr->payload1[count] = Link_list[count];
}
break;
case 2:
printf("[+]Multithreading operation\n");
break;
case 3:
printf("[+]FORK operation\n");
printf("[+]Enter The num of processes to be Created:\n");
scanf("%d", &(msg_ptr->payload));
break;
case 4:
printf("[+]IPC Mechanism operation\n");
printf("[+]Select Any one IPC operation\n[-]1.MSG Queue\n[-]2.PIPE\n");
scanf("%d", &select);
msg_ptr->payload = select;
break;
}
(msg_ptr)->payload_size = sizeof((msg_ptr)->payload);
return msg_ptr;
}
}