Annotation of embedaddon/mpd/src/mbuf.h, revision 1.1.1.2
1.1 misho 1:
2: /*
3: * mbuf.c
4: *
5: * Written by Toshiharu OHNO <tony-o@iij.ad.jp>
6: * Copyright (c) 1993, Internet Initiative Japan, Inc. All rights reserved.
7: * See ``COPYRIGHT.iij''
8: *
9: * Rewritten by Archie Cobbs <archie@freebsd.org>
10: * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
11: * See ``COPYRIGHT.whistle''
12: */
13:
14: #ifndef _MBUF_H_
15: #define _MBUF_H_
16:
17: /*
18: * DEFINITIONS
19: */
20:
21: struct mpdmbuf {
22: int size; /* size allocated */
23: int offset; /* offset to start position */
24: int cnt; /* available byte count in buffer */
25: };
26:
27: typedef struct mpdmbuf *Mbuf;
28:
29: /* Macros */
30: #define MBDATAU(bp) ((u_char *)(bp) + sizeof(struct mpdmbuf) + (bp)->offset)
31: #define MBDATA(bp) ((bp) ? MBDATAU(bp) : NULL)
32: #define MBLEN(bp) ((bp) ? (bp)->cnt : 0)
33: #define MBSPACE(bp) ((bp) ? (bp)->size - (bp)->offset : 0)
34:
35: /* Types of allocated memory */
36: #define MB_AUTH "AUTH"
37: #define MB_CONS "CONSOLE"
38: #define MB_WEB "WEB"
39: #define MB_IFACE "IFACE"
40: #define MB_BUND "BUND"
41: #define MB_REP "REP"
42: #define MB_LINK "LINK"
43: #define MB_CHAT "CHAT"
44: #define MB_CMD "CMD"
45: #define MB_CMDL "CMDL"
46: #define MB_COMP "COMP"
47: #define MB_CRYPT "CRYPT"
48: #define MB_ECHO "ECHO"
49: #define MB_EVENT "EVENT"
50: #define MB_FSM "FSM"
51: #define MB_LOG "LOG"
52: #define MB_MP "MP"
53: #define MB_MBUF "MBUF"
54: #define MB_PHYS "PHYS"
55: #define MB_PPTP "PPTP"
56: #define MB_RADIUS "RADIUS"
57: #define MB_RADSRV "RADSRV"
1.1.1.2 ! misho 58: #define MB_ACL "ACL_BPF"
! 59: #define MB_IPFW "ACL_IPFW"
1.1 misho 60: #define MB_UTIL "UTIL"
61: #define MB_VJCOMP "VJCOMP"
62: #define MB_IPPOOL "IPPOOL"
63:
64: #ifndef __malloc_like
65: #define __malloc_like
66: #endif
67:
68: /*
69: * FUNCTIONS
70: */
71:
72: /* Replacements for malloc() & free() */
73:
74: extern void *Malloc(const char *type, size_t size) __malloc_like;
75: extern void *Mdup(const char *type, const void *src, size_t size) __malloc_like;
76: extern void *Mstrdup(const char *type, const void *src) __malloc_like;
77: extern void Freee(void *ptr);
78:
79: /* Mbuf manipulation */
80:
81: extern Mbuf mballoc(int size) __malloc_like;
82: extern void mbfree(Mbuf bp);
83: extern Mbuf mbread(Mbuf bp, void *ptr, int cnt);
84: extern int mbcopy(Mbuf bp, int offset, void *buf, int cnt);
85: extern Mbuf mbcopyback(Mbuf bp, int offset, const void *buf, int cnt);
86: extern Mbuf mbtrunc(Mbuf bp, int max);
87: extern Mbuf mbadj(Mbuf bp, int cnt);
88: extern Mbuf mbsplit(Mbuf bp, int cnt);
89:
90: /* Etc */
91:
92: extern int MemStat(Context ctx, int ac, char *av[], void *arg);
93: extern void DumpBp(Mbuf bp);
94:
95: #endif
96:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>