]>
git.ipfire.org Git - thirdparty/nqptp.git/blob - general-utilities.h
2 * This file is part of the nqptp distribution (https://github.com/mikebrady/nqptp).
3 * Copyright (c) 2021-2022 Mike Brady.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Commercial licensing is also available.
20 #ifndef GENERAL_UTILITIES_H
21 #define GENERAL_UTILITIES_H
23 // functions that are pretty generic
24 // specialised stuff should go in the nqptp-utilities
27 #include <sys/socket.h>
30 // struct sockaddr_in6 is bigger than struct sockaddr. derp
32 #define SOCKADDR struct sockaddr_storage
33 #define SAFAMILY ss_family
35 #define SOCKADDR struct sockaddr
36 #define SAFAMILY sa_family
39 void hcton64(uint64_t num
, uint8_t *p
);
41 // these are designed to avoid aliasing check errors
42 uint64_t nctoh64(const uint8_t *p
);
43 uint32_t nctohl(const uint8_t *p
);
44 uint16_t nctohs(const uint8_t *p
);
45 uint64_t timespec_to_ns(struct timespec
*tn
);
46 uint64_t get_time_now();
48 uint64_t ntoh64(const uint64_t n
);