我需要帮助我试图使用memcpy复制内核空间的标题,但屏幕只是黑色,似乎它不喜欢我的memcpy。有人帮助我。
remaining = ntohs(iphead->tot_len) - 20; //(remaining = total size of ip packet - size of meta header)
while(remaining != 0) {
currentHead = (struct iphdr *) pos; //save the first 'real' header
if(currentHead == NULL)
goto fail;
nskb = dev_alloc_skb(ntohs(currentHead->tot_len) + MAC_LENGTH );
if(nskb == NULL)
goto fail; //We can't allocate that memory so we leave
if(nskb->tail + MAC_LENGTH + ntohs(currentHead->tot_len) <= nskb->end){
nskb->data = skb_put(nskb, (MAC_LENGTH + ntohs(currentHead->tot_len))); // allocated all the memory we need
memcpy(nskb->data,(*skb)->mac_header, MAC_LENGTH); //Put the mac header in place
nskb->mac_header = nskb->data; //Save the mac header location
nskb->network_header = nskb->data + MAC_LENGTH; //Move the pointer to where the network header will be
memcpy(nskb->network_header, pos, ntohs(currentHead->tot_len)); //save the ip + payload
nskb->data = nskb->network_header;
答案 0 :(得分:0)
pos真的有效吗?哪个memcpy给你带来问题?这是我假设的Linux内核吗?