| 424 | |
| 425 | |
| 426 | class ASN1F_SEQUENCE(ASN1F_field[List[Any], List[Any]]): |
| 427 | # Here is how you could decode a SEQUENCE |
| 428 | # with an unknown, private high-tag prefix : |
| 429 | # class PrivSeq(ASN1_Packet): |
| 430 | # ASN1_codec = ASN1_Codecs.BER |
| 431 | # ASN1_root = ASN1F_SEQUENCE( |
| 432 | # <asn1 field #0>, |
| 433 | # ... |
| 434 | # <asn1 field #N>, |
| 435 | # explicit_tag=0, |
| 436 | # flexible_tag=True) |
| 437 | # Because we use flexible_tag, the value of the explicit_tag does not matter. # noqa: E501 |
| 438 | ASN1_tag = ASN1_Class_UNIVERSAL.SEQUENCE |
| 439 | holds_packets = 1 |
| 440 | |
| 441 | def __init__(self, *seq, **kwargs): |
| 442 | # type: (*Any, **Any) -> None |
| 443 | name = "dummy_seq_name" |
| 444 | default = [field.default for field in seq] |
| 445 | super(ASN1F_SEQUENCE, self).__init__( |
| 446 | name, default, **kwargs |
| 447 | ) |
| 448 | self.seq = seq |
| 449 | self.islist = len(seq) > 1 |
| 450 | |
| 451 | def __repr__(self): |
| 452 | # type: () -> str |
| 453 | return "<%s%r>" % (self.__class__.__name__, self.seq) |
| 454 | |
| 455 | def is_empty(self, pkt): |
| 456 | # type: (ASN1_Packet) -> bool |
| 457 | return all(f.is_empty(pkt) for f in self.seq) |
| 458 | |
| 459 | def get_fields_list(self): |
| 460 | # type: () -> List[ASN1F_field[Any, Any]] |
| 461 | return reduce(lambda x, y: x + y.get_fields_list(), |
| 462 | self.seq, []) |
| 463 | |
| 464 | def m2i(self, pkt, s): |
| 465 | # type: (Any, bytes) -> Tuple[Any, bytes] |
| 466 | """ |
| 467 | ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being |
| 468 | dissected one by one. Because we use obj.dissect (see loop below) |
| 469 | instead of obj.m2i (as we trust dissect to do the appropriate set_vals) |
| 470 | we do not directly retrieve the list of nested objects. |
| 471 | Thus m2i returns an empty list (along with the proper remainder). |
| 472 | It is discarded by dissect() and should not be missed elsewhere. |
| 473 | """ |
| 474 | diff_tag, s = BER_tagging_dec(s, hidden_tag=self.ASN1_tag, |
| 475 | implicit_tag=self.implicit_tag, |
| 476 | explicit_tag=self.explicit_tag, |
| 477 | safe=self.flexible_tag, |
| 478 | _fname=pkt.name) |
| 479 | if diff_tag is not None: |
| 480 | if self.implicit_tag is not None: |
| 481 | self.implicit_tag = diff_tag |
| 482 | elif self.explicit_tag is not None: |
| 483 | self.explicit_tag = diff_tag |
no outgoing calls
no test coverage detected