SIM: Option to write sniffed PDU to file
parent
e671b21812
commit
2d1b5fb437
|
@ -41,6 +41,7 @@
|
|||
int num_kanal = 1;
|
||||
sim_sniffer_t sim_sniffer;
|
||||
sim_sim_t sim_sim;
|
||||
const char *write_pdu_file = NULL;
|
||||
static int quit = 0;
|
||||
static const char *serialdev = "/dev/ttyUSB0";
|
||||
static int baudrate = 9600;
|
||||
|
@ -80,6 +81,8 @@ void print_help(const char *arg0)
|
|||
printf(" Serial device (default = '%s')\n", serialdev);
|
||||
printf(" -b --baud-rate <baud>\n");
|
||||
printf(" Serial baud rate (default = %d)\n", baudrate);
|
||||
printf(" -w --write-pdu <filename>\n");
|
||||
printf(" Write PDU to file (sniffer only)\n");
|
||||
printf("\nSIM card simulator options:\n");
|
||||
printf(" -E --eeprom <name>\n");
|
||||
printf(" Stores and reads EEPROM data to/from file. The file is stored at\n");
|
||||
|
@ -120,6 +123,7 @@ void add_options(void)
|
|||
option_add('v', "debug", 1);
|
||||
option_add('s', "serial-device", 1);
|
||||
option_add('b', "baud-rate", 1);
|
||||
option_add('w', "write-pdu", 1);
|
||||
option_add('E', "eeprom", 1);
|
||||
option_add('F', "futln", 1);
|
||||
option_add(OPT_SICHERUNG, "sicherung", 1);
|
||||
|
@ -156,6 +160,9 @@ int handle_options(int short_option, int argi, char **argv)
|
|||
case 'b':
|
||||
baudrate = atoi(argv[argi]);
|
||||
break;
|
||||
case 'w':
|
||||
write_pdu_file = options_strdup(argv[argi]);
|
||||
break;
|
||||
case 'E':
|
||||
eeprom_name = options_strdup(argv[argi]);
|
||||
break;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "sim.h"
|
||||
#include "sniffer.h"
|
||||
|
||||
extern const char *write_pdu_file;
|
||||
|
||||
/* Layer 7 */
|
||||
|
||||
static void rx_icl_sdu(uint8_t *data, int length)
|
||||
|
@ -742,9 +744,18 @@ static void rx_char(sim_sniffer_t *sim, uint8_t c)
|
|||
else
|
||||
PDEBUG(DSIM2, DEBUG_INFO, " control unknown 0x%02x\n", sim->block_control);
|
||||
PDEBUG(DSIM2, DEBUG_INFO, " length %d\n", sim->block_length);
|
||||
if (sim->block_checksum == 0)
|
||||
if (sim->block_checksum == 0) {
|
||||
FILE *fp;
|
||||
if (write_pdu_file && (fp = fopen(write_pdu_file, "a"))) {
|
||||
int i;
|
||||
fprintf(fp, "PDU: addr=0x%02x ctrl=0x%02x len=0x%02x data:", sim->block_address, sim->block_control, sim->block_length);
|
||||
for (i = 0; i < sim->block_length; i++)
|
||||
fprintf(fp, " 0x%02x", sim->block_data[i]);
|
||||
fprintf(fp, "\n");
|
||||
fclose (fp);
|
||||
}
|
||||
rx_icl_pdu(sim->block_data, sim->block_length);
|
||||
else
|
||||
} else
|
||||
PDEBUG(DSIM2, DEBUG_NOTICE, "Received message with checksum error!\n");
|
||||
sim->block_state = BLOCK_STATE_ADDRESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue