?? zl5011xpacketrx.c
字號:
the RTP header when there is a choice of using if from the PW or RTP */
par->rtpForceSeqNumber = ZL5011X_TRUE;
if (zl5011xParams->devLimits.cesAvailable == ZL5011X_TRUE)
{
par->lengthUsage = ZL5011X_PACKET_LENGTH_CHECK;
par->payloadLength = (Uint16T)ZL5011X_INVALID;
}
else
{
/* for the non-CES function, assume that the payload is only
1 byte, since there is no need to queue data for playout */
par->lengthUsage = ZL5011X_PACKET_LENGTH_SPECIFIED;
par->payloadLength = 1;
/* default to 16 bit sequence number for timing only operation */
par->forceOneByteSeq = ZL5011X_FALSE;
}
/* checkLengthValue is only provided for compatability and lengthUsage should be
used in preference */
par->checkLengthValue = ZL5011X_TRUE;
par->osExclusionEnable = ZL5011X_TRUE;
par->removeHeader = ZL5011X_TRUE; /* Remove packet headers by default */
par->disableTimestamp = ZL5011X_FALSE;
/* Leave the status byte mask as ZL5011X_INVALID for the API to automatically
determine the mask. Otherwise, a 1 means that the bit position will be
checked for changes. */
par->statusByteMask = (Uint32T)ZL5011X_INVALID;
if (Zl5011xProtocolTableInitialised == ZL5011X_FALSE)
{
status = zl5011xPacketInitialiseTable(par);
}
par->classifyMpid = (Uint32T)ZL5011X_INVALID_CONTEXT;
}
return(status);
}
/******************************************************************************
Function:
zl5011xPacketRxSetProtocol
Description:
This is called to setup the protocol match structure which will be used
to program the PKC to match packets arriving from contexts with a specific
protocol stack.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items. See below:
Structure inputs:
context not used in this function
protocolType protocol type of the header being setup
enableVlan ZL5011X_TRUE if the protocol has a VLAN ethernet header
enableSnap ZL5011X_TRUE if the protocol has a SNAP ethernet header
ipVer4 ZL5011X_TRUE for IPv4 and ZL5011X_FALSE for IPv6
discardUdpCheckFails ZL5011X_TRUE to discard packets that fail UDP checksum
or ZL5011X_FALSE to forward them to the CPU
enableL2TPCookie for L2TPv3, the cookie is optional, set to ZL5011X_TRUE if the
cookie is present in the header
contextDescriptorOffset specifies the position of the CD header (MT90880 compatibility)
contextDescriptorNumber not used in this function
header pointer to the array holding packet header
headerLength length of the protocol header
classifyMpid not used in this function
matchDestMacAddress set to ZL5011X_TRUE to match destination MAC address
during the Protocol matching stage
matchDestIpv4Address set to ZL5011X_TRUE to match Ipv4 destination address
during the Protocol matching stage
matchSrcIpv4Address not used in this function
srcUdpPortMask mask to apply to the UDP port, bits set to 1 are used for protocol matching
destUdpPortMask mask to apply to the UDP port, bits set to 1 are used for protocol matching
enableClassificationChecks set to ZL5011X_FALSE to disable post classification checks
payloadLength not used in this function
statusByteMask mask to apply to the Pseudo Wire Status byte
changes in the status are ignored if mask bit is set to 1
lengthUsage controls how the length is checked / extracted from the packet
checkLengthValue DO NOT USE. see lengthUsage instead.
rtpForceSeqNumber set to ZL5011X_TRUE to force usage of the RTP sequence number
if the RTP and PW headers are both present.
(Note : in order to update the PW status byte, this must
be set to ZL5011X_TRUE when RTP is used)
cpuQueue not used in this function
disableTimestamp set to ZL5011X_TRUE to not extract the timestamp from the packet
NOTE : this invalidates RTP jitter calculations
forceOneByteSeq set to ZL5011X_TRUE to only use low byte of sequence number
from the packet
protocolMatchNumber can be set to specify which protocol match to use if the
protocol is not already defined, in which case the current
number is returned. If a number is not specified then
one will automatically be chosen.
classifyMatchNumber not used in this function
removeHeader not used in this function
osExclusionEnable ZL5011X_TRUE to enable OS exclusion
Structure outputs:
protocolMatchNumber returns the protocol match number for this protocol stack
Returns:
zlStatusE
Remarks:
If the protocol IP->L2TPv3 is being used, then the control header MUST be
set up before the data header.
******************************************************************************/
zlStatusE zl5011xPacketRxSetProtocol(zl5011xParamsS * zl5011xParams,
zl5011xPacketRxSetHeaderS *par)
{
zlStatusE status = ZL5011X_OK;
zl5011xBooleanE gotDevice = ZL5011X_FALSE;
/* do some parameter checking */
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_RUNNING(zl5011xParams);
}
if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
{
/* get access to the device */
status = zl5011xPacketGetTable(ZL5011X_GET_DEVICE_TIMEOUT_MODE);
if (status == ZL5011X_OK)
{
gotDevice = ZL5011X_TRUE;
}
}
/* main function code starts */
if (par->checkLengthValue == ZL5011X_FALSE)
{
/* provided for backwards compatability. If the deprecated parameter is changed
from it's default value then override the length usage */
par->lengthUsage = ZL5011X_PACKET_LENGTH_FROM_PKT;
}
if (status == ZL5011X_OK)
{
status = zl5011xPacketRxSetProtocolFunc(zl5011xParams, par);
}
if (gotDevice == ZL5011X_TRUE)
{
if (status == ZL5011X_OK)
{
status = zl5011xPacketReleaseTable();
}
else
{
/* already have an error code, so don't overwrite it */
(void)zl5011xPacketReleaseTable();
}
}
return status;
}
/******************************************************************************
Function:
zl5011xPacketRxSetProtocolFunc
Description:
This function is called from the OS exclusion wrapper function
zl5011xPacketRxSetProtocol
Inputs:
par Pointer to the zl5011xPacketRxSetHeaderS structure.
Outputs:
None
Returns:
zlStatusE
******************************************************************************/
static zlStatusE zl5011xPacketRxSetProtocolFunc(zl5011xParamsS * zl5011xParams,
zl5011xPacketRxSetHeaderS *par)
{
zlStatusE status = ZL5011X_OK;
Uint16T deviceIndex;
zl5011xLanRxSetProtocolMatchS * lanRxSetProtocolMatch;
zl5011xPacketRxTemplateS * templateInUse;
Uint32T n;
Sint32T temp;
Uint32T headerLength;
Uint32T vlanOffset;
Uint32T tempOffset;
Uint32T snapOffset;
Uint8T seqOffset;
Uint32T cookiePos;
Uint32T cookieOffset;
Uint32T realContextDescriptorOffset;
Uint32T protocolMatchIndex;
Uint32T headerMatchIndex;
Uint32T protocolMaskIndex;
Uint32T templateMaskIndex;
Uint32T l2tpHeaderPos;
Uint32T udpPos;
zl5011xBooleanE ipv4Header;
zl5011xBooleanE udpHeader;
ZL5011X_TRACE(ZL5011X_PACKET_FN_ID,"zl5011xPacketRxSetProtocol:",0, 0, 0, 0, 0, 0);
/* Check the arguments passed to the function */
ZL5011X_CHECK_POINTER(par->header);
if (par->protocolType >= ZL5011X_INVALID_PROTOCOL)
{
return(ZL5011X_PARAMETER_INVALID);
}
/* setup offsets for VLAN, SNAP and L2TPv3 cookie that will be used throughout */
if (par->enableSnap == ZL5011X_TRUE)
{
snapOffset = ZL5011X_PKT_SNAP_FIELD_LEN;
}
else
{
snapOffset = 0;
}
if (par->enableVlan == ZL5011X_TRUE)
{
vlanOffset = ZL5011X_PKT_VLAN_HDR_LEN;
}
else
{
vlanOffset = 0;
}
/* Calculate where the LT2P Header will be if the protocol stack includes L2TPv3 */
switch (par->protocolType)
{
case ZL5011X_IP_L2TPV3_PW:
case ZL5011X_IP_L2TPV3_RTP_PW:
case ZL5011X_IP_L2TPV3_RTCP_CTRL:
l2tpHeaderPos = ZL5011X_PKT_ETHERNET_HDR_LEN + vlanOffset + snapOffset;
if (par->ipVer4 == ZL5011X_TRUE)
{
l2tpHeaderPos += ZL5011X_PKT_IPV4_HDR_LEN;
}
else
{
l2tpHeaderPos += ZL5011X_PKT_IPV6_HDR_LEN;
}
if (par->enableL2TPCookie == ZL5011X_TRUE)
{
cookieOffset = ZL5011X_PKT_L2TPV3_COOKIE_LEN;
}
else
{
cookieOffset = 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -