VGSM Spooler
From VoiSmart Open Source Wiki
The SMS spooler is a command (executable or script) invoked upon reception of a SMS message (SMS-DELIVER) or a SMS-STATUS-REPORT.
Contents |
Usage
The path to the spooler's executable is configured in vgsm.conf
The command is spawned as a child of the URC handler thread in Asterisk's chan_vgsm channel driver. The message is passed to the spooler throught the standard input file descriptor.
Thought URCs get queued and their handling does not block the communication thread, it is good practice to process the message as quickly as possible as other URCs will be delayed some of which are time-sensitive (e.g. call-related URCs).
The message is RFC 2822 formatted, very much like a normal e-Mail, with additional headers. It is in facts possibile to use /usr/sbin/sendmail to directly submit the message in a Mail Transfer Agent.
Return codes from the spooler command should conform to <sysexits.h>
Just as an example, this simple script receives messages and appends them to a file in /tmp. Please note that this script lacks the needed locking and presents a security vulnerability by unconditionally opening the file in /tmp.
#!/bin/bash echo "******************* NEW SMS *******************" >>/tmp/sms_rx cat >>/tmp/sms_rx echo "******************* END SMS *******************" >>/tmp/sms_rx
List of headers
| Header | Description |
|---|---|
| To | Filled with data from vgsm.conf |
| Received | Filled with module name and registration info in a RFC2822 similar format |
| From | Contains the originator address (phone number) with the domain configured in vgsm.conf appended |
| Subject | Generic text describing the message |
| MIME-Version | Fixed to 1.0 |
| Content-Type | Fixed to text/plain charset="UTF-8" |
| Content-Transfer-Encoding | Fixed to 8bit |
| Date | Date received from Service Center |
| X-SMS-Message-Type | |
| X-SMS-Sender-NP | |
| X-SMS-Sender-TON | |
| X-SMS-Sender-Number | |
| X-SMS-SMCC-NP | |
| X-SMS-SMCC-TON | |
| X-SMS-SMCC-Number | |
| X-SMS-Class | |
| X-SMS-More-Messages-To-Send | |
| X-SMS-Reply-Path | |
| X-SMS-User-Data-Header-Indicator | |
| X-SMS-Status-Report-Indication |
Examples
SMS-DELIVER example
Received: from GSM module vodafone registered on Vodafone, Italy; Mon, 23 Oct 2006 02:01:03 +0200
From: <+393474659309@sms.voismart.it>
Subject: SMS message
MIME-Version: 1.0
Content-Type: text/plain
charset="UTF-8"
Content-Transfer-Encoding: 8bit
To: <sms@voismart.it>
Date: Mon, 23 Oct 2006 03:02:20 +0200
X-SMS-Message-Type: SMS-DELIVER
X-SMS-Sender-NP: ISDN telephony
X-SMS-Sender-TON: International
X-SMS-Sender-Number: +393474659309
X-SMS-SMCC-NP: ISDN telephony
X-SMS-SMCC-TON: International
X-SMS-SMCC-Number: +393492000896
X-SMS-Class: -1
X-SMS-More-Messages-To-Send: yes
X-SMS-Reply-Path: no
X-SMS-User-Data-Header-Indicator: no
X-SMS-Status-Report-Indication: no
Hello! This is an SMS, do you like me?
SMS-STATUS-REPORT example
Received: from GSM module vodafone registered on Vodafone, Italy; Mon, 23 Oct 2006 01:51:33 +0200
From: <+393474659309@sms.voismart.it>
Subject: SMS Status Report
MIME-Version: 1.0
Content-Type: text/plain
charset="UTF-8"
Content-Transfer-Encoding: 8bit
To: <sms@voismart.it>
Date: Mon, 23 Oct 2006 02:52:46 +0200
X-SMS-Message-Type: SMS-STATUS-REPORT
X-SMS-Message-Reference: 46
X-SMS-Discharge-Time: Mon, 23 Oct 2006 01:52:51 +0200
X-SMS-Recipient-NP: ISDN telephony
X-SMS-Recipient-TON: International
X-SMS-Recipient-Address: +393474659309
X-SMS-SMCC-NP: ISDN telephony
X-SMS-SMCC-TON: International
X-SMS-SMCC-Number: +393492000200
X-SMS-More-Messages-To-Send: no
X-SMS-User-Data-Header-Indicator: yes
X-SMS-Status-Report-Qualifier: SMS-SUBMIT
Message successfully delivered
SMS-DELIVERY with concatenated messages example
Message 1:
Received: from GSM module vodafone2, registered on 22210 (Vodafone, Italy); Mon, 16 Jul 2007 16:53:17 +0200 From: <+393471234567@sms.voismart.it> Subject: SMS message MIME-Version: 1.0 Content-Type: text/plain charset="UTF-8" Content-Transfer-Encoding: 8bit To: SMS Router <sms@voismart.it> Date: Mon, 16 Jul 2007 16:53:13 +0200 X-SMS-Message-Type: SMS-DELIVER X-SMS-Sender-NP: ISDN telephony X-SMS-Sender-TON: International X-SMS-Sender-Number: +393471234567 X-SMS-SMCC-NP: ISDN telephony X-SMS-SMCC-TON: International X-SMS-SMCC-Number: +393492000896 X-SMS-More-Messages-To-Send: yes X-SMS-Reply-Path: no X-SMS-User-Data-Header-Indicator: yes X-SMS-Status-Report-Indication: no X-SMS-Concatenate-RefID: 9 X-SMS-Concatenate-Total-Messages: 2 X-SMS-Concatenate-Sequence-Number: 1 This is a message longer than 160 characters thus is divided in more parts identified by the User Data Header. This is a message longer than 160 characte
Message 2:
Received: from GSM module vodafone2, registered on 22210 (Vodafone, Italy); Mon, 16 Jul 2007 16:53:19 +0200 From: <+393471234567@sms.voismart.it> Subject: SMS message MIME-Version: 1.0 Content-Type: text/plain charset="UTF-8" Content-Transfer-Encoding: 8bit To: SMS Router <sms@voismart.it> Date: Mon, 16 Jul 2007 16:53:16 +0200 X-SMS-Message-Type: SMS-DELIVER X-SMS-Sender-NP: ISDN telephony X-SMS-Sender-TON: International X-SMS-Sender-Number: +393471234567 X-SMS-SMCC-NP: ISDN telephony X-SMS-SMCC-TON: International X-SMS-SMCC-Number: +393492000896 X-SMS-More-Messages-To-Send: yes X-SMS-Reply-Path: no X-SMS-User-Data-Header-Indicator: yes X-SMS-Status-Report-Indication: no X-SMS-Concatenate-RefID: 9 X-SMS-Concatenate-Total-Messages: 2 X-SMS-Concatenate-Sequence-Number: 2 rs thus is divided in more parts identified by the User Data Header.

