ingress.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * src/lib/ingress.c ingress module for CLI lib
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
  10. */
  11. #include <netlink/cli/utils.h>
  12. #include <netlink/cli/tc.h>
  13. static void print_usage(void)
  14. {
  15. printf(
  16. "Usage: nl-qdisc-add [...] ingress\n"
  17. "\n"
  18. "OPTIONS\n"
  19. " --help Show this help text.\n"
  20. "\n"
  21. "EXAMPLE"
  22. " # Attach ingress to eth1\n"
  23. " nl-qdisc-add --dev=eth1 --parent=root ingress\n");
  24. }
  25. static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
  26. {
  27. for (;;) {
  28. int c, optidx = 0;
  29. static struct option long_opts[] = {
  30. { "help", 0, 0, 'h' },
  31. { 0, 0, 0, 0 }
  32. };
  33. c = getopt_long(argc, argv, "h", long_opts, &optidx);
  34. if (c == -1)
  35. break;
  36. switch (c) {
  37. case 'h':
  38. print_usage();
  39. return;
  40. }
  41. }
  42. }
  43. static struct nl_cli_tc_module ingress_module =
  44. {
  45. .tm_name = "ingress",
  46. .tm_type = RTNL_TC_TYPE_QDISC,
  47. .tm_parse_argv = ingress_parse_argv,
  48. };
  49. static void __init ingress_init(void)
  50. {
  51. nl_cli_tc_register(&ingress_module);
  52. }
  53. static void __exit ingress_exit(void)
  54. {
  55. nl_cli_tc_unregister(&ingress_module);
  56. }