Hmm, a typical hash-table with say linked-list chaining is an array of linked lists, with each linked-list consisting of colliding elements (I guess in your case, an element is a struct packet).
Then you use a hash function to map the key of your element (in your case, this translates to packet->id) into on of the array slots. If the array slot is not empty, it contains the head of a linked-list with elements whose key was already mapped to the same array-slot, so you just insert the new element to that linked-list.
When you need to retrieve an element (packet) for which you already know its key (packet->id), you call your hash-function passing to it the key of the desired element (packet->id). This gives you the array-slot that the desired element has been hashed into. You then traverse the linked-list of that array-slot until you find the node that contains the exact key (packet->id) you are looking for.
That's the general idea and it doesn't really care what values have been assigned to the inner fields of each element (well, except for the id of course).
Now, If I've got it right, you are receiving your packets with their inner fields already assigned their correct values (id included). So all you have to do is to hash each packet into your hash-table by using each packet->id as the hashing key (in other words, you pass the packet->id to your hash function in order to obtain at which array-slot that particular packet will be hashed into).
Accordingly, to retrieve an already hashed element with id say 4, you first obtain the array-slot it has been hashed into, and then you traverse the linked-list of that array-slot until you find the element whose id equals to 4.
Something like this...
Code:
int i = hash_function( 4, hashTable );
if ( !hashTable[i] ) {
puts( "The requested packet has not been hashed" );
}
else {
struct packet *node = llist_lookup( hashTable[i], 4 );
if ( !node ) {
puts( "The requested packet has not been hashed" );
}
else {
printf( "The requested packet has been hashed in slot %i\n", i );
printf( "age = %u, buffer = ", node->age );
fflush( stdout );
for (int i=0; i < MAX_SIZE; i++) {
printf( "%x ", node->buffer[i] );
}
putchar( '\n' );
}
}