Hi, I've build ICMP echo request packet:

Qt Code:
  1. #include <string.h>
  2.  
  3. class CIcmp {
  4. public:
  5. CIcmp(char type[8], char code[8], char checksum[8], char identifier[8], char sequenceNumber[8], char *additionalData=0);
  6. ~CIcmp();
  7. char* icmpBuildPacket(char *packet);
  8.  
  9. };
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. #include "icmp.h"
  2.  
  3. CIcmp::CIcmp(char type[8], char code[8], char checksum[8], char identifier[8], char sequenceNumber[8], char *additionalData) {
  4. char packet[strlen(type) + strlen(code) + strlen(checksum) + strlen(identifier) + strlen(sequenceNumber) + strlen(additionalData)];
  5.  
  6. //packet[0] = *type;
  7. strcpy(packet, type);
  8. strcpy(packet, code);
  9. strcpy(packet, checksum);
  10. strcpy(packet, identifier);
  11. strcpy(packet, sequenceNumber);
  12. strcpy(packet, additionalData);
  13.  
  14. icmpBuildPacket(packet);
  15.  
  16. }
  17.  
  18. CIcmp::~CIcmp() {
  19.  
  20. }
  21.  
  22. char* CIcmp::icmpBuildPacket(char *packet) {
  23. return packet;
  24. }
To copy to clipboard, switch view to plain text mode 

Now I want to know, if I did that correctly? (I know I have to calculate the checksum, but let's say the additionalData is always 0 for now)

Well, now I need a way to send this packet over the network to destination --> what would be the best way to do that?