Re: MC35i on a TCP terminal server -- patch now

Stanislav Sinyagin <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
now it's attached

--- Stanislav Sinyagin <[email protected]> wrote:

> Attached, please see the patch against CVS HEAD.
> 
> It shouldn't break any existing functionality, and I've tested it 
> with Perle IOLAN DS1 terminal server.
> 
> regards,
> stan
> 
> 
> 
> --- Stanislav Sinyagin <[email protected]> wrote:
> 
> > Here's the proposal for configuration options:
> > 
> > group = smsc
> > smsc = at
> > modemtype = auto
> > device = rawtcp
> > pin = 2345
> > rawtcp-host = 10.0.0.1
> > rawtcp-port = 10001
> 
> 
>
kannel.rawtcp.ssinyagin.20050708.patch (text/plain, 3.6 KB)
? sendsms?username=tester&password=foobar&to=0794419087&text=Hello+world
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.24
diff -u -r1.24 smsc_at.c
--- gw/smsc/smsc_at.c	6 May 2005 14:50:27 -0000	1.24
+++ gw/smsc/smsc_at.c	8 Jul 2005 15:36:23 -0000
@@ -100,8 +100,19 @@
                  octstr_get_cstr(privdata->name));
         at2_close_device(privdata);
     }
-    privdata->fd = open(octstr_get_cstr(privdata->device), 
-                        O_RDWR | O_NONBLOCK | O_NOCTTY);
+
+    if( privdata->is_serial ) {
+        privdata->fd = open(octstr_get_cstr(privdata->device),
+                            O_RDWR | O_NONBLOCK | O_NOCTTY);
+    }
+    else {
+        if (strcmp(octstr_get_cstr(privdata->device), "rawtcp") == 0) {
+            privdata->fd = tcpip_connect_to_server(octstr_get_cstr(privdata->rawtcp_host),privdata->rawtcp_port, NULL); 
+        }
+        else {
+            gw_assert(0);
+        }
+    }
     if (privdata->fd == -1) {
         error(errno, "AT2[%s]: open failed! ERRNO=%d", octstr_get_cstr(privdata->name), errno);
         privdata->fd = -1;
@@ -121,6 +132,9 @@
     if ((ret = at2_open_device1(privdata)) != 0)
         return ret;
 
+    if(! privdata->is_serial)
+        return 0;
+
     tcgetattr(privdata->fd, &tios);
 
     kannel_cfmakeraw(&tios);
@@ -1002,6 +1016,9 @@
     int ret;
     int	speed;
 
+    if(! privdata->is_serial)
+        return;
+
     tcgetattr(privdata->fd, &tios);
 
     switch (bps) {
@@ -1277,6 +1294,7 @@
 {
     PrivAT2data	*privdata;
     Octstr *modem_type_string;
+    long portno;   /* has to be long because of cfg_get_integer */
 
     privdata = gw_malloc(sizeof(PrivAT2data));
     privdata->outgoing_queue = gw_prioqueue_create(sms_priority_compare);
@@ -1289,6 +1307,23 @@
         error(0, "AT2[-]: 'device' missing in at2 configuration.");
         goto error;
     }
+    if (strcmp(octstr_get_cstr(privdata->device), "rawtcp") == 0) {
+        privdata->rawtcp_host = cfg_get(cfg, octstr_imm("rawtcp-host"));
+        if (privdata->rawtcp_host == NULL) {
+            error(0, "AT2[-]: 'rawtcp-host' missing in at2 configuration.");
+            goto error;
+        }
+
+        if (cfg_get_integer(&portno, cfg, octstr_imm("rawtcp-port")) == -1) {
+            error(0, "AT2[-]: 'rawtcp-port' missing in at2 configuration.");
+            goto error;
+        }
+        privdata->rawtcp_port = portno;
+        privdata->is_serial = 0;
+    }
+    else {
+        privdata->is_serial = 1;
+    }
 
     privdata->name = cfg_get(cfg, octstr_imm("smsc-id"));
     if (privdata->name == NULL) {
Index: gw/smsc/smsc_at.h
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.h,v
retrieving revision 1.9
diff -u -r1.9 smsc_at.h
--- gw/smsc/smsc_at.h	11 Feb 2005 15:35:48 -0000	1.9
+++ gw/smsc/smsc_at.h	8 Jul 2005 15:36:23 -0000
@@ -140,6 +140,9 @@
     int	sms_memory_usage;
     List *pending_incoming_messages;
     int        max_error_count;
+    Octstr *rawtcp_host;
+    int    rawtcp_port;
+    int    is_serial; /* false if device is rawtcp */ 
 } PrivAT2data;
 
 
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.111
diff -u -r1.111 cfg.def
--- gwlib/cfg.def	14 Apr 2005 11:58:57 -0000	1.111
+++ gwlib/cfg.def	8 Jul 2005 15:36:23 -0000
@@ -362,6 +362,8 @@
     OCTSTR(denied-prefix-regex)
     OCTSTR(preferred-prefix-regex)
     OCTSTR(max-error-count)
+    OCTSTR(rawtcp-host)
+    OCTSTR(rawtcp-port)
 )
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.