Skip to content

Instantly share code, notes, and snippets.

@caruizdiaz
caruizdiaz / dwgsms-client.c
Created October 13, 2012 17:53
dwgsms client written in C
/*
* main.c
*
* Created on: Sep 19, 2012
* Author: caruizdiaz
* caruizdiaz.com
*/
#include "dwg/dwg_util.h"
#include "dwg/dwg.h"
@caruizdiaz
caruizdiaz / expires-kamailio.sh
Last active December 14, 2015 08:59
Kamailio: modify "expires" attribute in Contact hdr.
$avp(s:contact) = $hdr(Contact);
# remove the proposed value
avp_subst("$avp(s:contact)", "/;expires=[0-9]+//gi");
# insert the value I want: 120.
append_to_reply("Contact: $avp(contact);expires=120\r\n");
sl_send_reply("200", "OK");
@caruizdiaz
caruizdiaz / start-server.cs
Last active December 22, 2015 03:09
Event handlers and server initialization
Gateway.StatusChanged += HandleGatewayStatusChanged;
Gateway.SMSReceived += HandleGatewaySMSReceived;
Gateway.SentSMSStatus += HandleGatewaySentSMSStatus;
Gateway.USSDReceived += HandleGatewayUSSDReceived;
Gateway.StartListener(port);
@caruizdiaz
caruizdiaz / event-handlers.cs
Last active December 22, 2015 03:09
implementation of events handlers
static void HandleGatewayUSSDReceived (string gatewayIP, int port, dwg_ussd_result_code status, string message)
{
Console.WriteLine("USSD response {0} at port {1}, status {2}", gatewayIP,port, Enum.GetName(typeof(dwg_ussd_result_code), status));
Console.WriteLine(message);
}
static void HandleGatewaySMSReceived (string gatewayIP, string number, string text, int port, string timestamp)
{
if (text == null)
text = string.Empty;
@caruizdiaz
caruizdiaz / send-sms.cs
Last active December 22, 2015 03:09
sending a message using a random port
string number = "+595981146623";
string text = "Hello World";
int sendingPort = 0;
for(;;)
{
Console.ReadLine();
if (!Gateway.IsGwConnected)
{
@caruizdiaz
caruizdiaz / sample-windows.cs
Last active December 22, 2015 03:09
Main form of the sample application for Windows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using dwgsms.API;
using dwgsms.DWG;
@caruizdiaz
caruizdiaz / ims_ro.c
Created December 17, 2013 17:27
return code as alphanumeric AVP
static int create_cca_return_code(int result) {
int rc;
int_str avp_val, avp_name;
avp_name.s.s = RO_AVP_CCA_RETURN_CODE;
avp_name.s.len = RO_AVP_CCA_RETURN_CODE_LENGTH;
avp_val.n = result;
avp_val.s.s = RO_RETURN_TRUE_STR; //assume true
avp_val.s.len = 1;
@caruizdiaz
caruizdiaz / presidentes.pl
Created December 18, 2013 01:00
Lista del presidentes del Paraguay desde la Guerra del Chaco, con sus periodos y partidos
% Lista de presidentes de Paraguay luego de la guerra del chaco
presidente('Eusebio Ayala', 1932, 1936, 'Liberal').
presidente('Rafael Franco', 1936, 1937, 'Militar').
presidente('Félix Paiva', 1937, 1939, 'Liberal').
presidente('José Félix Estigarribia', 1939, 1940, 'Liberal').
presidente('Higinio Morínigo', 1940, 1948, 'Liberal').
presidente('Juan Manuel Frutos', 1948, 1948, 'Militar').
presidente('Juan Natalicio González', 1948, 1949, 'Colorado').
presidente('Raimundo Rolón', 1949, 1949, 'Colorado').
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v3.2 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
# Direct your questions about this file to: <sr-users@lists.sip-router.org>
#
# Refer to the Core CookBook at http://www.kamailio.org/dokuwiki/doku.php
@caruizdiaz
caruizdiaz / cnxcc-check.cfg
Created April 28, 2014 00:45
uses cnxcc module to monitor the call. It does not allow more than 1 call per customer, simultaneously.
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v3.2 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
# Direct your questions about this file to: <sr-users@lists.sip-router.org>
#
# Refer to the Core CookBook at http://www.kamailio.org/dokuwiki/doku.php