LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-25-2008, 06:18 AM   #1
nasim751
Member
 
Registered: Jan 2008
Posts: 40

Rep: Reputation: 15
Wink mbuf.h: No such file or directory


how you will deal this problem

Quote:
udp_spoof_detect.c:56:19: error: systm.h: No such file or directory
udp_spoof_detect.c:58:18: error: mbuf.h: No such file or directory
udp_spoof_detect.c:59:20: error: kernel.h: No such file or directory
udp_spoof_detect.c:60:22: error: sys/proc.h: No such file or directory
udp_spoof_detect.c:65:25: error: sys/protosw.h: No such file or directory
udp_spoof_detect.c:70:28: error: netinet/in_pcb.h: No such file or directory
udp_spoof_detect.c:72:28: error: netinet/ip_var.h: No such file or directory
udp_spoof_detect.c:75:27: error: Linux/udp_var.h: No such file or directory
udp_spoof_detect.c:78: error: array type has incomplete element type
udp_spoof_detect.c:83: warning: ‘struct module’ declared inside parameter list
udp_spoof_detect.c:83: warning: its scope is only this definition or declaration, which is probably not what you want
udp_spoof_detect.c:85: warning: ‘struct proc’ declared inside parameter list
udp_spoof_detect.c:85: warning: ‘struct mbuf’ declared inside parameter list
udp_spoof_detect.c:85: warning: ‘struct socket’ declared inside parameter list
udp_spoof_detect.c:89: warning: ‘struct proc’ declared inside parameter list
udp_spoof_detect.c:89: warning: ‘struct mbuf’ declared inside parameter list
udp_spoof_detect.c:89: warning: ‘struct socket’ declared inside parameter list
udp_spoof_detect.c:93: warning: ‘struct proc’ declared inside parameter list
udp_spoof_detect.c:93: warning: ‘struct mbuf’ declared inside parameter list
udp_spoof_detect.c:93: warning: ‘struct inpcb’ declared inside parameter list
udp_spoof_detect.c:109: warning: ‘struct module’ declared inside parameter list
udp_spoof_detect.c:110: error: conflicting types for ‘s_load’
udp_spoof_detect.c:83: error: previous declaration of ‘s_load’ was here
udp_spoof_detect.c: In function ‘s_load’:
udp_spoof_detect.c:114: error: ‘MOD_LOAD’ undeclared (first use in this function)
udp_spoof_detect.c:114: error: (Each undeclared identifier is reported only once
udp_spoof_detect.c:114: error: for each function it appears in.)
udp_spoof_detect.c:116: error: ‘ip_protox’ undeclared (first use in this function)
udp_spoof_detect.c:121: error: ‘MOD_UNLOAD’ undeclared (first use in this function)
udp_spoof_detect.c: At top level:
udp_spoof_detect.c:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘s_mod_1’
udp_spoof_detect.c:137: warning: data definition has no type or storage class
udp_spoof_detect.c:137: warning: parameter names (without types) in function declaration
udp_spoof_detect.c:142: warning: ‘struct proc’ declared inside parameter list
udp_spoof_detect.c:142: warning: ‘struct mbuf’ declared inside parameter list
udp_spoof_detect.c:142: warning: ‘struct socket’ declared inside parameter list
udp_spoof_detect.c:143: error: conflicting types for ‘udp_send’
udp_spoof_detect.c:85: error: previous declaration of ‘udp_send’ was here
udp_spoof_detect.c: In function ‘udp_send’:
udp_spoof_detect.c:146: warning: assignment makes pointer from integer without a cast
udp_spoof_detect.c:149: error: ‘EINVAL’ undeclared (first use in this function)
udp_spoof_detect.c:151: warning: passing argument 1 of ‘udp_output’ from incompatible pointer type
udp_spoof_detect.c:151: warning: passing argument 2 of ‘udp_output’ from incompatible pointer type
udp_spoof_detect.c:151: warning: passing argument 4 of ‘udp_output’ from incompatible pointer type
udp_spoof_detect.c:151: warning: passing argument 5 of ‘udp_output’ from incompatible pointer type
udp_spoof_detect.c: In function ‘udp_output’:
udp_spoof_detect.c:162: error: argument ‘inp’ doesn’t match prototype
udp_spoof_detect.c:93: error: prototype declaration
udp_spoof_detect.c:162: error: argument ‘m’ doesn’t match prototype
udp_spoof_detect.c:93: error: prototype declaration
udp_spoof_detect.c:162: error: argument ‘control’ doesn’t match prototype
udp_spoof_detect.c:93: error: prototype declaration
udp_spoof_detect.c:162: error: argument ‘p’ doesn’t match prototype
udp_spoof_detect.c:93: error: prototype declaration
udp_spoof_detect.c:164: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:172: error: invalid application of ‘sizeof’ to incomplete type ‘struct udpiphdr’
udp_spoof_detect.c:173: error: ‘EMSGSIZE’ undeclared (first use in this function)
udp_spoof_detect.c:180: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:181: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:182: error: ‘EISCONN’ undeclared (first use in this function)
udp_spoof_detect.c:195: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:196: error: ‘ENOTCONN’ undeclared (first use in this function)
udp_spoof_detect.c:204: error: invalid application of ‘sizeof’ to incomplete type ‘struct udpiphdr’
udp_spoof_detect.c:204: error: ‘M_DONTWAIT’ undeclared (first use in this function)
udp_spoof_detect.c:206: error: ‘ENOBUFS’ undeclared (first use in this function)
udp_spoof_detect.c:216: error: expected expression before ‘struct’
udp_spoof_detect.c:216: warning: assignment makes pointer from integer without a cast
udp_spoof_detect.c:217: warning: incompatible implicit declaration of built-in function ‘bzero’
udp_spoof_detect.c:217: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:217: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:218: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:219: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:220: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:220: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:221: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:221: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:222: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:222: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:223: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:223: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:224: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:224: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:229: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:231: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:231: error: invalid application of ‘sizeof’ to incomplete type ‘struct udpiphdr’
udp_spoof_detect.c:232: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:234: error: invalid application of ‘sizeof’ to incomplete type ‘struct udpiphdr’
udp_spoof_detect.c:235: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:236: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:238: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:239: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:240: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:242: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:242: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:242: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:242: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:244: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:244: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:244: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:244: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:251: error: invalid use of undefined type ‘struct udpstat’
udp_spoof_detect.c:253: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:253: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:254: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:255: error: dereferencing pointer to incomplete type
udp_spoof_detect.c:259: error: dereferencing pointer to incomplete type

program...........
Code:
#define MY_IP 		"192.168.1.2"
#define MY_SECOND_IP	"192.168.1.2"
/* my machine has only an ip address and no other eth# or ip aliases */
#define LOOPBACK	"127.0.0.1"
#define DONT_PASS
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h>
#include <systm.h>
#include <malloc.h>
#include <mbuf.h>
#include <kernel.h>
#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <syslog.h>
#include <sys/protosw.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>


extern struct 	protosw 	inetsw[];
extern struct 	udpstat 	udpstat;
static int 	udpcksum	=	1;


static int  	 s_load	 		__P((struct module *, int, void *));

static int	 udp_send		__P((struct socket * , int , 
					     struct mbuf *, struct sockaddr *, 
					     struct mbuf *, struct proc *));

static int	 (*old_udp_send)	__P((struct socket * , int ,
					     struct mbuf *, struct sockaddr *,
					     struct mbuf *, struct proc *));

static int	 udp_output		__P((struct inpcb    *, struct mbuf *,
					     struct sockaddr *, struct mbuf *,
					     struct proc *));

static u_int32_t inaton			__P((const char *));


/* ipfw macro... inet_ntoa() also works well from here it's the same thing */

#define print_ip(a)	printf("%d.%d.%d.%d",				\
				(int)(ntohl(a.s_addr)  >> 24) & 0xFF,	\
				(int)(ntohl(a.s_addr)  >> 16) & 0xFF,	\
				(int)(ntohl(a.s_addr)  >> 8 ) & 0xFF,	\
				(int)(ntohl(a.s_addr))  & 0xFF);

static int
s_load (struct module *module, int cmd, void *arg)
{
 int s;

 switch(cmd) {
	case MOD_LOAD:
	  s = splnet();
	  old_udp_send = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs->pru_send;
	  inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs->pru_send = udp_send;
	  splx(s);
	  break;
			
	case MOD_UNLOAD:
	  s = splnet();
	  inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs->pru_send = old_udp_send;
	  splx(s);
	  break;
 }

 return 0;
}

static moduledata_t s_mod_1 = {
	        "udp_mod",
	        s_load,
	        0
};

DECLARE_MODULE(udp_mod, s_mod_1, SI_SUB_PSEUDO, SI_ORDER_ANY);


static int
udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
	    struct mbuf *control, struct proc *p)
{
	struct inpcb *inp;

	inp = sotoinpcb(so);
	if (inp == 0) {
		m_freem(m);
		return EINVAL;
	}
	return udp_output(inp, m, addr, control, p);
}


static int
udp_output(inp, m, addr, control, p)
	register struct inpcb *inp;
	register struct mbuf *m;
	struct sockaddr *addr;
	struct mbuf *control;
	struct proc *p;
{
	register struct udpiphdr *ui;
	register int len = m->m_pkthdr.len;
	struct in_addr laddr;
	struct sockaddr_in *sin;
	int s = 0, error = 0;

	if (control)
		m_freem(control);		/* XXX */

	if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
		error = EMSGSIZE;
		goto release;
	}

	if (addr) {
		sin = (struct sockaddr_in *)addr;
		prison_remote_ip(p, 0, &sin->sin_addr.s_addr);
		laddr = inp->inp_laddr;
		if (inp->inp_faddr.s_addr != INADDR_ANY) {
			error = EISCONN;
			goto release;
		}
		/*
		 * Must block input while temporarily connected.
		 */
		s = splnet();
		error = in_pcbconnect(inp, addr, p);
		if (error) {
			splx(s);
			goto release;
		}
	} else {
		if (inp->inp_faddr.s_addr == INADDR_ANY) {
			error = ENOTCONN;
			goto release;
		}
	}
	/*
	 * Calculate data length and get a mbuf
	 * for UDP and IP headers.
	 */
	M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
	if (m == 0) {
		error = ENOBUFS;
		if (addr)
			splx(s);
		goto release;
	}

	/*
	 * Fill in mbuf with extended UDP header
	 * and addresses and length put into network format.
	 */
	ui = mtod(m, struct udpiphdr *);
	bzero(ui->ui_x1, sizeof(ui->ui_x1));
	ui->ui_pr = IPPROTO_UDP;
	ui->ui_len = htons((u_short)len + sizeof (struct udphdr));
	ui->ui_src = inp->inp_laddr;
	ui->ui_dst = inp->inp_faddr;
	ui->ui_sport = inp->inp_lport;
	ui->ui_dport = inp->inp_fport;
	ui->ui_ulen = ui->ui_len;

	/*
	 * Stuff checksum and output datagram.
	 */
	ui->ui_sum = 0;
	if (udpcksum) {
	    if ((ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len)) == 0)
		ui->ui_sum = 0xffff;
	}
	((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
	((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl;	/* XXX */
	((struct ip *)ui)->ip_tos = inp->inp_ip_tos;	/* XXX */

	if(ui->ui_src.s_addr != inaton(MY_IP) 		&& 
	   ui->ui_src.s_addr != inaton(MY_SECOND_IP) 	&& 
	   ui->ui_src.s_addr != inaton(LOOPBACK)) {
	 printf("UDP Spoofing detected as: "); 
	 print_ip(ui->ui_src);
	 printf(" to ");
	 print_ip(ui->ui_dst);
#ifdef DONT_PASS		
	 printf(" Packet not accepted to be sent\n");
	 goto release;
#endif
	}
	
	udpstat.udps_opackets++;
	
	error = ip_output(m, inp->inp_options, &inp->inp_route,
	    inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
	    inp->inp_moptions);

	if (addr) {
		in_pcbdisconnect(inp);
		inp->inp_laddr = laddr;	/* XXX rehash? */
		splx(s);
	}
	return (error);

release:
	m_freem(m);
	return (error);
}

u_int32_t inaton(const char *str)
{
	unsigned long l;
	unsigned int val;
	int i;

	l = 0;

	for(i=0; i < 4; i++) {
		l <<= 8;
		if(*str != '\0') {
			val = 0;
			while(*str != '\0' && *str != '.') {
				val *= 10;
				val += *str - '0';
				str++;
			}
			l |= val;
			if(*str != '\0')
				str++;
		}
	}
	return(htonl(l));
}
 
Old 04-26-2008, 09:24 PM   #2
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
Makefile

In your Makefile you have to give information on the location of those header files. Something like:

Code:
INCS=-I. -I/usr/src/linux
SRCS=main.c
OBJS=main.o

exe:
    gcc -c $(SRCS) $(INCS)
    gcc -o exe $(OBJS) $(LIBS)
The linux headers can also be installed by using the kernel-devel package.

Linux

Last edited by marquardl; 05-01-2008 at 05:21 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 11:18 PM
How to untar a file in another directory other then current directory. dr_zayus69 Linux - Software 8 05-16-2007 12:01 PM
Java File Processing using Scanner; Can't get it to read file in running directory xemous Programming 2 09-26-2006 07:13 PM
How to protect a file/directory in your home login directory (RH Linux) jitsenho Linux - Security 9 07-04-2006 12:08 AM
FreeBSD struct mbuf mtod manipulation GodSendDeath *BSD 1 07-14-2005 10:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration