tc-api.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * netlink-private/route/tc-api.h Traffic Control API
  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) 2011-2013 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #ifndef NETLINK_TC_API_H_
  12. #define NETLINK_TC_API_H_
  13. #include <netlink/netlink.h>
  14. #include <netlink/msg.h>
  15. #include <netlink/route/tc.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * Traffic control object operations
  21. * @ingroup tc
  22. *
  23. * This structure holds function pointers and settings implementing
  24. * the features of each traffic control object implementation.
  25. */
  26. struct rtnl_tc_ops
  27. {
  28. /**
  29. * Name of traffic control module
  30. */
  31. char *to_kind;
  32. /**
  33. * Type of traffic control object
  34. */
  35. enum rtnl_tc_type to_type;
  36. /**
  37. * Size of private data
  38. */
  39. size_t to_size;
  40. /**
  41. * Dump callbacks
  42. */
  43. void (*to_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, void *,
  44. struct nl_dump_params *);
  45. /**
  46. * Used to fill the contents of TCA_OPTIONS
  47. */
  48. int (*to_msg_fill)(struct rtnl_tc *, void *, struct nl_msg *);
  49. /**
  50. * Uesd to to fill tc related messages, unlike with to_msg_fill,
  51. * the contents is not encapsulated with a TCA_OPTIONS nested
  52. * attribute.
  53. */
  54. int (*to_msg_fill_raw)(struct rtnl_tc *, void *, struct nl_msg *);
  55. /**
  56. * TCA_OPTIONS message parser
  57. */
  58. int (*to_msg_parser)(struct rtnl_tc *, void *);
  59. /**
  60. * Called before a tc object is destroyed
  61. */
  62. void (*to_free_data)(struct rtnl_tc *, void *);
  63. /**
  64. * Called whenever a classifier object needs to be cloned
  65. */
  66. int (*to_clone)(void *, void *);
  67. /**
  68. * Internal, don't touch
  69. */
  70. struct nl_list_head to_list;
  71. };
  72. struct rtnl_tc_type_ops
  73. {
  74. enum rtnl_tc_type tt_type;
  75. char *tt_dump_prefix;
  76. /**
  77. * Dump callbacks
  78. */
  79. void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *,
  80. struct nl_dump_params *);
  81. };
  82. extern int rtnl_tc_msg_parse(struct nlmsghdr *,
  83. struct rtnl_tc *);
  84. extern int rtnl_tc_msg_build(struct rtnl_tc *, int,
  85. int, struct nl_msg **);
  86. extern void rtnl_tc_free_data(struct nl_object *);
  87. extern int rtnl_tc_clone(struct nl_object *,
  88. struct nl_object *);
  89. extern void rtnl_tc_dump_line(struct nl_object *,
  90. struct nl_dump_params *);
  91. extern void rtnl_tc_dump_details(struct nl_object *,
  92. struct nl_dump_params *);
  93. extern void rtnl_tc_dump_stats(struct nl_object *,
  94. struct nl_dump_params *);
  95. extern int rtnl_tc_compare(struct nl_object *,
  96. struct nl_object *,
  97. uint32_t, int);
  98. extern void * rtnl_tc_data(struct rtnl_tc *);
  99. extern void * rtnl_tc_data_check(struct rtnl_tc *,
  100. struct rtnl_tc_ops *);
  101. extern struct rtnl_tc_ops * rtnl_tc_lookup_ops(enum rtnl_tc_type,
  102. const char *);
  103. extern struct rtnl_tc_ops * rtnl_tc_get_ops(struct rtnl_tc *);
  104. extern int rtnl_tc_register(struct rtnl_tc_ops *);
  105. extern void rtnl_tc_unregister(struct rtnl_tc_ops *);
  106. extern void rtnl_tc_type_register(struct rtnl_tc_type_ops *);
  107. extern void rtnl_tc_type_unregister(struct rtnl_tc_type_ops *);
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif