netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
byteorder.h File Reference
`#include <arpa/inet.h>`

Go to the source code of this file.

## Macros
#define | CVAL(buf, pos)
#define | CVAL_NC(buf, pos)
#define | PVAL(buf, pos)
#define | SCVAL(buf, pos, val)
#define | SVAL(buf, pos)
#define | SVALS(buf, pos)
#define | IVAL(buf, pos)
#define | IVALS(buf, pos)
#define | LVAL(buf, pos)
#define | LVALS(buf, pos)
#define | SSVALX(buf, pos, val)
#define | SIVALX(buf, pos, val)
#define | SLVALX(buf, pos, val)
#define | SSVAL(buf, pos, val)
#define | SSVALS(buf, pos, val)
#define | SIVAL(buf, pos, val)
#define | SIVALS(buf, pos, val)
#define | SLVAL(buf, pos, val)
#define | SLVALS(buf, pos, val)
#define | SREV(x)
#define | IREV(x)
#define | LREV(x)
#define | RSVAL(buf, pos)
#define | RSVALS(buf, pos)
#define | RIVAL(buf, pos)
#define | RIVALS(buf, pos)
#define | RLVAL(buf, pos)
#define | RLVALS(buf, pos)
#define | RSSVAL(buf, pos, val)
#define | RSSVALS(buf, pos, val)
#define | RSIVAL(buf, pos, val)
#define | RSIVALS(buf, pos, val)
#define | RSLVAL(buf, pos, val)
#define | RSLVALS(buf, pos, val)
#define | ALIGN4(p, base)
#define | ALIGN2(p, base)

## Detailed Description

Macros for machine independent short and int manipulation.

Derived from Samba's byteorder.h by Andrew Tridgell, where SVAL/IVAL always decode little-endian SMB wire format using byte-order independent arithmetic, and RSVAL/RIVAL always decode big-endian (NMB) wire format.

The netatalk version replaces this with a big-endian conditional that changes the semantics: SVAL/IVAL read in host-native byte order (safe unaligned access), and RSVAL/RIVAL read in the opposite byte order. This was done to support AFP (a big-endian protocol) and native-order in-memory Unicode on big-endian Unix servers.

## Macro Definition Documentation

## ◆ ALIGN2

#define ALIGN2 | ( |  | p,
|  |  | base )

Value:
((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1))
p
size_t p
Definition dircache.c:256
base
static struct event_base * base
Definition netatalk.c:83

## ◆ ALIGN4

#define ALIGN4 | ( |  | p,
|  |  | base )

Value:
((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3))

## ◆ CVAL

#define CVAL | ( |  | buf,
|  |  | pos )

Value:
((unsigned)(((const unsigned char *)(buf))[pos]))
buf
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:113

## ◆ CVAL_NC

#define CVAL_NC | ( |  | buf,
|  |  | pos )

Value:
(((unsigned char *)(buf))[pos])

Non-const version of CVAL

## ◆ IREV

#define IREV | ( |  | x | ) |

Value:
((SREV((uint32_t)(x))<<16) | (SREV(((uint32_t)(x))>>16)))
SREV
#define SREV(x)
Definition byteorder.h:81

## ◆ IVAL

#define IVAL | ( |  | buf,
|  |  | pos )

Value:
(SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
SVAL
#define SVAL(buf, pos)
Definition byteorder.h:60

## ◆ IVALS

#define IVALS | ( |  | buf,
|  |  | pos )

Value:
((int32_t)IVAL(buf,pos))
IVAL
#define IVAL(buf, pos)
Definition byteorder.h:62

## ◆ LREV

#define LREV | ( |  | x | ) |

Value:
(((uint64_t)IREV(x)<<32) | (IREV((x)>>32)))
IREV
#define IREV(x)
Definition byteorder.h:82

## ◆ LVAL

#define LVAL | ( |  | buf,
|  |  | pos )

Value:
(IVAL(buf,pos)|((uint64_t)IVAL(buf,(pos)+4))<<32)

## ◆ LVALS

#define LVALS | ( |  | buf,
|  |  | pos )

Value:
((int64_t)LVAL(buf,pos))
LVAL
#define LVAL(buf, pos)
Definition byteorder.h:64

## ◆ PVAL

#define PVAL | ( |  | buf,
|  |  | pos )

Value:
(CVAL(buf,pos))
CVAL
#define CVAL(buf, pos)
Definition byteorder.h:40

## ◆ RIVAL

#define RIVAL | ( |  | buf,
|  |  | pos )

Value:
IREV(IVAL(buf,pos))

## ◆ RIVALS

#define RIVALS | ( |  | buf,
|  |  | pos )

Value:
IREV(IVALS(buf,pos))
IVALS
#define IVALS(buf, pos)
Definition byteorder.h:63

## ◆ RLVAL

#define RLVAL | ( |  | buf,
|  |  | pos )

Value:
LREV(LVAL(buf,pos))
LREV
#define LREV(x)
Definition byteorder.h:83

## ◆ RLVALS

#define RLVALS | ( |  | buf,
|  |  | pos )

Value:
LREV(LVALS(buf,pos))
LVALS
#define LVALS(buf, pos)
Definition byteorder.h:65

## ◆ RSIVAL

#define RSIVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SIVAL(buf,pos,IREV(val))
SIVAL
#define SIVAL(buf, pos, val)
Definition byteorder.h:75

## ◆ RSIVALS

#define RSIVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SIVALS(buf,pos,IREV(val))
SIVALS
#define SIVALS(buf, pos, val)
Definition byteorder.h:76

## ◆ RSLVAL

#define RSLVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SLVAL(buf,pos,LREV(val))
SLVAL
#define SLVAL(buf, pos, val)
Definition byteorder.h:77

## ◆ RSLVALS

#define RSLVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SLVALS(buf,pos,LREV(val))
SLVALS
#define SLVALS(buf, pos, val)
Definition byteorder.h:78

## ◆ RSSVAL

#define RSSVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SSVAL(buf,pos,SREV(val))
SSVAL
#define SSVAL(buf, pos, val)
Definition byteorder.h:73

## ◆ RSSVALS

#define RSSVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SSVALS(buf,pos,SREV(val))
SSVALS
#define SSVALS(buf, pos, val)
Definition byteorder.h:74

## ◆ RSVAL

#define RSVAL | ( |  | buf,
|  |  | pos )

Value:
SREV(SVAL(buf,pos))

## ◆ RSVALS

#define RSVALS | ( |  | buf,
|  |  | pos )

Value:
SREV(SVALS(buf,pos))
SVALS
#define SVALS(buf, pos)
Definition byteorder.h:61

## ◆ SCVAL

#define SCVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
(CVAL_NC(buf,pos) = (val))
CVAL_NC
#define CVAL_NC(buf, pos)
Definition byteorder.h:41

## ◆ SIVAL

#define SIVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SIVALX((buf),(pos),((uint32_t)(val)))
SIVALX
#define SIVALX(buf, pos, val)
Definition byteorder.h:68

## ◆ SIVALS

#define SIVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SIVALX((buf),(pos),((int32_t)(val)))

## ◆ SIVALX

#define SIVALX | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
(SSVALX(buf,pos,((val)&0xFFFF)),SSVALX(buf,pos+2,(val)>>16))
SSVALX
#define SSVALX(buf, pos, val)
Definition byteorder.h:67

## ◆ SLVAL

#define SLVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SLVALX((buf),(pos),((uint64_t)(val)))
SLVALX
#define SLVALX(buf, pos, val)
Definition byteorder.h:69

## ◆ SLVALS

#define SLVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SLVALX((buf),(pos),((int64_t)(val)))

## ◆ SLVALX

#define SLVALX | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
(SIVALX(buf,pos,((val)&0xFFFFFFFF)),SIVALX(buf,pos+4,(val)>>32))

## ◆ SREV

#define SREV | ( |  | x | ) |

Value:
((((x)&0xFF)<<8) | (((x)>>8)&0xFF))

## ◆ SSVAL

#define SSVAL | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SSVALX((buf),(pos),((uint16_t)(val)))

## ◆ SSVALS

#define SSVALS | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
SSVALX((buf),(pos),((int16_t)(val)))

## ◆ SSVALX

#define SSVALX | ( |  | buf,
|  |  | pos,
|  |  | val )

Value:
(CVAL_NC(buf,pos)=(unsigned char)((val)&0xFF),CVAL_NC(buf,pos+1)=(unsigned char)((val)>>8))

## ◆ SVAL

#define SVAL | ( |  | buf,
|  |  | pos )

Value:
(PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
PVAL
#define PVAL(buf, pos)
Definition byteorder.h:42

## ◆ SVALS

#define SVALS | ( |  | buf,
|  |  | pos )

Value:
((int16_t)SVAL(buf,pos))