Hi,

I am trying to send my own IP packet through kernel (ip_output), but I get the following panic. Can anyone explain where the problem is? Thank you.

Max

Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
Fault virtual address = 0xc
fault code = supervisor read, page not present


My code:
struct mbuf *result=NULL;
MGETHDR(result, M_DONTWAIT, MT_DATA);
result->m_len = 20 + 4 ;
result->m_next = NULL;
struct ip xu;
xu.ip_hl = 0x5;
xu.ip_v = 0x4;
xu.ip_tos = 0x0;
xu.ip_len = htons(result->m_len);// total length of the IP packet
xu.ip_id = htons(12830);
xu.ip_off = 0x0;
xu.ip_ttl = 64;
xu.ip_p = IPPROTO_IP;
xu.ip_sum = 0x0;
xu.ip_src = sah->saidx.mobs.sin.sin_addr;
xu.ip_dst = sah->saidx.mobd.sin.sin_addr;
xu.ip_sum = in_cksum_hdr(&xu);
char ttt[5]="xuxu";
bcopy(&xu, mtod(result, caddr_t), sizeof(struct ip));
bcopy(ttt, mtod(result, caddr_t) + 20, 4);
for (n = result; n; n = n->m_next)
result->m_pkthdr.len += n->m_len;
ip_output(result, NULL, NULL, IP_RAWOUTPUT, NULL, NULL);