(self, pkt, x)
| 2194 | self.adjust = adjust |
| 2195 | |
| 2196 | def i2m(self, pkt, x): |
| 2197 | # type: (Optional[Packet], Optional[int]) -> int |
| 2198 | if x is None and pkt is not None: |
| 2199 | if self.length_of is not None: |
| 2200 | fld, fval = pkt.getfield_and_val(self.length_of) |
| 2201 | f = fld.i2len(pkt, fval) |
| 2202 | elif self.count_of is not None: |
| 2203 | fld, fval = pkt.getfield_and_val(self.count_of) |
| 2204 | f = fld.i2count(pkt, fval) |
| 2205 | else: |
| 2206 | raise ValueError( |
| 2207 | "Field should have either length_of or count_of" |
| 2208 | ) |
| 2209 | x = self.adjust(pkt, f) |
| 2210 | elif x is None: |
| 2211 | x = 0 |
| 2212 | return x |
| 2213 | |
| 2214 | |
| 2215 | class StrNullField(StrField): |
nothing calls this directly
no test coverage detected