Copyright © 2004 Enrique Marcote Peña
Version: 1.1, {07 June 2004} 11:56:47.
Behaviour: gen_fsm.
Authors: Enrique Marcote Peña (mpquique_at_users.sourceforge.net) [web site: http://oserl.sourceforge.net/].
A generic SMSC SMPP session modeled as a FSM. It also implements the gen_connection behaviour.
Every SMPP session works over a single TCP/IP connection. If the underlying connection exits, the session is also terminated.
Session failures due to connection errors must be handled by the callback SMSC.
To a better understanding of this behaviour, should notice that the state name on a SMSC session references that state of the ESME session on the other peer. Thus:
Possible states for the SMSC SMPP session are shown in the first row. Events are those in the first column. This table shows the next state given an event and the current state.
Operations issued by the other peer (ESME) are treated asynchronously by the SMSC session, thus represented by async events.
One instance
of this timer is started for each request.
On expiration, the request is considered unsuccessful.
The timer associated to a request is stopped when the corresponding response arrives.
A module implementing this behaviour must export these functions. Leaving a callback undefined crashes the entire session (when that particular function is called).
handle_bind/3 | Forwards bind_receiver, bind_transmitter and bind_transceiver operations (from the peer ESME) to the callback SMSC. |
handle_operation/3 | Forwards broadcast_sm, cancel_broadcast_sm, cancel_sm, query_broadcast_sm, query_sm, replace_sm, submit_multi, submit_sm and data_sm operations (from the peer ESME) to the callback SMSC. |
handle_unbind/3 | This callback forwards an unbind request (issued by a peer ESME) to the SMSC. |
Forwards bind_receiver, bind_transmitter and bind_transceiver operations (from the peer ESME) to the callback SMSC.
The ParamList included in the response is used to construct the bind response PDU. If a command_status other than ESME_ROK is to be returned by the ESME in the response PDU, the callback should return the term {error, Error, ParamList}, where Error is the desired command_status error code.
SMSC is the SMSC's process id, Session is the session id.
Forwards broadcast_sm, cancel_broadcast_sm, cancel_sm, query_broadcast_sm, query_sm, replace_sm, submit_multi, submit_sm and data_sm operations (from the peer ESME) to the callback SMSC.
The ParamList included in the response is used to construct the response PDU. If a command_status other than ESME_ROK is to be returned by the ESME in the response PDU, the callback should return the term {error, Error, ParamList}, where Error is the desired command_status error code.
SMSC is the SMSC's process id, Session is the session id.
This callback forwards an unbind request (issued by a peer ESME) to the SMSC.
If ok returned an unbind_resp with a ESME_ROK command_status is sent to the MC and the session moves into the unbound state. When {error, Error} is returned by the ESME, the response PDU sent by the session to the MC will have an Error command_status and the session will remain on it's current bound state (bound_rx, bound_tx or bound_trx).
SMSC is the SMSC's process id, Session is the session id.
alert_notification/2 | Issues an alert_notification operation on the session identified by FsmRef. |
behaviour_info/1 | Gives information about the behaviour. |
bound_rx/2 | gen_fsm - StateName/2 callback implementation. |
bound_rx/3 | gen_fsm - StateName/3 callback implementation. |
bound_trx/2 | gen_fsm - StateName/2 callback implementation. |
bound_trx/3 | gen_fsm - StateName/3 callback implementation. |
bound_tx/2 | gen_fsm - StateName/2 callback implementation. |
bound_tx/3 | gen_fsm - StateName/3 callback implementation. |
code_change/4 | gen_fsm - code_change/4 callback implementation. |
data_sm/2 | Issues a data_sm operation on the session identified by FsmRef. |
deliver_sm/2 | Issues a deliver_sm operation on the session identified by FsmRef. |
handle_event/3 | gen_fsm - handle_event/3 callback implementation. |
handle_info/3 | gen_fsm - handle_info/3 callback implementation. |
handle_sync_event/4 | gen_fsm - handle_sync_event/4 callback implementation. |
init/1 | gen_fsm - init/1 callback implementation. |
open/2 | gen_fsm - StateName/2 callback implementation. |
open/3 | gen_fsm - StateName/3 callback implementation. |
outbind/2 | Issues an outbind operation on the session identified by FsmRef. |
outbound/2 | gen_fsm - StateName/2 callback implementation. |
outbound/3 | gen_fsm - StateName/3 callback implementation. |
start/3 | Starts the server setting self() as the session SMSC (owner). |
start/4 | Starts the server setting self() as the session SMSC (owner). |
start_link/3 | Starts the server setting self() as the session SMSC (owner). |
start_link/4 | Starts the server setting self() as the session SMSC (owner). |
stop/1 | Stops the fsm. |
terminate/3 | gen_fsm - terminate/3 callback implementation. |
unbind/1 | Issues an unbind operation on the session identified by FsmRef. |
unbound/2 | gen_fsm - StateName/2 callback implementation. |
unbound/3 | gen_fsm - StateName/3 callback implementation. |
alert_notification(FsmRef, ParamList) -> Result
Issues an alert_notification operation on the session identified by FsmRef.
behaviour_info(Other::Category) -> Info
Gives information about the behaviour.
bound_rx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_rx. Bound against a receiver ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_rx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_rx. Bound against a receiver ESME.
bound_trx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_trx. Bound against a transceiver ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_trx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_trx. Bound against a transceiver ESME.
bound_tx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_tx. Bound against a transmitter ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_tx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_tx. Bound against a transmitter ESME.
code_change(OldVsn, StateName, StateData, Extra) -> Result
gen_fsm - code_change/4 callback implementation. Convert process state when code is changed
data_sm(FsmRef, ParamList) -> Result
Issues a data_sm operation on the session identified by FsmRef.
deliver_sm(FsmRef, ParamList) -> Result
Issues a deliver_sm operation on the session identified by FsmRef.
handle_event(R::Event, StateName, StateData) -> Result
gen_fsm - handle_event/3 callback implementation. Handles events received by gen_fsm:send_all_state_event/2.
handle_info(Info, StateName, StateData) -> Result
gen_fsm - handle_info/3 callback implementation. Call on reception of any other messages than a synchronous or asynchronous event.
handle_sync_event(Event, From, StateName, StateData) -> Result
gen_fsm - handle_sync_event/4 callback implementation. Handles events received via gen_fsm:sync_send_all_state_event/2,3.
init(X1::Args) -> Result
gen_fsm - init/1 callback implementation. Initializes the the fsm.
open(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name open.
PDUs comming from the other peer (ESME) are received asynchronously.
open(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name open.
outbind(FsmRef, ParamList) -> Result
Issues an outbind operation on the session identified by FsmRef.
outbound(R::Event, S) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name outbound.
PDUs comming from the other peer (ESME) are received asynchronously.
outbound(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name outbound.
start(Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
The gen_smsc_session is not registered.
See also: start_link/3, gen_fsm:start/3.
start(Name, Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
If Name = {local, TheName}, the gen_smsc_session is registered locally as TheName. If Name = {global, TheName}, the gen_smsc_session is registered globally as TheName.
See also: start_link/4, gen_fsm:start/4.
start_link(Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
The gen_smsc_session is not registered.
See also: start/3, gen_fsm:start_link/3.
start_link(Name, Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
If Name = {local, TheName}, the gen_smsc_session is registered locally as TheName. If Name = {global, TheName}, the gen_smsc_session is registered globally as TheName.
See also: start/4, gen_fsm:start_link/4.
stop(FsmRef) -> ok
Equivalent to gen_fsm:send_all_state_event(FsmRef, die).
Stops the fsm. This function does *NOT* issue an unbind operation. The unbind must have been previously sent using the unbind/1 function.
See also: gen_fsm:send_all_state_event/2.
terminate(R::Reason, N::StateName, S::StateData) -> true
gen_fsm - terminate/3 callback implementation. Shutdown the fsm.
Return value is ignored by the server.
unbind(FsmRef) -> Result
Issues an unbind operation on the session identified by FsmRef.
unbound(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name unbound.
PDUs comming from the other peer (ESME) are received asynchronously.
unbound(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name unbound.