Skip to Content
[CAIDA - Center for Applied Internet Data Analysis logo]
The Center for Applied Internet Data Analysis
ip_utils.h
1 /*
2  * cc-common
3  *
4  * Alistair King, CAIDA, UC San Diego
5  * corsaro-info@caida.org
6  *
7  * Copyright (C) 2012 The Regents of the University of California.
8  *
9  * This file is part of cc-common.
10  *
11  * cc-common is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * cc-common is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with cc-common. If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifndef __IP_UTILS_H
27 #define __IP_UTILS_H
28 
32 typedef struct ip_prefix
33 {
35  uint32_t addr;
37  uint8_t masklen;
38 } ip_prefix_t;
39 
41 typedef struct ip_prefix_list
42 {
48 
49 
59 uint32_t ip_set_bit(uint32_t addr, int bitno, int val);
60 
67 uint32_t ip_netmask(int masklen);
68 
76 uint32_t ip_broadcast_addr(uint32_t addr, int masklen);
77 
85 uint32_t ip_network_addr(uint32_t addr, int masklen);
86 
97 int ip_range_to_prefix(ip_prefix_t lower, ip_prefix_t upper,
98  ip_prefix_list_t **pfx_list);
99 
105 void ip_prefix_list_free(ip_prefix_list_t *pfx_list);
106 
107 #endif /* __IP_UTILS_H */
ip_prefix_t prefix
The prefix that this element represents.
Definition: ip_utils.h:44
An element in a linked list of IP prefixes.
Definition: ip_utils.h:41
uint8_t masklen
The length of the prefix mask.
Definition: ip_utils.h:37
struct ip_prefix_list * next
The next prefix in the list.
Definition: ip_utils.h:46
Represents a IPv4 prefix e.g.
Definition: ip_utils.h:32
uint32_t addr
The address component of the prefix.
Definition: ip_utils.h:35