class MGCPEngine

An MGCP engine. More...

Full nameTelEngine::MGCPEngine
Definition#include <libs/ymgcp/yatemgcp.h>
InheritsTelEngine::DebugEnabler [public ], TelEngine::Mutex [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Public Members

Protected Methods

Protected Members


Detailed Description

The engine may keep gateway endpoints or call agents Keep the transaction list and manage it (create/delete/modify/timeout...) Keep a list with the endpoints it services Generate transaction numbers (IDs) Parse received messages, validate and send them to the appropriate transaction Send MGCP messages to remote addresses

 MGCPEngine (bool gateway, const char* name = 0, const NamedList* params = 0)

MGCPEngine

Constructor. Construct the engine and, optionally, initialize it

Parameters:
gatewayEngine's mode: true if this engine is an MGCP Gateway, false if it's a collection of Call Agents
nameOptional debug name for this engine
paramsOptional parameters used to initialize this engine

 ~MGCPEngine ()

~MGCPEngine

[virtual]

Destructor. Clear all lists

inline bool  gateway ()

gateway

[const]

Check if this engine is an MGCP Gateway or a collection of Call Agents

Returns: True if this engine is an MGCP Gateway, false if it's a collection of Call Agents

inline const SocketAddr&  address ()

address

[const]

Get the IP address used by this engine to receive data

Returns: The IP address used by this engine to receive data

inline unsigned int  maxRecvPacket ()

maxRecvPacket

[const]

Get the maximum length or received packets. This is the size of the buffer used by this engine to read data from the socket

Returns: The maximum length or received packets

inline bool  allowUnkCmd ()

allowUnkCmd

[const]

Check if this engine is allowed to send/accept unknown commands

Returns: True if this engine is allowed to send/accept unknown commands

inline unsigned int  retransInterval ()

retransInterval

[const]

Get the message retransmission interval

Returns: The message retransmission interval

inline unsigned int  retransCount ()

retransCount

[const]

Get the maximum number of retransmissions for a message

Returns: The maximum number of retransmissions for a message

inline u_int64_t  extraTime ()

extraTime

[const]

Get the time to live after the transaction terminated gracefully

Returns: The time to live after the transaction terminated gracefully

inline bool  parseParamToLower ()

parseParamToLower

[const]

Check if the parser should convert received messages' parameters to lower case

Returns: True if the parser should convert received messages' parameters to lower case

inline bool  provisional ()

provisional

[const]

Check if incoming transactions would send provisional responses

Returns: True if incoming transactions would send provisional responses

inline bool  ackRequest ()

ackRequest

[const]

Get the remote ACK request flag

Returns: True if remote will be requested to send an ACK

inline void  ackRequest (bool request)

ackRequest

Set the remote ACK request flag

Parameters:
requestFalse to not request from remote to send an ACK

void  initialize (const NamedList& params)

initialize

[virtual]

Initialize this engine

Parameters:
paramsEngine's parameters

inline bool  knownCommand (const String& cmd)

knownCommand

Check if a command is known by this engine

Parameters:
cmdThe command name to check

Returns: True if the given command is known by this engine

void  addCommand (const char* cmd)

addCommand

Add a command to the list of known commands

Parameters:
cmdThe command name to add

void  attach (MGCPEndpoint* ep)

attach

Append an endpoint to this engine if not already done

Parameters:
epThe endpoint to append

void  detach (MGCPEndpoint* ep, bool del = false, bool delTrans = false)

detach

Remove an endpoint from this engine and, optionally, remove all its transactions

Parameters:
epThe endpoint to remove
delTrue to delete it, false to just remove it from the list
delTransTrue to remove all its transactions. Forced to true if the endpoint is deleted

MGCPEndpoint*  findEp (MGCPEndpoint* ep)

findEp

Find an endpoint by its pointer

Parameters:
epThe endpoint to find

Returns: MGCPEndpoint pointer or 0 if not found

MGCPEndpoint*  findEp (const String& epId)

findEp

Find an endpoint by its id

Parameters:
epIdThe endpoint's id to find

Returns: MGCPEndpoint pointer or 0 if not found

MGCPTransaction*  findTrans (unsigned int id, bool outgoing)

findTrans

Find a transaction by its id

Parameters:
idThe id of the transaction to find
outgoingThe transaction direction. True for outgoing, false for incoming

Returns: MGCPTransaction pointer or 0 if not found

unsigned int  getNextId ()

getNextId

Generate a new id for an outgoing transaction

Returns: An id for an outgoing transaction

MGCPTransaction*  sendCommand (MGCPMessage* cmd, const SocketAddr& address, bool engineProcess = true)

sendCommand

Send a command message. Create a transaction for it. The method will fail if the message is not a valid one or isn't a valid command

Parameters:
cmdThe message containig the command
addressThe destination IP address
engineProcessUse engine private processor thread for the new transaction. If false the caller is responsable with transaction processing

Returns: MGCPTransaction pointer or 0 if failed to create a transaction

bool  receive (unsigned char* buffer, SocketAddr& addr)

receive

Read data from the socket. Parse and process the received message

Parameters:
bufferBuffer used for read operation. The buffer must be large enough to keep the maximum packet length returned by maxRecvPacket()
addrThe sender's address if received any data

Returns: True if received any data (a message was successfully parsed)

bool  process (u_int64_t time = Time())

process

Try to get an event from a transaction. If the event contains an unknown command and this engine is not allowed to process such commands, calls the returnEvent() method, otherwise, calls the processEvent() method

Parameters:
timeCurrent time in microseconds

Returns: True if an event was processed

bool  processTransaction (MGCPTransaction* tr, u_int64_t time = Time())

processTransaction

Try to get an event from a given transaction. If the event contains an unknown command and this engine is not allowed to process such commands, calls the returnEvent() method, otherwise, calls the processEvent() method

Parameters:
trTransaction to process
timeCurrent time in microseconds

Returns: True if an event was processed

void  runReceive (SocketAddr& addr)

runReceive

Repeatedly calls receive() until the calling thread terminates

Parameters:
addrThe sender's address if received any data

void  runReceive ()

runReceive

Repeatedly calls receive() until the calling thread terminates

void  runProcess ()

runProcess

Repeatedly calls process() until the calling thread terminates

MGCPEvent*  getEvent (u_int64_t time = Time())

getEvent

Try to get an event from a transaction

Parameters:
timeCurrent time in microseconds

Returns: MGCPEvent pointer or 0 if none

bool  processEvent (MGCPEvent* event)

processEvent

[virtual]

Process an event generated by a transaction. Descendants must override this method if they want to process events. By default it calls the version of processEvent that accepts separate parameters of event

Parameters:
eventThe event to process

Returns: True if the event was processed. If the event carry a received command and it's not processed the transaction will receive an 'unknown command' response

bool  processEvent (MGCPTransaction* trans, MGCPMessage* msg)

processEvent

[virtual]

Process an event generated by a transaction. Descendants must override this method if they want to process events

Parameters:
transPointer to the transaction that generated the event
msgMGCP message of the event, may be NULL

Returns: True if the event was processed. If the event carry a received command and it's not processed the transaction will receive an 'unknown command' response

void  returnEvent (MGCPEvent* event)

returnEvent

Returns an unprocessed event to this engine to be deleted. Incoming transactions will be responded. Unknown commands will receive a 504 Unknown Command response, the others will receive a 507 Unsupported Functionality one

Parameters:
eventThe event to return

void  cleanup (bool gracefully = true, const char* text = "Shutdown")

cleanup

Terminate all transactions. Cancel all private threads if any and wait for them to terminate

Parameters:
gracefullyIf true, all incoming transaction will be responded and private threads will be gently cancelled. If false, all transactions will be deleted and threads will be cancelled the hard way
textOptional text to be sent with the response code of the incoming transactions on gracefully cleanup

inline int  defaultPort (bool gateway)

defaultPort

[static]

Get the default port defined by the protocol

Parameters:
gatewayTrue to get the default Gateway port, false to get the default port for the Call Agent

Returns: The default port defined by the protocol

void  timeout (MGCPTransaction* tr)

timeout

[virtual]

Handle a transaction that has timed out

Parameters:
trThe transaction that has timed out

static TokenDict mgcp_commands[]

mgcp_commands[]

static TokenDict mgcp_responses[]

mgcp_responses[]

static TokenDict mgcp_reasons[]

mgcp_reasons[]

bool  sendData (const String& msg, const SocketAddr& address)

sendData

[protected]

Send a string buffer through the socket

Parameters:
msgThe buffer to send
addressThe destination IP address

Returns: False if the operation failed

void  appendTrans (MGCPTransaction* trans)

appendTrans

[protected]

Append a transaction to the list

Parameters:
transThe transaction to append

void  removeTrans (MGCPTransaction* trans, bool del)

removeTrans

[protected]

Remove a transaction from the list

Parameters:
transThe transaction to remove
delTrue to delete it, false to just remove it from list

ObjList m_endpoints

m_endpoints

[protected]

ObjList m_transactions

m_transactions

[protected]

ListIterator m_iterator

m_iterator

[protected]


Generated by: paulc on bussard on Sun Oct 20 21:06:06 2013, using kdoc 2.0a54.