separation of ca_info and application_info in dst_test
PATCH 1/1 separation of ca_info and application_info in dst_test
Please review and comment.
---
This patch fixes an issue with with dst_test which uses an incorrect tag for retrieving application_info from the CAM. It also adds support for retrieving ca_info from the CAM.
Signed-off-by Henrik Kurelid <[email protected]>
util/dst-utils/dst_test.c +47 -5
@@ -3,6 +3,7 @@ an implementation for the High Level Common Interface Copyright (C) 2004, 2005 Manu Abraham <[email protected]> + Copyright (C) 2009 Henrik Kurelid <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
@@ -140,9 +141,10 @@return 0 ; } -static int dst_get_app_info (int cafd,struct ca_msg *msg) +static int dst_get_ca_info (int cafd,struct ca_msg *msg) {uint32_t tag =0 ; +int pos;/* Enquire */ tag =TAG_CA_INFO_ENQUIRY ;
@@ -159,10 +161,45 @@ }/* Process */ +printf ("%s: ================================ CI Module CA Info ======================================\n" , __FUNCTION__); +printf ("%s: Supported CA System IDs (%d):\n" , __FUNCTION__, msg->msg[3 ] /2 ); + pos =4 ; +while (pos < msg->msg[3 ] +4 ) { +printf ("%s: 0x%04X\n" , __FUNCTION__, (msg->msg[pos] <<8 ) + msg->msg[pos +1 ]); + pos +=2 ; + } +printf ("%s: ==================================================================================================\n" , __FUNCTION__); + +return 0 ; +} + +static int dst_get_app_info (int cafd,struct ca_msg *msg) +{ +uint32_t tag =0 ; +int i; + +/* Enquire */ + tag =TAG_APP_INFO_ENQUIRY ; +if ((dst_comms (cafd, tag,CA_SEND_MSG , msg)) <0 ) { +printf ("%s: Dst communication failed\n" , __FUNCTION__); +return -1 ; + } + +/* Receive */ + tag =TAG_APP_INFO ; +if ((dst_comms (cafd, tag,CA_GET_MSG , msg)) <0 ) { +printf ("%s: Dst communication failed\n" , __FUNCTION__); +return -1 ; + } + +/* Process */ printf ("%s: ================================ CI Module Application Info ======================================\n" , __FUNCTION__); -printf ("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n" , - __FUNCTION__, msg->msg[7 ], (msg->msg[8 ] <<8 ) | msg->msg[9 ], (msg->msg[10 ] <<8 ) | msg->msg[11 ], __FUNCTION__, - ((char *) (&msg->msg[12 ]))); +printf ("%s: Application Type=[%d], Application Vendor=[0x%04X], Vendor Code=[0x%04X]\n" , + __FUNCTION__, msg->msg[4 ], (msg->msg[5 ] <<8 ) | msg->msg[6 ], (msg->msg[7 ] <<8 ) | msg->msg[8 ]); +printf ("%s: Application info=[" , __FUNCTION__); +for (i =0 ; i < msg->msg[9 ]; i++) +printf ("%c" , (char )msg->msg[10 + i]); +printf ("]\n" );printf ("%s: ==================================================================================================\n" , __FUNCTION__);return 0 ;
@@ -195,6 +232,7 @@"\t -g get descr\n" "\t -s set_descr\n" "\t -a app_info\n" +"\t -b ca_info\n" "\t -t session test\n" ;
@@ -216,7 +254,7 @@return -1 ; } -switch (getopt (argc, argv,"cirpgsat" )) { +switch (getopt (argc, argv,"cirpgsabt" )) {case 'c' :printf ("%s: Capabilities\n" , __FUNCTION__);dst_get_caps (cafd, caps);
@@ -245,6 +283,10 @@printf ("%s: App Info\n" , __FUNCTION__);dst_get_app_info (cafd, msg);break ; +case 'b' : +printf ("%s: CA Info\n" , __FUNCTION__); +dst_get_ca_info (cafd, msg); +break ;case 't' :printf ("%s: Session test\n" , __FUNCTION__);dst_session_test (cafd, msg);