Example #1
0
File: cli.c Project: Juankc125/ivs
void
ivs_cli_init(const char *path)
{
    ucli_init();

    unlink(path);

    listen_socket = socket(AF_UNIX, SOCK_STREAM, 0);
    if (listen_socket < 0) {
        perror("socket (CLI)");
        abort();
    }

    struct sockaddr_un saddr;
    memset(&saddr, 0, sizeof(saddr));
    saddr.sun_family = AF_UNIX;
    strcpy(saddr.sun_path, path);

    if (bind(listen_socket, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
        perror("bind (CLI)");
        abort();
    }

    if (listen(listen_socket, LISTEN_BACKLOG) < 0) {
        perror("listen (CLI)");
        abort();
    }

    indigo_error_t rv = ind_soc_socket_register(listen_socket, listen_callback, NULL);
    if (rv < 0) {
        AIM_DIE("Failed to register CLI socket: %s", indigo_strerror(rv));
    }
}
Example #2
0
int main(int argc, char* argv[])
{
    ucli_t* uopts; 

    AIM_REFERENCE(argc); 

    ucli_init(); 
    ucli_module_init(&options_module); 
    uopts = ucli_create(NULL, &options_module, NULL); 
    ucli_dispatch_argv(uopts, &aim_pvs_stdout, argv+1); 
    ucli_destroy(uopts); 
    ucli_denit();
    return 0;
}
Example #3
0
int aim_main(int argc, char* argv[])
{
    ucli_t* uc = NULL; 
    int rv; 

    ucli_init();
    uc = ucli_create("fme", fme_utm_create(), NULL); 

    if(argc == 1 || !strcmp(argv[1], "tests")) {
        ucli_flags_set(uc, UCLI_F_DISPATCH_BLOCK_STATUS | UCLI_F_DISPATCH_ECHO_FAIL); 
        rv = ucli_dispatch_blocks(uc, &aim_pvs_stdout, 
                                  fme_utests, (argv[1]) ? argv[2] : NULL);
    }
    else if (!strcmp(argv[1], "cli")) {
        rv = ucli_run(uc, "fme"); 
    }
    else {
        rv = ucli_dispatch_argv(uc, &aim_pvs_stdout, argv+1); 
    }
    ucli_destroy(uc); 
    ucli_denit(); 
    return rv; 
}
Example #4
0
int aim_main(int argc, char* argv[])
{
    signal(SIGINT, __sighandler);

    if(argc == 1 ||
       !strcmp(argv[1], "help") ||
       !strcmp(argv[1], "-h") ||
       !strcmp(argv[1], "--help")) {
        const char* usage =
            "Usage:\n"
            "    vpitool -dump <vpiSpec>\n"
            "        Dump all packets on the given VPI\n"
            "\n"
            "    vpitool -bridge <vpiSec1> <vpiSpec2>\n"
            "        Forward all packets between two VPI interfaces.\n"
            "\n"
            "    vpitool -send <vpiSpec> <packetdata>\n"
            "        Send a single packet on the given VPI.\n"
            "\n"
            "    vpitool -echo <vpiSpec> <packetdata>\n"
            "        Send a VPI echo request.\n"
            "\n"
            "    vpitool -sendrecv <vpiSpec> <packetdata>\n"
            "        Send a single packet on the given VPI and wait for a response.\n"
            "\n"
            "    vpitool help\n"
            "        This help message.\n"
            "\n"
            "EXAMPLES:\n"
            "\n"
            "    # Dump all packets on veth0:\n"
            "    > vpitool -dump \"veth|veth0\"\n"
            "\n"
            "\n"
            "    # Bridge all packets between veth1 and veth2:\n"
            "    > vpitool -bridge \"veth|veth1\" \"veth|veth2\"\n"
            "\n"
            "    # Send a single packet to veth0\n"
            "    > vpitool -send \"veth|veth0\" {FFFFFFFFFFFF}{000000000001}{0800}{AABBCCDD}\n"
            "\n"
            "    # Send and receive a packet between two VPIs over UDP:\n"
            "    > vpitool -dump \"udp|bind|6000|6001\"\n"
            "    > vpitool -send \"udp|bind|6001|6000\" {FFFFFFFFFFFF}{000000000001}{0800}{AABBCCDD}\n"
            "\n"
            "    # A loopback server on port 8000:\n"
            "    > vpitool -bridge \"udp|recv:8000\" \"loop\"\n"
            "    # The corresponding client:\n"
            "    > vpitool -sendrecv \"*s|udp|send:8000|recv:5566\" {DEADBEEFCAFE} \n"
            "\n";

        printf("%s", usage);
        return 0;
    }

    {
        ucli_t* u;
        ucli_init();
        ucli_module_init(&vt_module);
        u = ucli_create(NULL, &vt_module, NULL);
        ucli_dispatch_argv(u, &aim_pvs_stdout, argv+1);
    }

    if(vt_ctrl__.bridges > 0) {
        for(;;) {
            sleep(1000);
        }
    }

    return 0;
}