/// <summary> /// Generate a rule action. /// </summary> /// <param name="actionTypes">The action Type.</param> /// <param name="countBytes">The length of the bytes count.</param> /// <param name="actionDataBufferValue">The actionData buffer.</param> /// <param name="actionFlavor">Action flavor value.</param> /// <param name="actionFlags">Action flag value.</param> /// <returns>An instance of the RuleAction.</returns> private static RuleAction GetRuleAction(ActionType[] actionTypes, CountByte countBytes, IActionData[] actionDataBufferValue, uint[] actionFlavor, uint[] actionFlags) { ActionBlock[] actionBlocks = new ActionBlock[actionTypes.Length]; for (int i = 0; i < actionDataBufferValue.Length; i++) { ActionBlock actionBlock = new ActionBlock(countBytes) { ActionType = actionTypes[i], ActionFlags = actionFlags[i], ActionDataValue = actionDataBufferValue[i], ActionFlavor = actionFlavor[i] }; // Get actionBlock size int lengthOfActionLength = 0; if (actionBlock.CountType == CountByte.TwoBytesCount) { lengthOfActionLength += 2; } else if (actionBlock.CountType == CountByte.FourBytesCount) { lengthOfActionLength += 4; } // Length of ActionType is 1 // Length of ActionFlavor is 4 // Length of ActionFlags is 4 int size = lengthOfActionLength + 1 + 4 + 4 + actionBlock.ActionDataValue.Size(); actionBlock.ActionLength = (countBytes == CountByte.TwoBytesCount) ? (size - 2) : (size - 4); actionBlocks[i] = actionBlock; } RuleAction ruleAction = new RuleAction(countBytes) { NoOfActions = actionBlocks.Length, Actions = actionBlocks }; return ruleAction; }
/// <summary> /// Generate a rule action. /// </summary> /// <param name="actionType">The action Type.</param> /// <param name="countBytes">The length of the bytes count.</param> /// <param name="actionDataBufferValue">The actionData buffer.</param> /// <param name="actionFlavor">Action flavor value.</param> /// <param name="actionFlags">Action flag value.</param> /// <returns>An instance of the RuleAction.</returns> private static RuleAction GetRuleAction(ActionType actionType, CountByte countBytes, IActionData actionDataBufferValue, uint actionFlavor, uint actionFlags) { ActionBlock actionBlock = new ActionBlock(countBytes) { ActionType = actionType, ActionFlags = actionFlags, ActionDataValue = actionDataBufferValue, ActionFlavor = actionFlavor }; // Get actionBlock size int lengthOfActionLength = 0; if (actionBlock.CountType == CountByte.TwoBytesCount) { lengthOfActionLength += 2; } else if (actionBlock.CountType == CountByte.FourBytesCount) { lengthOfActionLength += 4; } // Length of ActionType is 1 // Length of ActionFlavor is 4 // Length of ActionFlags is 4 int size = lengthOfActionLength + 1 + 4 + 4 + actionBlock.ActionDataValue.Size(); actionBlock.ActionLength = (countBytes == CountByte.TwoBytesCount) ? (size - 2) : (size - 4); RuleAction ruleAction = new RuleAction(countBytes) { NoOfActions = 0x01, Actions = new ActionBlock[1] { actionBlock } }; // Only one rule action is generated. return ruleAction; }