LCOV - code coverage report
Current view: top level - libsystemd-network - dhcp-server-internal.h (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 1 1 100.0 %
Date: 2015-07-29 18:47:03 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : /***
       4             :   This file is part of systemd.
       5             : 
       6             :   Copyright (C) 2013 Intel Corporation. All rights reserved.
       7             :   Copyright (C) 2014 Tom Gundersen
       8             : 
       9             :   systemd is free software; you can redistribute it and/or modify it
      10             :   under the terms of the GNU Lesser General Public License as published by
      11             :   the Free Software Foundation; either version 2.1 of the License, or
      12             :   (at your option) any later version.
      13             : 
      14             :   systemd is distributed in the hope that it will be useful, but
      15             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      17             :   Lesser General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Lesser General Public License
      20             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      21             : ***/
      22             : 
      23             : #pragma once
      24             : 
      25             : #include "sd-event.h"
      26             : #include "sd-dhcp-server.h"
      27             : 
      28             : #include "hashmap.h"
      29             : #include "refcnt.h"
      30             : #include "util.h"
      31             : #include "log.h"
      32             : 
      33             : #include "dhcp-internal.h"
      34             : 
      35             : typedef struct DHCPClientId {
      36             :         size_t length;
      37             :         uint8_t *data;
      38             : } DHCPClientId;
      39             : 
      40             : typedef struct DHCPLease {
      41             :         DHCPClientId client_id;
      42             : 
      43             :         be32_t address;
      44             :         be32_t gateway;
      45             :         uint8_t chaddr[16];
      46             :         usec_t expiration;
      47             : } DHCPLease;
      48             : 
      49             : struct sd_dhcp_server {
      50             :         RefCount n_ref;
      51             : 
      52             :         sd_event *event;
      53             :         int event_priority;
      54             :         sd_event_source *receive_message;
      55             :         int fd;
      56             :         int fd_raw;
      57             : 
      58             :         int index;
      59             :         be32_t address;
      60             :         be32_t netmask;
      61             :         be32_t pool_start;
      62             :         size_t pool_size;
      63             :         size_t next_offer;
      64             : 
      65             :         Hashmap *leases_by_client_id;
      66             :         DHCPLease **bound_leases;
      67             : };
      68             : 
      69             : typedef struct DHCPRequest {
      70             :         /* received message */
      71             :         DHCPMessage *message;
      72             : 
      73             :         /* options */
      74             :         DHCPClientId client_id;
      75             :         size_t max_optlen;
      76             :         be32_t server_id;
      77             :         be32_t requested_ip;
      78             :         int lifetime;
      79             : } DHCPRequest;
      80             : 
      81           2 : DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
      82             : #define _cleanup_dhcp_server_unref_ _cleanup_(sd_dhcp_server_unrefp)
      83             : 
      84             : #define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
      85             : 
      86             : int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
      87             :                                size_t length);
      88             : int dhcp_server_send_packet(sd_dhcp_server *server,
      89             :                             DHCPRequest *req, DHCPPacket *packet,
      90             :                             int type, size_t optoffset);
      91             : 
      92             : unsigned long client_id_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
      93             : int client_id_compare_func(const void *_a, const void *_b);

Generated by: LCOV version 1.11