X-Originating-IP: [198.26.123.36]
From: "Tuu Le" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: linux driver header files
Date: Mon, 13 Jan 2003 21:27:41 +0000
X-OriginalArrivalTime: 13 Jan 2003 21:27:41.0721 (UTC) FILETIME=[9AB34890:01C2BB4A]
X-SpamPal: PASS                                                                                                                                                                                                                                                                                                                  

Hi Dave,
 
I'm Tuu Le. I'm trying to port some STREAMS drivers from UNIX SCO over to LINUX STREAMS (LiS). In my ipf (internet packet filter) SCO driver, I have to use 'struct ip' which contains 'ip_v', ip_p, ip_src ...fields etc. So, that why I have to include <netinet/ip.h> for supporting that struct. But when I port to LiS, if I keep including <netinet/ip.h>, that won't compile, but if I include <linux/ip.h>, that will compile. However , <linux/ip.h> doesn't have 'struct ip' and ip_v, ip_p...fields. So, how can I use <netinet/ip.h> for kernel headers for my driver? Or do you have any idea how to use other kernel header that will include 'struct ip' for my LiS driver?
 
I also attach two files, one for my driver and another for makefile. If you have time, please take a look for me.
 
Thanks in advance!
 
Tuu


MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
/*
** CM BOILERPLATE:
**
** Copyright (c) 1997 TELOS Corporation
** ------------------------------------
** This computer program is copyrighted by TELOS Corporation.
** Its use, in whole or in part, is restricted to activities in
** support of work being done for the U.S. Government.  Any other
** use of this computer program is prohibited unless expressly
** approved by TELOS Corporation.
**
** This material may be reproduced by or for the U.S. Government
** pursuant to the copyright license under the clause at DFARS
** 252.227-7013 (OCT 88).
**
** ENG NO:                       TSS2718
** FILENAME:                     ipf.c
** CM LEVEL:                     1.2
**
** REVISION HISTORY:
** 05-AUG-1998                   Gilbert,CD
** TAR:TSF11-0240
** Fixed segmentation violation & implemented 188-220.
**
** END CURRENT HISTORY:
**
** 27-MAY-1996                   Chris Gilbert
** RSL:TSSRSL
** Developed to accommodate RSL 188-220A requirement, 2.3.19. Use with SCO5.
**
**
** END HISTORY:
*/
/*
*  STREAM MODULE (ipf.c) -- push between ppp and ip multiplexer.
*
*  This module monitors data and ioctls going to and from a STREAM device in
*  real time.  It allows Selected Directed Broadcast messages to be passed
*  up the stream.  The stream module will also allow us to transmit with
*  a fake IP source address for testing, and allow us to receive messages
*  addressed to our simulated subscribers.  This module is the key for our
*  network manipulation in a testing environment.  The serial device sets
*  in promiscuous mode which allows this module to look at all the messages
*  coming off the PPP net.  The IP multiplexer is relied upon to sort
*  or discard the appropriate messages.  For debugging or monitoring of
*  the PPP network the printout is on the console if cmn_err uses a "^"
*  or to the putbuf with the "!".  Usage is to push it into a Stream
*  before the IP multiplexer.
*
*  To install the STREAM MODULE perform the following:
*   1. su to root.
*   2. SCO5 USE ONLY: cc -c -Zp1 -DINKERNEL -D_INKERNEL ipf.c
*   3. cp ipf.o Driver.o
*   4. Ensure these files are in the current directory:
*      a. Driver.o
*      b. space.c (cp ipf_space.c)
*      c. Master  (ipf - Si ipf 0 0 1 4 -1)
*      d. System  (ipf Y 1 0 0 0 0 0 0 0)
*   5. /etc/conf/bin/idinstall -d ipf     #removes previous module versions
*   6. /etc/conf/bin/idinstall -a -k ipf  #installs module
*   7. cp space.c /etc/conf/pack.d/ipf
*   8. /etc/conf/bin/idbuild              #rebuilds kernel
*   9. SCO5 USE ONLY: ppplink will take care of this step when tss
*                    runs or you can add this option to /etc/ppphosts:
*
*      filter=tss
*
*      This entry must be added to /etc/pppfilter:
*
*         tss bringup \
*             pass dst net 0.0.0.0\
*             keepup
*
*      The system will automatically push the module on the device.
*
*  10. reboot system.
*/
#define __KERNEL__
#define MODULE                   /* LiS */
#include <sys/stream.h>          /* required in all modules and drivers */
#include <linux/version.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/config.h>
#include <linux/pci.h>
#include <linux/kernel.h>
#include <sys/stropts.h>
#include <sys/dlpi.h>
#include <sys/strport.h>
#include <sys/strconfig.h>
#include <sys/types.h>           /* required in all modules and drivers */
/*#include <sys/param.h>
#include <sys/socket.h>
#include <sys/cmn_err.h>*/
/*#include <sys/lihdr.h> */           /* stream control   */
/*#include <net/if.h>*/               /* struct ifreq     */
/*#include <netinet/in.h>*/          /* IP-related files */
/*#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>

#include "ipf.h"
*/
#include <sys/stropts.h>

/*#include <asm/socket.h>*/
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/osif.h>
/*
*  UNIX requirement:
*  These structures provide global info about the module and its queues.
*/
static struct module_info chckinfo = { 0x6475, "check", 0, INFPSZ, 0, 0 };
/*static struct module_info ipfwinfo = { 0x6475, "check", 0, INFPSZ, 0, 0 };
*/
/*
*  Prototypes for STREAMS module entry points.
*/
/* static int ipfopen(), ipfrput(), ipfwput(), ipfclose();
*/
/*
*  UNIX requirement:
*  These structures define the characteristics and processing
*  routines associated with the queue.
*/
static struct qinit rinit =
   { NULL, NULL, NULL, NULL, NULL, &chckinfo, NULL };

static struct qinit winit =
   { NULL, NULL, NULL, NULL, NULL, &chckinfo, NULL };

/*
*  UNIX requirement:
*  This structure provides the operating system a handle to the module.
*/
struct streamtab checkinfo = { &rinit, &winit, NULL, NULL };

int init_module(void)
{
        int ret = lis_register_strdev(125, &checkinfo, 4, "check");
        if (ret < 0) {
           printk("check.init_module: Unable to register module.\n");
           return ret;
        }
        return 0;
}

void cleanup_module(void)
{
        if (lis_unregister_strdev(125) < 0)
            printk("check.cleanup_module: Unable to unregister module.\n");
        else
          printk("check.cleanup_module: Unregistered, ready to be unloaded.\n");

}


#CFLAGS=-I/usr/src/LiS/include -I/usr/src/LiS/include/sys/LiS -O -Wall 
-DLIS_COMPILE -D__KERNEL__ -DLINUX

CFLAGS=-I/usr/src/LiS/include -I -O -Wall -DCONFIG_KERNELD -DLIS_COMPILE 
-D__KERNEL__ -DLINUX


check.o: check.c
        cc -c $(CFLAGS) $(DFLAGS) check.c

clean:
        rm -f *.o

Reply via email to