/* * T30 fax session consists of 5 phases: * * 1) Phase A "Call Establishment" * Off-hook, Dialing, Ringing, Answering, CNG and CED Tones * * 2) Phase B "Pre-Message Procedure" * Fax Terminal Identification, Capabilities exchanged and Set, Training * * 3) Phase C "In-Message Procedure, Message Transmission" * Transmission of Pages, Line Supervision, Error Detection and Correction * * 4) Phase D "Post Message Procedure" * End-of-Message Signaling, Page Confirmation * * 5) Phase E "Call Release" * Call Disconnect and Return to On-hook State */ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { t30_stats_t t30_stats; const char *local_ident; const char *far_ident; const char *tmp; fax_session_t *f_session = (fax_session_t *)user_data; t30_get_transfer_statistics(s, &t30_stats); tmp = t30_get_tx_ident(s); local_ident = tmp ? tmp : ""; tmp = t30_get_rx_ident(s); far_ident = tmp ? tmp : ""; printf("fax: Phase B handler (Call: '%s' %s)\n", f_session->call_id, f_session->pvt.caller ? "sender" : "receiver"); printf("fax: === Negotiation Result =======================================================\n"); printf("fax: Remote station id: %s\n", far_ident); printf("fax: Local station id: %s\n", local_ident); printf("fax: Transfer Rate: %i\n", t30_stats.bit_rate); printf("fax: ECM status %s\n", (t30_stats.error_correcting_mode) ? "on" : "off"); printf("fax: remote country: %s\n", (t30_get_rx_country(s) ? (t30_get_rx_country(s)) : "")); printf("fax: remote vendor: %s\n", (t30_get_rx_vendor(s) ? (t30_get_rx_vendor(s)) : "")); printf("fax: remote model: %s\n", (t30_get_rx_model(s) ? (t30_get_rx_model(s)) : "")); printf("fax: ==============================================================================\n"); return T30_ERR_OK; }
/* * Called at the end of the document */ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { t30_stats_t t; const char *local_ident; const char *far_ident; const char *tmp; fax_session_t *f_session; t30_get_transfer_statistics(s, &t); f_session = (fax_session_t *)user_data; tmp = t30_get_tx_ident(s); local_ident = tmp ? tmp : ""; tmp = t30_get_rx_ident(s); far_ident = tmp ? tmp : ""; printf("fax: Phase E handler (Call: '%s' %s)\n", f_session->call_id, f_session->pvt.caller ? "sender" : "receiver"); printf("fax: ==============================================================================\n"); if (result == T30_ERR_OK) { printf("fax: Fax successfully %s\n", f_session->pvt.caller ? "sent" : "received"); } else { printf("fax: Fax processing not successful - result (%d) %s\n", result, t30_completion_code_to_str(result)); } printf("fax: Remote station id: %s\n", far_ident); printf("fax: Local station id: %s\n", local_ident); printf("fax: Pages transferred: %i\n", f_session->pvt.caller ? t.pages_tx : t.pages_rx); printf("fax: Total fax pages: %i\n", t.pages_in_file); printf("fax: Image resolution: %ix%i\n", t.x_resolution, t.y_resolution); printf("fax: Transfer Rate: %i\n", t.bit_rate); printf("fax: ECM status %s\n", (t.error_correcting_mode) ? "on" : "off"); printf("fax: remote country: %s\n", (t30_get_rx_country(s) ? (t30_get_rx_country(s)) : "")); printf("fax: remote vendor: %s\n", (t30_get_rx_vendor(s) ? (t30_get_rx_vendor(s)) : "")); printf("fax: remote model: %s\n", (t30_get_rx_model(s) ? (t30_get_rx_model(s)) : "")); printf("fax: ==============================================================================\n"); /* Set our channel variables, variables are also used in event */ f_session->pvt.done = 1; if (result == T30_ERR_OK) f_session->fax_success = 1; else f_session->fax_success = 0; if(f_session->pvt.caller) sendRelese(f_session); }
void fax_log_rx_parameters(t30_state_t *s, const char *tag) { const char *u; if ((u = t30_get_rx_ident(s))) printf("%s: Remote ident '%s'\n", tag, u); if ((u = t30_get_rx_sub_address(s))) printf("%s: Remote sub-address '%s'\n", tag, u); if ((u = t30_get_rx_polled_sub_address(s))) printf("%s: Remote polled sub-address '%s'\n", tag, u); if ((u = t30_get_rx_selective_polling_address(s))) printf("%s: Remote selective polling address '%s'\n", tag, u); if ((u = t30_get_rx_sender_ident(s))) printf("%s: Remote sender ident '%s'\n", tag, u); if ((u = t30_get_rx_password(s))) printf("%s: Remote password '%s'\n", tag, u); if ((u = t30_get_rx_country(s))) printf("%s: Remote was made in '%s'\n", tag, u); if ((u = t30_get_rx_vendor(s))) printf("%s: Remote was made by '%s'\n", tag, u); if ((u = t30_get_rx_model(s))) printf("%s: Remote is model '%s'\n", tag, u); }