Badr Zarhri > Net-CIMD > Net::CIMD

Download:
Net-CIMD-01_02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01_02   Source   Latest Release: Net-CIMD-0.01_03

NAME ^

Net::CIMD - pure Perl implementation of CIMD2 over TCP

SYNOPSIS ^

  use Net::CIMD;
  my $me=Net::CIMD->login(
                        host    =>      $ip_address,
                        port    =>      $port,
                        user_identity   =>      $login,
                        password        =>      $password,
                        local_ip        =>      $ip_address
                        ) or croak "Cannot connect to $ip_address $!\n";

DESCRIPTION ^

Computer Interface for Message Distribution protocol, which is frequently used to pass short messages between mobile operators implementing short message service (SMS).

Operations, and parameters names are the same as in cimd specification document.

$me->read_sync() doesn't implement all response messages, but it was tested, and it answers at least to deliver_status_report operation.

This module lack also tests. Tests are ongoing, but you can help by reporting any observed bugs.

Except login method, all other methods work in asychronous mode. Which means it's to the user to wait for the answer for each sent packet. This approach makes it easier to use speed related mechanisms like windowing.

This module in intended to be used as client or server, but current version supports only client mode.

CONSTRUCTORS

login()

Create a new CIMD client object and open conncetion to SMSC host

        my $cimd=Net::CIMD->login(
                        host    =>      $ip_address,    # defaults to 127.0.0.1
                        port    =>      $port,  # defaults to 9971
                        user_identity   =>      $login
                        password        =>      $password,
                        local_ip        =>      $ip_address,    # defaults to 127.0.01: this parameter is very important when we've many network interfaces.
                        subaddr =>      $subaddr,
                        window_size     =>      $size,
                        IP_address      =>      $ip_address     # This is a new parameter not available in SC8.0.
                        ) or croak "Cannot connect to $ip_address $!\n";

It first establish a connexion with the server, and then send the credentials.

METHODS Although current version supports only client mode, all CIMD operations are already implemented ^

methods:
        login()
        logout()
        submit()
        enquire_message_status()
        delivery_request()
        cancel()
        set_parameters()
        get_parameters()
        submit_status_report()
        deliver_message()
        deliver_status_report()
        alive()
        login_resp()()
        logout_resp()
        submit_resp()
        enquire_message_status_resp()
        delivery_request_resp()
        cancel_resp()
        set_parameters_resp()
        get_parameters_resp()
        submit_status_report_resp()
        deliver_message_resp()
        deliver_status_report_resp()
        alive_resp()
        general_error_resp()
        nack()
parameters:

Previous methods can be used with the folowing parameter names:

        user_identity
        password
        subaddr
        window_size
        destination_address
        originating_address
        originating_IMSI
        alphanumeric_ariginating_address
        originated_visited_MSC_address
        data_coding_scheme
        user_data_header
        user_data
        user_data_binary
        more_messages_to_send
        validity_Period_Relative
        validity_Period_Absolute
        protocol_identifier
        first_delivery_time_relative
        first_delivery_time_absolute
        reply_path
        status_report_request
        cancel_enabled
        cancel_mode
        service_centre_time_stamp
        status_code
        status_error_code
        discharge_time
        tariff_class
        service_description
        message_count
        priority
        delivery_request_mode
        service_center_address
        get_parameter
        SMS_center_time
        error_code
        error_text

As an example, submit message can be wrote like this:

        my $cimd=Net::CIMD->login(
                        host    =>      $ip_address,
                        port    =>      $port,
                        user_identity   =>      $login,
                        password        =>      $password,
                        local_ip        =>      $ip_address
                        ) or croak "Cannot connect to $ip_address $!\n";
        $cimd->submit(
                destination_address     =>      '00212661093659',
                originating_address     =>      '2727',
                data_coding_scheme      =>      0,
                user_data       =>      'Salam cava ?',
                first_delivery_time_relative    =>      1,
                status_report_request   =>      12,
                priority        =>      1
                );

Current version assumes that all parameters are optional, unlike in the specification. This is mainly because of the lack of time, and will be fixed in next version. Strong parameters control will be added in future versions.

Receiving PDUs ^

For reception, this module has methods that send ACK before returning the packet, and other that don't.

receive_packet()

This method returns raw packet without sending ACK.

        my $raw_resp=$cimd->receive_packet();
read_sync()

This method receives a raw packet from network connexion, decodes it into Net::CIMD::PDU, send the ACK to the remote entity, and then return the decoded PDU.

        my $pdu=$cimd->read_sync();

OTHER METHODS ^

Some other useful methods that doesn't require a connexion to an SMSC are also available.

decode_packet()

This method is used to decode a raw packet. It was separated from reading from the stream, so it can be used for other sources of data (for example NetPacket::TCP).

        my $pdu=$cimd->decode_packet($var);
or
        my $pdu=Net::CIMD->decode_packet($var);

EXAMPLES ^

Typical client:

        #!/bin/env perl
        
        use Net::CIMD;
        use v5.8;
        use Data::Dumper;
        use Carp;
        
        my $ip_address='127.0.0.1';
        my $port='9971';
        my $login='login';
        my $password='secret';
        
        local $Carp::CarpLevel = 1;
        
        my $cimd=Net::CIMD->login(
                host    =>      $ip_address,
                port    =>      $port,
                user_identity   =>      $login,
                password        =>      $password,
                local_ip        =>      $ip_address
                ) or croak "Cannot connect to $ip_address $!\n";
        $cimd->submit(
                destination_address     =>      '00212661093659',
                originating_address     =>      '2727',
                data_coding_scheme      =>      0,
                user_data       =>      'Salam cava ?',
                first_delivery_time_relative    =>      1,
                status_report_request   =>      12,
                priority        =>      1
                );
        
        
        my $resp=$cimd->read_sync();
        
        print Dumper($resp)."\n";

Limitations ^

Current version supports only client mode.

CIMD Specific abreviations should be added with encoding methods.

Connexion check is not performed. (when connexion is closed for some reason, the module still use the session).

Text encoding methode should be added.

No restrictions are applied to parameters.

NET::CIMD COMES WITH ABSOLUTELY NO WARRANTY.

AUTHOR ^

Badr Zarhri <badr.zarhri@gmail.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2013 by Badr Zarhri <badr.zarhri@gmail.com>

Net::CIMD is copyright (c) 2013 by Badr Zarhri, All rights reserved. You may use and distribute Net::CIMD under same terms as perl itself.

syntax highlighting: