[Openvpn-devel] [S] Change in openvpn[master]: Factor out lookup_session_by_mda_key_id into its own method

"plaisthos \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups net.sourceforge.lists.openvpn-devel
Message-ID <[email protected]>
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1854?usp=email )


Change subject: Factor out lookup_session_by_mda_key_id into its own method
......................................................................

Factor out lookup_session_by_mda_key_id into its own method

This makes the code a bit easier to read and also allows reusing
the function later.

Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/multi.c
1 file changed, 21 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/1854/1

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 20b4f14..dda5c6b 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -4014,6 +4014,24 @@
     }
 }
 
+static struct tls_session *
+lookup_session_by_mda_key_id(struct tls_multi *multi,
+                             const unsigned int mda_key_id)
+{
+    if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == mda_key_id)
+    {
+        return &multi->session[TM_INITIAL];
+    }
+    else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == mda_key_id)
+    {
+        return &multi->session[TM_ACTIVE];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
 static bool
 management_client_pending_auth(void *arg, const unsigned long cid, const unsigned int mda_key_id,
                                const char *extra, unsigned int timeout)
@@ -4024,21 +4042,13 @@
     if (mi)
     {
         struct tls_multi *multi = mi->context.c2.tls_multi;
-        struct tls_session *session;
+        struct tls_session *session = lookup_session_by_mda_key_id(multi, mda_key_id);
 
-        if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == mda_key_id)
-        {
-            session = &multi->session[TM_INITIAL];
-        }
-        else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == mda_key_id)
-        {
-            session = &multi->session[TM_ACTIVE];
-        }
-        else
+        if (!session)
         {
             return false;
         }
-
+        
         /* sends INFO_PRE and AUTH_PENDING messages to client */
         bool ret = send_auth_pending_messages(multi, session, extra, timeout);
         reschedule_multi_process(&mi->context);

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1854?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438
Gerrit-Change-Number: 1854
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.