This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于NDK的raw socket的问题



各位工程师:

   你们好,我在利用NDK内SOCKET接口通信时,需要取得IP、TCP层以及应用层的数据。现在采用socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)这种去新建套接字时,只能获得应用层的数据。我想到利用raw socket方式去新建套接字,可是查看NDK的相关文档发现只能采用raw ethernet这种方式去新建套接字:

socket(AF_RAWETH,SOCK_RAWETH,protocol_type)     //其中protocol type不能为Ip或者IPV6等的协议

并且发送或者接受的数据格式必须为:

6字节的目标mac地址+6字节的src mac地址+ethernnet type+payload,

而我现在的需求是采用IPV4+tcp进行通信时获得这两层的数据,请问该如何实现?多谢帮忙了!