root/include/linux/net_alias.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. net_alias_is
  2. net_alias_has
  3. net_alias_main_dev
  4. net_alias_nextdev
  5. net_alias_nextdev_set

   1 /*
   2  *              NET_ALIAS network device aliasing definitions.
   3  *
   4  *
   5  * Version:     @(#)net_alias.h 0.43   12/20/95
   6  *
   7  * Author:      Juan Jose Ciarlante, <jjciarla@raiz.uncu.edu.ar>
   8  *
   9  *
  10  *      This program is free software; you can redistribute it and/or
  11  *      modify it under the terms of the GNU General Public License
  12  *      as published by the Free Software Foundation; either version
  13  *      2 of the License, or (at your option) any later version.
  14  *      
  15  */
  16 
  17 #ifndef _NET_ALIAS_H
  18 #define _NET_ALIAS_H
  19 
  20 #include <linux/types.h>
  21 #include <linux/if.h>
  22 #include <linux/netdevice.h>
  23 
  24 /*
  25  * max. alias slot number allowed 
  26  */
  27 
  28 #define NET_ALIAS_MAX_SLOT  256
  29 
  30 struct net_alias;
  31 struct net_alias_info;
  32 struct net_alias_type;
  33 
  34 
  35 /*
  36  * main alias structure
  37  * note that *defines* dev & devname
  38  */
  39 
  40 struct net_alias
  41 {
  42   struct device dev;            /* alias device defn*/
  43   char name[IFNAMSIZ];          /* device name defn */
  44   unsigned hash;                /* my hash value: for quick rehash */
  45   unsigned slot;                /* slot number */
  46   void *data;                   /* private data */
  47   struct device *main_dev;      /* pointer to main device */
  48   struct net_alias_type *nat;   /* alias type object bound */
  49   struct net_alias *next;       /* next alias (hashed linked list) */
  50 };
  51 
  52 
  53 /*
  54  *  alias structure pointed by main device
  55  *  it holds main device's alias hash table
  56  */
  57 
  58 struct net_alias_info
  59 {
  60   int n_aliases;                /* num aliases */
  61   struct device *taildev;       /* my last (alias) device */
  62   struct net_alias *hash_tab[16]; /* hashed alias table */
  63 };
  64 
  65 /*
  66  * net_alias_type class
  67  * declares a generic (AF_ independent) structure that will
  68  * manage generic to family-specific behavior.
  69  */
  70 
  71 struct net_alias_type
  72 {
  73   int type;                     /* aliasing type: address family */
  74   int n_attach;                 /* number of aliases attached */
  75   char name[16];                /* af_name */
  76   __u32 (*get_addr32)           /* get __u32 addr 'representation'*/
  77     (struct net_alias_type *this, struct sockaddr*);    
  78   int (*dev_addr_chk)           /* address checking func: */
  79     (struct net_alias_type *this, struct device *, struct sockaddr *);
  80   struct device * (*dev_select) /* closest alias selector*/
  81     (struct net_alias_type *this, struct device *, struct sockaddr *sa);
  82   int (*alias_init_1)           /* called after alias creation: */
  83     (struct net_alias_type *this,struct net_alias *alias, struct sockaddr *sa);
  84   int (*alias_done_1)           /* called before alias deletion */
  85     (struct net_alias_type *this, struct net_alias *alias);
  86   int (*alias_print_1)  
  87     (struct net_alias_type *this, struct net_alias *alias, char *buf, int len);
  88   struct net_alias_type *next;  /* link */
  89 };
  90 
  91 
  92 /*
  93  * is dev an alias?
  94  */
  95 
  96 static __inline__ int
  97 net_alias_is(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99   return (dev->my_alias != NULL);
 100 }
 101 
 102 
 103 /*
 104  * does dev have aliases?
 105  */
 106 
 107 static __inline__ int
 108 net_alias_has(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 109 {
 110   return (dev->alias_info != NULL);
 111 }
 112 
 113 
 114 extern void net_alias_init(void);
 115 
 116 extern struct device * net_alias_dev_get(char *dev_name, int aliasing_ok, int *err, struct sockaddr *sa, void *data);
 117 extern int net_alias_dev_rehash(struct device *dev, struct sockaddr *sa);
 118 
 119 extern int net_alias_getinfo(char *buf, char **, off_t , int , int );
 120 extern int net_alias_types_getinfo(char *buf, char **, off_t , int , int );
 121 
 122 extern int register_net_alias_type(struct net_alias_type *nat, int type);
 123 extern int unregister_net_alias_type(struct net_alias_type *nat);
 124 
 125 extern struct device * net_alias_dev_chk(struct device *main_dev, struct sockaddr *sa, int flags_on, int flags_off);
 126 extern struct device * net_alias_dev_chk32(struct device *main_dev, int family, __u32 addr32, int flags_on, int flags_off);
 127 
 128 extern struct device * net_alias_dev_rcv_sel(struct device *main_dev, struct sockaddr *sa_src, struct sockaddr *sa_dst);
 129 extern struct device * net_alias_dev_rcv_sel32(struct device *main_dev, int family, __u32 src, __u32 dst);
 130 
 131 
 132 /*
 133  * returns MY 'true' main device
 134  * intended for alias devices
 135  */
 136 
 137 static __inline__ struct device *net_alias_main_dev(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 138 {
 139   return (net_alias_is(dev))? dev->my_alias->main_dev : dev;
 140 }
 141 
 142 
 143 /*
 144  * returns NEXT 'true' device
 145  * intended for true devices
 146  */
 147 
 148 static __inline__ struct device *
 149 net_alias_nextdev(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 150 {
 151   return (dev->alias_info)? dev->alias_info->taildev->next : dev->next;
 152 }
 153 
 154 
 155 /*
 156  * sets NEXT 'true' device
 157  * intended for main devices (treat main device as block: dev+aliases).
 158  */
 159 
 160 static __inline__ struct device *
 161 net_alias_nextdev_set(struct device *dev, struct device *nextdev)
     /* [previous][next][first][last][top][bottom][index][help] */
 162 {
 163   struct device *pdev = dev;
 164   if (net_alias_has(dev))
 165   {
 166     pdev = dev->alias_info->taildev; /* point to last dev alias */
 167   }
 168   pdev->next = nextdev;
 169   return nextdev;
 170 }
 171 
 172 #endif  /* _NET_ALIAS_H */

/* [previous][next][first][last][top][bottom][index][help] */