Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | /* |
3 | | * PIM for Quagga |
4 | | * Copyright (C) 2008 Everton da Silva Marques |
5 | | */ |
6 | | |
7 | | #include <zebra.h> |
8 | | |
9 | | #include <string.h> |
10 | | #include <netinet/in.h> |
11 | | #include <arpa/inet.h> |
12 | | |
13 | | #include "pim_int.h" |
14 | | |
15 | | uint32_t pim_read_uint32_host(const uint8_t *buf) |
16 | 360 | { |
17 | 360 | uint32_t val; |
18 | 360 | memcpy(&val, buf, sizeof(val)); |
19 | | /* val is in netorder */ |
20 | 360 | val = ntohl(val); |
21 | | /* val is in hostorder */ |
22 | 360 | return val; |
23 | 360 | } |
24 | | |
25 | | void pim_write_uint32(uint8_t *buf, uint32_t val_host) |
26 | 428 | { |
27 | | /* val_host is in host order */ |
28 | 428 | val_host = htonl(val_host); |
29 | | /* val_host is in netorder */ |
30 | 428 | memcpy(buf, &val_host, sizeof(val_host)); |
31 | 428 | } |