LCOV - code coverage report
Current view: top level - libbpfilter - generic.c (source / functions) Coverage Total Hit
Test: lcov.out Lines: 0.0 % 18 0
Test Date: 2025-02-26 17:59:59 Functions: 0.0 % 1 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 "libbpfilter/generic.h"
       7              : 
       8              : #include <errno.h>
       9              : #include <string.h>
      10              : #include <sys/socket.h>
      11              : #include <sys/un.h>
      12              : 
      13              : #include "core/helper.h"
      14              : #include "core/io.h"
      15              : #include "core/logger.h"
      16              : 
      17            0 : int bf_send(const struct bf_request *request, struct bf_response **response)
      18              : {
      19              :     _cleanup_close_ int fd = -1;
      20            0 :     struct sockaddr_un addr = {};
      21              :     int r;
      22              : 
      23            0 :     bf_assert(request);
      24            0 :     bf_assert(response);
      25              : 
      26            0 :     fd = socket(AF_UNIX, SOCK_STREAM, 0);
      27            0 :     if (fd < 0)
      28            0 :         return bf_err_r(errno, "bpfilter: can't create socket");
      29              : 
      30            0 :     addr.sun_family = AF_UNIX;
      31            0 :     strncpy(addr.sun_path, BF_SOCKET_PATH, sizeof(addr.sun_path) - 1);
      32              : 
      33            0 :     r = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
      34            0 :     if (r < 0)
      35            0 :         return bf_err_r(errno, "bpfilter: failed to connect to socket");
      36              : 
      37            0 :     r = bf_send_request(fd, request);
      38            0 :     if (r < 0)
      39            0 :         return bf_err_r(r, "bpfilter: failed to send request to the daemon");
      40              : 
      41            0 :     r = bf_recv_response(fd, response);
      42            0 :     if (r < 0) {
      43            0 :         return bf_err_r(r,
      44              :                         "bpfilter: failed to receive response from the daemon");
      45              :     }
      46              : 
      47              :     return 0;
      48              : }
        

Generated by: LCOV version 2.0-1