/* * packet.c: Perforce protocol data packets * $Header$ */ #include <config.h> #include "netjunk.h" #include "packet.h" #include <malloc.h> packet *new_packet(size_t len) { packet *p; p = malloc(sizeof(packet)); p->len = len; p->data = malloc(len); return p; } void free_packet(packet *p) { free(p->data); free(p); } void *packet_to_blob(const packet *p) { char *blob; /* Start by creating the blob. Its length is the length of the packet, * plus five. */ blob = malloc(p->len + 5); /* Let's start from the end by copying in the data. */ memcpy(blob + 5, p->data, p->len); /* Create the size in the correct place. */ write_p4_long(blob + 1, p->len); /* Create the checksum. */ *blob = p4_checksum(blob + 1); /* All done. */ return blob; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 450 | sandy_currier |
Initial import of p4filter code. This contains a solaris2.6 binary but no others. |