samsam has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to use Net::SMPP implement a client send PDU to a server. The server is written with normal socket APIs, that is listen, bind, accept. So in the server side, I need to somehow decode the PDU message sent by the smpp client. How can the general purpose server decode the PDU message sent by the SMPP client? Thanks Sam

Replies are listed 'Best First'.
Re: SMPP client
by NetWallah (Canon) on Dec 15, 2005 at 04:41 UTC
    Plagerize code from the Net::SMPP module.

    Here is a possible starting point ..

    sub decode_submit_v4 { my $pdu = shift; ($pdu->{message_class}, # 1 (2) $pdu->{source_addr_ton}, # 2 (1) $pdu->{source_addr_npi}, # 3 (1) $pdu->{source_addr}, # 4 (n+1) ) = unpack 'nCCZ*', $pdu->{data}; my $len = 2 + 1 + 1 + length($pdu->{source_addr}) + 1; ($pdu->{number_of_dests}) = unpack 'N', substr($pdu->{data}, $len) +; $len += 4; #warn "a decode_submit $len ($pdu->{number_of_dests}): ".hexdump(s +ubstr($pdu->{data}, $len)); ....

         You're just jealous cause the voices are only talking to me.

         No trees were killed in the sending of this message.    However, a large number of electrons were terribly inconvenienced.

      Sorry, still not quite get the idea of your example. Is this the server code? How does it related to the APIs in Net::SMPP? What will be a smpp client look like? Thanks Sam
        My suggestion was to copy some of the code from the Net/SMPP.pm module into your server script. You would NOT be useing NET::SMPP in the server code, so it is not related to the API.

        Since you already have a mechanism (accept from IO::Socket) to receive packets, and all you requested was how to decode them, you could pass the received packet into the sample sub above, and have it decoded for you.

        In a similar manner, you would need to construct a response packet, and send it to the client.

        Hope this helps. Not having studied the SMPP protocol, I could not estimate the level of difficulty, or advise whether this is a wise direction. I was simply attempting to answer your direct question of how you whould go about doing such a thing.

             You're just jealous cause the voices are only talking to me.

             No trees were killed in the sending of this message.    However, a large number of electrons were terribly inconvenienced.