static void show_releases(const char *hostname, const int verbose) { GTH_api api; int result; char attribute[1000]; result = gth_connect(&api, hostname, verbose); if (result != 0) { die("unable to connect to GTH"); } result = gth_query_resource_attribute(&api, "system_image", "version", attribute, sizeof(attribute)); assert(result == 0); printf(" Current system image version: %s\n", attribute); result = gth_query_resource_attribute(&api, "failsafe_image", "version", attribute, sizeof(attribute)); assert(result == 0); printf("Current failsafe image version: %s\n", attribute); gth_bye(&api); }
// 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 }
// Entry point int main(int argc, char** argv) { GTH_api api; int data_socket; int result; char *end = "user"; int verbose = 0; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'v': verbose = 1; break; default: usage(); } argc--; argv++; } if (argc != 4 && argc != 5) { usage(); } if (argc == 5) { if (strcmp(argv[4], "user") && strcmp(argv[4], "network")) { usage(); } else { end = argv[4]; } } printf("end is %s\n", end); win32_specific_startup(); // Check a couple of assumptions about type size. assert(sizeof(unsigned int) == 4); assert(sizeof(unsigned short) == 2); result = gth_connect(&api, argv[1], verbose); if (result != 0) { die("Unable to connect to the GTH. Giving up."); } enable_l1(&api, argv[2]); data_socket = setup_lapd(&api, argv[2], atoi(argv[3]), end); fprintf(stderr, "lapd started, press ^C to abort\n"); dump_incoming_lapd(data_socket); return 0; // not reached }
// Entry point int main(int argc, char** argv) { int result; GTH_api api; int verbose = 0; GTH_const_attribute attrs[MAX_ATTRIBUTES]; int n_attrs = 0; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'v': verbose = 1; break; default: usage(); } argc--; argv++; } if (argc < 3) { usage(); } win32_specific_startup(); result = gth_connect(&api, argv[1], verbose); if (result != 0) { die("Unable to connect to the GTH. Giving up."); } api.event_handler = >h_silent_event_handler; // First attribute is in argv[3], first value in argv[4] if (argc >= MAX_ATTRIBUTES) { die("Too many name/value pairs. Abort."); } for (n_attrs = 0; n_attrs < (argc - 3) / 2; n_attrs++) { attrs[n_attrs].key = argv[n_attrs * 2 + 3]; attrs[n_attrs].value = argv[n_attrs * 2 + 4]; } result = gth_enable(&api, argv[2], attrs, n_attrs); if (result != 0) { fprintf(stderr, "failed to enable %s\n", argv[2]); exit(1); } gth_bye(&api); return 0; }
// Entry point int main(int argc, char** argv) { int result; GTH_api api; char pcm_name[20]; int t1_mulaw_mode = 0; int verbose = 0; int setup_l1 = 1; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'v': verbose = 1; break; case 'l': setup_l1 = 0; break; case 'T': t1_mulaw_mode = 1; break; default: usage(); } argc--; argv++; } if (argc != 5) { usage(); } win32_specific_startup(); result = gth_connect(&api, argv[1], verbose); if (result != 0) { die("unable to connect to the GTH"); } assert(sizeof(pcm_name) > (strlen("pcm") + strlen(argv[2]))); strncpy_s(pcm_name, sizeof pcm_name, "pcm", sizeof pcm_name - 1); strncat(pcm_name, argv[2], sizeof pcm_name); if (setup_l1) { setup_layer_1(&api, pcm_name, t1_mulaw_mode); } record_a_file(&api, argv[2], atoi(argv[3]), argv[4], t1_mulaw_mode); gth_bye(&api); fprintf(stderr, "all done\n"); return 0; }
// Entry point int main(int argc, char** argv) { int result; GTH_api api; int verbose = 0; char name[MAX_RESOURCE_NAME]; char *sdh_resource; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'v': verbose = 1; break; default: usage(); } argc--; argv++; } if (argc != 3) { usage(); } sdh_resource = argv[2]; win32_specific_startup(); result = gth_connect(&api, argv[1], verbose); if (result != 0) { die("Unable to connect to the GTH. Giving up."); } result = gth_map(&api, sdh_resource, name, MAX_RESOURCE_NAME); if (result == 0) { printf("%s\n", name); } else { fprintf(stderr, "unable to map %s. Is SDH enabled? -v for more info.\n", sdh_resource); exit(-1); } gth_bye(&api); return 0; }
// Entry point int main(int argc, char** argv) { int result; GTH_api api; if (argc != 3) { usage(); } win32_specific_startup(); result = gth_connect(&api, argv[1], 1 /* verbose */); if (result != 0) { die("Unable to connect to the GTH. Giving up."); } gth_raw_xml(&api, argv[2]); gth_bye(&api); return 0; }
//------------------------------ static void install_release(const char *hostname, const char *filename, int verbose) { GTH_api api; int result; FILE *image; int image_length; char *image_data; result = gth_connect(&api, hostname, verbose); fopen_s(&image, filename, "rb"); fprintf(stderr, "installing software image %s\n", filename); if (!image) die("unable to open software image file"); fseek(image, 0, SEEK_END); image_length = ftell(image); rewind(image); image_data = malloc(image_length); assert(image_data); result = fread(image_data, image_length, 1, image); assert(result == 1); fclose(image); result = gth_set_single(&api, "system_image", "locked", "false"); assert(result == 0); result = gth_install(&api, "system_image", "binary/filesystem", image_data, image_length); free(image_data); if (result != 0) die("install failed"); }