- z_GDU(print, &gdu, 0, 0);
- odr_reset(print);
+ fprintf(stderr, "Decoding error. Reconnecting\n");
+ cs_close(conn);
+ conn = 0;
+ session_connect();
+ reconnect_ok = 0;
+ if (conn)
+ {
+ char *buf_out;
+ int len_out;
+ buf_out = odr_getbuf(out, &len_out, 0);
+ do_hex_dump(buf_out, len_out);
+ cs_put(conn, buf_out, len_out);
+ odr_reset(out);
+ continue;
+ }
+ }
+ else
+ {
+ FILE *f = ber_file ? ber_file : stdout;
+ odr_perror(in, "Decoding incoming APDU");
+ fprintf(f, "[Near %ld]\n", (long) odr_offset(in));
+ fprintf(f, "Packet dump:\n---------\n");
+ odr_dumpBER(f, netbuffer, res);
+ fprintf(f, "---------\n");
+ if (apdu_file)
+ {
+ z_GDU(print, &gdu, 0, 0);
+ odr_reset(print);
+ }
+ if (conn && cs_more(conn))
+ continue;
+ break;