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-api.h>
17
#include <netlink/route/classifier.h>
18
#include <netlink/route/cls/police.h>
25
static const struct trans_tbl police_types[] = {
26
__ADD(TC_POLICE_UNSPEC,unspec)
27
__ADD(TC_POLICE_OK,ok)
28
__ADD(TC_POLICE_RECLASSIFY,reclassify)
29
__ADD(TC_POLICE_SHOT,shot)
31
__ADD(TC_POLICE_PIPE,pipe)
36
* Transform a policer type number into a character string (Reentrant).
37
* @arg type policer type
38
* @arg buf destination buffer
39
* @arg len buffer length
41
* Transforms a policer type number into a character string and stores
42
* it in the provided buffer.
44
* @return The destination buffer or the type encoded in hex if no match was found.
46
char * nl_police2str(int type, char *buf, size_t len)
48
return __type2str(type, buf, len, police_types,
49
ARRAY_SIZE(police_types));
53
* Transform a character string into a policer type number
54
* @arg name policer type name
56
* Transform the provided character string specifying a policer
57
* type into the corresponding numeric value
59
* @return Policer type number or a negative value.
61
int nl_str2police(const char *name)
63
return __str2type(name, police_types, ARRAY_SIZE(police_types));