⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transmitter.cxx

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 CXX
字号:
/*transmitter.cc       (c) 1999-2000 Derek J Smithies (dereks@ibm.net) *                           Indranet Technologies ltd (lara@indranet.co.nz) * * This file is derived from vic, http://www-nrg.ee.lbl.gov/vic/ * Their copyright notice is below. *//*- * Copyright (c) 1993-1994 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *      This product includes software developed by the Network Research *	Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used *    to endorse or promote products derived from this software without *    specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */static const char rcsid[] =    "@(#) $Header: /home/cvsroot/openh323/src/vic/transmitter.cxx,v 1.2 2000/02/04 05:16:24 craigs Exp $ (LBL)";#if 0#include <sys/types.h>#include <sys/socket.h>#include <stdio.h>#include <stdlib.h>#ifndef WIN32#include <unistd.h>#endif#include <errno.h>#include <string.h>#ifdef WIN32#include <winsock.h>#include <io.h>#include <sys/stat.h>#else#include <sys/param.h>#include <sys/uio.h>#include <netinet/in.h>#include <sys/file.h>#include <sys/stat.h>#endif#endif#include "transmitter.h"Transmitter::pktbuf* Transmitter::freehdrs_;Transmitter::buffer* Transmitter::freebufs_;int Transmitter::nbufs_;int Transmitter::nhdrs_;/* * Sequence number is static so when we change the encoding (which causes * new encoder to be allocated) we don't reset the sequence counter. * Otherwise, receivers will get confused, reset their stats, and generate * odd looking streams of reception reports (i.e., the packet counts will * drop back to 0). */u_int Transmitter::seqno_ = 1;Transmitter::Transmitter() :	head_(0),	tail_(0){  freehdrs_ = NULL;  freebufs_ = NULL;}Transmitter::~Transmitter() {  PurgeBufferQueue(freehdrs_);  PurgeBufferQueue(head_);}  void Transmitter::PurgeBufferQueue(pktbuf *queue){  pktbuf *pb;  pb=queue;  while (pb) {    pktbuf *tpb=pb->next;    if(pb->buf)       delete(pb->buf);    delete pb;    pb=tpb;  }}Transmitter::pktbuf* Transmitter::alloch(){	pktbuf* pb = freehdrs_;	if (pb != 0)		freehdrs_ = pb->next;	else {		/*XXX grow exponentially*/		pb = new pktbuf;		++nhdrs_;	}	pb->buf = 0;	return (pb);}Transmitter::pktbuf* Transmitter::alloc(){	pktbuf* pb = alloch();	buffer* p = freebufs_;	if (p != 0)		freebufs_ = p->next;	else		p = new buffer;	pb->buf = p;	return (pb);}void Transmitter::ReleaseOnePacket(pktbuf* pb){        head_=head_->next;	pb->next = freehdrs_;	freehdrs_ = pb;	buffer* p = pb->buf;	if (p != 0) {		p->next = freebufs_;		freebufs_ = p;	}}//Add packet to pending queue.void Transmitter::StoreOnePacket(pktbuf* pb){  if (head_ != 0) {  	tail_->next = pb;  	tail_ = pb;  } else  	tail_ = head_ = pb;  pb->next = 0;}int Transmitter::PacketsOutStanding(){  return(head_!=NULL);}void Transmitter::GetNextPacket(u_char ** hptr,u_char ** bptr, u_int & hlen, u_int & blen){  *hptr=(u_char*)head_->hdr;  *bptr=(u_char*)head_->buf->data;  hlen=head_->lenHdr;  blen=head_->lenBuf;  ReleaseOnePacket(head_);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -