How does one properly allocate array of unsigned chars?
packet = (u_char*) malloc (20*sizeof(u_char)); //is it simmilar to u_char packet[20]?
I have 2 functions which are declared as follows
u_char *frame(bool type, char* srcmac, char* dstmac);
u_char *ip(bool type, char* srcip, char* dstip);
how can I concatenate those 2 unsigned chars? I tried memcpy, strcat[only for char].
u_char *concat(u_char *s1, u_char *s2) {
u_char *result = (u_char*) malloc((sizeof(s1)+sizeof(s2)+1));//+1 for the zero-terminator
memcpy(result, s1, sizeof(s1));
memcpy(result, s2, sizeof(s2)); //I am overwriting result already and sizeof is size of pointer...
return result;
}