// Start up L1 on the given span. It defaults to E1/doubleframe. We
// disable the TX pins since we're only listening.
static void enable_l1(GTH_api *api, const char* span) 
{
  int result;
  char pcm_name[20];

  // E1s carring ISDN LAPD normally use multiframe
  GTH_attribute attributes[] = { {"status", "enabled"}, 
				 {"framing", "multiframe"}
  };

  assert(sizeof(pcm_name) > (strlen(span) + strlen("pcm")));
  strncpy(pcm_name, "pcm", sizeof pcm_name);
  strncat(pcm_name, span, sizeof pcm_name);
  
  result = gth_set(api, pcm_name, attributes, 2);
  if (result != 0) {
    die("<set> command failed (-v shows more information)");
  }

  // give L1 a chance to settle down
  sleep_seconds(1);
}
// Electrical E1: disable TX pins and possibly enable -20dB monitoring
static void
enable_electrical_l1(GTH_api *api,
		     const char* span,
		     const int monitoring)
{
  int result;
  char span_name[20];

  int n_attributes = (monitoring)?3:2;
  GTH_attribute attributes[] = { {"status", "enabled"},
				 {"tx_enabled", "false"},
				 {"monitoring", "true"}
  };

  assert(sizeof(span_name) > (strlen(span) + strlen("pcm")));
  strncpy_s(span_name, sizeof span_name, "pcm", sizeof span_name - 1);
  strncat(span_name, span, sizeof span_name);

  // Use <set> here: <enable> isn't supported until gth2_system_37a.
  result = gth_set(api, span_name, attributes, n_attributes);

  if (result != 0)
    die("Setting up L1 failed. (-v switch gives more information)");
}