Browse code

Add packet type in accept/reject messages for HMAC packet

This allows a bit easier debugging when trying to figure what kind
of packet triggered a reject/accpet.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20221108151407.1132097-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25489.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Arne Schwabe authored on 2022/11/09 00:14:07
Showing 1 changed files
... ...
@@ -148,14 +148,18 @@ do_pre_decrypt_check(struct multi_context *m,
148 148
         bool ret = check_session_id_hmac(state, from, hmac, handwindow);
149 149
 
150 150
         const char *peer = print_link_socket_actual(&m->top.c2.from, &gc);
151
+        uint8_t pkt_firstbyte = *BPTR( &m->top.c2.buf);
152
+        int op = pkt_firstbyte >> P_OPCODE_SHIFT;
153
+
151 154
         if (!ret)
152 155
         {
153
-            msg(D_MULTI_MEDIUM, "Packet with invalid or missing SID from %s", peer);
156
+            msg(D_MULTI_MEDIUM, "Packet (%s) with invalid or missing SID from %s",
157
+                packet_opcode_name(op), peer);
154 158
         }
155 159
         else
156 160
         {
157
-            msg(D_MULTI_DEBUG, "Valid packet with HMAC challenge from peer (%s), "
158
-                "accepting new connection.", peer);
161
+            msg(D_MULTI_DEBUG, "Valid packet (%s) with HMAC challenge from peer (%s), "
162
+                "accepting new connection.", packet_opcode_name(op), peer);
159 163
         }
160 164
         gc_free(&gc);
161 165