mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-28 21:17:54 +00:00
Use ISC_UxxTOyy_BE macros for {peek,get,put}_uint16 macros
Reduce the duplication and use existing macros from isc/endian.h for network to host and vice versa conversion.
This commit is contained in:
parent
727fb9a011
commit
80dac1bbae
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <isc/endian.h>
|
||||||
|
|
||||||
#include <dns/rdataslab.h>
|
#include <dns/rdataslab.h>
|
||||||
|
|
||||||
#define ANCIENT(header) \
|
#define ANCIENT(header) \
|
||||||
@ -58,7 +60,7 @@
|
|||||||
((atomic_load_acquire(&(header)->attributes) & \
|
((atomic_load_acquire(&(header)->attributes) & \
|
||||||
DNS_SLABHEADERATTR_ZEROTTL) != 0)
|
DNS_SLABHEADERATTR_ZEROTTL) != 0)
|
||||||
|
|
||||||
#define peek_uint16(buffer) ({ ((uint16_t)*(buffer) << 8) | *((buffer) + 1); })
|
#define peek_uint16(buffer) ISC_U8TO16_BE(buffer)
|
||||||
#define get_uint16(buffer) \
|
#define get_uint16(buffer) \
|
||||||
({ \
|
({ \
|
||||||
uint16_t __ret = peek_uint16(buffer); \
|
uint16_t __ret = peek_uint16(buffer); \
|
||||||
@ -66,7 +68,7 @@
|
|||||||
__ret; \
|
__ret; \
|
||||||
})
|
})
|
||||||
#define put_uint16(buffer, val) \
|
#define put_uint16(buffer, val) \
|
||||||
({ \
|
{ \
|
||||||
*buffer++ = (val & 0xff00) >> 8; \
|
ISC_U16TO8_BE(buffer, val); \
|
||||||
*buffer++ = (val & 0x00ff); \
|
(buffer) += sizeof(uint16_t); \
|
||||||
})
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user