VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/sbuf.h@ 34244

Last change on this file since 34244 was 30045, checked in by vboxsync, 14 years ago

NAT: BSD sbuf.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: sbuf.h 30045 2010-06-04 20:38:56Z vboxsync $ */
2/** @file
3 * NAT - sbuf declarations/defines.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*
19 * This code is based on:
20 *
21 * Copyright (c) 1995 Danny Gasparovski.
22 *
23 * Please read the file COPYRIGHT for the
24 * terms and conditions of the copyright.
25 */
26
27#ifndef _SBUF_H_
28#define _SBUF_H_
29
30#ifndef VBOX_WITH_SLIRP_BSD_SBUF
31# define sbflush(sb) sbdrop((sb),(sb)->sb_cc)
32# define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
33# define SBUF_LEN(sb) ((sb)->sb_cc)
34# define SBUF_SIZE(sb) ((sb)->sb_datalen)
35
36
37struct sbuf
38{
39 u_int sb_cc; /* actual chars in buffer */
40 u_int sb_datalen; /* Length of data */
41 char *sb_wptr; /* write pointer. points to where the next
42 * bytes should be written in the sbuf */
43 char *sb_rptr; /* read pointer. points to where the next
44 * byte should be read from the sbuf */
45 char *sb_data; /* Actual data */
46};
47
48void sbfree (struct sbuf *);
49void sbdrop (struct sbuf *, int);
50void sbreserve (PNATState, struct sbuf *, int);
51void sbappend (PNATState, struct socket *, struct mbuf *);
52void sbappendsb (PNATState, struct sbuf *, struct mbuf *);
53void sbcopy (struct sbuf *, int, int, char *);
54#else
55void sbappend (PNATState, struct socket *, struct mbuf *);
56# include "bsd/sys/sbuf.h"
57# define SBUF_LEN(sb) (sbuf_len(sb))
58/* XXX: @todo SBUF_SIZE is a hack both space and SIZE shouldn't be used out of subr_sbuf.c*/
59# define SBUF_SIZE(sb) ((sb)->s_size)
60/* see subr_sbuf.c to verify the formula */
61# define sbspace(sb) (SBUF_SIZE(sb) - SBUF_LEN((sb)) - 1)
62#endif
63#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette