LCOV - code coverage report
Current view: top level - libbpfilter - cli.c (source / functions) Coverage Total Hit
Test: lcov.out Lines: 0.0 % 28 0
Test Date: 2025-02-26 17:59:59 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /* SPDX-License-Identifier: GPL-2.0-only */
       2              : /*
       3              :  * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
       4              :  */
       5              : 
       6              : #include <stdio.h>
       7              : #include <string.h>
       8              : 
       9              : #include "core/chain.h"
      10              : #include "core/front.h"
      11              : #include "core/logger.h"
      12              : #include "core/marsh.h"
      13              : #include "core/request.h"
      14              : #include "core/response.h"
      15              : #include "libbpfilter/generic.h"
      16              : 
      17            0 : int bf_cli_ruleset_flush(void)
      18              : {
      19            0 :     _cleanup_bf_request_ struct bf_request *request = NULL;
      20            0 :     _cleanup_bf_response_ struct bf_response *response = NULL;
      21              :     int r;
      22              : 
      23            0 :     r = bf_request_new(&request, NULL, 0);
      24            0 :     if (r)
      25            0 :         return bf_err_r(r, "failed to create a ruleset flush request");
      26              : 
      27            0 :     request->front = BF_FRONT_CLI;
      28            0 :     request->cmd = BF_REQ_RULESET_FLUSH;
      29              : 
      30            0 :     r = bf_send(request, &response);
      31            0 :     if (r)
      32            0 :         return bf_err_r(r, "failed to send a ruleset flush request");
      33              : 
      34            0 :     return response->type == BF_RES_FAILURE ? response->error : 0;
      35              : }
      36              : 
      37            0 : int bf_cli_set_chain(const struct bf_chain *chain)
      38              : {
      39            0 :     _cleanup_bf_request_ struct bf_request *request = NULL;
      40            0 :     _cleanup_bf_response_ struct bf_response *response = NULL;
      41            0 :     _cleanup_bf_marsh_ struct bf_marsh *marsh = NULL;
      42              :     int r;
      43              : 
      44            0 :     r = bf_chain_marsh(chain, &marsh);
      45            0 :     if (r)
      46            0 :         return bf_err_r(r, "failed to marsh chain");
      47              : 
      48            0 :     r = bf_request_new(&request, marsh, bf_marsh_size(marsh));
      49            0 :     if (r)
      50            0 :         return bf_err_r(r, "failed to create request for chain");
      51              : 
      52            0 :     request->front = BF_FRONT_CLI;
      53            0 :     request->cmd = BF_REQ_RULES_SET;
      54              : 
      55            0 :     r = bf_send(request, &response);
      56            0 :     if (r)
      57            0 :         return bf_err_r(r, "failed to send chain to the daemon");
      58              : 
      59            0 :     return response->type == BF_RES_FAILURE ? response->error : 0;
      60              : }
        

Generated by: LCOV version 2.0-1