Thread: How can I read what data is in packet?

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    26

    How can I read what data is in packet?

    Hello,

    I am working with video packets and know that MPEG4 packets begin with hex values 00 00 01 B6. I want to know if I am working with mp4 or not. How can I read information from packet to equal these values? m->payload gives only payload of packet without any headers.

    Code:
     case IPQM_PACKET: 
     {
    // take packets from buffer here
      ipq_packet_msg_t *m = ipq_get_packet(buf);
    
       int x;
      if(value in m->payload[x] == value) ??
    {
      printf("MPEG packet");
    x++;
    }
     
     // and put them back here
    status = ipq_set_verdict(h, m->packet_id,NF_ACCEPT, 0, NULL); 
         
      break;
         }
    Full code: http://pastebin.com/raw.php?i=c2UgZkEj

    MC

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    You might be looking for:
    Code:
        if (memcmp(m->payload, "\0\0\1\xb6", 4) == 0)
    Last edited by oogabooga; 07-14-2012 at 02:45 PM. Reason: escaped characters were f'ed up
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    26
    Hmm. As I work with Ubuntu and execute code (tried with few memory functions), I got error: "Segmentation fault (core dumped)" instantly. Any other suggestions?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    Actually, why don't you try debugging it yourself?

    gcc -g -Wall T.c -o T -lipq
    gdb ./T

    Then type 'run' at the gdb prompt.


    When it crashes, investigate commands such as
    bt - to print a stack trace
    frame n - to pick a stack frame to look at
    print var - to examine the values of variables
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    26
    Thank you Salem. I will try to do this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Packet data extraction
    By shinpin in forum C Programming
    Replies: 14
    Last Post: 08-09-2011, 07:29 AM
  2. WinPCap - Packet data containing strings?
    By Glorfindel in forum C Programming
    Replies: 11
    Last Post: 02-11-2009, 03:34 PM
  3. Replies: 21
    Last Post: 11-03-2007, 02:56 PM
  4. packet data
    By l2u in forum Networking/Device Communication
    Replies: 16
    Last Post: 01-22-2007, 11:46 AM
  5. packet data format check
    By gooddevil in forum Networking/Device Communication
    Replies: 1
    Last Post: 05-12-2004, 01:26 PM