EOF
}
+sub gen_parse_ind_func($$)
+{
+ my $name = shift;
+ my $data = shift;
+
+ my $type = "svc";
+ $ctl and $type = "ctl";
+
+ print gen_tlv_parse_func($name, $data)."\n";
+ print <<EOF;
+{
+ void *tlv_buf = &msg->$type.tlv;
+ unsigned int tlv_len = le16_to_cpu(msg->$type.tlv_len);
+EOF
+
+ if (gen_has_types($data)) {
+ my $n_bits = scalar @$data;
+ my $n_words = int(($n_bits + 31) / 32);
+ my $i = 0;
+
+ print <<EOF;
+ struct tlv *tlv;
+ int i;
+ uint32_t found[$n_words] = {};
+
+ memset(res, 0, sizeof(*res));
+
+ __qmi_alloc_reset();
+ while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) {
+ unsigned int cur_tlv_len = le16_to_cpu(tlv->len);
+ unsigned int ofs = 0;
+
+ switch(tlv->type) {
+EOF
+ foreach my $field (@$data) {
+ $field = gen_common_ref($field);
+ my $cname = gen_cname($field->{name});
+ gen_tlv_type($cname, $field, $i++);
+ }
+
+ print <<EOF;
+ default:
+ break;
+ }
+ }
+
+ return 0;
+
+error_len:
+ fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\\n",
+ __func__, tlv->type, le16_to_cpu(tlv->len));
+ return QMI_ERROR_INVALID_DATA;
+EOF
+ } else {
+ print <<EOF;
+
+ return qmi_check_message_status(tlv_buf, tlv_len);
+EOF
+ }
+
+ print <<EOF;
+}
+
+EOF
+}
+
my %tlv_set = (
guint8 => sub { my $a = shift; my $b = shift; print "*(uint8_t *) $a = $b;\n" },
guint16 => sub { my $a = shift; my $b = shift; print "*(uint16_t *) $a = cpu_to_le16($b);\n" },
EOF
-gen_foreach_message_type($data, \&gen_set_func, \&gen_parse_func);
+gen_foreach_message_type($data, \&gen_set_func, \&gen_parse_func, \&gen_parse_ind_func);
my $data = shift;
my $req_sub = shift;
my $res_sub = shift;
+ my $ind_sub = shift;
foreach my $entry (@$data) {
my $args = [];
&$req_sub($prefix.$entry->{name}." Request", $entry->{input}, $entry);
&$res_sub($prefix.$entry->{name}." Response", $entry->{output}, $entry);
}
+
+ foreach my $entry (@$data) {
+ my $args = [];
+ my $fields = [];
+
+ $common_ref{$entry->{'common-ref'}} = $entry if $entry->{'common-ref'} ne '';
+
+ next if $entry->{type} ne 'Indication';
+ next if not defined $entry->{input} and not defined $entry->{output};
+
+ &$ind_sub($prefix.$entry->{name}." Indication", $entry->{output}, $entry);
+ }
}
+
1;
$func and print "$func;\n\n";
}
-gen_foreach_message_type($data, \&gen_tlv_struct, \&gen_tlv_struct);
-gen_foreach_message_type($data, \&gen_set_func_header, \&gen_parse_func_header);
+gen_foreach_message_type($data, \&gen_tlv_struct, \&gen_tlv_struct, \&gen_tlv_struct);
+gen_foreach_message_type($data, \&gen_set_func_header, \&gen_parse_func_header, \&gen_parse_func_header);