Skip navigation.
Home
The QNX Community Portal

View topic - how to solve this error ??

Page 1 of 1

how to solve this error ??

PostPosted: Wed May 14, 2014 5:45 pm
by hemanth
#include <sys/types.h>
#include <errno.h>
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
#include <net/if.h>
#include <net/pfil.h>
#include <netinet/in.h>
#include <netinet/ip.h>

#include <net/pfil.h>
#include <time.h>
#include <sys/param.h>
#include <sys/mbuf.h>
#include <net/if.h>
#include <net/pfil.h>

#include <signal.h>

#include <string.h> /* for memset */
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <sys/select.h>
#include <netdb.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/neutrino.h>
#include <sched.h> /* for sched_setsched */
#include <unistd.h> /* for usleep */


#include <libc.h>
#include <inttypes.h>
#include <sys/neutrino.h>
#include <sys/netmgr.h>
#include <sys/syspage.h>


#include <sys/procfs.h>
#include "sys/io-pkt.h"
#include "nw_datastruct.h"



struct pfil_head *
pfil_head_get(int af, u_long dlt);

struct packet_filter_hook *
pfil_hook_get(int dir, struct pfil_head *ph);

int
pfil_add_hook(int (*func)(), void *arg, int flags,
struct pfil_head *ph);

int
pfil_remove_hook(int (*func)(), void *arg, int flags,
struct pfil_head *ph);

int
(*func)(void *arg, struct mbuf **mp, struct ifnet *, int dir);



static int in_bytes = 0;
static int out_bytes = 0;


static int input_hook(void *arg, struct mbuf **m,
struct ifnet *ifp, int dir)
{
in_bytes += (*m)->m_len;
return 0;
}

static int output_hook(void *arg, struct mbuf **m,
struct ifnet *ifp, int dir)
{
out_bytes += (*m)->m_len;
return 0;
}


static int deinit_module(void);
static int iface_hook(void *arg, struct mbuf **m,
struct ifnet *ifp, int dir)
{
printf("Iface hook called ... ");
if ( (int)m == PFIL_IFNET_ATTACH) {
printf("Interface attached\n");
printf("%d bytes in, %d bytes out\n", in_bytes,
out_bytes);
} else if ((int)m == PFIL_IFNET_DETACH) {
printf("Interface detached\n");
printf("%d bytes in, %d bytes out\n", in_bytes,
out_bytes);
deinit_module();
}
return 0;
}

static int ifacecfg_hook(void *arg, struct mbuf **m,
struct ifnet *ifp, int dir)
{

printf("Iface cfg hook called with 0x%08X\n", (int)(m));

return 0;
}

static int deinit_module(void)
{
struct pfil_head *pfh_inet;

pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET);
if (pfh_inet == NULL) {
return ESRCH;
}
pfil_remove_hook(input_hook, NULL, PFIL_IN | PFIL_WAITOK,
pfh_inet);
pfil_remove_hook(output_hook, NULL, PFIL_OUT | PFIL_WAITOK,
pfh_inet);

pfh_inet = pfil_head_get(PFIL_TYPE_IFNET, 0);
if (pfh_inet == NULL) {
return ESRCH;
}

pfil_remove_hook(ifacecfg_hook, NULL, PFIL_IFNET, pfh_inet);

pfil_remove_hook(iface_hook, NULL, PFIL_IFNET | PFIL_WAITOK,
pfh_inet);
printf("Unloaded pfil hook\n" );

return 0;
}



int pfil_entry(void *dll_hdl, struct _iopkt_self *iopkt,
char *options)
{
struct pfil_head *pfh_inet;

pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET);
if (pfh_inet == NULL) {
return ESRCH;
}
pfil_add_hook(input_hook, NULL, PFIL_IN | PFIL_WAITOK,
pfh_inet);
pfil_add_hook(output_hook, NULL, PFIL_OUT | PFIL_WAITOK,
pfh_inet);

pfh_inet = pfil_head_get(PFIL_TYPE_IFNET,0);
if (pfh_inet == NULL) {
return ESRCH;
}

pfil_add_hook(iface_hook, NULL, PFIL_IFNET, pfh_inet);
pfil_add_hook(ifacecfg_hook, NULL, PFIL_IFADDR, pfh_inet);
printf("Loaded pfil hook\n" );

return 0;
}

struct _iopkt_lsm_entry IOPKT_LSM_ENTRY_SYM(mod) =
IOPKT_LSM_ENTRY_SYM_INIT(pfil_entry);


int main()
{
return 1;
}

ERROR :

Description Resource Path Location Type
undefined reference to `pfil_add_hook' packet.c /packet line 0 C/C++ Problem
undefined reference to `pfil_add_hook' packet.c /packet line 160 C/C++ Problem
undefined reference to `pfil_add_hook' packet.c /packet line 162 C/C++ Problem
undefined reference to `pfil_add_hook' packet.c /packet line 170 C/C++ Problem
undefined reference to `pfil_add_hook' packet.c /packet line 171 C/C++ Problem
undefined reference to `pfil_head_get' packet.c /packet line 0 C/C++ Problem
undefined reference to `pfil_head_get' packet.c /packet line 126 C/C++ Problem
undefined reference to `pfil_head_get' packet.c /packet line 135 C/C++ Problem
undefined reference to `pfil_head_get' packet.c /packet line 156 C/C++ Problem
undefined reference to `pfil_head_get' packet.c /packet line 165 C/C++ Problem
undefined reference to `pfil_remove_hook' packet.c /packet line 0 C/C++ Problem
undefined reference to `pfil_remove_hook' packet.c /packet line 130 C/C++ Problem
undefined reference to `pfil_remove_hook' packet.c /packet line 132 C/C++ Problem


how to perform the communication between io-pkt and user application ??
how to rebuild the io -pkt driver ??
can i use packet filter to communication between io-pkt and user application ?
how to solve he above error ?

Re: how to solve this error ??

PostPosted: Tue May 20, 2014 12:57 pm
by space
Try #include <sys/io-pkt.h> instead of #include "sys/io-pkt.h"
Using <> tells the compiler to look in system directories.
Using "" tells the compiler to look in local directories.