X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..41a0ee6544be0e947c6062a966a93310b9ea5ce5:/projects/stargazer/plugins/capture/cap_debug/packet.c?ds=sidebyside diff --git a/projects/stargazer/plugins/capture/cap_debug/packet.c b/projects/stargazer/plugins/capture/cap_debug/packet.c index 6b76f005..b7cdc172 100644 --- a/projects/stargazer/plugins/capture/cap_debug/packet.c +++ b/projects/stargazer/plugins/capture/cap_debug/packet.c @@ -1,4 +1,4 @@ -/* $Id: packet.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ +/* $Id: packet.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ Copyright (C) 2002 Marc Kirchner @@ -67,35 +67,13 @@ pkt_free(struct packet *pkt) /* <++doc++> -@name int pkt_set_actptr(struct packet *pkt, unsigned int bytepos) -@desc This function sets the active pointer position inside the packet. -@param pkt the packet whose active ptr is to be set -@param bytepos the byte position where to set the active ptr to, starting from 0 -<--doc--> -*/ - -int -pkt_set_actptr(struct packet *pkt, unsigned int bytepos) -{ - if (!pkt) - return EPKTINVALPTR; - if (bytepos > pkt->pkt_size) { - return EPKTRANGE; - } else { - pkt->pkt_ptr = pkt->pkt + bytepos; - return PKTOK; - } -} - -/* -<++doc++> -@name int pkt_move_actptr(struct packet *pkt, int relmov) +@name int pkt_move_actptr(struct packet *pkt, int relmov) @desc This function moves the active pointer inside the packet. @param pkt the packet whose active ptr is to be moved @param relmov number of bytes the active ptr shall be moved. To move it backward, negative values may be used. <--doc--> */ -int +int pkt_move_actptr(struct packet *pkt, int relmov) { if (!pkt) @@ -108,54 +86,3 @@ pkt_move_actptr(struct packet *pkt, int relmov) return PKTOK; } } - -/* -<++doc++> -@name int pkt_add_data(struct packet *pkt, char *data, size_t data_len) -@desc Adds supplied data at the current active ptr position of the given packet.This basically is a memcpy() wrapper function. -@param pkt data will be written into this packet -@param data a pointer to the data that shall be copied into the packet -@param data_len the amount of data (in bytes) that will be copied -<--doc--> -*/ -int -pkt_add_data(struct packet *pkt, char *data, size_t data_len) -{ - if (!pkt || !data) - return EPKTINVALPTR; - if (pkt->pkt_size >= (pkt->pkt_pos + data_len)) { - memcpy(pkt->pkt_ptr, data, data_len); - return 0; - } else - return EPKTRANGE; -} - -/* -<++doc++> -@name int pkt_resize(struct packet *pkt, unsigned int newsize) -@desc The given packet will be resized to newsize -@param pkt the packet to resize -@param newsize the new size of the packet -<--doc--> -*/ -int -pkt_resize(struct packet *pkt, unsigned int newsize) -{ - unsigned char *newpkt; - - if (!pkt) - return EPKTINVALPTR; - - if ((newpkt = (unsigned char *) malloc(newsize)) != NULL) { - memset(newpkt, 0, newsize); - memcpy(newpkt, pkt->pkt, (pkt->pkt_size < newsize ? pkt->pkt_size : newsize)); - pkt->pkt_size = newsize; - pkt->pkt_ptr = newpkt; - pkt->pkt_pos = 0; - /* free old mem */ - free (pkt->pkt); - pkt->pkt = newpkt; - return 0; - } else - return EERRNO; -}