Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/dsslib/ip_t/pt.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2000-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* Phong Vo <[email protected]> *
19
* *
20
***********************************************************************/
21
#pragma prototyped
22
/*
23
* prefix table interface definitions
24
*
25
* Glenn Fowler
26
* AT&T Research
27
*/
28
29
#ifndef _PT_H
30
#define _PT_H
31
32
#include <ast.h>
33
#include <cdt.h>
34
35
#define PT_VERSION 20090315L
36
37
#define PTBITS 32
38
#define PTSHIFT 1
39
40
#define PTMIN(a,b) ((a)&~((b)?((((Ptaddr_t)1)<<(PTBITS-(b)))-1):~((Ptaddr_t)0)))
41
#define PTMAX(a,b) ((a)|((b)?((((Ptaddr_t)1)<<(PTBITS-(b)))-1):~((Ptaddr_t)0)))
42
43
struct Pt_s; typedef struct Pt_s Pt_t;
44
struct Ptdisc_s; typedef struct Ptdisc_s Ptdisc_t;
45
struct Ptprefix_s; typedef struct Ptprefix_s Ptprefix_t;
46
47
typedef uint32_t Ptaddr_t;
48
typedef uintmax_t Ptcount_t;
49
50
struct Ptprefix_s
51
{
52
Ptaddr_t min;
53
Ptaddr_t max;
54
union
55
{
56
long number;
57
void* pointer;
58
} data;
59
Dtlink_t link;
60
};
61
62
struct Ptdisc_s /* user discipline */
63
{
64
unsigned long version; /* interface version */
65
Error_f errorf; /* error function */
66
};
67
68
struct Pt_s
69
{
70
Ptcount_t entries;
71
Dt_t* dict;
72
Ptdisc_t* disc;
73
#ifdef _PT_PRIVATE_
74
_PT_PRIVATE_
75
#endif
76
};
77
78
#if _BLD_pt && defined(__EXPORT__)
79
#define extern __EXPORT__
80
#endif
81
82
#define ptinit(d) (memset(d,0,sizeof(Ptdisc_t)),(d)->version=PT_VERSION)
83
84
extern Pt_t* ptopen(Ptdisc_t*);
85
extern int ptclose(Pt_t*);
86
extern Ptprefix_t* ptinsert(Pt_t*, Ptaddr_t, Ptaddr_t);
87
extern int ptdelete(Pt_t*, Ptaddr_t, Ptaddr_t);
88
89
extern Ptprefix_t* ptmatch(Pt_t*, Ptaddr_t);
90
91
extern int ptprint(Pt_t*, Sfio_t*);
92
extern int ptstats(Pt_t*, Sfio_t*);
93
extern int ptdump(Pt_t*, Sfio_t*);
94
95
extern Ptcount_t ptaddresses(Pt_t*);
96
extern Ptcount_t ptranges(Pt_t*);
97
extern Ptcount_t ptsize(Pt_t*);
98
99
extern Pt_t* ptcopy(Pt_t*);
100
extern Pt_t* ptinvert(Pt_t*);
101
extern Pt_t* ptintersect(Pt_t*, Pt_t*);
102
extern Pt_t* ptunion(Pt_t*, Pt_t*);
103
extern Pt_t* ptdifference(Pt_t*, Pt_t*);
104
extern Pt_t* ptcover(Pt_t*, Pt_t*);
105
extern Pt_t* ptrebit(Pt_t*, int);
106
107
extern int ptequal(Pt_t*, Pt_t*);
108
extern int ptsubset(Pt_t*, Pt_t*);
109
110
#undef extern
111
112
#endif
113
114