OSDN Git Service

Merge commit 'sfj/autotools-fix'; commit 'sfj/modulefix'; commit 'sfj/sslid-sslidleng...
[ultramonkey-l7/ultramonkey-l7-v2.git] / module / protocol / module_sslid_hash_map.cpp
index 496b989..026fe08 100644 (file)
@@ -6,6 +6,7 @@
  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
  * Copyright (C) 2008  NTT COMWARE Corporation.
  * Copyright (C) 2009  Shinya TAKEBAYASHI
+ * Copyright (C) 2009  NTT Resonant Inc. O.Nakayama, T.Motoda.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -124,12 +125,38 @@ void CSSLIDMap::setPointer(const void *keymap, const void *keylist, unsigned int
 }
 
 
+/*!
+ * Convert SSL session ID (hex to binary)   // 2009.4.9 T.Motoda@NTTR
+ * @param[out] id  SSL session ID
+ * @param[out] id_len a pointer to SSL session ID length
+ * @param[in]  buf hex string
+ */
+static void str_c_id(char *id, int *id_len, const char* buf) {
+        int i;
+       char hexbuf[3] = {0,0,0};
+       (*id_len) = 0;
+        if (buf == NULL) {
+                memset(id, 0, SSLID_LENGTH);
+        } else {
+                for (i = 0; i < SSLID_LENGTH; i++) {
+                       if ((hexbuf[0] = buf[i * 2 + 0]) > 0) {
+                               hexbuf[1] = buf[i * 2 + 1];
+                               id[i] = strtol(hexbuf, NULL, 16);
+                               (*id_len) ++;
+                       } else {
+                               break;
+                       }
+                }
+        }
+}
+
 void CSSLIDMap::construct_sessionlist(struct l7vs_sslid_service* sslid_service)
 {
   int pick = 0;
   IDMAP::const_iterator it;
   
   for (it = m->begin(); it != m->end(); it++, pick++) {
+    str_c_id((sslid_service->session + pick)->id, &((sslid_service->session + pick)->id_len), it->first.c_str());   // 2009.4.9 T.Motoda@NTTR
     memcpy((sslid_service->session + pick)->id, &(it->first), 32);
     memcpy(&(sslid_service->session + pick)->dest, &(it->second), sizeof(struct l7vs_dest));
 
@@ -147,6 +174,7 @@ void CSSLIDMap::rebuild_sessionlist(struct l7vs_sslid_service* sslid_service)
 
   for (pick = 0; pick < sslid_service->maxlist; pick++) {
     memset(&tmp_session, 0, sizeof (struct ssl_session));
+    tmp_session.id_len = (sslid_service->session + pick)->id_len;      // added by 2009.4.9 T.Motoda@NTTR
     memcpy(&(tmp_session.id), &(sslid_service->session + pick)->id, 32);
     memcpy(&(tmp_session.dest), &(sslid_service->session + pick)->dest, sizeof(struct l7vs_dest));
     add(tmp_session.id, tmp_session.dest);