/src/haproxy/include/haproxy/action.h
Line | Count | Source |
1 | | /* |
2 | | * include/haproxy/action.h |
3 | | * This file contains actions prototypes. |
4 | | * |
5 | | * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu |
6 | | * |
7 | | * This library is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation, version 2.1 |
10 | | * exclusively. |
11 | | * |
12 | | * This library is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with this library; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #ifndef _HAPROXY_ACTION_H |
23 | | #define _HAPROXY_ACTION_H |
24 | | |
25 | | #include <stdio.h> |
26 | | #include <haproxy/action-t.h> |
27 | | #include <haproxy/cfgparse.h> |
28 | | #include <haproxy/list.h> |
29 | | #include <haproxy/sample.h> |
30 | | |
31 | | struct resolv_requester; |
32 | | struct dns_counters; |
33 | | |
34 | | int act_resolution_cb(struct resolv_requester *requester, struct dns_counters *counters); |
35 | | int act_resolution_error_cb(struct resolv_requester *requester, int error_code); |
36 | | const char *action_suggest(const char *word, const struct list *keywords, const char **extra); |
37 | | void free_act_rule(struct act_rule *rule); |
38 | | void act_add_list(struct list *head, struct action_kw_list *kw_list); |
39 | | |
40 | | static inline struct action_kw *action_lookup(struct list *keywords, const char *kw) |
41 | 0 | { |
42 | 0 | struct action_kw_list *kw_list; |
43 | 0 | struct action_kw *best = NULL; |
44 | 0 | int len, bestlen = 0; |
45 | 0 | int i; |
46 | |
|
47 | 0 | if (LIST_ISEMPTY(keywords)) |
48 | 0 | return NULL; |
49 | | |
50 | 0 | list_for_each_entry(kw_list, keywords, list) { |
51 | 0 | for (i = 0; kw_list->kw[i].kw != NULL; i++) { |
52 | 0 | if ((kw_list->kw[i].flags & KWF_MATCH_PREFIX) && |
53 | 0 | (len = strlen(kw_list->kw[i].kw)) > bestlen && |
54 | 0 | strncmp(kw, kw_list->kw[i].kw, len) == 0) { |
55 | 0 | if (len > bestlen) { |
56 | 0 | bestlen = len; |
57 | 0 | best = &kw_list->kw[i]; |
58 | 0 | } |
59 | 0 | } |
60 | 0 | if (strcmp(kw, kw_list->kw[i].kw) == 0) |
61 | 0 | return &kw_list->kw[i]; |
62 | 0 | } |
63 | 0 | } |
64 | 0 | return best; |
65 | 0 | } Unexecuted instantiation: haproxy.c:action_lookup Unexecuted instantiation: log.c:action_lookup Unexecuted instantiation: proxy.c:action_lookup Unexecuted instantiation: resolvers.c:action_lookup Unexecuted instantiation: server.c:action_lookup Unexecuted instantiation: stream.c:action_lookup Unexecuted instantiation: tcp_rules.c:action_lookup Unexecuted instantiation: tcpcheck.c:action_lookup Unexecuted instantiation: uri_auth.c:action_lookup Unexecuted instantiation: vars.c:action_lookup Unexecuted instantiation: action.c:action_lookup Unexecuted instantiation: cfgparse-listen.c:action_lookup Unexecuted instantiation: cfgparse.c:action_lookup Unexecuted instantiation: check.c:action_lookup Unexecuted instantiation: connection.c:action_lookup Unexecuted instantiation: dns.c:action_lookup Unexecuted instantiation: http_rules.c:action_lookup |
66 | | |
67 | | static inline void action_build_list(struct list *keywords, |
68 | | struct buffer *chk) |
69 | 0 | { |
70 | 0 | struct action_kw_list *kw_list; |
71 | 0 | int i; |
72 | 0 | char *p; |
73 | 0 | char *end; |
74 | 0 | int l; |
75 | |
|
76 | 0 | p = chk->area; |
77 | 0 | end = p + chk->size - 1; |
78 | 0 | list_for_each_entry(kw_list, keywords, list) { |
79 | 0 | for (i = 0; kw_list->kw[i].kw != NULL; i++) { |
80 | 0 | l = snprintf(p, end - p, "'%s%s', ", kw_list->kw[i].kw, (kw_list->kw[i].flags & KWF_MATCH_PREFIX) ? "(*)" : ""); |
81 | 0 | if (l > end - p) |
82 | 0 | continue; |
83 | 0 | p += l; |
84 | 0 | } |
85 | 0 | } |
86 | 0 | if (p > chk->area) |
87 | 0 | *(p-2) = '\0'; |
88 | 0 | else |
89 | 0 | *p = '\0'; |
90 | 0 | } Unexecuted instantiation: haproxy.c:action_build_list Unexecuted instantiation: log.c:action_build_list Unexecuted instantiation: proxy.c:action_build_list Unexecuted instantiation: resolvers.c:action_build_list Unexecuted instantiation: server.c:action_build_list Unexecuted instantiation: stream.c:action_build_list Unexecuted instantiation: tcp_rules.c:action_build_list Unexecuted instantiation: tcpcheck.c:action_build_list Unexecuted instantiation: uri_auth.c:action_build_list Unexecuted instantiation: vars.c:action_build_list Unexecuted instantiation: action.c:action_build_list Unexecuted instantiation: cfgparse-listen.c:action_build_list Unexecuted instantiation: cfgparse.c:action_build_list Unexecuted instantiation: check.c:action_build_list Unexecuted instantiation: connection.c:action_build_list Unexecuted instantiation: dns.c:action_build_list Unexecuted instantiation: http_rules.c:action_build_list |
91 | | |
92 | | /* Check an action ruleset validity. It returns the number of error encountered |
93 | | * and err_code is updated if a warning is emitted. |
94 | | */ |
95 | | int check_action_rules(struct list *rules, struct proxy *px, int *err_code); |
96 | | |
97 | | /* Find and check the target table used by an action track-sc*. This |
98 | | * function should be called during the configuration validity check. |
99 | | * |
100 | | * The function returns 1 in success case, otherwise, it returns 0 and err is |
101 | | * filled. |
102 | | */ |
103 | | int check_trk_action(struct act_rule *rule, struct proxy *px, char **err); |
104 | | |
105 | | /* check a capture rule. This function should be called during the configuration |
106 | | * validity check. |
107 | | * |
108 | | * The function returns 1 in success case, otherwise, it returns 0 and err is |
109 | | * filled. |
110 | | */ |
111 | | int check_capture(struct act_rule *rule, struct proxy *px, char **err); |
112 | | |
113 | | int cfg_parse_rule_set_timeout(const char **args, int idx, struct act_rule *rule, |
114 | | struct proxy *px, char **err); |
115 | | |
116 | | static inline void release_timeout_action(struct act_rule *rule) |
117 | 0 | { |
118 | 0 | release_sample_expr(rule->arg.timeout.expr); |
119 | 0 | } Unexecuted instantiation: haproxy.c:release_timeout_action Unexecuted instantiation: log.c:release_timeout_action Unexecuted instantiation: proxy.c:release_timeout_action Unexecuted instantiation: resolvers.c:release_timeout_action Unexecuted instantiation: server.c:release_timeout_action Unexecuted instantiation: stream.c:release_timeout_action Unexecuted instantiation: tcp_rules.c:release_timeout_action Unexecuted instantiation: tcpcheck.c:release_timeout_action Unexecuted instantiation: uri_auth.c:release_timeout_action Unexecuted instantiation: vars.c:release_timeout_action Unexecuted instantiation: action.c:release_timeout_action Unexecuted instantiation: cfgparse-listen.c:release_timeout_action Unexecuted instantiation: cfgparse.c:release_timeout_action Unexecuted instantiation: check.c:release_timeout_action Unexecuted instantiation: connection.c:release_timeout_action Unexecuted instantiation: dns.c:release_timeout_action Unexecuted instantiation: http_rules.c:release_timeout_action |
120 | | |
121 | | /* |
122 | | * Release expr_int rule argument when action is no longer used |
123 | | */ |
124 | | static inline void release_expr_int_action(struct act_rule *rule) |
125 | 0 | { |
126 | 0 | release_sample_expr(rule->arg.expr_int.expr); |
127 | 0 | } Unexecuted instantiation: haproxy.c:release_expr_int_action Unexecuted instantiation: log.c:release_expr_int_action Unexecuted instantiation: proxy.c:release_expr_int_action Unexecuted instantiation: resolvers.c:release_expr_int_action Unexecuted instantiation: server.c:release_expr_int_action Unexecuted instantiation: stream.c:release_expr_int_action Unexecuted instantiation: tcp_rules.c:release_expr_int_action Unexecuted instantiation: tcpcheck.c:release_expr_int_action Unexecuted instantiation: uri_auth.c:release_expr_int_action Unexecuted instantiation: vars.c:release_expr_int_action Unexecuted instantiation: action.c:release_expr_int_action Unexecuted instantiation: cfgparse-listen.c:release_expr_int_action Unexecuted instantiation: cfgparse.c:release_expr_int_action Unexecuted instantiation: check.c:release_expr_int_action Unexecuted instantiation: connection.c:release_expr_int_action Unexecuted instantiation: dns.c:release_expr_int_action Unexecuted instantiation: http_rules.c:release_expr_int_action |
128 | | |
129 | | struct act_rule *new_act_rule(enum act_from from, const char *file, int linenum); |
130 | | void free_act_rules(struct list *rules); |
131 | | void dump_act_rules(const struct list *rules, const char *pfx); |
132 | | |
133 | | #endif /* _HAPROXY_ACTION_H */ |