Beispiel #1
0
int
main(int argc, char *argv[])
{
    int rank, size;
    MPI_Comm parent;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    /* Check to see if we *were* spawned -- because this is a test, we
       can only assume the existence of this one executable.  Hence, we
       both mpirun it and spawn it. */

    parent = MPI_COMM_NULL;
    MPI_Comm_get_parent(&parent);
    if (parent != MPI_COMM_NULL) {
        whoami = argv[1];
        do_target(argv, parent);
    } else {
        do_parent(argv, rank, size);
    }

    /* All done */
    MPI_Finalize();
    return 0;
}
Beispiel #2
0
/*************************
 * main
 */
int main(int argc, char **argv) {
	int opt, retVal;
	char consultantHost[BUF_SIZE];
	char targetHost[BUF_SIZE];
	int tunnelPort = 0, servicePort = 0, mode = 0xff;
	
	memset(consultantHost, 0, BUF_SIZE);
	memset(targetHost, 0, BUF_SIZE);
	strncpy(targetHost, "localhost", BUF_SIZE);
	
	// parse commandline
	while((opt = getopt(argc, argv, "m:t:s:h:H:e")) != -1) {
		switch(opt) {
			case 'm':
				mode = (int)strtol(optarg, NULL, 10);
				if(mode != 0 && mode != 1) {
					usage();
					exit(1);
				}
				break;
			case 't':
				tunnelPort = (int)strtol(optarg, NULL, 10);
				break;
			case 's':
				servicePort = (int)strtol(optarg, NULL, 10);
				break;
			case 'H':
				strncpy(targetHost, optarg, BUF_SIZE);
				break;
			case 'h':
				strncpy(consultantHost, optarg, BUF_SIZE);
				break;
			case 'e':
				pr00gie=strdup(CMD_SHELL);
				break;
			default:
				usage();
				exit(1);
				break;
		}
	}

	// Windows requires extra fiddling
	#ifdef __WIN32__
		WORD wVersionRequested;
		WSADATA wsaData;
		wVersionRequested = MAKEWORD( 1, 1 );
		WSAStartup( wVersionRequested, &wsaData );
	#endif
	
	// In consultant 
	if(mode == CONSULTANT_MODE) {
		if(!tunnelPort || !servicePort) {
			usage();
			exit(1);
		}
		retVal = do_consultant(tunnelPort, servicePort);
	} else if(mode == TARGET_MODE) {
		if(!(tunnelPort && (servicePort || pr00gie)) || !consultantHost[0] || (servicePort && pr00gie)) {
			usage();
			exit(1);
		}
		retVal = do_target(consultantHost, targetHost, tunnelPort, servicePort);
	} else {
		usage();
		exit(1);
	}
	
	exit(retVal);
}