-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathutils.h
72 lines (59 loc) · 2.38 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* =====================================================================================
*
* Filename: enums.h
*
* Description: This file contains the decalaration of all enumerations used in this file
*
* Version: 1.0
* Created: Wednesday 18 September 2019 02:38:12 IST
* Revision: 1.0
* Compiler: gcc
*
* Author: Er. Abhishek Sagar, Networking Developer (AS), [email protected]
* Company: Brocade Communications(Jul 2012- Mar 2016), Current : Juniper Networks(Apr 2017 - Present)
*
* This file is part of the NetworkGraph distribution (https://github.com/sachinites).
* Copyright (c) 2017 Abhishek Sagar.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* =====================================================================================
*/
/* Visit my Website for more wonderful assignments and projects :
* www.csepracticals.com
* if above URL dont work, then try visit : https://csepracticals.com*/
#ifndef __UTILS__
#define __UTILS__
#include <stdint.h>
typedef enum{
FALSE,
TRUE
} bool_t;
#define IS_BIT_SET(n, pos) ((n & (1 << (pos))) != 0)
#define TOGGLE_BIT(n, pos) (n = n ^ (1 << (pos)))
#define COMPLEMENT(num) (num = num ^ 0xFFFFFFFF)
#define UNSET_BIT(n, pos) (n = n & ((1 << pos) ^ 0xFFFFFFFF))
#define SET_BIT(n, pos) (n = n | 1 << pos)
void
apply_mask(char *prefix, char mask, char *str_prefix);
void
layer2_fill_with_broadcast_mac(char *mac_array);
#define IS_MAC_BROADCAST_ADDR(mac) \
(mac[0] == 0xFF && mac[1] == 0xFF && mac[2] == 0xFF && \
mac[3] == 0xFF && mac[4] == 0xFF && mac[5] == 0xFF)
char *
tcp_ip_covert_ip_n_to_p(uint32_t ip_addr,
char *output_buffer);
uint32_t
tcp_ip_covert_ip_p_to_n(char *ip_addr);
#endif /* __UTILS__ */