diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_handle.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_handle.c | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c deleted file mode 100644 index 86f2b901a..000000000 --- a/src/messenger/gnunet-service-messenger_message_handle.c +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020--2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Tobias Frisch | ||
22 | * @file src/messenger/gnunet-service-messenger_message_handle.c | ||
23 | * @brief GNUnet MESSENGER service | ||
24 | */ | ||
25 | |||
26 | #include "gnunet-service-messenger_message_handle.h" | ||
27 | |||
28 | static void | ||
29 | handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session, | ||
30 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
31 | { | ||
32 | struct GNUNET_MESSENGER_MemberSession *next = switch_member_session(session, message, hash); | ||
33 | |||
34 | if (next != session) | ||
35 | add_member_session(next->member, next); | ||
36 | } | ||
37 | |||
38 | void | ||
39 | handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
40 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
41 | { | ||
42 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n", | ||
43 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); | ||
44 | |||
45 | if (GNUNET_OK != reset_member_session(session, hash)) | ||
46 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Resetting member session failed!\n"); | ||
47 | |||
48 | solve_room_member_collisions ( | ||
49 | room, | ||
50 | &(message->body.join.key), | ||
51 | &(message->header.sender_id), | ||
52 | GNUNET_TIME_absolute_ntoh(message->header.timestamp) | ||
53 | ); | ||
54 | } | ||
55 | |||
56 | void | ||
57 | handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
58 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
59 | { | ||
60 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n", | ||
61 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); | ||
62 | |||
63 | close_member_session(session); | ||
64 | } | ||
65 | |||
66 | void | ||
67 | handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
68 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
69 | { | ||
70 | struct GNUNET_MESSENGER_Contact *contact = get_member_session_contact(session); | ||
71 | |||
72 | if (!contact) | ||
73 | return; | ||
74 | |||
75 | set_contact_name (contact, message->body.name.name); | ||
76 | } | ||
77 | |||
78 | void | ||
79 | handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
80 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
81 | { | ||
82 | handle_session_switch (session, message, hash); | ||
83 | } | ||
84 | |||
85 | void | ||
86 | handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
87 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
88 | { | ||
89 | if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer))) | ||
90 | add_to_list_tunnels (&(room->basement), &(message->body.peer.peer)); | ||
91 | |||
92 | if (room->peer_message) | ||
93 | rebuild_room_basement_structure (room); | ||
94 | } | ||
95 | |||
96 | void | ||
97 | handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
98 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
99 | { | ||
100 | handle_session_switch (session, message, hash); | ||
101 | |||
102 | solve_room_member_collisions ( | ||
103 | room, | ||
104 | get_member_session_public_key(session), | ||
105 | &(message->body.id.id), | ||
106 | GNUNET_TIME_absolute_ntoh(message->header.timestamp) | ||
107 | ); | ||
108 | } | ||
109 | |||
110 | void | ||
111 | handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
112 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
113 | { | ||
114 | struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL); | ||
115 | |||
116 | if (!element) | ||
117 | return; | ||
118 | |||
119 | remove_from_list_tunnels (&(room->basement), element); | ||
120 | |||
121 | if (room->peer_message) | ||
122 | rebuild_room_basement_structure (room); | ||
123 | } | ||
124 | |||
125 | void | ||
126 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
127 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | ||
128 | { | ||
129 | struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.deletion.delay); | ||
130 | struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp); | ||
131 | |||
132 | action = GNUNET_TIME_absolute_add (action, delay); | ||
133 | delay = GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (), action); | ||
134 | |||
135 | delete_room_message (room, session, &(message->body.deletion.hash), delay); | ||
136 | } | ||