-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract.h
73 lines (62 loc) · 1.82 KB
/
extract.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
73
#ifndef _EMERALD_EXTRACT_H
#define _EMERALD_EXTRACT_H
#ifndef _EMERALD_TYPES_H
#include "types.h"
#endif
#ifdef E_NEEDS_EXTRACT_BITS8
static inline void ExtractBits8(Bits8 *theByte, Bits8 *data)
{
*theByte = *data;
}
#endif
#if defined(E_NEEDS_EXTRACT_BITS16) || defined(E_NEEDS_EXTRACT_NODE) || defined(E_NEEDS_EXTRACT_OID)
static inline void ExtractBits16(Bits16 *theWord, Bits8 *data)
{
*theWord = ntohs(*((Bits16 *) data));
}
#endif
static inline void ExtractBits32(Bits32 *theLong, Bits8 *data)
{
*theLong = ntohl(*((Bits32 *) data));
}
#ifdef E_NEEDS_EXTRACT_OID
static inline void ExtractOID(OID *theOID, Bits8 *data)
{
ExtractBits32(&theOID->ipaddress, data);
ExtractBits16(&theOID->port, data + 4);
ExtractBits16(&theOID->epoch, data + 6);
ExtractBits32(&theOID->Seq, data + 8);
}
#endif
extern void incomingRef(Object, int), incomingObject(Object);
extern void makeRefBlack(Object), makeRefGrey(Object);
#ifdef E_NEEDS_EXTRACT_OBJECT_DESCRIPTOR
static inline void ExtractObjectDescriptor(Object o, Bits8 *data)
{
unsigned int newflags, finalflags;
ExtractBits32(&newflags, data);
finalflags = (o->flags & ALLBITS) | newflags;
/*
* If we are dgcing, and the other side says the object is black,
* and it was not resident before, then remove it from greys.
*/
if (inDistGC() && !RESDNT(o->flags))
if (DISTGC(newflags))
makeRefBlack(o);
else
makeRefGrey(o);
if (DISTGC(o->flags) && !DISTGC(newflags)) CLEARDISTGC(finalflags);
TRACE(index, 2, ("EOD: %x was %x now %x", o, o->flags, finalflags));
o->flags = finalflags;
}
#endif
#ifdef E_NEEDS_EXTRACT_NODE
static void ExtractNode(Node *t, Bits8 *data)
{
/* No ntoh desired here */
t->ipaddress = *(Bits32 *) data;
ExtractBits16(&t->port, data + 4);
ExtractBits16(&t->epoch, data + 6);
}
#endif
#endif /* _EMERALD_EXTRACT_H */