📄 rvmegacoentity.h
字号:
/******************************************************************************
Filename: rvmegacoentity.h
Description: megaco entity class
*******************************************************************************
Copyright (c) 2000 RADVision Inc.
*******************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision Inc.
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVision Inc.
RADVision Inc. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.
******************************************************************************/
#ifndef RV_MEGACOENTITY_H
#define RV_MEGACOENTITY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "rvmutex.h"
#include "rvtime.h"
#include "rvtimer.h"
#include "rvhash.h"
#include "rvstrstream.h"
#include "rvsocket.h"
#include "rvtransport.h"
#include "rvmegacoobjects.h"
#include "rvmegacostack.h"
#include "rvmegacotrans.h"
#include "rvroundtripstats.h"
/* public: */
/*$
{type:
{name: RvMegacoEntityType}
{include: rvmegacoentity.h}
{description:
{p: Entity type:}
{p: RV_MEGACOENTITYTYPE_MG - Media Gateway }
{p: RV_MEGACOENTITYTYPE_MGC - Media Gateway Controller }
}
}
$*/
typedef enum
{
RV_MEGACOENTITYTYPE_MG,
RV_MEGACOENTITYTYPE_MGC
} RvMegacoEntityType;
/*$
{type:
{name: RvMegacoEncoding}
{include: rvmegacoentity.h}
{description:
{p: Megaco message encoding type:}
{p: RV_MEGACOENCODING_TEXT - Text encoding }
{p: RV_MEGACOENCODING_BINARY - Binary encoding }
}
}
$*/
typedef enum
{
RV_MEGACOENCODING_TEXT,
RV_MEGACOENCODING_BINARY
} RvMegacoEncoding;
/*$
{callback:
{name: RvMegacoRecvRequestCB}
{include: rvmegacoentity.h}
{description:
{p: A function for processing received transaction requests.}
}
{proto: typedef void (*RvMegacoRecvRequestCB)(RvMegacoTcb *tcb, const RvMegacoTransaction *transaction, void *data);}
{params:
{param: {n:tcb} {d:The transaction control block. This pointer must be passed as a parameter
when calling rvMegacoTcbSendReply or rvMegacoTcbSendPending.}}
{param: {n:transaction} {d:The transaction.}}
{param: {n:data} {d:User data that was registered with the callback.}}
}
}
$*/
typedef void (*RvMegacoRecvRequestCB)(RvMegacoTcb *tcb, const RvMegacoTransaction *transaction, void *data);
/*$
{callback:
{name: RvMegacoRecvErrorMsgCB}
{include: rvmegacoentity.h}
{description:
{p: A function for processing messages that contain only an error descriptor.}
}
{proto: typedef void (*RvMegacoRecvErrorMsgCB)(RvMegacoEntity *remote, const RvMegacoErrorDescriptor *error, void *data);}
{params:
{param: {n:remote} {d:The remote entity that sent the message.}}
{param: {n:error} {d:The error descriptor.}}
{param: {n:data} {d:User data that was registered with the callback.}}
}
}
$*/
typedef void (*RvMegacoRecvErrorMsgCB)(struct RvMegacoEntity_ *remote, const RvMegacoErrorDescriptor *error, void *data);
rvDeclareList (RvMegacoEntityAddress)
/* private: */
typedef struct RvMegacoEntity_ *RvMegacoEntityPtr;
rvDeclareHash(RvMegacoEntityAddress, RvMegacoEntityPtr)
typedef RvMegacoTcb *RvMegacoTcbPtr;
rvDeclareHash(RvMegacoTransactionId, RvMegacoTcbPtr)
typedef struct RvMegacoEntity_
{
RvMutex mutex;
RvMegacoEntityAddress mId;
RvMegacoEntityType entityType;
RvTransportType transportType;
RvMegacoEncoding encoding;
RvMegacoStack *stack;
RvBool primary;
RvBool dead;
RvSocket *socket;
RvHash(RvMegacoTransactionId, RvMegacoTcbPtr) tcbs;
RvBool isLocal;
union
{
struct
{
RvHash(RvMegacoEntityAddress, RvMegacoEntityPtr) remotes;
RvMegacoTransactionId nextTransactionId;
RvMegacoRecvRequestCB processRequest;
RvMegacoRecvErrorMsgCB processError;
void *processRequestData, *processErrorData;
RvRandomGenerator randomGenerator;
} local;
struct
{
struct RvMegacoEntity_ *localEntity;
RvSocketAddr socketAddr;
RvPtrList transactionsToSend;
RvStrStream msgStream;
size_t maxTransactionSize;
RvMegacoResponseAck acks;
RvTimer sendTimer;
RvRoundTripStats roundTripStats;
RvBool deleteMe;
} remote;
} u;
} RvMegacoEntity;
/* public: */
/*$
{type:
{name: RvMegacoEntity}
{include: rvmegacoentity.h}
{description:
{p: A megaco entity object, representing either an MG or an MGC.}
}
{methods:
{method: RvMegacoEntity *rvMegacoEntityConstructLocal(RvMegacoEntity *entity, const RvMegacoEntityAddress *address,
RvBool primary, RvMegacoEntityType entityType, RvTransportType transportType, RvMegacoEncoding encoding, RvMegacoStack *stack);}
{method: RvMegacoEntity *rvMegacoEntityConstructRemote(RvMegacoEntity *entity, const RvMegacoEntityAddress *address,
RvBool primary, RvMegacoEntity *local);}
{method: void rvMegacoEntityDestruct(RvMegacoEntity *entity);}
{method: const RvMegacoEntityAddress *rvMegacoEntityGetAddress(const RvMegacoEntity *entity);}
{method: RvBool rvMegacoEntityIsPrimary(const RvMegacoEntity *entity);}
{method: RvMegacoEntityType rvMegacoEntityGetType(const RvMegacoEntity *entity);}
{method: RvTransportType rvMegacoEntityGetTransportType(const RvMegacoEntity *entity);}
{method: RvMegacoEncoding rvMegacoEntityGetEncoding(const RvMegacoEntity *entity);}
{method: RvMegacoEntity *rvMegacoEntityGetLocalEntity(const RvMegacoEntity *remote);}
{method: RvMegacoEntity *rvMegacoEntityFindRemote(RvMegacoEntity *local, const RvMegacoEntityAddress *remoteAddress);}
{method: void rvMegacoEntityMakePrimary(RvMegacoEntity *entity);}
{method: void rvMegacoEntityMakeSecondary(RvMegacoEntity *entity);}
{method: void rvMegacoEntityRegisterRecvRequestCB(RvMegacoEntity *local, RvMegacoRecvRequestCB f, void *data);}
{method: void rvMegacoEntityRegisterRecvErrorMsgCB(RvMegacoEntity *local, RvMegacoRecvErrorMsgCB f, void *data);}
{method: void rvMegacoEntitySendRequest(RvMegacoEntity *remote, RvMegacoTransaction *t, RvMegacoReplyCb f, void *data);}
}
}
$*/
RvMegacoEntity *rvMegacoEntityConstructLocal(RvMegacoEntity *entity, const RvMegacoEntityAddress *address, RvBool primary,
RvMegacoEntityType entityType, RvTransportType transportType, RvMegacoEncoding encoding, RvMegacoStack *stack);
RvMegacoEntity *rvMegacoEntityConstructRemote(RvMegacoEntity *entity,
const RvMegacoEntityAddress *address, RvBool primary, RvMegacoEntity *local);
RvMegacoEntity *rvMegacoEntityConstructRemoteEx(RvMegacoEntity *entity,
const RvMegacoEntityAddress *address, const RvSocketAddr *socketAddr, RvBool primary, RvMegacoEntity *local);
void rvMegacoEntityDestruct(RvMegacoEntity *entity);
const RvMegacoEntityAddress *rvMegacoEntityGetAddress(const RvMegacoEntity *entity);
RvBool rvMegacoEntityIsPrimary(const RvMegacoEntity *entity);
RvMegacoEntityType rvMegacoEntityGetType(const RvMegacoEntity *entity);
RvTransportType rvMegacoEntityGetTransportType(const RvMegacoEntity *entity);
RvMegacoEncoding rvMegacoEntityGetEncoding(const RvMegacoEntity *entity);
RvMegacoEntity *rvMegacoEntityGetLocalEntity(const RvMegacoEntity *remote);
RvMegacoEntity *rvMegacoEntityFindRemote(RvMegacoEntity *local, const RvMegacoEntityAddress *remoteAddress);
void rvMegacoEntityMakePrimary(RvMegacoEntity *entity);
void rvMegacoEntityMakeSecondary(RvMegacoEntity *entity);
void rvMegacoEntityRegisterRecvRequestCB(RvMegacoEntity *local, RvMegacoRecvRequestCB f, void *data);
void rvMegacoEntityRegisterRecvErrorMsgCB(RvMegacoEntity *local, RvMegacoRecvErrorMsgCB f, void *data);
void rvMegacoEntitySendRequest(RvMegacoEntity *remote, RvMegacoTransaction *t, RvMegacoReplyCb f, void *data);
/* private: */
#define RV_MEGACOENTITY_ENCODEBUFINITSIZE 2048
#define RV_MEGACOENTITY_SENDBUFHDRSIZE 108
const RvSocketAddr *rvMegacoEntityGetSocketAddr(const RvMegacoEntity *remote);
void rvMegacoEntitySetSocketAddr(RvMegacoEntity *remote, const RvSocketAddr *socketAddr);
RvSocket *rvMegacoEntityGetSocket(RvMegacoEntity *entity);
void rvMegacoEntitySetSocket(RvMegacoEntity *entity, RvSocket *socket);
void rvMegacoEntityOnSocketDelete(RvSocket *socket, void *data);
void rvMegacoEntitySetDeleteFlag(RvMegacoEntity *remote);
void rvMegacoEntityRemoveRemote(RvMegacoEntity *local, const RvMegacoEntityAddress *remoteAddress);
RvMegacoTransactionId rvMegacoEntityGetNextTransactionId(RvMegacoEntity *local);
void rvMegacoEntityAddTcb(RvMegacoEntity *entity, RvMegacoTcb *tcb);
void rvMegacoEntityRemoveTcb(RvMegacoEntity *entity, RvMegacoTransactionId tId);
RvMegacoTcb *rvMegacoEntityFindTcb(RvMegacoEntity *entity, RvMegacoTransactionId tId);
void rvMegacoEntityAddResponseAck(RvMegacoEntity *remote, RvMegacoTransactionId tId);
void rvMegacoEntitySendListInsert(RvMegacoEntity *remote, RvMegacoTcb *transaction);
void rvMegacoEntitySendNow(RvMegacoEntity *remote);
void rvMegacoEntityUpdateRoundTripTime(RvMegacoEntity *remote, RvHrtime roundTripTime);
RvHrtime rvMegacoEntityGetFirstRetransTimeout(RvMegacoEntity *remote);
RvHrtime rvMegacoEntityGetNextRetransTimeout(RvMegacoEntity *remote);
void rvMegacoTransMgrRecvRequest(RvMegacoEntity *remote, const RvMegacoTransaction *trans);
void rvMegacoTransMgrRecvReply(RvMegacoEntity *remote, const RvMegacoTransactionReply *reply);
void rvMegacoTransMgrRecvPending(RvMegacoEntity *remote, RvMegacoTransactionId id);
void rvMegacoTransMgrRecvRespAck(RvMegacoEntity *remote, RvMegacoTransactionId id);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -