예제 #1
0
int KSG_Reactor_Listener_Task::start_task(int max_task)
{
#ifdef ACE_HAS_EVENT_POLL
	ACE_Dev_Poll_Reactor *reactor_imp = new ACE_Dev_Poll_Reactor;
#else
	ACE_Select_Reactor *reactor_imp = new ACE_Select_Reactor;
#endif // ACE_HAS_EVENT_POLL
	reactor_ = new ACE_Reactor(reactor_imp);
	std::auto_ptr<ACE_Reactor> delete_instance(ACE_Reactor::instance(reactor_));
	work_thr_.activate(THR_NEW_LWP | THR_JOINABLE,max_task);
	max_work_thr_ = max_task;
	this->activate(THR_NEW_LWP | THR_JOINABLE,1);
	return 0;
}
예제 #2
0
/*f c_log_toggle::~c_log_toggle
 */
c_log_toggle::~c_log_toggle()
{
    delete_instance();
}
예제 #3
0
int
do_create(int argc, char *argv[])
{
	char c;
	char *buf, *ptr, *instance_name;
	char *inaddr_any_name = NULL;
	int i, status, len, pcnt;
	const char *token_label = NULL;
	const char *filename = NULL;
	const char *certname = NULL;
	const char *username = NULL;
	const char *proxy_port = NULL;
	char *format = NULL;
	boolean_t quote_next;
	char address_port[MAX_ADRPORT_LEN + 1];

	argc -= 1;
	argv += 1;

	/*
	 * Many of these arguments are passed on to kssladm command
	 * in the start method of the SMF instance created. So, we do only
	 * the basic usage checks here and let kssladm check the validity
	 * of the arguments. This is the reason we ignore optarg
	 * for some of the cases below.
	 */
	while ((c = getopt(argc, argv, "vT:d:f:h:i:p:c:C:t:u:x:z:")) != -1) {
		switch (c) {
		case 'd':
			break;
		case 'c':
			break;
		case 'C':
			certname = optarg;
			break;
		case 'f':
			format = optarg;
			break;
		case 'h':
			break;
		case 'i':
			filename = optarg;
			break;
		case 'T':
			token_label = optarg;
			break;
		case 'p':
			break;
		case 't':
			break;
		case 'u':
			username = optarg;
			break;
		case 'x':
			proxy_port = optarg;
			break;
		case 'v':
			verbose = B_TRUE;
			break;
		case 'z':
			break;
		default:
			goto err;
		}
	}

	if (format == NULL || proxy_port == NULL) {
		goto err;
	}

	if (get_portnum(proxy_port, NULL) == 0) {
		(void) fprintf(stderr,
		    gettext("Error: Invalid proxy port value %s\n"),
		    proxy_port);
		goto err;
	}

	if (strcmp(format, "pkcs11") == 0) {
		if (token_label == NULL || certname == NULL) {
			goto err;
		}
	} else if (strcmp(format, "pkcs12") == 0 ||
	    strcmp(format, "pem") == 0) {
		if (filename == NULL) {
			goto err;
		}
	} else {
		goto err;
	}

	pcnt = argc - optind;
	if (pcnt == 1) {
		if (strlen(argv[optind]) < MAX_ADRPORT_LEN) {
			(void) strcpy(address_port, argv[optind]);
		} else {
			(void) fprintf(stderr, gettext(
			    "argument too long -- %s\n"),
			    argv[optind]);
			return (FAILURE);
		}
	} else if (pcnt == 2) {
		if ((len = strlen(argv[optind])) +
		    (strlen(argv[optind + 1])) < MAX_ADRPORT_LEN) {
			(void) strcpy(address_port, argv[optind]);
			address_port[len] = ' ';
			(void) strcpy(address_port + len + 1, argv[optind + 1]);
		} else {
			(void) fprintf(stderr, gettext(
			    "arguments too long -- %s %s\n"),
			    argv[optind], argv[optind + 1]);
			return (FAILURE);
		}
	} else {
		goto err;
	}

	/*
	 * We need to create the kssladm command line in
	 * the SMF instance from the current arguments.
	 *
	 * Construct a buffer with all the arguments except
	 * the -u argument. We have to quote the string arguments,
	 * -T and -C, as they can contain white space.
	 */
	len = 0;
	for (i = 1; i < optind; i++) {
		len += strlen(argv[i]) + 3;
	}

	if ((buf = malloc(len)) == NULL) {
		return (FAILURE);
	}

	ptr = buf;
	quote_next = B_FALSE;
	for (i = 1; i < optind; i++) {
		int arglen =  strlen(argv[i]) + 1;

		if (strncmp(argv[i], "-u", 2) == 0) {
			i++;
			continue;
		}

		if (quote_next) {
			(void) snprintf(ptr, len, "\"%s\" ", argv[i]);
			quote_next = B_FALSE;
			arglen += 2;
		} else {
			(void) snprintf(ptr, len, "%s ", argv[i]);
		}

		quote_next = (strncmp(argv[i], "-T", 2) == 0 ||
		    strncmp(argv[i], "-C", 2) == 0);

		ptr += arglen;
		len -= arglen;
	}
	KSSL_DEBUG("buf=%s\n", buf);

	instance_name = create_instance_name(address_port,
	    &inaddr_any_name, B_TRUE);
	if (instance_name == NULL || inaddr_any_name == NULL) {
		free(buf);
		return (FAILURE);
	}
	KSSL_DEBUG("instance_name=%s\n", instance_name);
	KSSL_DEBUG("inaddr_any_name=%s\n", inaddr_any_name);

	if (username == NULL)
		username = "******";
	status = create_service(instance_name, address_port,
	    buf, username, inaddr_any_name);
	if (status == INSTANCE_OTHER_EXISTS || status == INSTANCE_ANY_EXISTS) {
		if (status == INSTANCE_ANY_EXISTS &&
		    (strcmp(instance_name, inaddr_any_name) != SUCCESS)) {
			/*
			 * The following could result in a misconfiguration.
			 * Better bail out with an error.
			 */
			(void) fprintf(stderr,
			    gettext("Error: INADDR_ANY instance exists."
			    " Can not create a new instance %s.\n"),
			    instance_name);
			free(instance_name);
			free(inaddr_any_name);
			free(buf);
			return (status);
		}

		/*
		 * Delete the existing instance and create a new instance
		 * with the supplied arguments.
		 */
		KSSL_DEBUG("Deleting duplicate instance\n");
		if (delete_instance(instance_name) != SUCCESS) {
			(void) fprintf(stderr,
			    gettext(
			    "Error: Can not delete existing instance %s.\n"),
			    instance_name);
		} else {
			(void) fprintf(stdout, gettext(
			    "Note: reconfiguring the existing instance %s.\n"),
			    instance_name);
			status = create_service(instance_name, address_port,
			    buf, username, inaddr_any_name);
		}
	}

	free(instance_name);
	free(inaddr_any_name);
	free(buf);
	return (status);

err:
	usage_create(B_TRUE);
	return (ERROR_USAGE);
}
예제 #4
0
int
main( int argc, char *argv[] ) {
  command_options options;
  bool ret = parse_arguments( argc, argv, &options );
  if ( !ret ) {
    usage();
    exit( EXIT_FAILURE );
  }

  init_log( basename( argv[ 0 ] ), LOG_OUTPUT_STDOUT );
  init_vxlan_ctrl_client();

  uint8_t status = SUCCEEDED;
  ret = false;
  switch ( options.type ) {
    case ADD_INSTANCE_REQUEST:
    {
      ret = add_instance( options.vni, options.ip_addr, options.port, options.aging_time, &status );
    }
    break;

    case SET_INSTANCE_REQUEST:
    {
      ret = set_instance( options.vni, options.set_bitmap, options.ip_addr, options.port,
                          options.aging_time, &status );
    }
    break;

    case INACTIVATE_INSTANCE_REQUEST:
    {
      ret = inactivate_instance( options.vni, &status );
    }
    break;

    case ACTIVATE_INSTANCE_REQUEST:
    {
      ret = activate_instance( options.vni, &status );
    }
    break;

    case DEL_INSTANCE_REQUEST:
    {
      ret = delete_instance( options.vni, &status );
    }
    break;

    case SHOW_GLOBAL_REQUEST:
    {
      ret = show_global( options.set_bitmap, &status );
    }
    break;

    case LIST_INSTANCES_REQUEST:
    {
      ret = list_instances( options.vni, options.set_bitmap, &status );
    }
    break;

    case SHOW_FDB_REQUEST:
    {
      ret = show_fdb( options.vni, &status );
    }
    break;

    case ADD_FDB_ENTRY_REQUEST:
    {
      ret = add_fdb_entry( options.vni, options.eth_addr, options.ip_addr, options.aging_time, &status );
    }
    break;

    case DEL_FDB_ENTRY_REQUEST:
    {
      ret = delete_fdb_entry( options.vni, options.eth_addr, &status );
    }
    break;

    default:
    {
      printf( "Undefined command ( %#x ).\n", options.type );
      status = OTHER_ERROR;
      ret = false;
    }
    break;
  }

  if ( !ret ) {
    printf( "Failed to execute a command ( %u ).\n", status );
  }

  finalize_vxlan_ctrl_client();
  finalize_log();

  return status;
}
예제 #5
0
/*f c_memory::~c_memory
*/
c_memory::~c_memory()
{
    delete_instance();
}
예제 #6
0
int
do_delete(int argc, char *argv[])
{
	char c;
	int status, len, pcnt;
	char address_port[MAX_ADRPORT_LEN + 1];
	char *instance_name;

	if (argc < 3) {
		goto err;
	}

	argc -= 1;
	argv += 1;

	while ((c = getopt(argc, argv, "v")) != -1) {
		switch (c) {
		case 'v':
			verbose = B_TRUE;
			break;
		default:
			goto err;
		}
	}

	pcnt = argc - optind;
	if (pcnt == 1) {
		if (strlen(argv[optind]) < MAX_ADRPORT_LEN) {
			(void) strcpy(address_port, argv[optind]);
		} else {
			(void) fprintf(stderr, gettext(
			    "argument too long -- %s\n"),
			    argv[optind]);
			return (FAILURE);
		}
	} else if (pcnt == 2) {
		if ((len = strlen(argv[optind])) +
		    (strlen(argv[optind + 1])) < MAX_ADRPORT_LEN) {
			(void) strcpy(address_port, argv[optind]);
			address_port[len] = ' ';
			(void) strcpy(address_port + len + 1, argv[optind + 1]);
		} else {
			(void) fprintf(stderr, gettext(
			    "arguments too long -- %s %s\n"),
			    argv[optind], argv[optind + 1]);
			return (FAILURE);
		}
	} else {
		goto err;
	}

	instance_name = create_instance_name(address_port, NULL, B_FALSE);
	if (instance_name == NULL) {
		return (FAILURE);
	}

	KSSL_DEBUG("instance_name=%s\n", instance_name);
	status = delete_instance(instance_name);
	free(instance_name);

	return (status);

err:
	usage_delete(B_TRUE);
	return (ERROR_USAGE);
}
예제 #7
0
/*f c_uart_testbench::~c_uart_testbench
*/
c_uart_testbench::~c_uart_testbench()
{
    delete_instance();
}