packetforge: add option to show spec and mask only
In some cases with Generic FLow, it is only required to show the pattern of spec and mask, but no need to add the flow. Therefore, add an option in packetforge so that users can show spec and mask only. Type: improvement Signed-off-by: Ting Xu <ting.xu@intel.com> Change-Id: I7b3040689eb82d0b58924712ee6fc9cfa0a42fa1
This commit is contained in:
@ -21,7 +21,7 @@ import os
|
||||
parsegraph_path = os.getcwd() + "/parsegraph"
|
||||
|
||||
|
||||
def Forge(pattern, actions, file_flag):
|
||||
def Forge(pattern, actions, file_flag, show_result_only):
|
||||
pg = ParseGraph.Create(parsegraph_path)
|
||||
if pg == None:
|
||||
print("error: create parsegraph failed")
|
||||
@ -54,7 +54,6 @@ def Forge(pattern, actions, file_flag):
|
||||
|
||||
# create generic flow
|
||||
my_flow = {
|
||||
"type": VppEnum.vl_api_flow_type_v2_t.FLOW_TYPE_GENERIC_V2,
|
||||
"flow": {
|
||||
"generic": {
|
||||
"pattern": {"spec": bytes(spec.encode()), "mask": bytes(mask.encode())}
|
||||
@ -62,6 +61,15 @@ def Forge(pattern, actions, file_flag):
|
||||
},
|
||||
}
|
||||
|
||||
if show_result_only:
|
||||
return my_flow
|
||||
|
||||
my_flow.update(
|
||||
{
|
||||
"type": VppEnum.vl_api_flow_type_v2_t.FLOW_TYPE_GENERIC_V2,
|
||||
}
|
||||
)
|
||||
|
||||
# update actions entry
|
||||
my_flow = GetAction(actions, my_flow)
|
||||
|
||||
|
Reference in New Issue
Block a user