MCPcopy Create free account
hub / github.com/FDio/vpp / Forge

Method Forge

extras/packetforge/ParseGraph.py:116–179  ·  view source on GitHub ↗
(self, path)

Source from the content-addressed store, hash-verified

114 self.edgeDict[key] = edge
115
116 def Forge(self, path):
117 headerList = []
118
119 # set field value/mask
120 for headerConfig in path.stack:
121 header = self.createProtocolHeader(headerConfig.Header)
122
123 if header == None:
124 return None
125
126 for hcf in headerConfig.fields:
127 attr = False
128 if not header.SetField(hcf.Name, hcf.Value):
129 if not header.SetAttribute(hcf.Name, hcf.Value):
130 print("failed to set value of " + hcf.Name)
131 return None
132 else:
133 attr = True
134
135 if not attr and not header.SetMask(hcf.Name, hcf.Mask):
136 print("failed to set mask of " + hcf.Name)
137 return None
138
139 header.Adjust()
140
141 headerList.append(header)
142
143 # apply edge actions and length autoincrease
144 for i in range(1, len(headerList)):
145 start = headerList[i - 1]
146 end = headerList[i]
147
148 edge = self.GetEdge(start.Name(), end.Name())
149
150 if edge == None:
151 print("no edge exist for {0}, {1}", start.Name, end.Name)
152 return None
153
154 edge.Apply(start, end)
155
156 increase = end.GetSize()
157 for j in range(i):
158 headerList[j].AppendAuto(increase)
159
160 # resolve buffer
161 pktLen = 0
162 for header in headerList:
163 header.Resolve()
164 pktLen += len(header.Buffer)
165
166 # join buffer
167 pktbuf = []
168 mskbuf = []
169
170 offset = 0
171 for header in headerList:
172 pktbuf.extend(header.Buffer)
173 mskbuf.extend(header.Mask)

Callers 3

MainFunction · 0.80
ForgeFunction · 0.80
MainFunction · 0.80

Calls 14

createProtocolHeaderMethod · 0.95
GetEdgeMethod · 0.95
ForgeResultClass · 0.90
printFunction · 0.85
SetFieldMethod · 0.80
SetAttributeMethod · 0.80
SetMaskMethod · 0.80
AdjustMethod · 0.80
appendMethod · 0.80
ApplyMethod · 0.80
GetSizeMethod · 0.80
AppendAutoMethod · 0.80

Tested by

no test coverage detected