Commit bfac7109d25c00bbc24423d18b1e581412c915e7
1 parent
28370a4b
presque la fin
Showing
7 changed files
with
96 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,18 @@ |
1 | +CC=gcc | |
2 | +OBJ=memory.o | |
3 | +INCDIRS = -I ../DNS/ | |
4 | +DLFLAGS1=-fpic -std=c99 | |
5 | +DLFLAGS2=-shared -Wl,-soname, | |
6 | +LIB=libmemoire.so | |
7 | +DEST= ../dynamic/ | |
8 | + | |
9 | +all: memory.o $(LIB) | |
10 | + mv $(LIB) $(DEST) | |
11 | +$(LIB): $(OBJ) | |
12 | + $(CC) $(DLFLAGS2)$(LIB) -o $(LIB) $(OBJ) | |
13 | +%.o:%.c | |
14 | + $(CC) $(DLFLAGS1) -c $(CFLAGS) $(INCDIRS) $< -o $@ | |
15 | + | |
16 | +clean: | |
17 | + rm -f $(OBJ) $(DEST)*.so $(DEST)*.o | |
18 | + | |
... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
... | ... | @@ -0,0 +1,39 @@ |
1 | +#include "mdp.h" | |
2 | +#include "/usr/include/sys/msg.h" | |
3 | + | |
4 | +#include <sys/types.h> | |
5 | +#include <stdlib.h> | |
6 | +#include <stdio.h> | |
7 | +#include <string.h> | |
8 | + | |
9 | + | |
10 | +int main(){ | |
11 | + int msgid1, msgid2; | |
12 | + key_t KEY2=500; | |
13 | + mdpSendMsg_t sen_msg; | |
14 | + mdpAnswerMsg_t ans_msg; | |
15 | + | |
16 | + if((msgid1 = msgget(KEY,IPC_EXCL|0666)) == -1){ | |
17 | + perror("msgget1 Failed"); | |
18 | + exit(1); | |
19 | + } | |
20 | + if((msgid2 = msgget(KEY2,IPC_CREAT|0666)) == -1){ | |
21 | + perror("msgget2 Failed"); | |
22 | + exit(1); | |
23 | + } | |
24 | + | |
25 | + sen_msg.type=66; | |
26 | + sen_msg.key_ipc_response=KEY2; | |
27 | + strcpy(sen_msg.login, "mbalbast\0"); | |
28 | + //strcpy(sen_msg.mdp, "0x62c66a7a5dd7 0c3146618063c344e531e6 d4b59e379808443c e962b3abd63c5a"); | |
29 | + | |
30 | + //uint8_t mdp={"0x5a","0x3c","0xd6","0xab","0xb3","0x62","0xe9","0x3c","0x44","0x08","0x98","0x37","0x9e","0xb5","0xd4","0xe6","0x31","0xe5","0x44","0xc3","0x63","0x80","0x61","0x46","0x31","0x0c","0xd7","0x5d","0x7a","0x6a","0xc6","0x62"}; | |
31 | + uint8_t mdp={"\x5a","\x3c","\xd6","\xab","\xb3","\x62","\xe9","\x3c","\x44","\x08","\x98","\x37","\x9e","\xb5","\xd4","\xe6","\x31","\xe5","\x44","\xc3","\x63","\x80","\x61","\x46","\x31","\x0c","\xd7","\x5d","\x7a","\x6a","\xc6","\x62"}; | |
32 | + memcpy(sen_msg.mdp,mdp,32); | |
33 | + msgsnd(msgid1, &sen_msg, MSG_SIZE,0); | |
34 | + | |
35 | + msgrcv(msgid2, &ans_msg, ANSWER_SIZE,66,0); | |
36 | + printf("%s", ans_msg.answer); | |
37 | + | |
38 | + | |
39 | +} | |
... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +#ifndef __MDP_H__ | |
2 | +#define __MDP_H__ | |
3 | + | |
4 | +#include <stdint.h> | |
5 | + | |
6 | +#define LOGIN_SIZE 9 | |
7 | +#define MSG_SIZE 32 | |
8 | +#define ANSWER_SIZE 128 | |
9 | + | |
10 | +/* Key for the message queue of the Daemon */ | |
11 | +#define KEY (key_t)1000 | |
12 | + | |
13 | +/* Types for the message */ | |
14 | +#define TYPE_NORMAL 66 | |
15 | +#define TYPE_WIN 666 | |
16 | +#define TYPE_LOOSE 44 | |
17 | +#define TYPE_HINT 33 | |
18 | + | |
19 | +typedef struct mdpSendMsg_s { | |
20 | + long type; | |
21 | + int key_ipc_response; | |
22 | + uint8_t login[LOGIN_SIZE]; | |
23 | + uint8_t mdp[MSG_SIZE]; | |
24 | +} mdpSendMsg_t; | |
25 | + | |
26 | +typedef struct mdpAnswerMsg_s { | |
27 | + long type; | |
28 | + uint8_t answer[ANSWER_SIZE]; | |
29 | +} mdpAnswerMsg_t; | |
30 | + | |
31 | +#endif | |
... | ... |