diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2018-02-24 12:31:36 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-03-19 16:04:05 -0500 |
commit | a210e722d53571f2edc90f03dc2814f954031e7e (patch) | |
tree | 1947ed3aebbfe0c8204b016274b2e5ce5a0e5fc7 /build-aux | |
parent | 01fc5408a05cbb0fb9a21054c43ce22ce64970c5 (diff) | |
download | libqmi-a210e722d53571f2edc90f03dc2814f954031e7e.tar.gz |
qmi-codegen: TLVs < 0x10 are mandatory by default
The fallback logic of specifying an explicit value has been retained
because the following fields:
CTL Set Data Format: Protocol id=0x10 mandatory=True
NAS Attach Detach: Action id=0x10 mandatory=True
DMS Set Time: Time Reference Type id=0x10 mandatory=True
WDS Get Current Settings: Requested Settings id=0x10 mandatory=True
PDC Register: Enable Reporting id=0x10 mandatory=True
PDC List Configs: Config Type id=0x11 mandatory=True
PDC Delete Config: Id id=0x11 mandatory=True
This was also true for the following, but changed because testing
revealed that they should be indeed mandatory:
LOC Start: Session ID id=0x01 mandatory=False
LOC Stop: Session ID id=0x01 mandatory=False
LOC Start: Session ID id=0x01 mandatory=False
LOC Stop: Session ID id=0x01 mandatory=False
Also the old code did not regard any TLVs as mandatory, as
Field.mandatory was a boolean but was compared to the string "yes",
breaking the logic.
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/qmi-codegen/Field.py | 11 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Message.py | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/build-aux/qmi-codegen/Field.py b/build-aux/qmi-codegen/Field.py index 631890ff..fde9ed40 100644 --- a/build-aux/qmi-codegen/Field.py +++ b/build-aux/qmi-codegen/Field.py @@ -41,8 +41,8 @@ class Field: self.name = dictionary['name'] # The specific TLV ID self.id = dictionary['id'] - # Whether the field is to be considered mandatory in the message - self.mandatory = True if dictionary['mandatory'] == 'yes' else False + # Overridden mandatory field, the default is calculated from id + self._mandatory = dictionary.get('mandatory') # The type, which must always be "TLV" self.type = dictionary['type'] # The container type, which must be either "Input" or "Output" @@ -87,6 +87,13 @@ class Field: raise RuntimeError('Common type \'%s\' not found' % prerequisite_dictionary['name']) + @property + def mandatory(self): + if self._mandatory is None: + return int(self.id, 0) < 0x10 + return self._mandatory == 'yes' + + """ Emit new types required by this field """ diff --git a/build-aux/qmi-codegen/Message.py b/build-aux/qmi-codegen/Message.py index ea6622ba..8a1d1500 100644 --- a/build-aux/qmi-codegen/Message.py +++ b/build-aux/qmi-codegen/Message.py @@ -125,7 +125,7 @@ class Message: # Count how many mandatory fields we have n_mandatory = 0 for field in self.input.fields: - if field.mandatory == 'yes': + if field.mandatory: n_mandatory += 1 if n_mandatory == 0: @@ -164,7 +164,7 @@ class Message: # Emit the TLV getter field.emit_input_tlv_add(cfile, ' ') - if field.mandatory == 'yes': + if field.mandatory: template = ( ' } else {\n' ' g_set_error (error,\n' |