?? zl5011xpacketrx.c
字號:
}
/* If the VLAN ID is to be classified on, then setup the fields */
if (templateInUse->vlanClassifyPos[0] < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS)
{
lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->vlanClassifyPos[0]] =
ZL5011X_MAC_SIZE + ZL5011X_MAC_SIZE + ZL5011X_PKT_ETHERTYPE_LEN;
}
if (templateInUse->vlanClassifyPos[1] < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS)
{
lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->vlanClassifyPos[1]] =
ZL5011X_MAC_SIZE + ZL5011X_MAC_SIZE + ZL5011X_PKT_ETHERTYPE_LEN + 1;
}
}
/* If the protocol stack to be supported includes L2TPv3 and there is to be
a cookie then some more check fields will need to be added */
if (cookieOffset != 0)
{
/* Work out the position of the cookie - allowing for the fact that the SNAP header
is removed internally by the device */
cookiePos = l2tpHeaderPos - snapOffset + ZL5011X_PKT_L2TPV3_HDR_LEN;
/* Allow checking on each byte of the cookie individually. Any bytes that aren't to be checked are set to an invalid
number like 0xff in the template. */
for (n = 0; n < ZL5011X_PKT_L2TPV3_COOKIE_LEN; n++)
{
if (templateInUse->l2tpCookieCheckPos[n] < ZL5011X_PKC_CLASSIFY_NUM_CHECK_FIELDS)
{
lanRxSetProtocolMatch->output.extractCheckBytes[templateInUse->l2tpCookieCheckPos[n]] = (Uint8T)(cookiePos + n);
lanRxSetProtocolMatch->output.checkMask[templateInUse->l2tpCookieCheckPos[n]] = ZL5011X_MASK_IN;
}
}
}
/* If the protocol stack to be supported includes CD fields then the CD portion of the header needs to be setup
in the classifier, but only if the template contains good values for the index of the extract to classifier bytes. */
if ((par->protocolType == ZL5011X_CD) || (par->protocolType == ZL5011X_IP_CD) ||
(par->protocolType == ZL5011X_IP_UDP_CD))
{
/* If the relevant structure members have not been setup or are otherwise invalid,
assume that the CD header exists in the last two bytes of the header */
if (par->contextDescriptorOffset > (Uint8T)(par->headerLength - ZL5011X_PKT_CD_HDR_LEN))
{
par->contextDescriptorOffset = par->headerLength - ZL5011X_PKT_CD_HDR_LEN;
}
if (templateInUse->cdClassifyPos[0] < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS)
{
lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->cdClassifyPos[0]] = (Uint8T)(par->contextDescriptorOffset - snapOffset);
}
if (templateInUse->cdClassifyPos[1] < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS)
{
lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->cdClassifyPos[1]] = (Uint8T)(par->contextDescriptorOffset - snapOffset + 1);
}
/* now that we have worked out where the CD header is, update the field
in the protocol match itself */
if (par->protocolType == ZL5011X_IP_UDP_CD)
{
lanRxSetProtocolMatch->match.protocolMatchBytes[lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->cdClassifyPos[0]]] = ZL5011X_PKT_CD_TYPE_UDP << (ZL5011X_PKT_CD_TYPE_POS - 8);
}
else
{
lanRxSetProtocolMatch->match.protocolMatchBytes[lanRxSetProtocolMatch->output.extractClassifyBytes[templateInUse->cdClassifyPos[0]]] = ZL5011X_PKT_CD_TYPE_STD << (ZL5011X_PKT_CD_TYPE_POS - 8);
}
}
if (par->enableClassificationChecks == ZL5011X_FALSE)
{
for (n = 0; n < ZL5011X_PKC_CLASSIFY_NUM_CHECK_FIELDS; n++)
{
/* disable classification checks by setting the mask fields */
lanRxSetProtocolMatch->output.checkMask[n] = ZL5011X_MASK_OUT;
}
}
status = zl5011xLanRxSetProtocolMatch(zl5011xParams,lanRxSetProtocolMatch);
if (status != ZL5011X_OK)
{
OS_FREE(lanRxSetProtocolMatch);
return(status);
}
/* Record the protocol match number which this was set up into for the packet rx structure and for the device structure */
par->protocolMatchNumber = lanRxSetProtocolMatch->matchNum;
/* record the protocol type in the device structure - useful for debugging */
zl5011xParams->packetIf.packetRx.pkcProtocol[lanRxSetProtocolMatch->matchNum].protocolType = par->protocolType;
/* There are various exceptions and exclusions between the similar protocol types,
so deal with that now */
switch (par->protocolType)
{
case ZL5011X_CD:
case ZL5011X_PW:
case ZL5011X_IP_PW_TS:
case ZL5011X_MPLS_MPLS_PW:
case ZL5011X_CUSTOM8_PW :
case ZL5011X_CUSTOM8_RTP_PW :
case ZL5011X_CUSTOM8_PW_RTP :
/* no restrictions on use of these protocols, so just put an entry in the table */
Zl5011xProtocolTable[deviceIndex].protocol[par->protocolType].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
break;
case ZL5011X_IP_L2TPV3_PW:
case ZL5011X_IP_L2TPV3_CTRL:
/* IP->L2TP cannot coexist with IP->L2TP->RTP so mark the RTP ones as unusable */
Zl5011xProtocolTable[deviceIndex].protocol[par->protocolType].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_L2TPV3_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_L2TPV3_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
break;
case ZL5011X_IP_L2TPV3_RTP_PW:
case ZL5011X_IP_L2TPV3_RTCP_CTRL:
/* IP->L2TP cannot coexist with IP->L2TP->RTP so mark the non-RTP ones as unusable */
Zl5011xProtocolTable[deviceIndex].protocol[par->protocolType].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_L2TPV3_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_L2TPV3_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
break;
case ZL5011X_MPLS_PW_RTP:
case ZL5011X_MPLS_RTCP_CTRL:
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_PW_RTP].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
/* MPLS uses a common protocol match for the various different header options.
However, if the RTP sequence number is used for ZL5011X_MPLS_PW_RTP then this breaks the rule
and the other protocols become invalid */
if (par->rtpForceSeqNumber == ZL5011X_TRUE)
{
/* using the RTP sequence number means that this protocol match is now incompatible
with the other MPLS stacks */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
}
else
{
{
/* all of the MPLS protocols can co-exist, so mark them in the IPv4
part of the device table */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_PW].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
}
}
break;
case ZL5011X_MPLS:
case ZL5011X_MPLS_PW:
/* all of the MPLS protocols can co-exist, so mark them in the IPv4
part of the device table */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_PW].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_PW_RTP].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_MPLS_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
/* the RTP sequence number variable was irrelevant to this mode, but set it to FALSE,
to represent how the protocol was configured. */
par->rtpForceSeqNumber = ZL5011X_FALSE;
break;
case ZL5011X_IP_UDP:
/* IP->UDP cannot co-exist with any other IP->UDP->?? header, so mark
all others as unavailable */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_CD].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
break;
case ZL5011X_IP_UDP_PW:
/* IP->UDP->PW cannot co-exist with any other IP->UDP->?? header, so mark
all others as unavailable */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_PW].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_CD].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
break;
case ZL5011X_IP_UDP_CD:
case ZL5011X_IP_UDP_RTP:
case ZL5011X_IP_UDP_RTP_PW:
case ZL5011X_IP_UDP_RTP_PW_ALT:
case ZL5011X_IP_UDP_RTCP_CTRL:
case ZL5011X_IP_UDP_L2TPV2_PW:
case ZL5011X_IP_UDP_L2TPV2_CTRL:
if (par->ipVer4 == ZL5011X_TRUE)
{
/* mark IP->UDP and IP->UDP->PW as unusable, since they cannot co-exist with
any other UDP protocols */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
if ((par->protocolType == ZL5011X_IP_UDP_RTP) ||
(par->protocolType == ZL5011X_IP_UDP_RTP_PW) ||
(par->protocolType == ZL5011X_IP_UDP_RTP_PW_ALT))
{
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
}
Zl5011xProtocolTable[deviceIndex].protocol[par->protocolType].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
}
else
{
/* the IPv6 header is so large, that only one protocol can be supported - except for
RTP / RTCP and L2TP data/control. So mark all protocols as unuseable */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_CD].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
/* now record the protocol match for the protocol that has been setup */
if ((par->protocolType == ZL5011X_IP_UDP_RTCP_CTRL) ||
(par->protocolType == ZL5011X_IP_UDP_RTP) ||
(par->protocolType == ZL5011X_IP_UDP_RTP_PW) ||
(par->protocolType == ZL5011X_IP_UDP_RTP_PW_ALT))
{
if (par->protocolType == ZL5011X_IP_UDP_RTCP_CTRL)
{
/* if the control protocol has not been initialised, then this is the first UDP->RTP
header to be configured. So, initially allow any of the UDP->RTP data protocols
to be valid, then upon first use of a data protocol, invalidate the others */
if (Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] == (Uint32T)ZL5011X_INVALID)
{
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
}
}
else
{
/* it is only possible to support one of the UDP->RTP data protocols,
so update the table to reflect that this is the one that is allowed */
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
/* the only valid data protocol is the one requested */
Zl5011xProtocolTable[deviceIndex].protocol[par->protocolType].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
}
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = lanRxSetProtocolMatch->matchNum;
}
else
{
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTP_PW_ALT].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_RTCP_CTRL].matchNum[par->enableVlan][par->ipVer4] = ZL5011X_PKT_INCOMPATIBLE_HEADER;
if ((par->protocolType == ZL5011X_IP_UDP_L2TPV2_PW) || (par->protocolType == ZL5011X_IP_UDP_L2TPV2_CTRL))
{
Zl5011xProtocolTable[deviceIndex].protocol[ZL5011X_IP_UDP_L2TPV2_PW].m
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -