示例#1
0
static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
{
    int OK = 0;
    int gaa_last_non_option;
	struct GAAOPTION_port GAATMP_port;
	struct GAAOPTION_pskkey GAATMP_pskkey;
	struct GAAOPTION_pskusername GAATMP_pskusername;
	struct GAAOPTION_srppasswd GAATMP_srppasswd;
	struct GAAOPTION_srpusername GAATMP_srpusername;
	struct GAAOPTION_x509certfile GAATMP_x509certfile;
	struct GAAOPTION_x509keyfile GAATMP_x509keyfile;
	struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey;
	struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile;
	struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring;
	struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile;
	struct GAAOPTION_x509crlfile GAATMP_x509crlfile;
	struct GAAOPTION_x509cafile GAATMP_x509cafile;
	struct GAAOPTION_priority GAATMP_priority;
	struct GAAOPTION_recordsize GAATMP_recordsize;
	struct GAAOPTION_mtu GAATMP_mtu;
	struct GAAOPTION_debug GAATMP_debug;

#line 393 "gaa.skel"
#ifdef GAA_REST_EXISTS
    struct GAAREST GAAREST_tmp;
#endif

    opt_list[gaa_num] = 1;
    
    for(gaa_last_non_option = gaa_index;
        (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION);
        gaa_last_non_option++);

    if(gaa_num == GAA_REST)
    {
        gaa_index = 1;
        gaa_last_non_option = GAAargc;
    }
    
    switch(gaa_num)
    {
	case GAAOPTID_version:
	OK = 0;
#line 109 "cli.gaa"
{ cli_version(); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_help:
	OK = 0;
#line 107 "cli.gaa"
{ gaa_help(); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_list:
	OK = 0;
#line 106 "cli.gaa"
{ print_list(gaaval->priorities, gaaval->verbose); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_benchmark_tls:
	OK = 0;
#line 104 "cli.gaa"
{ benchmark_tls(gaaval->debug); exit(0) ;};

		return GAA_OK;
		break;
	case GAAOPTID_benchmark_soft_ciphers:
	OK = 0;
#line 103 "cli.gaa"
{ benchmark_cipher(0, gaaval->debug); exit(0) ;};

		return GAA_OK;
		break;
	case GAAOPTID_benchmark_ciphers:
	OK = 0;
#line 102 "cli.gaa"
{ benchmark_cipher(1, gaaval->debug); exit(0) ;};

		return GAA_OK;
		break;
	case GAAOPTID_insecure:
	OK = 0;
#line 100 "cli.gaa"
{ gaaval->insecure = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_port:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_port.arg1, gaa_getstr, GAATMP_port.size1);
		gaa_index++;
#line 97 "cli.gaa"
{ gaaval->port = GAATMP_port.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pskkey:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pskkey.arg1, gaa_getstr, GAATMP_pskkey.size1);
		gaa_index++;
#line 94 "cli.gaa"
{ gaaval->psk_key = GAATMP_pskkey.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pskusername:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pskusername.arg1, gaa_getstr, GAATMP_pskusername.size1);
		gaa_index++;
#line 91 "cli.gaa"
{ gaaval->psk_username = GAATMP_pskusername.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_srppasswd:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_srppasswd.arg1, gaa_getstr, GAATMP_srppasswd.size1);
		gaa_index++;
#line 88 "cli.gaa"
{ gaaval->srp_passwd = GAATMP_srppasswd.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_srpusername:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_srpusername.arg1, gaa_getstr, GAATMP_srpusername.size1);
		gaa_index++;
#line 85 "cli.gaa"
{ gaaval->srp_username = GAATMP_srpusername.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_x509certfile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_x509certfile.arg1, gaa_getstr, GAATMP_x509certfile.size1);
		gaa_index++;
#line 82 "cli.gaa"
{ gaaval->x509_certfile = GAATMP_x509certfile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_x509keyfile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_x509keyfile.arg1, gaa_getstr, GAATMP_x509keyfile.size1);
		gaa_index++;
#line 79 "cli.gaa"
{ gaaval->x509_keyfile = GAATMP_x509keyfile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pgpsubkey:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pgpsubkey.arg1, gaa_getstr, GAATMP_pgpsubkey.size1);
		gaa_index++;
#line 76 "cli.gaa"
{ gaaval->pgp_subkey = GAATMP_pgpsubkey.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pgpcertfile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pgpcertfile.arg1, gaa_getstr, GAATMP_pgpcertfile.size1);
		gaa_index++;
#line 73 "cli.gaa"
{ gaaval->pgp_certfile = GAATMP_pgpcertfile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pgpkeyring:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pgpkeyring.arg1, gaa_getstr, GAATMP_pgpkeyring.size1);
		gaa_index++;
#line 70 "cli.gaa"
{ gaaval->pgp_keyring = GAATMP_pgpkeyring.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_pgpkeyfile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_pgpkeyfile.arg1, gaa_getstr, GAATMP_pgpkeyfile.size1);
		gaa_index++;
#line 67 "cli.gaa"
{ gaaval->pgp_keyfile = GAATMP_pgpkeyfile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_x509crlfile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_x509crlfile.arg1, gaa_getstr, GAATMP_x509crlfile.size1);
		gaa_index++;
#line 64 "cli.gaa"
{ gaaval->x509_crlfile = GAATMP_x509crlfile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_x509cafile:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_x509cafile.arg1, gaa_getstr, GAATMP_x509cafile.size1);
		gaa_index++;
#line 61 "cli.gaa"
{ gaaval->x509_cafile = GAATMP_x509cafile.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_priority:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_priority.arg1, gaa_getstr, GAATMP_priority.size1);
		gaa_index++;
#line 58 "cli.gaa"
{ gaaval->priorities = GAATMP_priority.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_verbose:
	OK = 0;
#line 55 "cli.gaa"
{ gaaval->verbose = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_recordsize:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_recordsize.arg1, gaa_getint, GAATMP_recordsize.size1);
		gaa_index++;
#line 52 "cli.gaa"
{ gaaval->record_size = GAATMP_recordsize.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_print_cert:
	OK = 0;
#line 49 "cli.gaa"
{ gaaval->print_cert = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_disable_extensions:
	OK = 0;
#line 46 "cli.gaa"
{ gaaval->disable_extensions = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_fingerprint:
	OK = 0;
#line 43 "cli.gaa"
{ gaaval->fingerprint = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_x509fmtder:
	OK = 0;
#line 40 "cli.gaa"
{ gaaval->fmtder = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_crlf:
	OK = 0;
#line 37 "cli.gaa"
{ gaaval->crlf = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_mtu:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_mtu.arg1, gaa_getint, GAATMP_mtu.size1);
		gaa_index++;
#line 34 "cli.gaa"
{ gaaval->mtu = GAATMP_mtu.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_udp:
	OK = 0;
#line 31 "cli.gaa"
{ gaaval->udp = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_starttls:
	OK = 0;
#line 28 "cli.gaa"
{ gaaval->starttls = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_noticket:
	OK = 0;
#line 25 "cli.gaa"
{ gaaval->noticket = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_rehandshake:
	OK = 0;
#line 22 "cli.gaa"
{ gaaval->rehandshake = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_resume:
	OK = 0;
#line 19 "cli.gaa"
{ gaaval->resume = 1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_debug:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_debug.arg1, gaa_getint, GAATMP_debug.size1);
		gaa_index++;
#line 16 "cli.gaa"
{ gaaval->debug = GAATMP_debug.arg1 ;};

		return GAA_OK;
		break;
	case GAA_REST:
		GAA_TESTMOREARGS;
		GAA_FILL(GAAREST_tmp.arg1, gaa_getstr, GAAREST_tmp.size1);
		gaa_index++;
#line 112 "cli.gaa"
{ gaaval->rest_args = GAAREST_tmp.arg1; ;};

		return GAA_OK;
		break;

#line 413 "gaa.skel"
    default: break;
    }
    return GAA_ERROR_UNKNOWN;
}
示例#2
0
static void
cmd_parser (int argc, char **argv)
{
const char* rest = NULL;

  int optct = optionProcess( &gnutls_cliOptions, argc, argv);
  argc -= optct;
  argv += optct;
  
  if (rest == NULL && argc > 0)
    rest = argv[0];
    
  if (HAVE_OPT(BENCHMARK_CIPHERS))
    {
      benchmark_cipher(1, OPT_VALUE_DEBUG); 
      exit(0);
    }

  if (HAVE_OPT(BENCHMARK_SOFT_CIPHERS))
    {
      benchmark_cipher(0, OPT_VALUE_DEBUG); 
      exit(0);
    }

  if (HAVE_OPT(BENCHMARK_TLS))
    {
      benchmark_tls(OPT_VALUE_DEBUG); 
      exit(0);
    }

  if (HAVE_OPT(PRIORITY)) 
    {
      priorities = OPT_ARG(PRIORITY);
    } 
  verbose = HAVE_OPT( VERBOSE);
  if (verbose)
    print_cert = 1;
  else
    print_cert = HAVE_OPT( PRINT_CERT);
  
  if (HAVE_OPT(LIST))
    {
      print_list(priorities, verbose);
      exit(0);
    }

  disable_extensions = HAVE_OPT( DISABLE_EXTENSIONS);
  starttls = HAVE_OPT(STARTTLS);
  resume = HAVE_OPT(RESUME);
  rehandshake = HAVE_OPT(REHANDSHAKE);
  insecure = HAVE_OPT(INSECURE);

  udp = HAVE_OPT(UDP);
  mtu = OPT_VALUE_MTU;
  
  if (HAVE_OPT(PORT)) 
    {
      service = OPT_ARG(PORT);
    }
  else 
    {
      service = "443";
    }

  record_max_size = OPT_VALUE_RECORDSIZE;
  fingerprint = HAVE_OPT(FINGERPRINT);

  if (HAVE_OPT(X509FMTDER))
    x509ctype = GNUTLS_X509_FMT_DER;
  else
    x509ctype = GNUTLS_X509_FMT_PEM;

  if (HAVE_OPT(SRPUSERNAME))
    srp_username = OPT_ARG(SRPUSERNAME);
    
  if (HAVE_OPT(SRPPASSWD))
    srp_passwd = OPT_ARG(SRPPASSWD);
  
  if (HAVE_OPT(X509CAFILE))
    x509_cafile = OPT_ARG(X509CAFILE);
  else
    {
      if (access(DEFAULT_CA_FILE, R_OK) == 0)
        x509_cafile = DEFAULT_CA_FILE;
    }
  
  if (HAVE_OPT(X509CRLFILE))
    x509_crlfile = OPT_ARG(X509CRLFILE);
    
  if (HAVE_OPT(X509KEYFILE))
    x509_keyfile = OPT_ARG(X509KEYFILE);
  
  if (HAVE_OPT(X509CERTFILE))
    x509_certfile = OPT_ARG(X509CERTFILE);
  
  if (HAVE_OPT(PGPKEYFILE))
    pgp_keyfile = OPT_ARG(PGPKEYFILE);
  
  if (HAVE_OPT(PGPCERTFILE))
    pgp_certfile = OPT_ARG(PGPCERTFILE);

  if (HAVE_OPT(PSKUSERNAME))
    psk_username = OPT_ARG(PSKUSERNAME);

  if (HAVE_OPT(PSKKEY))
    {
      psk_key.data = (unsigned char *) OPT_ARG(PSKKEY);
      psk_key.size = strlen (OPT_ARG(PSKKEY));
    }
  else
    psk_key.size = 0;

  if (HAVE_OPT(PGPKEYRING))
    pgp_keyring = OPT_ARG(PGPKEYRING);

  crlf = HAVE_OPT(CRLF);

  if (rest != NULL)
    hostname = rest;
    
  if (hostname == NULL)
    {
      fprintf(stderr, "No hostname specified\n");
      exit(1);
    }
}