root/vic/trunk/net/pktbuf.h @ 995

Revision 995, 3.0 KB (checked in by piers, 15 years ago)

Introduced factor of 2 into the PKTBUF_SIZE as the H261 codec seems to over-run
the buffer a bit - causing random errors. This was the size in the vic before
but in MASH (where the new pktbuf stuff came from) the size was:
#define PKTBUF_SIZE (MAXHDR + 2 * 1024 + PKTBUF_PAD)
Now it is:
#define PKTBUF_SIZE (2 * 1024)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * Copyright (c) 1996 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *      This product includes software developed by the MASH Research
16 *      Group at University of California, Berkeley.
17 * 4. Neither the name of the University nor of the Laboratory may be used
18 *    to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#) $Header$ (LBL)
34 */
35
36#ifndef mash_pktbuf_h
37#define mash_pktbuf_h
38
39#ifdef WIN32
40//#include <winsock.h>
41#else
42#include <sys/param.h>
43#include <sys/types.h>
44#include <sys/socket.h>
45#include <sys/uio.h>
46#endif
47//#include "config.h"
48#include "vic_tcl.h"
49//#include "timer.h"
50//#include "inet.h"
51//#include "module.h"
52
53class pktbuf;
54
55class Buffer {
56public:
57        virtual Buffer* copy() = 0;
58        virtual void release();
59};
60
61/*
62 * The base object for performing the outbound path of
63 * the application level protocol.
64 */
65class BufferPool : public TclObject {
66    public:
67        BufferPool();
68        void release(pktbuf*);
69        /*
70         * Buffer allocation hooks.
71         */
72        pktbuf* alloc(int layer = 0);
73    private:
74        static pktbuf* freebufs_;
75        static int nbufs_;
76};
77
78/*XXX*/
79#define MAXHDR 128
80#define PKTBUF_PAD 256
81#define RTP_MTU 1024
82/* Introduced factor of 2 as the H261 codec seems to over-run the buffer a bit
83#define PKTBUF_SIZE (MAXHDR + 1024 + PKTBUF_PAD) from MASH */
84#define PKTBUF_SIZE (2 * RTP_MTU)
85
86class pktbuf : public Buffer {
87public:
88        pktbuf* next;
89        int layer;
90        int len;
91        int ref;
92        u_int8_t* dp;
93        u_int8_t data[PKTBUF_SIZE];
94        BufferPool* manager;
95        inline void release() {
96                ref--;
97                if (!ref)
98                  manager->release(this);
99        }
100        inline void attach() {
101                ref++;
102        }
103        Buffer* copy();
104};
105
106#endif
Note: See TracBrowser for help on using the browser.