예제 #1
0
// Set the mode for the given E1/T1, using default parameters.
//
// This works for many setups, but not all. The possible problems are:
//
//   - GTH 2.x hardware has restrictions on mixing E1 and T1 modes.
//     This might hit someone trying out options. They'll get a 'conflict'
//     error. If in doubt, disable all the E1/T1 before changing modes,
//     for instance by cycling power.
//
//   - The T1 default settings might not be right for a particular site.
//     Check the L1 status page on the in-built webserver (port 8888)
//     to see.
//
static void setup_layer_1(GTH_api *api, const char *pcm_name, const int mulaw) {
  int result;
  const char e1[] = "E1";
  const char t1[] = "T1";

  result = gth_set_single(api, pcm_name, "mode", (mulaw)?t1:e1);

  if (result != 0) {
    fprintf(stderr, "Layer 1 setup failed, useless recording likely.\n");
  }
}
//------------------------------
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");
}