views:

17

answers:

0

How can we encapsulate a message with any protocol header.Message can be char * or a pointer to memory field (void *). Actually i want to do is :

message --> add protocol header(e.g udp)

|udp header + message |

struct UdpHeader { 
    int Sport,Dport,chksum,size;
}

void sendMsg(void *msg,int sport,int dport,int size)
{
    UdpHeader *t;   
    t->Sport = sport;
    t->Dport = dport;
    // t->chksum = //calc chksum
    // i don't know how to add message to this udp header,  
    // i tried to add msg field to Udpheader structure but  
    // message size is variable length
}