我需要帮助我正在尝试使用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;发布于 2011-05-18 00:25:36
pos真的有效吗?哪个memcpy给你带来了问题?我猜这是Linux内核吗?
https://stackoverflow.com/questions/6033912
复制相似问题