libnl
3.2.3
|
00001 00002 /* 00003 * src/lib/pfifo.c pfifo module for CLI lib 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation version 2.1 00008 * of the License. 00009 * 00010 * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> 00011 */ 00012 00013 #include <netlink/cli/utils.h> 00014 #include <netlink/cli/tc.h> 00015 #include <netlink/route/qdisc/fifo.h> 00016 00017 static void print_usage(void) 00018 { 00019 printf( 00020 "Usage: nl-qdisc-add [...] pfifo [OPTIONS]...\n" 00021 "\n" 00022 "OPTIONS\n" 00023 " --help Show this help text.\n" 00024 " --limit=LIMIT Maximum queue length in number of packets.\n" 00025 "\n" 00026 "EXAMPLE" 00027 " # Attach pfifo with a 32 packet limit to eth1\n" 00028 " nl-qdisc-add --dev=eth1 --parent=root pfifo --limit=32\n"); 00029 } 00030 00031 static void pfifo_parse_argv(struct rtnl_tc *tc, int argc, char **argv) 00032 { 00033 struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc; 00034 00035 for (;;) { 00036 int c, optidx = 0; 00037 enum { 00038 ARG_LIMIT = 257, 00039 }; 00040 static struct option long_opts[] = { 00041 { "help", 0, 0, 'h' }, 00042 { "limit", 1, 0, ARG_LIMIT }, 00043 { 0, 0, 0, 0 } 00044 }; 00045 00046 c = getopt_long(argc, argv, "h", long_opts, &optidx); 00047 if (c == -1) 00048 break; 00049 00050 switch (c) { 00051 case 'h': 00052 print_usage(); 00053 return; 00054 00055 case ARG_LIMIT: 00056 rtnl_qdisc_fifo_set_limit(qdisc, nl_cli_parse_u32(optarg)); 00057 break; 00058 } 00059 } 00060 } 00061 00062 static struct nl_cli_tc_module pfifo_module = 00063 { 00064 .tm_name = "pfifo", 00065 .tm_type = RTNL_TC_TYPE_QDISC, 00066 .tm_parse_argv = pfifo_parse_argv, 00067 }; 00068 00069 static void __init pfifo_init(void) 00070 { 00071 nl_cli_tc_register(&pfifo_module); 00072 } 00073 00074 static void __exit pfifo_exit(void) 00075 { 00076 nl_cli_tc_unregister(&pfifo_module); 00077 }