Esempio n. 1
0
int
main(int argc, char *argv[])
{
    char opt;
    int ret;
    int option_index;

    while ((opt = getopt_long(argc, argv, "d:f:i:lrs",
                    long_options, &option_index)) >= 0) {
        switch (opt) {
        case 'f':
        case 'd':
        case 'i':
            flow_cmd = opt;
            flow_index = strtoul(optarg, NULL, 0);
            break;

        case 'l':
            list = 1;
            break;

        case 'r':
            rate = 1;
            break;
        case 's':
            stats = 1;
            break;
        case 0:
            parse_long_opts(option_index, optarg);
            break;

        default:
            Usage();
        }
    }

    validate_options();

    ret = flow_table_setup();
    if (ret < 0)
        return ret;

    ret = flow_table_get();
    if (ret < 0)
        return ret;

    if (list)
        flow_list();
    else if (rate)
        flow_rate();
    else if (stats)
        flow_stats();
    else
        flow_validate(flow_index, flow_cmd);

    return 0;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
   int ret;
    int opt;
    int ind;

    cl = nl_register_client();
    if (!cl) {
        exit(1);
    }

    ret = nl_socket(cl, NETLINK_GENERIC);    
    if (ret <= 0) {
       exit(1);
    }

    if (vrouter_get_family_id(cl) <= 0) {
        return 0;
    }

    while ((opt = getopt_long(argc, argv, "",
                                        long_options, &ind)) >= 0) {
        switch(opt) {
            case 0:
                parse_long_opts(ind, optarg);
                break;

            default:
                usage();
        }

    }

    validate_options();

    vr_nh_op(command, type, nh_id, if_id, vrf_id, dst_mac,
            src_mac, sip, dip, flags);


    return 0;
}
int
main(int argc, char *argv[])
{
    char opt;
    int ret, option_index;

    while (((opt = getopt_long(argc, argv, "",
                        long_options, &option_index)) >= 0)) {
        switch (opt) {
        case 0:
            parse_long_opts(option_index, optarg);
            break;

        default:
            Usage();
        }
    }

    validate_options();

    cl = nl_register_client();
    if (!cl) {
        exit(1);
    }

    ret = nl_socket(cl, NETLINK_GENERIC);    
    if (ret <= 0) {
       exit(1);
    }

    if (vrouter_get_family_id(cl) <= 0) {
        return -1;
    }

    stats_req.vsr_marker = -1;
    vr_stats_op();

    return 0;
}
Esempio n. 4
0
int
main(int argc, char *argv[])
{
    int ret, opt, option_index;
    vrouter_ops req;

    parse_ini_file();
    platform = get_platform();

    if (argc == 1) {
        Usage();
    }

    while ((opt = getopt_long(argc, argv, "",
                    long_options, &option_index)) >= 0) {
        switch (opt) {
        case 0:
            parse_long_opts(option_index, optarg);
            break;

        case '?':
        default:
            Usage();
            break;
        }
    }


    validate_options();

    cl = vr_get_nl_client(VR_NETLINK_PROTO_DEFAULT);
    if (!cl) {
        exit(1);
    }

    vr_vrouter_op(cl);

    return 0;
}
Esempio n. 5
0
int
main(int argc, char *argv[])
{
    int ret, opt, option_index;
    /* 
     * the proto of the socket changes based on whether we are creating an
     * interface in linux or doing an operation in vrouter
     */
    unsigned int sock_proto = NETLINK_GENERIC;

    while ((opt = getopt_long(argc, argv, "ba:c:d:g:klm:t:v:p:",
                    long_options, &option_index)) >= 0) {
            switch (opt) {
            case 'a':
                add_set = 1;
                parse_long_opts(ADD_OPT_INDEX, optarg);
                break;

            case 'c':
                create_set = 1;
                parse_long_opts(CREATE_OPT_INDEX, optarg);
                break;

            case 'd':
                delete_set = 1;
                parse_long_opts(DELETE_OPT_INDEX, optarg);
                break;

            case 'g':
                get_set = 1;
                parse_long_opts(GET_OPT_INDEX, optarg);
                break;

            case 'k':
                parse_long_opts(KINDEX_OPT_INDEX, optarg);
                kindex_set = 1;
                break;

            case 'l':
            case 'b':
                list_set = 1;
                parse_long_opts(LIST_OPT_INDEX, NULL);
                break;

            case 'm':
                mac_set = 1;
                parse_long_opts(MAC_OPT_INDEX, optarg);
                break;

            case 'v':
                vrf_set = 1;
                parse_long_opts(VRF_OPT_INDEX, optarg);
                break;

            case 'p':  
                policy_set = 1;
                parse_long_opts(POLICY_OPT_INDEX, NULL);
                break;

            case 't':
                type_set = 1;
                parse_long_opts(TYPE_OPT_INDEX, optarg);
                break;

            case 0:
                parse_long_opts(option_index, optarg);
                break;

            case '?':
            default:
                Usage();
            }
    }

    validate_options();

    cl = nl_register_client();
    if (!cl)
        exit(-ENOMEM);

    if (create_set)
        sock_proto = NETLINK_ROUTE;

    ret = nl_socket(cl, sock_proto);
    if (ret <= 0)
       exit(ret);

    if (sock_proto == NETLINK_GENERIC)
        if (vrouter_get_family_id(cl) <= 0)
            return -1;

    if (add_set) {
        /*
         * for addition, we need to see whether the interface already
         * exists in vrouter or not. so, get can return error if the
         * interface does not exist in vrouter
         */
        ignore_error = true;
        vr_intf_op(SANDESH_OP_GET);
        ignore_error = false;
    }

    vr_intf_op(vr_op);

    return 0;
}
Esempio n. 6
0
int main(int argc, char *argv[])
{
    int ret, opt, option_index;

    while ((opt = getopt_long(argc, argv, "bcdgn:l:",
                    long_options, &option_index)) >= 0) {
            switch (opt) {
            case 'c':
                if (vxlan_op >= 0)
                    Usage();

                vxlan_op = SANDESH_OP_ADD;
                create_set = 1;
                break;

            case 'd':
                if (vxlan_op >= 0)
                    Usage();

                vxlan_op = SANDESH_OP_DELETE;
                delete_set = 1;
                break;

            case 'g':
                if (vxlan_op >= 0)
                    Usage();

                vxlan_op = SANDESH_OP_GET;
                get_set = 1;
                break;

            case 'b':
                if (vxlan_op >= 0)
                    Usage();

                vxlan_op = SANDESH_OP_DUMP;
                dump_set = 1;
                break;

            case 'n':
                vxlan_nh = atoi(optarg);
                nh_set = 1;
                break;

            case 'l':
                vxlan_vnid = strtoul(optarg, NULL, 10);
                vnid_set = 1;
                break;

            case 0:
                parse_long_opts(option_index, optarg);
                break;

            case '?':
            default:
                Usage();
        }
    }

    validate_options();

    if ((vxlan_op == SANDESH_OP_DUMP) ||
            (vxlan_op == SANDESH_OP_GET)) {
        printf("VXLAN Table\n\n");
        printf(" VNID    NextHop\n");
        printf("----------------\n");
    }

    cl = vr_get_nl_client(VR_NETLINK_PROTO_DEFAULT);
    if (!cl) {
        exit(1);
    }

    vr_vxlan_op(cl);

    return 0;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
    int ret, opt, option_index;

    mirror_fill_nl_callbacks();

    while ((opt = getopt_long(argc, argv, "bcdgn:m:",
                    long_options, &option_index)) >= 0) {
            switch (opt) {
            case 'c':
                if (mirror_op >= 0)
                    Usage();

                create_set = 1;
                mirror_op = SANDESH_OP_ADD;
                break;

            case 'd':
                if (mirror_op >= 0)
                    Usage();

                delete_set = 1;
                mirror_op = SANDESH_OP_DEL;
                break;

            case 'g':
                if (mirror_op >= 0)
                    Usage();

                get_set = 1;
                mirror_op = SANDESH_OP_GET;
                break;

            case 'b':
                if (mirror_op >= 0)
                    Usage();

                dump_set = 1;
                mirror_op = SANDESH_OP_DUMP;
                break;

            case 'n':
                mirror_nh = atoi(optarg);
                nh_set = 1;
                break;

            case 'm':
                mirror_index = atoi(optarg);
                mirror_set = 1;
                break;

            case 0:
                parse_long_opts(option_index, optarg);
                break;

            case '?':
            default:
                Usage();
                break;
        }
    }

    validate_options();

    if ((mirror_op == SANDESH_OP_DUMP) ||
            (mirror_op == SANDESH_OP_GET)) {
        printf("Mirror Table\n\n");
        printf("Flags:D=Dynamic Mirroring, Hw=NIC Assisted Mirroring \n\n");
        printf("Index    NextHop    Flags       VNI    Vlan\n");
        printf("------------------------------------------------\n");
    }

    cl = vr_get_nl_client(VR_NETLINK_PROTO_DEFAULT);
    if (!cl) {
        exit(1);
    }

    vr_mirror_op(cl);

    return 0;
}