|
Yate
|
An MGCP engine. More...
#include <yatemgcp.h>
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 String &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 engineProcess=true) |
| bool | receive (unsigned char *buffer, SocketAddr &addr) |
| bool | process (u_int64_t time=Time()) |
| bool | processTransaction (MGCPTransaction *tr, u_int64_t time=Time()) |
| void | runReceive (SocketAddr &addr) |
| void | runReceive () |
| void | runProcess () |
| MGCPEvent * | getEvent (u_int64_t time=Time()) |
| virtual bool | processEvent (MGCPEvent *event) |
| virtual bool | processEvent (MGCPTransaction *trans, MGCPMessage *msg) |
| void | returnEvent (MGCPEvent *event) |
| void | cleanup (bool gracefully=true, const char *text="Shutdown") |
| virtual void | timeout (MGCPTransaction *tr) |
Public Member Functions inherited from DebugEnabler | |
| DebugEnabler (int level=TelEngine::debugLevel(), bool enabled=true) | |
| int | debugLevel () const |
| int | debugLevel (int level) |
| bool | debugEnabled () const |
| void | debugEnabled (bool enable) |
| const char * | debugName () const |
| bool | debugAt (int level) const |
| bool | debugChained () const |
| void | debugChain (const DebugEnabler *chain=0) |
| void | debugCopy (const DebugEnabler *original=0) |
Public Member Functions inherited from Mutex | |
| Mutex (bool recursive=false, const char *name=0) | |
| Mutex (const Mutex &original) | |
| ~Mutex () | |
| Mutex & | operator= (const Mutex &original) |
| virtual bool | lock (long maxwait=-1) |
| virtual bool | unlock () |
| virtual bool | locked () const |
| const char * | owner () const |
| bool | recursive () const |
Public Member Functions inherited from Lockable | |
| virtual | ~Lockable () |
| virtual bool | check (long maxwait=-1) |
| virtual bool | unlockAll () |
Static Public Member Functions | |
| static int | defaultPort (bool gateway) |
Static Public Member Functions inherited from Mutex | |
| static int | count () |
| static int | locks () |
| static bool | efficientTimedLock () |
Static Public Member Functions inherited from Lockable | |
| static void | wait (unsigned long maxwait) |
| static unsigned long | wait () |
| static void | startUsingNow () |
| static void | enableSafety (bool safe=true) |
| static bool | safety () |
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 Member Functions inherited from DebugEnabler | |
| void | debugName (const char *name) |
Protected Attributes | |
| ObjList | m_endpoints |
| ObjList | m_transactions |
| ListIterator | m_iterator |
Friends | |
| class | MGCPPrivateThread |
| class | MGCPTransaction |
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
| MGCPEngine | ( | bool | gateway, |
| const char * | name = 0, | ||
| const NamedList * | params = 0 ) |
Constructor. Construct the engine and, optionally, initialize it
| 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 |
References gateway().
|
virtual |
Destructor. Clear all lists
|
inline |
Get the remote ACK request flag
|
inline |
Set the remote ACK request flag
| request | False to not request from remote to send an ACK |
| void addCommand | ( | const char * | cmd | ) |
Add a command to the list of known commands
| cmd | The command name to add |
|
inline |
Get the IP address used by this engine to receive data
Referenced by sendCommand(), and sendData().
|
inline |
Check if this engine is allowed to send/accept unknown commands
|
protected |
Append a transaction to the list
| trans | The transaction to append |
| void attach | ( | MGCPEndpoint * | ep | ) |
Append an endpoint to this engine if not already done
| 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
| 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 |
|
inlinestatic |
Get the default port defined by the protocol
| gateway | True to get the default Gateway port, false to get the default port for the Call Agent |
References gateway().
| void detach | ( | MGCPEndpoint * | ep, |
| bool | del = false, | ||
| bool | delTrans = false ) |
Remove an endpoint from this engine and, optionally, remove all its transactions
| 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 |
|
inline |
Get the time to live after the transaction terminated gracefully
| MGCPEndpoint * findEp | ( | const String & | epId | ) |
Find an endpoint by its id
| epId | The endpoint's id to find |
| MGCPEndpoint * findEp | ( | MGCPEndpoint * | ep | ) |
Find an endpoint by its pointer
| ep | The endpoint to find |
| MGCPTransaction * findTrans | ( | unsigned int | id, |
| bool | outgoing ) |
Find a transaction by its id
| id | The id of the transaction to find |
| outgoing | The transaction direction. True for outgoing, false for incoming |
|
inline |
Check if this engine is an MGCP Gateway or a collection of Call Agents
Referenced by defaultPort(), and MGCPEngine().
Try to get an event from a transaction
| time | Current time in microseconds |
| unsigned int getNextId | ( | ) |
Generate a new id for an outgoing transaction
|
virtual |
Initialize this engine
| params | Engine's parameters |
|
inline |
Check if a command is known by this engine
| cmd | The command name to check |
References Mutex::lock().
|
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
|
inline |
Check 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
| time | Current time in microseconds |
|
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
| event | The event to process |
|
virtual |
Process an event generated by a transaction. Descendants must override this method if they want to process events
| trans | Pointer to the transaction that generated the event |
| msg | MGCP message of the event, may be NULL |
| bool processTransaction | ( | MGCPTransaction * | tr, |
| u_int64_t | time = Time() ) |
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
| tr | Transaction to process |
| time | Current time in microseconds |
|
inline |
Check 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
| 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 |
|
protected |
Remove a transaction from the list
| trans | The transaction to remove |
| del | True to delete it, false to just remove it from list |
|
inline |
Get the maximum number of retransmissions for a message
|
inline |
Get the message retransmission interval
| void returnEvent | ( | MGCPEvent * | event | ) |
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
| event | The event to return |
| void runProcess | ( | ) |
Repeatedly calls process() until the calling thread terminates
| void runReceive | ( | ) |
Repeatedly calls receive() until the calling thread terminates
| void runReceive | ( | SocketAddr & | addr | ) |
Repeatedly calls receive() until the calling thread terminates
| addr | The sender's address if received any data |
| MGCPTransaction * sendCommand | ( | MGCPMessage * | cmd, |
| const SocketAddr & | address, | ||
| bool | engineProcess = true ) |
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
| cmd | The message containig the command |
| address | The destination IP address |
| engineProcess | Use engine private processor thread for the new transaction. If false the caller is responsable with transaction processing |
References address().
|
protected |
Send a string buffer through the socket
| msg | The buffer to send |
| address | The destination IP address |
References address().
|
inlinevirtual |
Handle a transaction that has timed out
| tr | The transaction that has timed out |
|
protected |
The list of endpoints attached to this engine
|
protected |
The transaction list iterator used to get events
|
protected |
The transaction list
|
static |
The list of commands defined in RFC 3435
|
static |
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
|
static |
The list of known responses defined in RFC 3435 2.4