/************************************************************************ ** * ** Copyright © 1996 Digital Equipment Corporation. * ** All rights reserved. * ** * ** Redistribution and use in source and binary forms are permitted * ** provided that the above copyright notice and this paragraph are * ** duplicated in all such forms and that any documentation, * ** advertising materials, and other materials related to such * ** distribution and use acknowledge that the software was developed * ** by Digital Equipment Corporation. The name of the * ** Corporation may not be used to endorse or promote products derived * ** from this software without specific prior written permission. * ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * ** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * ** WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * ** * ************************************************************************* **++ ** FACILITY: ** ** ppp_buf.h. ** ** ABSTRACT: ** ** Macros for allocating and manipulating buffers ** ** AUTHORS: ** ** Patrick Crilly, Networks Engineering (Australia). ** ** CREATION DATE: ** ** 7-December-1995 ** ** MODIFICATION HISTORY: ** ** 17-December-1996 Barry W. Kierstein ** Replaced the standard Digital copyright with ** one compatible with the CMU copyright. ** ** 24-July-1996 Barry W. Kierstein ** Corrected copyright notice. ** ** 7-December-1995 Original version. ** **-- */ #ifndef _PPP_BUF_H_ #define _PPP_BUF_H_ /* ** ** import definitions: ** offsetof ** */ #ifndef __STDDEF_LOADED #include "stddef.h" #endif /* ** ** import definitions: ** struct vcibdef ** */ #ifndef __VCRPDEF_LOADED #include "vcrpdef.h" #endif /* ** ** import definitions: ** prototype macro ** types ** */ #ifndef _PPPD_H_ #include "pppd.h" #endif /* Buffer typedef */ typedef struct vcrpdef PPPBuffer; #define NULL_BUF (PPPBuffer *)(0) /* Macros for manipulating buffers */ #define BUF_ALLOC( size ) pppBufAlloc((size)) #define BUF_DEALLOC( buf ) pppBufDealloc((buf)) #define BUF_DATA_PTR( buf ) ((unsigned char *)(buf)->vcrp$l_buffer_address) #define BUF_DATA_LEN( buf ) ((buf)->vcrp$l_total_pdu_size) #define BUF_DATA_TRIM( buf, len ) \ if ( len > 0 ) \ { \ buf->vcrp$l_buffer_address = (unsigned char *)buf->vcrp$l_buffer_address + len; \ buf->vcrp$l_boff += len; \ buf->vcrp$l_bcnt -= len; \ buf->vcrp$l_total_pdu_size -= len; \ } \ else \ { \ buf->vcrp$l_bcnt += len; \ buf->vcrp$l_total_pdu_size += len; \ } #define BUF_DATA_EXPAND( buf, len ) \ if ( len > 0 ) \ { \ buf->vcrp$l_buffer_address = (unsigned char *)buf->vcrp$l_buffer_address - len; \ buf->vcrp$l_boff -= len; \ buf->vcrp$l_bcnt += len; \ buf->vcrp$l_total_pdu_size += len; \ } \ else \ { \ buf->vcrp$l_bcnt -= len; \ buf->vcrp$l_total_pdu_size -= len; \ } #define BUF_PUSH( buf, item, itemLen ) \ ((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused = (char *)(((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused) - itemLen; \ BCOPY( &(item), ((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused, itemLen ); #define BUF_POP( buf, item, itemLen ) \ BCOPY( ((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused, &item, itemLen ); \ ((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused = (char *)(((VCRPSTACK *)(buf)->vcrp$a_stack)->stack$l_lastused) + itemLen; /* ** Prototypes */ PPPBuffer *pppBufAlloc( u_int size ); void pppBufDealloc( PPPBuffer *buf ); #endif /* _PPP_BUF_H */