Portech MV-37x patch

Ariel Wainer <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi, I modified slightly Raivis Rengelis's patch to use it with Kannel
1.4.4, the original patch was for 1.4.3.
The only modification is on the line numbers. I'm posting it in hope
that someone else might find it useful.
I'm not sure if it's main-tree material, but it would be nice to have it
merged into trunk.

Regards.

-- 
Ariel Wainer
Contenta Mobile
portech-1.4.4.patch (text/x-patch, 3.6 KB)
diff -rupN gateway-1.4.4/gw/smsc/smsc_at.c gateway-1.4.4-patched/gw/smsc/smsc_at.c
--- gateway-1.4.4/gw/smsc/smsc_at.c	2014-08-01 11:39:45.000000000 -0300
+++ gateway-1.4.4-patched/gw/smsc/smsc_at.c	2014-11-11 11:08:42.050133075 -0300
@@ -217,6 +217,11 @@ static int at2_login_device(PrivAT2data
         at2_send_modem_command(privdata, octstr_get_cstr(privdata->password), 2,0); /* wait for OK: */
         at2_send_modem_command(privdata, "AT", 2,0); /* wait for OK: */
     }
+    if(octstr_len(privdata->extra_login)>0) {
+        at2_wait_modem_command(privdata, 10, 4, NULL); /* wait for extra login prompt */
+        at2_send_modem_command(privdata, octstr_get_cstr(privdata->extra_login), 10, 5); /* wait for extra login ok */
+    }    
+    at2_send_modem_command(privdata, "AT", 2,0); /* wait for OK: */
 
     return 0;
 }
@@ -411,6 +416,19 @@ static Octstr *at2_extract_line(PrivAT2d
         if(gtloc == -1) {
             gtloc = octstr_search(privdata->ilb,octstr_imm("Password:"),0);
         }
+      else if ((gt_flag == 4) && (privdata->extra_login_prompt)) { /* looking for extra login prompt */
+          gtloc = -1;
+          if(privdata->extra_login_prompt) {
+              gtloc = octstr_search(privdata->ilb,privdata->extra_login_prompt,0);
+          }
+      }
+      else if ((gt_flag == 5) && (privdata->extra_login_prompt)) { /* looking for extra login ok */
+          gtloc = -1;
+          if(privdata->extra_login_ok) {
+              gtloc = octstr_search(privdata->ilb,privdata->extra_login_ok,0);
+          }
+    }
+
     } else
         gtloc = -1;
 
@@ -1632,6 +1650,22 @@ int smsc_at2_create(SMSCConn *conn, CfgG
     if (cfg_get_integer((long *) &privdata->max_error_count,  cfg, octstr_imm("max-error-count")) == -1)
         privdata->max_error_count = -1;
 
+    privdata->extra_login = cfg_get(cfg, octstr_imm("extra-login"));
+    if (privdata->extra_login != NULL) {
+        privdata->extra_login_prompt = cfg_get(cfg, octstr_imm("extra-login-prompt"));
+        if (privdata->extra_login_prompt == NULL) {
+            error(0, "AT2[-]: 'extra-login-prompt' missing in at2 configuration.");
+            goto error;
+        }
+        privdata->extra_login_ok = cfg_get(cfg, octstr_imm("extra-login-ok"));
+        if (privdata->extra_login_ok == NULL) {
+            error(0, "AT2[-]: 'extra-login-ok' missing in at2 configuration.");
+            goto error;
+        }
+    }
+
+
+
     privdata->load = load_create_real(0);
     load_add_interval(privdata->load, 1);
 
diff -rupN gateway-1.4.4/gw/smsc/smsc_at.h gateway-1.4.4-patched/gw/smsc/smsc_at.h
--- gateway-1.4.4/gw/smsc/smsc_at.h	2014-08-01 11:39:45.000000000 -0300
+++ gateway-1.4.4-patched/gw/smsc/smsc_at.h	2014-11-11 11:02:19.334140634 -0300
@@ -152,6 +152,10 @@ typedef struct PrivAT2data {
     int is_serial; /* false if device is rawtcp */ 
     int use_telnet; /* use telnet escape sequences */
     Load *load;
+    Octstr *extra_login; /* non-modem commands to give after login, used for PorTECH for example */
+    Octstr *extra_login_prompt; /* non-modem commands to give after login, used for PorTECH for example */
+    Octstr *extra_login_ok; /* non-modem commands to give after login, used for PorTECH for example */
+
  } PrivAT2data;
 
 
diff -rupN gateway-1.4.4/gwlib/cfg.def gateway-1.4.4-patched/gwlib/cfg.def
--- gateway-1.4.4/gwlib/cfg.def	2014-08-01 11:39:45.000000000 -0300
+++ gateway-1.4.4-patched/gwlib/cfg.def	2014-11-11 11:03:09.838139637 -0300
@@ -425,6 +425,10 @@ MULTI_GROUP(smsc,
     OCTSTR(generic-status-sent)
     OCTSTR(generic-status-error)
     OCTSTR(generic-foreign-id-regex)
+    OCTSTR(extra-login)
+    OCTSTR(extra-login-prompt)
+    OCTSTR(extra-login-ok)
+
 )
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.