c++ - End of file on pipe magic during open -
i have c++ application in starting process(wireshark) following.
if (fp == null){ fp = popen(processpath, "r"); //processpath process want start if (!fp){ throw std::invalid_argument("cannot start process"); } fprintf(fp, d_msg);//d_msg input want provide process } else if(fp != null){ fprintf(fp, d_msg); }
the problem when execute c++ application, start wireshark error end of file on pipe magic during open
what should avoid that?
also tried using mkfifo create named pipe , execute it. used this:
if (fp == null){ system("mkfifo /tmp/mine.pcap"); fp = popen("wireshark -k -i /tmp/mine.pcap", "r"); if (!fp){ dout << "cannot start wireshark"<<std::endl; throw std::invalid_argument("cannot start wireshark"); } input = fopen("/tmp/mine.pcap", "wb"); fprintf(input , d_msg); fclose(input); } else if(fp != null){ input = fopen("/tmp/mine.pcap", "wb"); fprintf(input , d_msg); fclose(input); }
but didn't work. following error:
the file "/tmp/wireshark_mine.pcap_20130730012654_ndbfzk" capture network type wireshark doesn't support
any appreciated.
thank much.
the problem when execute c++ application, start wireshark error
end of file on pipe magic during open
what should avoid that?
you should write pcap file or pcap-ng file pipe, rather fprintfing something.
both of file formats binary. if you're constructing own packets, have construct , write pipe valid pcap file header or several valid pcap-ng blocks (section header block , @ least 1 interface description block) before can write packets, , then, each packet, have write per-packet pcap header or beginning and end of pcap-ng enhanced packet block before (and, enhanced block, after) raw packet data. if you're sending existing file wireshark, need read raw bytes file , send raw bytes down pipe.
Comments
Post a Comment