2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "stc-manager-gdbus.h"
18 #include "helper-iptables.h"
20 #define STC_IPTABLES_DBUS_SERVICE "net.stc.iptables"
21 #define STC_IPTABLES_DBUS_RULE_INTERFACE STC_IPTABLES_DBUS_SERVICE ".rule"
22 #define STC_IPTABLES_DBUS_CHAIN_INTERFACE STC_IPTABLES_DBUS_SERVICE ".chain"
23 #define STC_IPTABLES_DBUS_RULE_PATH "/net/stc/iptables/rule"
24 #define STC_IPTABLES_DBUS_CHAIN_PATH "/net/stc/iptables/chain"
25 #define STC_IPTABLES_DBUS_METHOD_IPT_ADD_CHAIN "IptAddChain"
26 #define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_CHAIN "IptRemoveChain"
27 #define STC_IPTABLES_DBUS_METHOD_IPT_FLUSH_CHAIN "IptFlushChain"
28 #define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_CHAIN "Ip6tAddChain"
29 #define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_CHAIN "Ip6tRemoveChain"
30 #define STC_IPTABLES_DBUS_METHOD_IP6T_FLUSH_CHAIN "Ip6tFlushChain"
31 #define STC_IPTABLES_DBUS_METHOD_IPT_ADD_RULE "IptAddRule"
32 #define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_RULE "IptRemoveRule"
33 #define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_RULE "Ip6tAddRule"
34 #define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_RULE "Ip6tRemoveRule"
35 #define STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST "IptAddList"
36 #define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST "IptRemoveList"
37 #define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST "Ip6tAddList"
38 #define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST "Ip6tRemoveList"
40 #define RULE_CHAIN "chain"
41 #define RULE_DIRECTION "direction"
42 #define RULE_IFNAME "ifname"
43 #define RULE_CGROUP "cgroup"
44 #define RULE_NFACCT "nfacct"
45 #define RULE_TARGET "target"
46 #define RULE_SIPTYPE "s_ip_type"
47 #define RULE_SIP1 "s_ip1"
48 #define RULE_SIP2 "s_ip2"
49 #define RULE_DIPTYPE "d_ip_type"
50 #define RULE_DIP1 "d_ip1"
51 #define RULE_DIP2 "d_ip2"
53 static void __add_rule_info_to_builder(GVariantBuilder *builder,
54 iptables_rule_s *rule)
56 if (builder == NULL || rule == NULL)
57 return; //LCOV_EXCL_LINE
59 g_variant_builder_add(builder, "{sv}", RULE_CHAIN,
60 g_variant_new_string(rule->chain));
62 g_variant_builder_add(builder, "{sv}", RULE_DIRECTION,
63 g_variant_new_uint16(rule->direction));
66 g_variant_builder_add(builder, "{sv}", RULE_IFNAME,
67 g_variant_new_string(rule->ifname));
69 if (rule->classid > 0)
70 g_variant_builder_add(builder, "{sv}", RULE_CGROUP,
71 g_variant_new_uint32(rule->classid));
73 if (rule->nfacct_name)
74 g_variant_builder_add(builder, "{sv}", RULE_NFACCT,
75 g_variant_new_string(rule->nfacct_name));
78 g_variant_builder_add(builder, "{sv}", RULE_TARGET,
79 g_variant_new_string(rule->target));
81 g_variant_builder_add(builder, "{sv}", RULE_SIPTYPE,
82 g_variant_new_uint16(rule->s_iprange_type));
84 g_variant_builder_add(builder, "{sv}", RULE_DIPTYPE,
85 g_variant_new_uint16(rule->d_iprange_type));
87 if (rule->s_ip1.s_addr)
88 g_variant_builder_add(builder, "{sv}", RULE_SIP1,
89 g_variant_new_uint32(rule->s_ip1.s_addr));
91 if (rule->s_ip2.s_addr)
92 g_variant_builder_add(builder, "{sv}", RULE_SIP2,
93 g_variant_new_uint32(rule->s_ip2.s_addr));
95 if (rule->d_ip1.s_addr)
96 g_variant_builder_add(builder, "{sv}", RULE_DIP1,
97 g_variant_new_uint32(rule->d_ip1.s_addr));
99 if (rule->d_ip2.s_addr)
100 g_variant_builder_add(builder, "{sv}", RULE_DIP2,
101 g_variant_new_uint32(rule->d_ip2.s_addr));
104 static void __add_rule_reply(
105 GObject *source_object, GAsyncResult *res, gpointer user_data)
107 GDBusConnection *conn = NULL;
108 GVariant *dbus_data = NULL;
109 GError *dbus_error = NULL;
111 char *nfacct_name = user_data;
113 conn = G_DBUS_CONNECTION(source_object);
114 dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
115 if (dbus_error != NULL) {
116 STC_LOGE("Dbus reply error [%s]", dbus_error->message);
117 g_error_free(dbus_error);
119 g_variant_get(dbus_data, "(i)", &result);
120 STC_LOGI("Added rule [%d:%s]", result, nfacct_name);
126 static void __remove_rule_reply(
127 GObject *source_object, GAsyncResult *res, gpointer user_data)
129 GDBusConnection *conn = NULL;
130 GVariant *dbus_data = NULL;
131 GError *dbus_error = NULL;
133 char *nfacct_name = user_data;
135 conn = G_DBUS_CONNECTION(source_object);
136 dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
137 if (dbus_error != NULL) {
138 STC_LOGE("Dbus reply error [%s]", dbus_error->message);
139 g_error_free(dbus_error);
141 g_variant_get(dbus_data, "(i)", &result);
142 STC_LOGI("Removed rule [%d:%s]", result, nfacct_name);
148 static void __add_list_info_to_builder(GVariantBuilder *builder,
149 GSList *iptables_list)
152 GVariantBuilder sub_builder;
154 for (list = iptables_list; list; list = list->next) {
155 iptables_rule_s *rule = list->data;
157 g_variant_builder_init(&sub_builder, G_VARIANT_TYPE("a{sv}"));
159 g_variant_builder_add(&sub_builder, "{sv}", RULE_CHAIN,
160 g_variant_new_string(rule->chain));
162 g_variant_builder_add(&sub_builder, "{sv}", RULE_DIRECTION,
163 g_variant_new_uint16(rule->direction));
166 g_variant_builder_add(&sub_builder, "{sv}", RULE_IFNAME,
167 g_variant_new_string(rule->ifname));
169 if (rule->classid > 0)
170 g_variant_builder_add(&sub_builder, "{sv}", RULE_CGROUP,
171 g_variant_new_uint32(rule->classid));
173 if (rule->nfacct_name)
174 g_variant_builder_add(&sub_builder, "{sv}", RULE_NFACCT,
175 g_variant_new_string(rule->nfacct_name));
178 g_variant_builder_add(&sub_builder, "{sv}", RULE_TARGET,
179 g_variant_new_string(rule->target));
181 g_variant_builder_add_value(builder, g_variant_builder_end(&sub_builder));
185 static int __iptables_rule_add(GDBusConnection *connection,
186 iptables_rule_s *rule)
188 int result = STC_ERROR_NONE;
189 GVariantBuilder *builder = NULL;
190 GVariant *params = NULL;
191 char *nfacct_name = NULL;
193 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
194 __add_rule_info_to_builder(builder, rule);
195 params = g_variant_new("(a{sv})", builder);
196 g_variant_builder_unref(builder);
198 nfacct_name = g_strdup_printf("4:%s", rule->nfacct_name);
200 result = stc_manager_gdbus_call_async(connection,
201 STC_IPTABLES_DBUS_SERVICE,
202 STC_IPTABLES_DBUS_RULE_PATH,
203 STC_IPTABLES_DBUS_RULE_INTERFACE,
204 STC_IPTABLES_DBUS_METHOD_IPT_ADD_RULE,
209 if (result != STC_ERROR_NONE) {
210 STC_LOGE("Failed to invoke dbus method async");
217 static int __iptables_rule_remove(GDBusConnection *connection,
218 iptables_rule_s *rule)
220 int result = STC_ERROR_NONE;
221 GVariantBuilder *builder = NULL;
222 GVariant *params = NULL;
223 char *nfacct_name = NULL;
225 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
226 __add_rule_info_to_builder(builder, rule);
227 params = g_variant_new("(a{sv})", builder);
228 g_variant_builder_unref(builder);
230 nfacct_name = g_strdup_printf("4:%s", rule->nfacct_name);
232 result = stc_manager_gdbus_call_async(connection,
233 STC_IPTABLES_DBUS_SERVICE,
234 STC_IPTABLES_DBUS_RULE_PATH,
235 STC_IPTABLES_DBUS_RULE_INTERFACE,
236 STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_RULE,
241 if (result != STC_ERROR_NONE) {
242 STC_LOGE("Failed to invoke dbus method async");
249 static int __ip6tables_rule_add(GDBusConnection *connection,
250 iptables_rule_s *rule)
252 int result = STC_ERROR_NONE;
253 GVariantBuilder *builder = NULL;
254 GVariant *params = NULL;
255 char *nfacct_name = NULL;
257 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
258 __add_rule_info_to_builder(builder, rule);
259 params = g_variant_new("(a{sv})", builder);
260 g_variant_builder_unref(builder);
262 nfacct_name = g_strdup_printf("6:%s", rule->nfacct_name);
264 result = stc_manager_gdbus_call_async(connection,
265 STC_IPTABLES_DBUS_SERVICE,
266 STC_IPTABLES_DBUS_RULE_PATH,
267 STC_IPTABLES_DBUS_RULE_INTERFACE,
268 STC_IPTABLES_DBUS_METHOD_IP6T_ADD_RULE,
273 if (result != STC_ERROR_NONE) {
274 STC_LOGE("Failed to invoke dbus method async");
281 static int __ip6tables_rule_remove(GDBusConnection *connection,
282 iptables_rule_s *rule)
284 int result = STC_ERROR_NONE;
285 GVariantBuilder *builder = NULL;
286 GVariant *params = NULL;
287 char *nfacct_name = NULL;
289 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
290 __add_rule_info_to_builder(builder, rule);
291 params = g_variant_new("(a{sv})", builder);
292 g_variant_builder_unref(builder);
294 nfacct_name = g_strdup_printf("6:%s", rule->nfacct_name);
296 result = stc_manager_gdbus_call_async(connection,
297 STC_IPTABLES_DBUS_SERVICE,
298 STC_IPTABLES_DBUS_RULE_PATH,
299 STC_IPTABLES_DBUS_RULE_INTERFACE,
300 STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_RULE,
305 if (result != STC_ERROR_NONE) {
306 STC_LOGE("Failed to invoke dbus method async");
313 static int __iptables_list_add(GDBusConnection *connection,
314 GSList *iptables_list, iptables_ip_type_e iptype)
316 stc_error_e result = STC_ERROR_NONE;
317 GVariantBuilder *builder = NULL;
318 GVariant *params = NULL;
319 GVariant *message = NULL;
320 const char *method = (iptype == IP_TYPE_IPV4) ?
321 STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST :
322 STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST;
324 builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
325 __add_list_info_to_builder(builder, iptables_list);
326 params = g_variant_new("(aa{sv})", builder);
327 g_variant_builder_unref(builder);
329 message = stc_manager_gdbus_call_sync(connection,
330 STC_IPTABLES_DBUS_SERVICE,
331 STC_IPTABLES_DBUS_RULE_PATH,
332 STC_IPTABLES_DBUS_RULE_INTERFACE,
336 if (message == NULL) {
337 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
338 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
341 g_variant_get(message, "(i)", &result);
343 STC_LOGD("%s to add list [%s:%d]",
344 result == STC_ERROR_NONE ? "Successed" : "Failed",
345 iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result);
347 g_variant_unref(message);
351 static int __iptables_list_remove(GDBusConnection *connection,
352 GSList *iptables_list, iptables_ip_type_e iptype)
355 GVariantBuilder *builder = NULL;
356 GVariant *params = NULL;
357 GVariant *message = NULL;
358 const char *method = (iptype == IP_TYPE_IPV4) ?
359 STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST :
360 STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST;
362 builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
363 __add_list_info_to_builder(builder, iptables_list);
364 params = g_variant_new("(aa{sv})", builder);
365 g_variant_builder_unref(builder);
367 message = stc_manager_gdbus_call_sync(connection,
368 STC_IPTABLES_DBUS_SERVICE,
369 STC_IPTABLES_DBUS_RULE_PATH,
370 STC_IPTABLES_DBUS_RULE_INTERFACE,
374 if (message == NULL) {
375 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
376 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
379 g_variant_get(message, "(i)", &result);
381 STC_LOGD("%s to add list [%s:%d]",
382 result == STC_ERROR_NONE ? "Successed" : "Failed",
383 iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result);
385 g_variant_unref(message);
386 return STC_ERROR_NONE;
389 static int __iptables_add_chain(GDBusConnection *connection,
393 GVariant *message = NULL;
395 message = stc_manager_gdbus_call_sync(connection,
396 STC_IPTABLES_DBUS_SERVICE,
397 STC_IPTABLES_DBUS_CHAIN_PATH,
398 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
399 STC_IPTABLES_DBUS_METHOD_IPT_ADD_CHAIN,
400 g_variant_new("(s)", chain));
402 if (message == NULL) {
403 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
404 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
407 g_variant_get(message, "(i)", &result);
408 STC_LOGD("Successfully added ipv4 chain [%d:%s]", result, chain);
409 g_variant_unref(message);
411 return STC_ERROR_NONE;
414 static int __ip6tables_add_chain(GDBusConnection *connection,
418 GVariant *message = NULL;
420 message = stc_manager_gdbus_call_sync(connection,
421 STC_IPTABLES_DBUS_SERVICE,
422 STC_IPTABLES_DBUS_CHAIN_PATH,
423 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
424 STC_IPTABLES_DBUS_METHOD_IP6T_ADD_CHAIN,
425 g_variant_new("(s)", chain));
427 if (message == NULL) {
428 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
429 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
432 g_variant_get(message, "(i)", &result);
433 STC_LOGD("Successfully added ipv6 chain [%d:%s]", result, chain);
434 g_variant_unref(message);
436 return STC_ERROR_NONE;
439 static int __iptables_remove_chain(GDBusConnection *connection,
443 GVariant *message = NULL;
445 message = stc_manager_gdbus_call_sync(connection,
446 STC_IPTABLES_DBUS_SERVICE,
447 STC_IPTABLES_DBUS_CHAIN_PATH,
448 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
449 STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_CHAIN,
450 g_variant_new("(s)", chain));
452 if (message == NULL) {
453 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
454 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
457 g_variant_get(message, "(i)", &result);
458 STC_LOGD("Successfully removed ipv4 chain [%d:%s]", result, chain);
459 g_variant_unref(message);
461 return STC_ERROR_NONE;
464 static int __ip6tables_remove_chain(GDBusConnection *connection,
468 GVariant *message = NULL;
470 message = stc_manager_gdbus_call_sync(connection,
471 STC_IPTABLES_DBUS_SERVICE,
472 STC_IPTABLES_DBUS_CHAIN_PATH,
473 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
474 STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_CHAIN,
475 g_variant_new("(s)", chain));
477 if (message == NULL) {
478 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
479 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
482 g_variant_get(message, "(i)", &result);
483 STC_LOGD("Successfully removed ipv6 chain [%d:%s]", result, chain);
484 g_variant_unref(message);
486 return STC_ERROR_NONE;
489 static int __iptables_flush_chain(GDBusConnection *connection,
493 GVariant *message = NULL;
495 message = stc_manager_gdbus_call_sync(connection,
496 STC_IPTABLES_DBUS_SERVICE,
497 STC_IPTABLES_DBUS_CHAIN_PATH,
498 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
499 STC_IPTABLES_DBUS_METHOD_IPT_FLUSH_CHAIN,
500 g_variant_new("(s)", chain));
502 if (message == NULL) {
503 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
504 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
507 g_variant_get(message, "(i)", &result);
508 STC_LOGD("Successfully flushed ipv4 chain [%d:%s]", result, chain);
509 g_variant_unref(message);
511 return STC_ERROR_NONE;
514 static int __ip6tables_flush_chain(GDBusConnection *connection,
518 GVariant *message = NULL;
520 message = stc_manager_gdbus_call_sync(connection,
521 STC_IPTABLES_DBUS_SERVICE,
522 STC_IPTABLES_DBUS_CHAIN_PATH,
523 STC_IPTABLES_DBUS_CHAIN_INTERFACE,
524 STC_IPTABLES_DBUS_METHOD_IP6T_FLUSH_CHAIN,
525 g_variant_new("(s)", chain));
527 if (message == NULL) {
528 STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
529 return STC_ERROR_FAIL; //LCOV_EXCL_LINE
532 g_variant_get(message, "(i)", &result);
533 STC_LOGD("Successfully flushed ipv6 chain [%d:%s]", result, chain);
534 g_variant_unref(message);
536 return STC_ERROR_NONE;
539 static int __iptables_add_chain_jump_rule(const char *chain,
542 stc_error_e ret = STC_ERROR_NONE;
543 iptables_rule_s iptables_rule;
544 memset(&iptables_rule, 0, sizeof(iptables_rule_s));
546 iptables_rule.target = g_strdup(target);
547 iptables_rule.chain = g_strdup(chain);
549 ret = iptables_add(&iptables_rule, IP_TYPE_IPV4_IPV6);
551 g_free(iptables_rule.target);
552 g_free(iptables_rule.chain);
557 static stc_error_e _iptables_add_in_chain(stc_s *stc)
559 stc_error_e ret = STC_ERROR_NONE;
561 ret = __iptables_add_chain(stc->connection, STC_IN_CHAIN);
562 if (ret != STC_ERROR_NONE)
563 goto done; //LCOV_EXCL_LINE
565 ret = __iptables_add_chain(stc->connection, STC_IN_DROP_CHAIN);
566 if (ret != STC_ERROR_NONE)
567 goto done; //LCOV_EXCL_LINE
569 ret = __iptables_add_chain(stc->connection, STC_IN_FG_CHAIN);
570 if (ret != STC_ERROR_NONE)
571 goto done; //LCOV_EXCL_LINE
573 ret = __iptables_add_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
574 if (ret != STC_ERROR_NONE)
575 goto done; //LCOV_EXCL_LINE
577 ret = __iptables_add_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
578 if (ret != STC_ERROR_NONE)
579 goto done; //LCOV_EXCL_LINE
581 ret = __iptables_add_chain(stc->connection, STC_IN_BG_CHAIN);
582 if (ret != STC_ERROR_NONE)
583 goto done; //LCOV_EXCL_LINE
589 static stc_error_e _iptables_add_out_chain(stc_s *stc)
591 stc_error_e ret = STC_ERROR_NONE;
593 ret = __iptables_add_chain(stc->connection, STC_OUT_CHAIN);
594 if (ret != STC_ERROR_NONE)
595 goto done; //LCOV_EXCL_LINE
597 ret = __iptables_add_chain(stc->connection, STC_OUT_DROP_CHAIN);
598 if (ret != STC_ERROR_NONE)
599 goto done; //LCOV_EXCL_LINE
601 ret = __iptables_add_chain(stc->connection, STC_OUT_FG_CHAIN);
602 if (ret != STC_ERROR_NONE)
603 goto done; //LCOV_EXCL_LINE
605 ret = __iptables_add_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
606 if (ret != STC_ERROR_NONE)
607 goto done; //LCOV_EXCL_LINE
609 ret = __iptables_add_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
610 if (ret != STC_ERROR_NONE)
611 goto done; //LCOV_EXCL_LINE
613 ret = __iptables_add_chain(stc->connection, STC_OUT_BG_CHAIN);
614 if (ret != STC_ERROR_NONE)
615 goto done; //LCOV_EXCL_LINE
621 static stc_error_e _ip6tables_add_in_chain(stc_s *stc)
623 stc_error_e ret = STC_ERROR_NONE;
625 ret = __ip6tables_add_chain(stc->connection, STC_IN_CHAIN);
626 if (ret != STC_ERROR_NONE)
627 goto done; //LCOV_EXCL_LINE
629 ret = __ip6tables_add_chain(stc->connection, STC_IN_DROP_CHAIN);
630 if (ret != STC_ERROR_NONE)
631 goto done; //LCOV_EXCL_LINE
633 ret = __ip6tables_add_chain(stc->connection, STC_IN_FG_CHAIN);
634 if (ret != STC_ERROR_NONE)
635 goto done; //LCOV_EXCL_LINE
637 ret = __ip6tables_add_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
638 if (ret != STC_ERROR_NONE)
639 goto done; //LCOV_EXCL_LINE
641 ret = __ip6tables_add_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
642 if (ret != STC_ERROR_NONE)
643 goto done; //LCOV_EXCL_LINE
645 ret = __ip6tables_add_chain(stc->connection, STC_IN_BG_CHAIN);
646 if (ret != STC_ERROR_NONE)
647 goto done; //LCOV_EXCL_LINE
653 static stc_error_e _ip6tables_add_out_chain(stc_s *stc)
655 stc_error_e ret = STC_ERROR_NONE;
657 ret = __ip6tables_add_chain(stc->connection, STC_OUT_CHAIN);
658 if (ret != STC_ERROR_NONE)
659 goto done; //LCOV_EXCL_LINE
661 ret = __ip6tables_add_chain(stc->connection, STC_OUT_DROP_CHAIN);
662 if (ret != STC_ERROR_NONE)
663 goto done; //LCOV_EXCL_LINE
665 ret = __ip6tables_add_chain(stc->connection, STC_OUT_FG_CHAIN);
666 if (ret != STC_ERROR_NONE)
667 goto done; //LCOV_EXCL_LINE
669 ret = __ip6tables_add_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
670 if (ret != STC_ERROR_NONE)
671 goto done; //LCOV_EXCL_LINE
673 ret = __ip6tables_add_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
674 if (ret != STC_ERROR_NONE)
675 goto done; //LCOV_EXCL_LINE
677 ret = __ip6tables_add_chain(stc->connection, STC_OUT_BG_CHAIN);
678 if (ret != STC_ERROR_NONE)
679 goto done; //LCOV_EXCL_LINE
685 static stc_error_e _iptables_add_in_chain_jump_rule(void)
687 stc_error_e ret = STC_ERROR_NONE;
689 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_CHAIN);
690 if (ret != STC_ERROR_NONE)
691 goto done; //LCOV_EXCL_LINE
693 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_DROP_CHAIN);
694 if (ret != STC_ERROR_NONE)
695 goto done; //LCOV_EXCL_LINE
697 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_FG_CHAIN);
698 if (ret != STC_ERROR_NONE)
699 goto done; //LCOV_EXCL_LINE
701 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_ACCEPT_CHAIN);
702 if (ret != STC_ERROR_NONE)
703 goto done; //LCOV_EXCL_LINE
705 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_BG_DROP_CHAIN);
706 if (ret != STC_ERROR_NONE)
707 goto done; //LCOV_EXCL_LINE
709 ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_BG_CHAIN);
710 if (ret != STC_ERROR_NONE)
711 goto done; //LCOV_EXCL_LINE
717 static stc_error_e _iptables_add_out_chain_jump_rule(void)
719 stc_error_e ret = STC_ERROR_NONE;
721 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_CHAIN);
722 if (ret != STC_ERROR_NONE)
723 goto done; //LCOV_EXCL_LINE
725 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_DROP_CHAIN);
726 if (ret != STC_ERROR_NONE)
727 goto done; //LCOV_EXCL_LINE
729 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_FG_CHAIN);
730 if (ret != STC_ERROR_NONE)
731 goto done; //LCOV_EXCL_LINE
733 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_ACCEPT_CHAIN);
734 if (ret != STC_ERROR_NONE)
735 goto done; //LCOV_EXCL_LINE
737 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_BG_DROP_CHAIN);
738 if (ret != STC_ERROR_NONE)
739 goto done; //LCOV_EXCL_LINE
741 ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_BG_CHAIN);
742 if (ret != STC_ERROR_NONE)
743 goto done; //LCOV_EXCL_LINE
749 static stc_error_e _iptables_remove_in_chain(stc_s *stc)
751 stc_error_e ret = STC_ERROR_NONE;
753 ret = __iptables_remove_chain(stc->connection, STC_IN_DROP_CHAIN);
754 if (ret != STC_ERROR_NONE)
755 goto done; //LCOV_EXCL_LINE
757 ret = __iptables_remove_chain(stc->connection, STC_IN_FG_CHAIN);
758 if (ret != STC_ERROR_NONE)
759 goto done; //LCOV_EXCL_LINE
761 ret = __iptables_remove_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
762 if (ret != STC_ERROR_NONE)
763 goto done; //LCOV_EXCL_LINE
765 ret = __iptables_remove_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
766 if (ret != STC_ERROR_NONE)
767 goto done; //LCOV_EXCL_LINE
769 ret = __iptables_remove_chain(stc->connection, STC_IN_BG_CHAIN);
770 if (ret != STC_ERROR_NONE)
771 goto done; //LCOV_EXCL_LINE
773 ret = __iptables_remove_chain(stc->connection, STC_IN_CHAIN);
774 if (ret != STC_ERROR_NONE)
775 goto done; //LCOV_EXCL_LINE
781 static stc_error_e _iptables_remove_out_chain(stc_s *stc)
783 stc_error_e ret = STC_ERROR_NONE;
785 ret = __iptables_remove_chain(stc->connection, STC_OUT_DROP_CHAIN);
786 if (ret != STC_ERROR_NONE)
787 goto done; //LCOV_EXCL_LINE
789 ret = __iptables_remove_chain(stc->connection, STC_OUT_FG_CHAIN);
790 if (ret != STC_ERROR_NONE)
791 goto done; //LCOV_EXCL_LINE
793 ret = __iptables_remove_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
794 if (ret != STC_ERROR_NONE)
795 goto done; //LCOV_EXCL_LINE
797 ret = __iptables_remove_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
798 if (ret != STC_ERROR_NONE)
799 goto done; //LCOV_EXCL_LINE
801 ret = __iptables_remove_chain(stc->connection, STC_OUT_BG_CHAIN);
802 if (ret != STC_ERROR_NONE)
803 goto done; //LCOV_EXCL_LINE
805 ret = __iptables_remove_chain(stc->connection, STC_OUT_CHAIN);
806 if (ret != STC_ERROR_NONE)
807 goto done; //LCOV_EXCL_LINE
813 static stc_error_e _ip6tables_remove_in_chain(stc_s *stc)
815 stc_error_e ret = STC_ERROR_NONE;
817 ret = __ip6tables_remove_chain(stc->connection, STC_IN_DROP_CHAIN);
818 if (ret != STC_ERROR_NONE)
819 goto done; //LCOV_EXCL_LINE
821 ret = __ip6tables_remove_chain(stc->connection, STC_IN_FG_CHAIN);
822 if (ret != STC_ERROR_NONE)
823 goto done; //LCOV_EXCL_LINE
825 ret = __ip6tables_remove_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
826 if (ret != STC_ERROR_NONE)
827 goto done; //LCOV_EXCL_LINE
829 ret = __ip6tables_remove_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
830 if (ret != STC_ERROR_NONE)
831 goto done; //LCOV_EXCL_LINE
833 ret = __ip6tables_remove_chain(stc->connection, STC_IN_BG_CHAIN);
834 if (ret != STC_ERROR_NONE)
835 goto done; //LCOV_EXCL_LINE
837 ret = __ip6tables_remove_chain(stc->connection, STC_IN_CHAIN);
838 if (ret != STC_ERROR_NONE)
839 goto done; //LCOV_EXCL_LINE
845 static stc_error_e _ip6tables_remove_out_chain(stc_s *stc)
847 stc_error_e ret = STC_ERROR_NONE;
849 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_DROP_CHAIN);
850 if (ret != STC_ERROR_NONE)
851 goto done; //LCOV_EXCL_LINE
853 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_FG_CHAIN);
854 if (ret != STC_ERROR_NONE)
855 goto done; //LCOV_EXCL_LINE
857 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
858 if (ret != STC_ERROR_NONE)
859 goto done; //LCOV_EXCL_LINE
861 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
862 if (ret != STC_ERROR_NONE)
863 goto done; //LCOV_EXCL_LINE
865 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_BG_CHAIN);
866 if (ret != STC_ERROR_NONE)
867 goto done; //LCOV_EXCL_LINE
869 ret = __ip6tables_remove_chain(stc->connection, STC_OUT_CHAIN);
870 if (ret != STC_ERROR_NONE)
871 goto done; //LCOV_EXCL_LINE
877 static stc_error_e _iptables_flush_in_chain(stc_s *stc)
879 stc_error_e ret = STC_ERROR_NONE;
881 ret = __iptables_flush_chain(stc->connection, STC_IN_DROP_CHAIN);
882 if (ret != STC_ERROR_NONE)
883 goto done; //LCOV_EXCL_LINE
885 ret = __iptables_flush_chain(stc->connection, STC_IN_FG_CHAIN);
886 if (ret != STC_ERROR_NONE)
887 goto done; //LCOV_EXCL_LINE
889 ret = __iptables_flush_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
890 if (ret != STC_ERROR_NONE)
891 goto done; //LCOV_EXCL_LINE
893 ret = __iptables_flush_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
894 if (ret != STC_ERROR_NONE)
895 goto done; //LCOV_EXCL_LINE
897 ret = __iptables_flush_chain(stc->connection, STC_IN_BG_CHAIN);
898 if (ret != STC_ERROR_NONE)
899 goto done; //LCOV_EXCL_LINE
901 ret = __iptables_flush_chain(stc->connection, STC_IN_CHAIN);
902 if (ret != STC_ERROR_NONE)
903 goto done; //LCOV_EXCL_LINE
909 static stc_error_e _iptables_flush_out_chain(stc_s *stc)
911 stc_error_e ret = STC_ERROR_NONE;
913 ret = __iptables_flush_chain(stc->connection, STC_OUT_DROP_CHAIN);
914 if (ret != STC_ERROR_NONE)
915 goto done; //LCOV_EXCL_LINE
917 ret = __iptables_flush_chain(stc->connection, STC_OUT_FG_CHAIN);
918 if (ret != STC_ERROR_NONE)
919 goto done; //LCOV_EXCL_LINE
921 ret = __iptables_flush_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
922 if (ret != STC_ERROR_NONE)
923 goto done; //LCOV_EXCL_LINE
925 ret = __iptables_flush_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
926 if (ret != STC_ERROR_NONE)
927 goto done; //LCOV_EXCL_LINE
929 ret = __iptables_flush_chain(stc->connection, STC_OUT_BG_CHAIN);
930 if (ret != STC_ERROR_NONE)
931 goto done; //LCOV_EXCL_LINE
933 ret = __iptables_flush_chain(stc->connection, STC_OUT_CHAIN);
934 if (ret != STC_ERROR_NONE)
935 goto done; //LCOV_EXCL_LINE
941 static stc_error_e _ip6tables_flush_in_chain(stc_s *stc)
943 stc_error_e ret = STC_ERROR_NONE;
945 ret = __ip6tables_flush_chain(stc->connection, STC_IN_DROP_CHAIN);
946 if (ret != STC_ERROR_NONE)
947 goto done; //LCOV_EXCL_LINE
949 ret = __ip6tables_flush_chain(stc->connection, STC_IN_FG_CHAIN);
950 if (ret != STC_ERROR_NONE)
951 goto done; //LCOV_EXCL_LINE
953 ret = __ip6tables_flush_chain(stc->connection, STC_IN_ACCEPT_CHAIN);
954 if (ret != STC_ERROR_NONE)
955 goto done; //LCOV_EXCL_LINE
957 ret = __ip6tables_flush_chain(stc->connection, STC_IN_BG_DROP_CHAIN);
958 if (ret != STC_ERROR_NONE)
959 goto done; //LCOV_EXCL_LINE
961 ret = __ip6tables_flush_chain(stc->connection, STC_IN_BG_CHAIN);
962 if (ret != STC_ERROR_NONE)
963 goto done; //LCOV_EXCL_LINE
965 ret = __ip6tables_flush_chain(stc->connection, STC_IN_CHAIN);
966 if (ret != STC_ERROR_NONE)
967 goto done; //LCOV_EXCL_LINE
973 static stc_error_e _ip6tables_flush_out_chain(stc_s *stc)
975 stc_error_e ret = STC_ERROR_NONE;
977 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_DROP_CHAIN);
978 if (ret != STC_ERROR_NONE)
979 goto done; //LCOV_EXCL_LINE
981 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_FG_CHAIN);
982 if (ret != STC_ERROR_NONE)
983 goto done; //LCOV_EXCL_LINE
985 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_ACCEPT_CHAIN);
986 if (ret != STC_ERROR_NONE)
987 goto done; //LCOV_EXCL_LINE
989 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_BG_DROP_CHAIN);
990 if (ret != STC_ERROR_NONE)
991 goto done; //LCOV_EXCL_LINE
993 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_BG_CHAIN);
994 if (ret != STC_ERROR_NONE)
995 goto done; //LCOV_EXCL_LINE
997 ret = __ip6tables_flush_chain(stc->connection, STC_OUT_CHAIN);
998 if (ret != STC_ERROR_NONE)
999 goto done; //LCOV_EXCL_LINE
1005 stc_error_e iptables_add(iptables_rule_s *rule, iptables_ip_type_e iptype)
1007 stc_error_e ret = STC_ERROR_NONE;
1008 stc_s *stc = stc_get_manager();
1010 if (!stc || !stc->connection)
1011 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1013 if (iptype == IP_TYPE_IPV4 ||
1014 iptype == IP_TYPE_IPV4_IPV6) {
1015 ret = __iptables_rule_add(stc->connection, rule);
1016 if (ret != STC_ERROR_NONE)
1017 goto done; //LCOV_EXCL_LINE
1020 if (iptype == IP_TYPE_IPV6 ||
1021 iptype == IP_TYPE_IPV4_IPV6)
1022 ret = __ip6tables_rule_add(stc->connection, rule);
1028 stc_error_e iptables_remove(iptables_rule_s *rule, iptables_ip_type_e iptype)
1030 stc_error_e ret = STC_ERROR_NONE;
1031 stc_s *stc = stc_get_manager();
1033 if (!stc || !stc->connection)
1034 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1036 if (iptype == IP_TYPE_IPV4 ||
1037 iptype == IP_TYPE_IPV4_IPV6) {
1038 ret = __iptables_rule_remove(stc->connection, rule);
1039 if (ret != STC_ERROR_NONE)
1040 goto done; //LCOV_EXCL_LINE
1043 if (iptype == IP_TYPE_IPV6 ||
1044 iptype == IP_TYPE_IPV4_IPV6)
1045 ret = __ip6tables_rule_remove(stc->connection, rule);
1051 stc_error_e iptables_add_list(GSList *iptables_list, iptables_ip_type_e iptype)
1053 stc_s *stc = stc_get_manager();
1055 if (!stc || !stc->connection)
1056 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1058 return __iptables_list_add(stc->connection, iptables_list, iptype);
1061 stc_error_e iptables_remove_list(GSList *iptables_list, iptables_ip_type_e iptype)
1063 stc_s *stc = stc_get_manager();
1065 if (!stc || !stc->connection)
1066 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1068 return __iptables_list_remove(stc->connection, iptables_list, iptype);
1071 API stc_error_e iptables_flush_chains(void)
1073 stc_error_e ret = STC_ERROR_NONE;
1074 stc_s *stc = stc_get_manager();
1076 if (!stc || !stc->connection)
1077 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1079 ret = _iptables_flush_in_chain(stc);
1080 if (ret != STC_ERROR_NONE)
1081 goto done; //LCOV_EXCL_LINE
1083 ret = _iptables_flush_out_chain(stc);
1084 if (ret != STC_ERROR_NONE)
1085 goto done; //LCOV_EXCL_LINE
1087 ret = __iptables_flush_chain(stc->connection, STC_FRWD_CHAIN);
1088 if (ret != STC_ERROR_NONE)
1089 goto done; //LCOV_EXCL_LINE
1091 ret = __iptables_flush_chain(stc->connection, STC_TETHER_CHAIN);
1092 if (ret != STC_ERROR_NONE)
1093 goto done; //LCOV_EXCL_LINE
1095 ret = _ip6tables_flush_in_chain(stc);
1096 if (ret != STC_ERROR_NONE)
1097 goto done; //LCOV_EXCL_LINE
1099 ret = _ip6tables_flush_out_chain(stc);
1100 if (ret != STC_ERROR_NONE)
1101 goto done; //LCOV_EXCL_LINE
1103 ret = __ip6tables_flush_chain(stc->connection, STC_FRWD_CHAIN);
1108 stc_error_e iptables_init(void)
1110 __STC_LOG_FUNC_ENTER__;
1112 stc_error_e ret = STC_ERROR_NONE;
1113 stc_s *stc = stc_get_manager();
1115 if (!stc || !stc->connection) {
1116 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1117 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1120 ret = _iptables_add_in_chain(stc);
1121 if (ret != STC_ERROR_NONE) {
1122 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1123 goto done; //LCOV_EXCL_LINE
1126 ret = _iptables_add_out_chain(stc);
1127 if (ret != STC_ERROR_NONE) {
1128 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1129 goto done; //LCOV_EXCL_LINE
1132 ret = __iptables_add_chain(stc->connection, STC_FRWD_CHAIN);
1133 if (ret != STC_ERROR_NONE) {
1134 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1135 goto done; //LCOV_EXCL_LINE
1138 ret = __iptables_add_chain(stc->connection, STC_TETHER_CHAIN);
1139 if (ret != STC_ERROR_NONE) {
1140 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1141 goto done; //LCOV_EXCL_LINE
1144 ret = _ip6tables_add_in_chain(stc);
1145 if (ret != STC_ERROR_NONE) {
1146 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1147 goto done; //LCOV_EXCL_LINE
1150 ret = _ip6tables_add_out_chain(stc);
1151 if (ret != STC_ERROR_NONE) {
1152 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1153 goto done; //LCOV_EXCL_LINE
1156 ret = __ip6tables_add_chain(stc->connection, STC_FRWD_CHAIN);
1157 if (ret != STC_ERROR_NONE) {
1158 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1159 goto done; //LCOV_EXCL_LINE
1162 ret = __ip6tables_add_chain(stc->connection, STC_TETHER_CHAIN);
1163 if (ret != STC_ERROR_NONE) {
1164 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1165 goto done; //LCOV_EXCL_LINE
1168 ret = _iptables_add_in_chain_jump_rule();
1169 if (ret != STC_ERROR_NONE) {
1170 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1171 goto done; //LCOV_EXCL_LINE
1174 ret = _iptables_add_out_chain_jump_rule();
1175 if (ret != STC_ERROR_NONE) {
1176 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1177 goto done; //LCOV_EXCL_LINE
1180 ret = __iptables_add_chain_jump_rule("FORWARD", STC_FRWD_CHAIN);
1181 if (ret != STC_ERROR_NONE) {
1182 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1183 goto done; //LCOV_EXCL_LINE
1186 ret = __iptables_add_chain_jump_rule("FORWARD", STC_TETHER_CHAIN);
1187 if (ret != STC_ERROR_NONE) {
1188 __STC_LOG_FUNC_EXIT__;
1193 __STC_LOG_FUNC_ENTER__;
1197 stc_error_e iptables_deinit(void)
1199 __STC_LOG_FUNC_ENTER__;
1201 stc_error_e ret = STC_ERROR_NONE;
1202 stc_s *stc = stc_get_manager();
1204 if (!stc || !stc->connection) {
1205 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1206 return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1209 ret = _iptables_remove_in_chain(stc);
1210 if (ret != STC_ERROR_NONE) {
1211 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1212 goto done; //LCOV_EXCL_LINE
1215 ret = _iptables_remove_out_chain(stc);
1216 if (ret != STC_ERROR_NONE) {
1217 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1218 goto done; //LCOV_EXCL_LINE
1221 ret = __iptables_remove_chain(stc->connection, STC_TETHER_CHAIN);
1222 if (ret != STC_ERROR_NONE) {
1223 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1224 goto done; //LCOV_EXCL_LINE
1227 ret = __iptables_remove_chain(stc->connection, STC_FRWD_CHAIN);
1228 if (ret != STC_ERROR_NONE) {
1229 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1230 goto done; //LCOV_EXCL_LINE
1233 ret = _ip6tables_remove_in_chain(stc);
1234 if (ret != STC_ERROR_NONE) {
1235 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1236 goto done; //LCOV_EXCL_LINE
1239 ret = _ip6tables_remove_out_chain(stc);
1240 if (ret != STC_ERROR_NONE) {
1241 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1242 goto done; //LCOV_EXCL_LINE
1245 ret = __ip6tables_remove_chain(stc->connection, STC_FRWD_CHAIN);
1246 if (ret != STC_ERROR_NONE) {
1247 __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
1248 goto done; //LCOV_EXCL_LINE
1252 __STC_LOG_FUNC_ENTER__;