// Start up duplex LAPD on the given timeslot static int setup_lapd(GTH_api *api, const char *span, const int timeslot, const char *end) { int listen_port = 0; int listen_socket = gth_make_listen_socket(&listen_port); int data_socket; int result; int sapi = 0; int tei = 0; char job_id[MAX_JOB_ID]; if ( (timeslot < 1) || (timeslot > 31) ) { fprintf(stderr, "valid timeslots are 1--31, not %d. Aborting\n", timeslot); exit(-1); } result = gth_new_lapd_layer(api, 0, span, timeslot, end, sapi, tei, job_id, api->my_ip, listen_port); if (result != 0) { die("starting LAPD failed. (re-run with -v for more information)"); } data_socket = gth_wait_for_accept(listen_socket); return data_socket; }
// Entry point int main(int argc, char **argv) { GTH_api api; int data_socket = -1; int result; int monitoring = 0; int verbose = 0; Channel_t channels[MAX_MTP2_CHANNELS]; int i; int n_channels = 0; int n_sus_per_file = 0; int duration_per_file = 0; int stop_after_interval = 0; int output_filename_format = 0; int drop_fisus = 0; int esnf = 0; int listen_port = 0; int listen_socket = -1; enum PCap_format format = PCAP_NG; char *hostname; char *base_filename; // Check a couple of assumptions about type size. assert(sizeof(u32) == 4); assert(sizeof(u16) == 2); win32_specific_startup(); process_arguments(argv, argc, &monitoring, &verbose, &n_sus_per_file, &duration_per_file, &stop_after_interval, &output_filename_format, &drop_fisus, &esnf, &hostname, channels, &n_channels, &base_filename, &format); result = gth_connect(&api, hostname, verbose); if (result != 0) { die("Unable to connect to the GTH. Giving up."); } read_hw_description(&api, hostname); enable_l1(&api, channels, n_channels, monitoring); listen_socket = gth_make_listen_socket(&listen_port); for (i = 0; i < n_channels; i++){ monitor_mtp2(&api, channels + i, i, drop_fisus, esnf, listen_port, listen_socket); if (i == 0) { data_socket = gth_wait_for_accept(listen_socket); } } fprintf(stderr, "capturing packets, press ^C to abort\n"); convert_to_pcap(&api, data_socket, base_filename, n_sus_per_file, duration_per_file, stop_after_interval, output_filename_format, channels, n_channels, format); return 0; // not reached }