MGCPEngine Class Reference
An MGCP engine.
More...
#include <yatemgcp.h>
List of all members.
Public Member Functions |
| MGCPEngine (bool gateway, const char *name=0, const NamedList *params=0) |
virtual | ~MGCPEngine () |
bool | gateway () const |
const SocketAddr & | address () const |
unsigned int | maxRecvPacket () const |
bool | allowUnkCmd () const |
unsigned int | retransInterval () const |
unsigned int | retransCount () const |
u_int64_t | extraTime () const |
bool | parseParamToLower () const |
bool | provisional () const |
bool | ackRequest () const |
void | ackRequest (bool request) |
virtual void | initialize (const NamedList ¶ms) |
bool | knownCommand (const char *cmd) |
void | addCommand (const char *cmd) |
void | attach (MGCPEndpoint *ep) |
void | detach (MGCPEndpoint *ep, bool del=false, bool delTrans=false) |
MGCPEndpoint * | findEp (MGCPEndpoint *ep) |
MGCPEndpoint * | findEp (const String &epId) |
MGCPTransaction * | findTrans (unsigned int id, bool outgoing) |
unsigned int | getNextId () |
MGCPTransaction * | sendCommand (MGCPMessage *cmd, const SocketAddr &address) |
bool | receive (unsigned char *buffer, SocketAddr &addr) |
bool | process (u_int64_t time=Time()) |
void | runReceive () |
void | runProcess () |
MGCPEvent * | getEvent (u_int64_t time=Time()) |
virtual bool | processEvent (MGCPEvent *event) |
virtual bool | processEvent (MGCPTransaction *trans, MGCPMessage *msg, void *data) |
void | returnEvent (MGCPEvent *event) |
void | cleanup (bool gracefully=true, const char *text="Shutdown") |
Static Public Member Functions |
static int | defaultPort (bool gateway) |
Static Public Attributes |
static TokenDict | mgcp_commands [] |
static TokenDict | mgcp_responses [] |
static TokenDict | mgcp_reasons [] |
Protected Member Functions |
bool | sendData (const String &msg, const SocketAddr &address) |
void | appendTrans (MGCPTransaction *trans) |
void | removeTrans (MGCPTransaction *trans, bool del) |
Protected Attributes |
ObjList | m_endpoints |
ObjList | m_transactions |
Friends |
class | MGCPPrivateThread |
class | MGCPTransaction |
Detailed Description
An MGCP engine.
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
Constructor & Destructor Documentation
Constructor. Construct the engine and, optionally, initialize it
- Parameters:
-
| gateway | Engine's mode: true if this engine is an MGCP Gateway, false if it's a collection of Call Agents |
| name | Optional debug name for this engine |
| params | Optional parameters used to initialize this engine |
Destructor. Clear all lists
Member Function Documentation
void ackRequest |
( |
bool |
request |
) |
[inline] |
Set the remote ACK request flag
- Parameters:
-
| request | False to not request from remote to send an ACK |
bool ackRequest |
( |
|
) |
const [inline] |
Get the remote ACK request flag
- Returns:
- True if remote will be requested to send an ACK
void addCommand |
( |
const char * |
cmd |
) |
|
Add a command to the list of known commands
- Parameters:
-
| cmd | The command name to add |
Get the IP address used by this engine to receive data
- Returns:
- The IP address used by this engine to receive data
bool allowUnkCmd |
( |
|
) |
const [inline] |
Check if this engine is allowed to send/accept unknown commands
- Returns:
- True if this engine is allowed to send/accept unknown commands
Append a transaction to the list
- Parameters:
-
| trans | The transaction to append |
Append an endpoint to this engine if not already done
- Parameters:
-
| ep | The endpoint to append |
void cleanup |
( |
bool |
gracefully = true , |
|
|
const char * |
text = "Shutdown" | |
|
) |
| | |
Terminate all transactions. Cancel all private threads if any and wait for them to terminate
- Parameters:
-
| gracefully | If 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 |
| text | Optional text to be sent with the response code of the incoming transactions on gracefully cleanup |
static int defaultPort |
( |
bool |
gateway |
) |
[inline, static] |
Get the default port defined by the protocol
- Parameters:
-
| gateway | True 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 detach |
( |
MGCPEndpoint * |
ep, |
|
|
bool |
del = false , |
|
|
bool |
delTrans = false | |
|
) |
| | |
Remove an endpoint from this engine and, optionally, remove all its transactions
- Parameters:
-
| ep | The endpoint to remove |
| del | True to delete it, false to just remove it from the list |
| delTrans | True to remove all its transactions. Forced to true if the endpoint is deleted |
u_int64_t extraTime |
( |
|
) |
const [inline] |
Get the time to live after the transaction terminated gracefully
- Returns:
- The time to live after the transaction terminated gracefully
Find an endpoint by its id
- Parameters:
-
| epId | The endpoint's id to find |
- Returns:
- MGCPEndpoint pointer or 0 if not found
Find an endpoint by its pointer
- Parameters:
-
- Returns:
- MGCPEndpoint pointer or 0 if not found
Find a transaction by its id
- Parameters:
-
| id | The id of the transaction to find |
| outgoing | The transaction direction. True for outgoing, false for incoming |
- Returns:
- MGCPTransaction pointer or 0 if not found
bool gateway |
( |
|
) |
const [inline] |
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
Try to get an event from a transaction
- Parameters:
-
| time | Current time in microseconds |
- Returns:
- MGCPEvent pointer or 0 if none
unsigned int getNextId |
( |
|
) |
|
Generate a new id for an outgoing transaction
- Returns:
- An id for an outgoing transaction
virtual void initialize |
( |
const NamedList & |
params |
) |
[virtual] |
Initialize this engine
- Parameters:
-
| params | Engine's parameters |
bool knownCommand |
( |
const char * |
cmd |
) |
[inline] |
Check if a command is known by this engine
- Parameters:
-
| cmd | The command name to check |
- Returns:
- True if the given command is known by this engine
unsigned int maxRecvPacket |
( |
|
) |
const [inline] |
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
bool parseParamToLower |
( |
|
) |
const [inline] |
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
bool process |
( |
u_int64_t |
time = Time() |
) |
|
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:
-
| time | Current time in microseconds |
- Returns:
- True if an event was processed
Process an event generated by a transaction. Descendants must override this method if they want to process events
- Parameters:
-
| trans | Pointer to the transaction that generated the event |
| msg | MGCP message of the event, may be NULL |
| data | User data that is stored in transaction, 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
virtual bool processEvent |
( |
MGCPEvent * |
event |
) |
[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:
-
| event | The 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 provisional |
( |
|
) |
const [inline] |
Check if incoming transactions would send provisional responses
- Returns:
- True if incoming transactions would send provisional responses
bool receive |
( |
unsigned char * |
buffer, |
|
|
SocketAddr & |
addr | |
|
) |
| | |
Read data from the socket. Parse and process the received message
- Parameters:
-
| buffer | Buffer used for read operation. The buffer must be large enough to keep the maximum packet length returned by maxRecvPacket() |
| addr | The sender's address if received any data |
- Returns:
- True if received any data (a message was successfully parsed)
Remove a transaction from the list
- Parameters:
-
| trans | The transaction to remove |
| del | True to delete it, false to just remove it from list |
unsigned int retransCount |
( |
|
) |
const [inline] |
Get the maximum number of retransmissions for a message
- Returns:
- The maximum number of retransmissions for a message
unsigned int retransInterval |
( |
|
) |
const [inline] |
Get the message retransmission interval
- Returns:
- The message retransmission interval
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:
-
| event | The event to return |
Repeatedly calls process() until the calling thread terminates
Repeatedly calls receive() until the calling thread terminates
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:
-
| cmd | The message containig the command |
| address | The destination IP address |
- Returns:
- MGCPTransaction pointer or 0 if failed to create a transaction
Send a string buffer through the socket
- Parameters:
-
| msg | The buffer to send |
| address | The destination IP address |
- Returns:
- False if the operation failed
Member Data Documentation
The list of endpoints attached to this engine
The list of commands defined in RFC 3435
The list of known reason codes defined in RFC 3435 2.5. Reason codes are used by the gateway when deleting a connection to inform the Call Agent about the reason for deleting the connection. They may also be used in a RestartInProgress command to inform the Call Agent of the reason for the RestartInProgress
The list of known responses defined in RFC 3435 2.4
The documentation for this class was generated from the following file: