2 * lib/route/cls/police.c Policer
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
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
12 #include <netlink-local.h>
13 #include <netlink-tc.h>
14 #include <netlink/netlink.h>
15 #include <netlink/utils.h>
16 #include <netlink/route/tc.h>
17 #include <netlink/route/classifier.h>
18 #include <netlink/route/classifier-modules.h>
19 #include <netlink/route/cls/police.h>
26 static struct trans_tbl police_types[] = {
27 __ADD(TC_POLICE_UNSPEC,unspec)
28 __ADD(TC_POLICE_OK,ok)
29 __ADD(TC_POLICE_RECLASSIFY,reclassify)
30 __ADD(TC_POLICE_SHOT,shot)
32 __ADD(TC_POLICE_PIPE,pipe)
37 * Transform a policer type number into a character string (Reentrant).
38 * @arg type policer type
39 * @arg buf destination buffer
40 * @arg len buffer length
42 * Transforms a policer type number into a character string and stores
43 * it in the provided buffer.
45 * @return The destination buffer or the type encoded in hex if no match was found.
47 char * nl_police2str(int type, char *buf, size_t len)
49 return __type2str(type, buf, len, police_types,
50 ARRAY_SIZE(police_types));
54 * Transform a character string into a policer type number
55 * @arg name policer type name
57 * Transform the provided character string specifying a policer
58 * type into the corresponding numeric value
60 * @return Policer type number or a negative value.
62 int nl_str2police(const char *name)
64 return __str2type(name, police_types, ARRAY_SIZE(police_types));