--- linux/kernel/ksyms.c.orig Mon Sep 21 20:19:39 1998 +++ linux/kernel/ksyms.c Tue Sep 15 21:01:40 1998 @@ -105,6 +105,11 @@ EXPORT_SYMBOL(exit_fs); EXPORT_SYMBOL(exit_sighand); +#ifdef CONFIG_VIRTUAL_MOD +extern int virtual_mod(void *,void *,void *); +EXPORT_SYMBOL(virtual_mod); +#endif + /* internal kernel memory management */ EXPORT_SYMBOL(__get_free_pages); EXPORT_SYMBOL(free_pages); --- linux/Makefile~ Wed Aug 26 19:30:01 1998 +++ linux/Makefile Sun Sep 13 18:50:52 1998 @@ -111,6 +111,12 @@ LIBS =$(TOPDIR)/lib/lib.a SUBDIRS =kernel drivers mm fs net ipc lib + +ifdef CONFIG_VIRTUAL +SUBDIRS += virtual +NETWORKS += virtual/virtual.a +endif + ifdef CONFIG_NUBUS DRIVERS := $(DRIVERS) drivers/nubus/nubus.a endif --- linux/arch/alpha/config.in.orig Wed Aug 26 19:29:29 1998 +++ linux/arch/alpha/config.in Sun Sep 13 14:26:01 1998 @@ -280,6 +280,8 @@ fi endmenu +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/arm/config.in.orig Wed Aug 26 19:28:36 1998 +++ linux/arch/arm/config.in Sun Sep 13 14:26:01 1998 @@ -164,6 +164,8 @@ source fs/nls/Config.in +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/i386/config.in.orig Wed Aug 26 19:28:37 1998 +++ linux/arch/i386/config.in Sun Sep 13 14:26:01 1998 @@ -142,6 +142,8 @@ fi endmenu +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/m68k/config.in.orig Wed Aug 26 19:29:37 1998 +++ linux/arch/m68k/config.in Sun Sep 13 14:26:01 1998 @@ -355,6 +355,8 @@ fi endmenu +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/mips/config.in.orig Wed Aug 26 19:28:38 1998 +++ linux/arch/mips/config.in Sun Sep 13 14:26:01 1998 @@ -202,6 +202,8 @@ source drivers/sgi/char/Config.in fi +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/sparc/config.in.orig Wed Aug 26 19:28:46 1998 +++ linux/arch/sparc/config.in Sun Sep 13 14:26:01 1998 @@ -182,6 +182,8 @@ tristate 'Software watchdog' CONFIG_SOFT_WATCHDOG endmenu +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/arch/sparc64/config.in.orig Wed Aug 26 19:28:48 1998 +++ linux/arch/sparc64/config.in Sun Sep 13 14:26:01 1998 @@ -242,6 +242,8 @@ tristate 'Software watchdog' CONFIG_SOFT_WATCHDOG endmenu +source virtual/Config.in + mainmenu_option next_comment comment 'Kernel hacking' --- linux/net/socket.c.orig Wed Aug 26 19:30:13 1998 +++ linux/net/socket.c Sun Sep 13 14:26:01 1998 @@ -93,6 +93,10 @@ #include #include +#ifdef CONFIG_VIRTUAL +extern int sys_vipt(unsigned int mode, unsigned int ip, char *path); +#endif + static long long sock_lseek(struct file *file, long long offset, int whence); static ssize_t sock_read(struct file *file, char *buf, @@ -1319,9 +1323,16 @@ /* Argument list sizes for sys_socketcall */ #define AL(x) ((x) * sizeof(unsigned long)) + +#ifdef CONFIG_VIRTUAL +static unsigned char nargs[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), + AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), + AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),AL(3)}; +#else static unsigned char nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), AL(6),AL(2),AL(5),AL(5),AL(3),AL(3)}; +#endif #undef AL /* @@ -1337,8 +1348,11 @@ unsigned long a[6]; unsigned long a0,a1; int err; - +#ifdef CONFIG_VIRTUAL + if(call<1||call>SYS_VIPT) +#else if(call<1||call>SYS_RECVMSG) +#endif return -EINVAL; /* copy_from_user should be SMP safe. */ @@ -1403,6 +1417,11 @@ case SYS_RECVMSG: err = sys_recvmsg(a0, (struct msghdr *) a1, a[2]); break; +#ifdef CONFIG_VIRTUAL + case SYS_VIPT: + err = sys_vipt((unsigned int)a0,(unsigned int)a1,(char *)a[2]); + break; +#endif default: err = -EINVAL; break; --- linux/include/linux/net.h~ Sun Sep 13 14:53:26 1998 +++ linux/include/linux/net.h Sun Sep 13 18:36:00 1998 @@ -42,7 +42,7 @@ #define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ #define SYS_SENDMSG 16 /* sys_sendmsg(2) */ #define SYS_RECVMSG 17 /* sys_recvmsg(2) */ - +#define SYS_VIPT 18 typedef enum { SS_FREE = 0, /* not allocated */ --- linux/net/ipv4/af_inet.c~ Thu Sep 24 19:15:39 1998 +++ linux/net/ipv4/af_inet.c Sun Oct 4 14:38:32 1998 @@ -114,6 +114,10 @@ #ifdef CONFIG_NET_RADIO #include #endif /* CONFIG_NET_RADIO */ +#ifdef CONFIG_VIRTUAL +extern u32 virtual_getmyip(void); +extern int virtual_checkaddr(u32); +#endif #define min(a,b) ((a)<(b)?(a):(b)) @@ -428,6 +432,10 @@ sk->prot->hash(sk); add_to_prot_sklist(sk); } + +#ifdef CONFIG_VIRTUAL + sk->saddr = virtual_getmyip(); +#endif if (sk->prot->init) { int err = sk->prot->init(sk); @@ -543,6 +543,9 @@ #endif return -EADDRNOTAVAIL; /* Source address MUST be ours! */ } +#ifdef CONFIG_VIRTUAL + if(virtual_checkaddr(addr->sin_addr.s_addr)==0) return -EADDRNOTAVAIL; +#endif /* We keep a pair of addresses. rcv_saddr is the one * used by hash lookups, and saddr is used for transmit. --- linux/kernel/sys.c.orig Fri Dec 25 14:35:21 1998 +++ linux/kernel/sys.c Fri Dec 25 14:36:43 1998 @@ -818,6 +818,9 @@ { int errno = 0; +#ifdef CONFIG_VIRTUAL + if (virtual_newuname(name)==0) return 0; +#endif down(&uts_sem); if (copy_to_user(name,&system_utsname,sizeof *name)) errno = -EFAULT; @@ -833,6 +836,9 @@ return -EPERM; if (len < 0 || len > __NEW_UTS_LEN) return -EINVAL; +#ifdef CONFIG_VIRTUAL + if (virtual_sethostname(name,len)==0) return 0; +#endif down(&uts_sem); errno = -EFAULT; if (!copy_from_user(system_utsname.nodename, name, len)) { @@ -849,6 +855,9 @@ if (len < 0) return -EINVAL; +#ifdef CONFIG_VIRTUAL + if (virtual_gethostname(name,len)==0) return 0; +#endif down(&uts_sem); i = 1 + strlen(system_utsname.nodename); if (i > len) @@ -873,6 +882,9 @@ if (len < 0 || len > __NEW_UTS_LEN) return -EINVAL; +#ifdef CONFIG_VIRTUAL + if (virtual_setdomainname(name,len)==0) return 0; +#endif down(&uts_sem); errno = -EFAULT; if (!copy_from_user(system_utsname.domainname, name, len)) { --- linux/arch/i386/kernel/sys_i386.c~ Wed Aug 26 19:24:32 1998 +++ linux/arch/i386/kernel/sys_i386.c Fri Dec 25 18:03:30 1998 @@ -220,6 +220,9 @@ int err; if (!name) return -EFAULT; +#ifdef CONFIG_VIRTUAL + if (virtual_uname(name)==0) return 0; +#endif down(&uts_sem); err=copy_to_user(name, &system_utsname, sizeof (*name)); up(&uts_sem); @@ -235,6 +238,9 @@ if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname))) return -EFAULT; +#ifdef CONFIG_VIRTUAL + if (virtual_olduname(name)==0) return 0; +#endif down(&uts_sem); error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN); diff -ruN linux2/virtual/Config.in linux/virtual/Config.in --- linux2/virtual/Config.in Thu Jan 1 01:00:00 1970 +++ linux/virtual/Config.in Fri Dec 25 19:16:06 1998 @@ -0,0 +1,13 @@ +# +# Network configuration +# +mainmenu_option next_comment +comment 'Virtuality options' +tristate 'Virtual' CONFIG_VIRTUAL_M +if [ "$CONFIG_VIRTUAL_M" != "n" ]; then + define_bool CONFIG_VIRTUAL y +fi +if [ "$CONFIG_VIRTUAL_M" = "m" ]; then + define_bool CONFIG_VIRTUAL_MOD y +fi +endmenu diff -ruN linux2/virtual/Makefile linux/virtual/Makefile --- linux2/virtual/Makefile Thu Jan 1 01:00:00 1970 +++ linux/virtual/Makefile Fri Dec 25 19:16:06 1998 @@ -0,0 +1,21 @@ + +L_TARGET := virtual.a + +LX_OBJS := calls.o + +ifeq ($(CONFIG_VIRTUAL_M),m) + vobjs := virt.o vmodule.o datavip.o + + M_OBJS := virtual.o +else + ifeq ($(CONFIG_VIRTUAL),y) + L_OBJS += virt.o datavip.o calls.o + endif +endif + +include $(TOPDIR)/Rules.make + +virtual.o: $(vobjs) + $(LD) -r -o $@ $(vobjs) + + diff -ruN linux2/virtual/calls.c linux/virtual/calls.c --- linux2/virtual/calls.c Thu Jan 1 01:00:00 1970 +++ linux/virtual/calls.c Fri Dec 25 19:16:06 1998 @@ -0,0 +1,138 @@ +#if defined(CONFIG_VIRTUAL_MOD) +#include +#include +#else +#include "datavip.h" +#endif +// #include +#include +#include +#include +#include "virt.h" +#include "vip.h" + +#ifdef CONFIG_VIRTUAL_MOD +static int vis_loaded; + +static int (*dovipt_func)(unsigned int mode, unsigned int ip, char *path,char *hostname); +static unsigned int (*get_my_ip_func)(void); +static int (*check_this_addr_func)(unsigned int addr); + +void virtual_mod(void *doviptf, void *getmyip, void *check) +{ +dovipt_func = doviptf; +get_my_ip_func = getmyip; +check_this_addr_func = check; +if (dovipt_func) vis_loaded = 1; else vis_loaded = 0; +} +#endif + +/* sys_vipt - function used to change entries in table + */ +int sys_vipt(unsigned int mode, unsigned int ip, char *path,char *hostname) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return (-EBUSY); +return dovipt_func(mode,ip,path,hostname); +#else +return do_vipt(mode,ip,path,hostname); +#endif +} + +/* virtual_getmyip - gives ip for process + * it checks actual root directory and find ip in data + * structure for that directory + */ +unsigned int virtual_getmyip(void) +{ +#ifdef CONFIG_VIRTUAL_MOD + if (!vis_loaded) return INADDR_ANY; + return get_my_ip_func(); +#else + return get_my_ip(); +#endif +} + + +/* virtual_ckeckaddr - function checks actual root and gets ip for it + * like virtual_getmyip, but then it compares it + * with given (by bind) and returns 0 if it is not good + * and 1 if is good + * it can be changed in future to allow use of more + * than 1 ip on 1 virtual + */ +int virtual_checkaddr(unsigned int addr) +{ +#ifdef CONFIG_VIRTUAL_MOD + if (!vis_loaded) return 1; + return check_this_addr_func(addr); +#else + return check_this_addr(addr); +#endif +} + +int virtual_sethostname(char *name, int len) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +return dovipt_func(VIP_SETHOSTNAME,len,NULL,name); +#else +return do_vipt(VIP_SETHOSTNAME,len,NULL,name); +#endif +} + +// virtual_gethostname - we try to get hostname for that root fs +// if found it returns 0 +// (we use dovipt to do this..:)) +int virtual_gethostname(char *name, int len) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +return dovipt_func(VIP_GETHOSTNAME,len,NULL,name); +#else +return do_vipt(VIP_GETHOSTNAME,len,NULL,name); +#endif +} + +int virtual_newuname(struct new_utsname *name) +{ +int error; +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +error=dovipt_func(VIP_NEWUNAME,0,NULL,name); +return error; +#else +return do_vipt(VIP_NEWUNAME,0,NULL,name); +#endif +} + + +int virtual_setdomainname(char *name, int len) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +return dovipt_func(VIP_SETDOMAINNAME,len,NULL,name); +#else +return do_vipt(VIP_SETDOMAINNAME,len,NULL,name); +#endif +} + +int virtual_uname(struct old_utsname *name) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +return dovipt_func(VIP_UNAME,0,NULL,name); +#else +return do_vipt(VIP_UNAME,0,NULL,name); +#endif +} + +int virtual_olduname(struct oldold_utsname *name) +{ +#ifdef CONFIG_VIRTUAL_MOD +if (!vis_loaded) return -EBUSY; +return dovipt_func(VIP_OLDUNAME,0,NULL,name); +#else +return do_vipt(VIP_OLDUNAME,0,NULL,name); +#endif +} diff -ruN linux2/virtual/calls.h linux/virtual/calls.h --- linux2/virtual/calls.h Thu Jan 1 01:00:00 1970 +++ linux/virtual/calls.h Fri Dec 25 19:16:06 1998 @@ -0,0 +1 @@ +extern void virt_mod(int stat); diff -ruN linux2/virtual/datavip.c linux/virtual/datavip.c --- linux2/virtual/datavip.c Thu Jan 1 01:00:00 1970 +++ linux/virtual/datavip.c Fri Dec 25 19:16:06 1998 @@ -0,0 +1,331 @@ +// todoo: +// sprawdzic czy przy utsname maja byc & +// sprawdzic czy jest ok bez copy_from_user + +#include +#include +#include +#include +#include "vip.h" +#include + +struct vip { + unsigned int ip; + struct dentry *dentry; + struct new_utsname utsname; // like from normal system + struct vip *next; + }; + +static struct vip *vip_elem; +static unsigned int defaultip; + +extern void *vmalloc(size_t size); +extern void vfree(void *); + + +/* find_vip - finds inode in data struct and returns pointer to data's about + * it or NULL + */ + +struct vip *find_vip(struct inode *inode) +{ +struct vip *new,*tmp; + +new=vip_elem; +if (new->dentry==NULL) return NULL; +do + { + if (inode==new->dentry->d_inode) + return new; + tmp=new->next; + new=tmp; + } +while (new!=NULL); +return NULL; +} + + +/* inode2ip - finds inode in data structure and returns ip for this inode + * or defaultip if path not found + */ + +unsigned int inode2ip(struct inode *inode) +{ +struct vip *tmp; + +if ((tmp=find_vip(inode))==NULL) return defaultip; +else return tmp->ip; +} + + +/* check_ip_inode - checks if on current root fs we can use this ip + * it is used in bind check + * we don't use here find_vip because we must search whole struct + */ +int check_ip_inode(struct inode *inode,unsigned int ip) +{ + struct vip *new,*tmp; + + new=vip_elem; + if (new->dentry==NULL) return defaultip; + do + { + if ((inode==new->dentry->d_inode)&&(new->ip==ip)) + return 1; + tmp=new->next; + new=tmp; + } + while (new!=NULL); + return 0; +} + +/* vip_create - creates new entry in structure + * BUGS: no len-checking in hostname + */ +int vip_create(unsigned int ip, char *path, char *hostname) +{ +int len; +if ((vip_elem->ip==0)&&(vip_elem->next==NULL)) + { + struct dentry *dentry; + + dentry = lookup_dentry(path,NULL,1); + if (IS_ERR(dentry)) return (-ENOENT); + vip_elem->dentry = dentry; + vip_elem->ip=ip; + memcpy(&vip_elem->utsname,&system_utsname,sizeof system_utsname); + if (hostname!=NULL) + { + len=strlen_user(hostname); + // here args checking + strncpy_from_user(vip_elem->utsname.nodename,hostname,len); + } + return 0; + } else { + struct vip *next,*last,*tmp; + struct dentry *dentry; + + dentry = lookup_dentry(path,NULL,1); + if (IS_ERR(dentry)) return (-ENOENT); + next=vmalloc(sizeof(vip_elem)); + next->dentry = dentry; + next->ip = ip; + memcpy(&next->utsname,&system_utsname,sizeof system_utsname); + next->next = NULL; + if (hostname!=NULL) + { + len=strlen_user(hostname); + strncpy_from_user(vip_elem->utsname.nodename,hostname,len); + } + + last = vip_elem; + do + { + if (last->next==NULL) + { + last->next=next; + return 0; + } + tmp=last->next; + last=tmp; + } + while (last!=NULL); + return (-EIO); + } +} + +/* virtual_init - initializes structure + * we must write there 0 because we don't have / then + */ + +void virtual_init(void) +{ + vip_elem = vmalloc(sizeof(vip_elem)); + vip_elem->dentry = NULL; + vip_elem->ip = 0; + vip_elem->next = NULL; + defaultip = INADDR_ANY; +} + +/* virtual_free - removes whole structure + */ +int virtual_free(void) +{ + struct vip *next,*last; + + next=vip_elem->next; + if (vip_elem->dentry!=NULL) dput(vip_elem->dentry); + vfree(vip_elem); + if (!next) return 0; + do + { + if (next->dentry!=NULL) dput(next->dentry); + last=next; + next=last->next; + vfree(last); + } + while (next!=NULL); + return 0; +} + +/* do_vipt - changes data in structure + * only root can do it + * it takes ip, path and mode: + * VIP_CREAT - to create new entry + * VIP_WRITEBP - to change ip in entry with path + * VIP_WRITEBI - to change path in entry with ip + * VIP_CLEAR - to clear structure + * it returns 0 if done or -1 if there was error + */ +int do_vipt(unsigned int mode,unsigned int ip, char *path,char *hostname) +{ +if (mode==VIP_GETHOSTNAME) + { + struct vip *tmp; + int i; + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + i = 1+strlen(tmp->utsname.nodename); + // we use ip as lenght :)) + if (i > ip) + i=ip; + if (copy_to_user(hostname,tmp->utsname.nodename,i)) return -EFAULT; + return 0; + } +if (mode==VIP_NEWUNAME) + { + struct new_utsname *name = (struct new_utsname *)hostname; + // we get it from hostname pointer + struct vip *tmp; + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + if (copy_to_user(name,&tmp->utsname,sizeof *name)) + return -EFAULT; + return 0; + } +if (mode==VIP_UNAME) + { + struct old_utsname *name = (struct old_utsname *)hostname; + // we get it from hostname pointer + struct vip *tmp; + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + if (copy_to_user(name,&tmp->utsname,sizeof *name)) + return -EFAULT; + + return 0; + } +if (mode==VIP_OLDUNAME) + { + struct oldold_utsname *name = (struct oldold_utsname *)hostname; + // we get it from hostname pointer + struct vip *tmp; + int error; + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + error=0; + error = __copy_to_user(&name->sysname,&tmp->utsname.sysname,__OLD_UTS_LEN); + error |= __put_user(0,name->sysname+__OLD_UTS_LEN); + error |= __copy_to_user(&name->nodename,&tmp->utsname.nodename,__OLD_UTS_LEN); + error |= __put_user(0,name->nodename+__OLD_UTS_LEN); + error |= __copy_to_user(&name->release,&tmp->utsname.release,__OLD_UTS_LEN); + error |= __put_user(0,name->release+__OLD_UTS_LEN); + error |= __copy_to_user(&name->version,&tmp->utsname.version,__OLD_UTS_LEN); + error |= __put_user(0,name->version+__OLD_UTS_LEN); + error |= __copy_to_user(&name->machine,&tmp->utsname.machine,__OLD_UTS_LEN); + error |= __put_user(0,name->machine+__OLD_UTS_LEN); + return error; + } +if (current->uid) return -EPERM; +if (mode==VIP_CREAT) + { + if (strcmp(path,"DEFAULT")==0) defaultip=ip; + else return vip_create(ip,path,hostname); + return 0; + } +if (mode==VIP_WRITEBP) + { + struct vip *next,*tmp; + struct dentry *dentry; + + dentry = __namei(path,0); + if (IS_ERR(dentry)) return (-ENOENT); + + next=vip_elem; + do + { + if (dentry==next->dentry) + { + next->ip=ip; + return 0; + } + tmp=next->next; + next=tmp; + } + while (next!=NULL); + return (-ENOENT); + } + +if (mode==VIP_WRITEBI) + { + struct vip *next,*tmp; + next=vip_elem; + do + { + if (next->ip==ip) + { + struct dentry *dentry; + + dentry = __namei(path,0); + if (IS_ERR(dentry)) return (-ENOENT); + if (next->dentry) dput(next->dentry); + next->dentry = dentry; + return 0; + } + tmp=next->next; + next=tmp; + } + while (next!=NULL); + return (-ENOENT); + } +if (mode==VIP_CLEAR) + { + struct dentry *dentry; + + virtual_free(); + virtual_init(); + dentry = lookup_dentry(path,NULL,1); + if (IS_ERR(dentry)) return -ENOENT; + + vip_elem->dentry = dentry; + vip_elem->ip=ip; + } +if (mode==VIP_SETHOSTNAME) + { + struct vip *tmp; + // we assume here we have all checks passed and only hostname here + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + // we assume that args checking was done and len-checking done + if (copy_from_user(tmp->utsname.nodename,hostname,ip)) return -EFAULT; + else { + tmp->utsname.nodename[ip]='\0'; + return 0; + } + } +if (mode==VIP_SETDOMAINNAME) + { + // we get it from hostname pointer + struct vip *tmp; + + if ((tmp=find_vip(current->fs->root->d_inode))==NULL) return -ENOENT; + if (!copy_to_user(tmp->utsname.domainname,hostname,ip)) + { + tmp->utsname.domainname[ip]='\0'; + return 0; + } + return -EFAULT; + } +return (-ENOENT); +} + diff -ruN linux2/virtual/datavip.h linux/virtual/datavip.h --- linux2/virtual/datavip.h Thu Jan 1 01:00:00 1970 +++ linux/virtual/datavip.h Fri Dec 25 19:16:06 1998 @@ -0,0 +1,6 @@ +#include +extern unsigned int inode2ip(struct inode *inode); +extern int do_vipt(unsigned int mode,unsigned int ip, char *path); +extern void virtual_init(void); +extern int virtual_free(void); +extern int check_ip_inode(struct inode *inode, unsigned int ip); diff -ruN linux2/virtual/vip.h linux/virtual/vip.h --- linux2/virtual/vip.h Thu Jan 1 01:00:00 1970 +++ linux/virtual/vip.h Fri Dec 25 19:16:06 1998 @@ -0,0 +1,11 @@ + +#define VIP_CREAT 0 +#define VIP_WRITEBP 1 +#define VIP_WRITEBI 2 +#define VIP_CLEAR 3 +#define VIP_GETHOSTNAME 4 +#define VIP_SETHOSTNAME 5 +#define VIP_NEWUNAME 6 +#define VIP_SETDOMAINNAME 7 +#define VIP_UNAME 8 +#define VIP_OLDUNAME 9 diff -ruN linux2/virtual/virt.c linux/virtual/virt.c --- linux2/virtual/virt.c Thu Jan 1 01:00:00 1970 +++ linux/virtual/virt.c Fri Dec 25 19:16:06 1998 @@ -0,0 +1,37 @@ +#include +#include "datavip.h" + +/* get_my_ip - gives ip for process + * it checks actual root directory and find ip in data + * structure for that directory + */ +unsigned int get_my_ip(void) +{ + struct dentry *root; + unsigned int dst_ip = INADDR_ANY; + + if ((root = current->fs->root)!=NULL) + dst_ip = inode2ip(root->d_inode); + else + virtual_init(); + return dst_ip; +} + + +/* check_this_addr - function checks actual root and gets ip for it + * like get_my_ip, but then it compares it + * with given (by bind) and returns 0 if it is not good + * and 1 if is good + * it can be changed in future to allow use of more + * than 1 ip on 1 virtual + */ +int check_this_addr(unsigned int addr) +{ + struct dentry *root; + unsigned int dst_ip; + + if ((root = current->fs->root)!=NULL) + if (check_ip_inode(root->d_inode,addr)==1) return 1; + else return 0; +} + diff -ruN linux2/virtual/virt.h linux/virtual/virt.h --- linux2/virtual/virt.h Thu Jan 1 01:00:00 1970 +++ linux/virtual/virt.h Fri Dec 25 19:16:06 1998 @@ -0,0 +1,2 @@ +extern unsigned int get_my_ip(void); +extern int check_this_addr(unsigned int addr); diff -ruN linux2/virtual/vmodule.c linux/virtual/vmodule.c --- linux2/virtual/vmodule.c Thu Jan 1 01:00:00 1970 +++ linux/virtual/vmodule.c Fri Dec 25 19:16:06 1998 @@ -0,0 +1,19 @@ +#include +#include "datavip.h" +#include "virt.h" + +extern void virtual_mod(void *,void *,void *); + +int init_module(void) +{ + virtual_init(); + virtual_mod(&do_vipt,&get_my_ip,&check_this_addr); + return 0; +} + +void cleanup_module(void) +{ + virtual_mod(NULL,NULL,NULL); + virtual_free(); +} +