Re: RAWTCP mode (AT modem on a TCP terminal server) -- patch updated
Alexander Malysh <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
patch looks good to me.
+1 from me.
Thanks,
Alex
Stanislav Sinyagin wrote:
> Attached, please see the patch against current CVS HEAD.
> Alexander Malysh's advices and comments are integrated.
>
> I'm looking forward for this patch to be committed,
> as we're about to start deploying first production systems.
>
> thanks,
> stan
>
>
> ------------------------------------------------------------------------
>
> Index: doc/userguide/userguide.xml
> ===================================================================
> RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
> retrieving revision 1.302
> diff -u -r1.302 userguide.xml
> --- doc/userguide/userguide.xml 26 Jul 2005 12:47:17 -0000 1.302
> +++ doc/userguide/userguide.xml 14 Sep 2005 15:16:44 -0000
> @@ -3460,6 +3460,9 @@
> <entry><literal>device-name</literal></entry>
> <entry valign="bottom">
> The device the modem is connected to, like <literal>/dev/ttyS0</literal>.
> + When the device name is set to <literal>rawtcp</literal>, two other
> + variables are required in the configuration: <literal>host</literal>
> + and <literal>port</literal>. See the note below.
> </entry></row>
>
> <row><entry><literal>speed</literal></entry>
> @@ -3529,6 +3532,21 @@
> hard reset. Default disabled.
> </entry></row>
>
> + <row><entry><literal>host</literal></entry>
> + <entry><literal>IP address</literal></entry>
> + <entry valign="bottom">
> + Hostname or IP address to connect in <literal>rawtcp</literal> mode.
> + Required if <literal>device</literal> is set to <literal>rawtcp</literal>.
> + </entry></row>
> +
> + <row><entry><literal>port</literal></entry>
> + <entry><literal>integer</literal></entry>
> + <entry valign="bottom">
> + TCP port to connect to on <literal>rawtcp-host</literal>.
> + Required if <literal>device</literal> is set to <literal>rawtcp</literal>.
> + </entry></row>
> +
> +
> </tbody></tgroup></informaltable>
>
> <para>Modem definitions are now multiple groups present in kannel.conf,
> @@ -3684,6 +3702,13 @@
> finally your GSM network provider may not support delivery reports to mobile
> units.</para>
>
> + <para><emphasis>About <literal>rawtcp</literal> mode:</emphasis>
> + This mode allows you to use a GSM modem connected to a remote terminal server,
> + such as Perle IOLAN DS1 or a Cisco router with reverse telnet. The teminal
> + server should support raw TCP mode. The driver is not tested in telnet mode.
> + It is recommended to use <literal>keepalive</literal> variable, in order to
> + automatically reconnect in case of network connectivity problems.</para>
> +
> </sect2>
>
>
> Index: gw/smsc/smsc_at.c
> ===================================================================
> RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
> retrieving revision 1.26
> diff -u -r1.26 smsc_at.c
> --- gw/smsc/smsc_at.c 14 Sep 2005 14:10:21 -0000 1.26
> +++ gw/smsc/smsc_at.c 14 Sep 2005 15:16:45 -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 (octstr_str_compare(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);
> @@ -1011,6 +1025,9 @@
> int ret;
> int speed;
>
> + if(! privdata->is_serial)
> + return;
> +
> tcgetattr(privdata->fd, &tios);
>
> switch (bps) {
> @@ -1286,6 +1303,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);
> @@ -1298,6 +1316,23 @@
> error(0, "AT2[-]: 'device' missing in at2 configuration.");
> goto error;
> }
> + if (octstr_str_compare(privdata->device, "rawtcp") == 0) {
> + privdata->rawtcp_host = cfg_get(cfg, octstr_imm("host"));
> + if (privdata->rawtcp_host == NULL) {
> + error(0, "AT2[-]: 'host' missing in at2 rawtcp configuration.");
> + goto error;
> + }
> +
> + if (cfg_get_integer(&portno, cfg, octstr_imm("port")) == -1) {
> + error(0, "AT2[-]: 'port' missing in at2 rawtcp 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 14 Sep 2005 15:16:45 -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;
>
>