Looking for example for SIP invite

23 views
Skip to first unread message

jquin...@gmail.com

unread,
Dec 31, 2019, 4:57:43 PM12/31/19
to PcapPlusPlus support
    Hi,

I'm trying to create an application which generates a SIP invite.  I'm trying to find a good example of how to set up a SIP header.  Below is the code I have so far.  I believe I have the invite header set up correctly.  However, I'm not sure how to add the rest of the SIP header (to/from/via...).  sipLayer.isHeaderComplete returns 0, which makes sense.  Does any one have a good example of how to add the other parameters?  Thanks!

    MacAddress mac;
    EthLayer ethLayer(mac, mac, PCPP_ETHERTYPE_IP);

    IPv4Layer ipLayer("127.0.0.1", "127.0.0.1");
    UdpLayer udpLayer(5061, 5060);
    SipRequestLayer sipLayer(SipRequestLayer::SipINVITE, "sip:us...@127.0.0.1:5060", "SIP/2.0");
    
    Packet packet(800);
    packet.addLayer(&ethLayer);
    packet.addLayer(&ipLayer);
    packet.addLayer(&udpLayer);
    packet.addLayer(&sipLayer);  // Right now I'm crashing here

jquin...@gmail.com

unread,
Jan 3, 2020, 9:58:06 AM1/3/20
to PcapPlusPlus support
I figured out the solution.  Posting it here is case someone else has the same question.  Just needed to call the addField method:

SipRequestLayer sipLayer(SipRequestLayer::SipINVITE, "sip:ser...@10.180.117.11:5060", "SIP/2.0");
    sipLayer.addField("Via", "SIP/2.0/UDP 127.0.1.1:5061;branch=z9hG4bK-3193-47-0");
    sipLayer.addField("From", "sipp <sip:si...@127.0.1.1:5061>;tag=3193SIPpTag0047");
    sipLayer.addField("To", "service <sip:ser...@10.180.117.11:5060>");
    sipLayer.addField("Call-ID", "39-2...@127.0.1.1");
    sipLayer.addField("CSeq", "1 INVITE");
    sipLayer.addField("Contact", "sip:si...@127.0.1.1:5061");
    sipLayer.addField("Max-Forwards", "70");
    sipLayer.addField("Subject", "Performance Test");
    sipLayer.addField("Content-Type", "application/sdp");
Reply all
Reply to author
Forward
0 new messages