/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_pkttype.h |
---|
0,0 → 1,11 |
#ifndef __LINUX_BRIDGE_EBT_PKTTYPE_H |
#define __LINUX_BRIDGE_EBT_PKTTYPE_H |
struct ebt_pkttype_info |
{ |
uint8_t pkt_type; |
uint8_t invert; |
}; |
#define EBT_PKTTYPE_MATCH "pkttype" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_vlan.h |
---|
0,0 → 1,20 |
#ifndef __LINUX_BRIDGE_EBT_VLAN_H |
#define __LINUX_BRIDGE_EBT_VLAN_H |
#define EBT_VLAN_ID 0x01 |
#define EBT_VLAN_PRIO 0x02 |
#define EBT_VLAN_ENCAP 0x04 |
#define EBT_VLAN_MASK (EBT_VLAN_ID | EBT_VLAN_PRIO | EBT_VLAN_ENCAP) |
#define EBT_VLAN_MATCH "vlan" |
struct ebt_vlan_info { |
uint16_t id; /* VLAN ID {1-4095} */ |
uint8_t prio; /* VLAN User Priority {0-7} */ |
uint16_t encap; /* VLAN Encapsulated frame code {0-65535} */ |
uint8_t bitmask; /* Args bitmask bit 1=1 - ID arg, |
bit 2=1 User-Priority arg, bit 3=1 encap*/ |
uint8_t invflags; /* Inverse bitmask bit 1=1 - inversed ID arg, |
bit 2=1 - inversed Pirority arg */ |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_log.h |
---|
0,0 → 1,17 |
#ifndef __LINUX_BRIDGE_EBT_LOG_H |
#define __LINUX_BRIDGE_EBT_LOG_H |
#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */ |
#define EBT_LOG_ARP 0x02 |
#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP) |
#define EBT_LOG_PREFIX_SIZE 30 |
#define EBT_LOG_WATCHER "log" |
struct ebt_log_info |
{ |
uint8_t loglevel; |
uint8_t prefix[EBT_LOG_PREFIX_SIZE]; |
uint32_t bitmask; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_redirect.h |
---|
0,0 → 1,11 |
#ifndef __LINUX_BRIDGE_EBT_REDIRECT_H |
#define __LINUX_BRIDGE_EBT_REDIRECT_H |
struct ebt_redirect_info |
{ |
/* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ |
int target; |
}; |
#define EBT_REDIRECT_TARGET "redirect" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_among.h |
---|
0,0 → 1,65 |
#ifndef __LINUX_BRIDGE_EBT_AMONG_H |
#define __LINUX_BRIDGE_EBT_AMONG_H |
#define EBT_AMONG_DST 0x01 |
#define EBT_AMONG_SRC 0x02 |
/* Grzegorz Borowiak <grzes@gnu.univ.gda.pl> 2003 |
* |
* Write-once-read-many hash table, used for checking if a given |
* MAC address belongs to a set or not and possibly for checking |
* if it is related with a given IPv4 address. |
* |
* The hash value of an address is its last byte. |
* |
* In real-world ethernet addresses, values of the last byte are |
* evenly distributed and there is no need to consider other bytes. |
* It would only slow the routines down. |
* |
* For MAC address comparison speedup reasons, we introduce a trick. |
* MAC address is mapped onto an array of two 32-bit integers. |
* This pair of integers is compared with MAC addresses in the |
* hash table, which are stored also in form of pairs of integers |
* (in `cmp' array). This is quick as it requires only two elementary |
* number comparisons in worst case. Further, we take advantage of |
* fact that entropy of 3 last bytes of address is larger than entropy |
* of 3 first bytes. So first we compare 4 last bytes of addresses and |
* if they are the same we compare 2 first. |
* |
* Yes, it is a memory overhead, but in 2003 AD, who cares? |
*/ |
struct ebt_mac_wormhash_tuple |
{ |
uint32_t cmp[2]; |
uint32_t ip; |
}; |
struct ebt_mac_wormhash |
{ |
int table[257]; |
int poolsize; |
struct ebt_mac_wormhash_tuple pool[0]; |
}; |
#define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \ |
+ (x)->poolsize * sizeof(struct ebt_mac_wormhash_tuple) : 0) |
struct ebt_among_info |
{ |
int wh_dst_ofs; |
int wh_src_ofs; |
int bitmask; |
}; |
#define EBT_AMONG_DST_NEG 0x1 |
#define EBT_AMONG_SRC_NEG 0x2 |
#define ebt_among_wh_dst(x) ((x)->wh_dst_ofs ? \ |
(struct ebt_mac_wormhash*)((char*)(x) + (x)->wh_dst_ofs) : NULL) |
#define ebt_among_wh_src(x) ((x)->wh_src_ofs ? \ |
(struct ebt_mac_wormhash*)((char*)(x) + (x)->wh_src_ofs) : NULL) |
#define EBT_AMONG_MATCH "among" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_arp.h |
---|
0,0 → 1,32 |
#ifndef __LINUX_BRIDGE_EBT_ARP_H |
#define __LINUX_BRIDGE_EBT_ARP_H |
#define EBT_ARP_OPCODE 0x01 |
#define EBT_ARP_HTYPE 0x02 |
#define EBT_ARP_PTYPE 0x04 |
#define EBT_ARP_SRC_IP 0x08 |
#define EBT_ARP_DST_IP 0x10 |
#define EBT_ARP_SRC_MAC 0x20 |
#define EBT_ARP_DST_MAC 0x40 |
#define EBT_ARP_MASK (EBT_ARP_OPCODE | EBT_ARP_HTYPE | EBT_ARP_PTYPE | \ |
EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_SRC_MAC | EBT_ARP_DST_MAC) |
#define EBT_ARP_MATCH "arp" |
struct ebt_arp_info |
{ |
uint16_t htype; |
uint16_t ptype; |
uint16_t opcode; |
uint32_t saddr; |
uint32_t smsk; |
uint32_t daddr; |
uint32_t dmsk; |
unsigned char smaddr[ETH_ALEN]; |
unsigned char smmsk[ETH_ALEN]; |
unsigned char dmaddr[ETH_ALEN]; |
unsigned char dmmsk[ETH_ALEN]; |
uint8_t bitmask; |
uint8_t invflags; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_nat.h |
---|
0,0 → 1,13 |
#ifndef __LINUX_BRIDGE_EBT_NAT_H |
#define __LINUX_BRIDGE_EBT_NAT_H |
struct ebt_nat_info |
{ |
unsigned char mac[ETH_ALEN]; |
/* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ |
int target; |
}; |
#define EBT_SNAT_TARGET "snat" |
#define EBT_DNAT_TARGET "dnat" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_mark_m.h |
---|
0,0 → 1,15 |
#ifndef __LINUX_BRIDGE_EBT_MARK_M_H |
#define __LINUX_BRIDGE_EBT_MARK_M_H |
#define EBT_MARK_AND 0x01 |
#define EBT_MARK_OR 0x02 |
#define EBT_MARK_MASK (EBT_MARK_AND | EBT_MARK_OR) |
struct ebt_mark_m_info |
{ |
unsigned long mark, mask; |
uint8_t invert; |
uint8_t bitmask; |
}; |
#define EBT_MARK_MATCH "mark_m" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_stp.h |
---|
0,0 → 1,46 |
#ifndef __LINUX_BRIDGE_EBT_STP_H |
#define __LINUX_BRIDGE_EBT_STP_H |
#define EBT_STP_TYPE 0x0001 |
#define EBT_STP_FLAGS 0x0002 |
#define EBT_STP_ROOTPRIO 0x0004 |
#define EBT_STP_ROOTADDR 0x0008 |
#define EBT_STP_ROOTCOST 0x0010 |
#define EBT_STP_SENDERPRIO 0x0020 |
#define EBT_STP_SENDERADDR 0x0040 |
#define EBT_STP_PORT 0x0080 |
#define EBT_STP_MSGAGE 0x0100 |
#define EBT_STP_MAXAGE 0x0200 |
#define EBT_STP_HELLOTIME 0x0400 |
#define EBT_STP_FWDD 0x0800 |
#define EBT_STP_MASK 0x0fff |
#define EBT_STP_CONFIG_MASK 0x0ffe |
#define EBT_STP_MATCH "stp" |
struct ebt_stp_config_info |
{ |
uint8_t flags; |
uint16_t root_priol, root_priou; |
char root_addr[6], root_addrmsk[6]; |
uint32_t root_costl, root_costu; |
uint16_t sender_priol, sender_priou; |
char sender_addr[6], sender_addrmsk[6]; |
uint16_t portl, portu; |
uint16_t msg_agel, msg_ageu; |
uint16_t max_agel, max_ageu; |
uint16_t hello_timel, hello_timeu; |
uint16_t forward_delayl, forward_delayu; |
}; |
struct ebt_stp_info |
{ |
uint8_t type; |
struct ebt_stp_config_info config; |
uint16_t bitmask; |
uint16_t invflags; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebtables.h |
---|
0,0 → 1,363 |
/* |
* ebtables |
* |
* Authors: |
* Bart De Schuymer <bdschuym@pandora.be> |
* |
* ebtables.c,v 2.0, April, 2002 |
* |
* This code is stongly inspired on the iptables code which is |
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling |
*/ |
#ifndef __LINUX_BRIDGE_EFF_H |
#define __LINUX_BRIDGE_EFF_H |
#include <linux/if.h> |
#include <linux/netfilter_bridge.h> |
#include <linux/if_ether.h> |
#define EBT_TABLE_MAXNAMELEN 32 |
#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN |
#define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN |
/* verdicts >0 are "branches" */ |
#define EBT_ACCEPT -1 |
#define EBT_DROP -2 |
#define EBT_CONTINUE -3 |
#define EBT_RETURN -4 |
#define NUM_STANDARD_TARGETS 4 |
struct ebt_counter |
{ |
uint64_t pcnt; |
uint64_t bcnt; |
}; |
struct ebt_replace |
{ |
char name[EBT_TABLE_MAXNAMELEN]; |
unsigned int valid_hooks; |
/* nr of rules in the table */ |
unsigned int nentries; |
/* total size of the entries */ |
unsigned int entries_size; |
/* start of the chains */ |
struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; |
/* nr of counters userspace expects back */ |
unsigned int num_counters; |
/* where the kernel will put the old counters */ |
struct ebt_counter *counters; |
char *entries; |
}; |
struct ebt_entries { |
/* this field is always set to zero |
* See EBT_ENTRY_OR_ENTRIES. |
* Must be same size as ebt_entry.bitmask */ |
unsigned int distinguisher; |
/* the chain name */ |
char name[EBT_CHAIN_MAXNAMELEN]; |
/* counter offset for this chain */ |
unsigned int counter_offset; |
/* one standard (accept, drop, return) per hook */ |
int policy; |
/* nr. of entries */ |
unsigned int nentries; |
/* entry list */ |
char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); |
}; |
/* used for the bitmask of struct ebt_entry */ |
/* This is a hack to make a difference between an ebt_entry struct and an |
* ebt_entries struct when traversing the entries from start to end. |
* Using this simplifies the code alot, while still being able to use |
* ebt_entries. |
* Contrary, iptables doesn't use something like ebt_entries and therefore uses |
* different techniques for naming the policy and such. So, iptables doesn't |
* need a hack like this. |
*/ |
#define EBT_ENTRY_OR_ENTRIES 0x01 |
/* these are the normal masks */ |
#define EBT_NOPROTO 0x02 |
#define EBT_802_3 0x04 |
#define EBT_SOURCEMAC 0x08 |
#define EBT_DESTMAC 0x10 |
#define EBT_F_MASK (EBT_NOPROTO | EBT_802_3 | EBT_SOURCEMAC | EBT_DESTMAC \ |
| EBT_ENTRY_OR_ENTRIES) |
#define EBT_IPROTO 0x01 |
#define EBT_IIN 0x02 |
#define EBT_IOUT 0x04 |
#define EBT_ISOURCE 0x8 |
#define EBT_IDEST 0x10 |
#define EBT_ILOGICALIN 0x20 |
#define EBT_ILOGICALOUT 0x40 |
#define EBT_INV_MASK (EBT_IPROTO | EBT_IIN | EBT_IOUT | EBT_ILOGICALIN \ |
| EBT_ILOGICALOUT | EBT_ISOURCE | EBT_IDEST) |
struct ebt_entry_match |
{ |
union { |
char name[EBT_FUNCTION_MAXNAMELEN]; |
struct ebt_match *match; |
} u; |
/* size of data */ |
unsigned int match_size; |
unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); |
}; |
struct ebt_entry_watcher |
{ |
union { |
char name[EBT_FUNCTION_MAXNAMELEN]; |
struct ebt_watcher *watcher; |
} u; |
/* size of data */ |
unsigned int watcher_size; |
unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); |
}; |
struct ebt_entry_target |
{ |
union { |
char name[EBT_FUNCTION_MAXNAMELEN]; |
struct ebt_target *target; |
} u; |
/* size of data */ |
unsigned int target_size; |
unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); |
}; |
#define EBT_STANDARD_TARGET "standard" |
struct ebt_standard_target |
{ |
struct ebt_entry_target target; |
int verdict; |
}; |
/* one entry */ |
struct ebt_entry { |
/* this needs to be the first field */ |
unsigned int bitmask; |
unsigned int invflags; |
uint16_t ethproto; |
/* the physical in-dev */ |
char in[IFNAMSIZ]; |
/* the logical in-dev */ |
char logical_in[IFNAMSIZ]; |
/* the physical out-dev */ |
char out[IFNAMSIZ]; |
/* the logical out-dev */ |
char logical_out[IFNAMSIZ]; |
unsigned char sourcemac[ETH_ALEN]; |
unsigned char sourcemsk[ETH_ALEN]; |
unsigned char destmac[ETH_ALEN]; |
unsigned char destmsk[ETH_ALEN]; |
/* sizeof ebt_entry + matches */ |
unsigned int watchers_offset; |
/* sizeof ebt_entry + matches + watchers */ |
unsigned int target_offset; |
/* sizeof ebt_entry + matches + watchers + target */ |
unsigned int next_offset; |
unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); |
}; |
/* {g,s}etsockopt numbers */ |
#define EBT_BASE_CTL 128 |
#define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) |
#define EBT_SO_SET_COUNTERS (EBT_SO_SET_ENTRIES+1) |
#define EBT_SO_SET_MAX (EBT_SO_SET_COUNTERS+1) |
#define EBT_SO_GET_INFO (EBT_BASE_CTL) |
#define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO+1) |
#define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES+1) |
#define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO+1) |
#define EBT_SO_GET_MAX (EBT_SO_GET_INIT_ENTRIES+1) |
#ifdef __KERNEL__ |
/* return values for match() functions */ |
#define EBT_MATCH 0 |
#define EBT_NOMATCH 1 |
struct ebt_match |
{ |
struct list_head list; |
const char name[EBT_FUNCTION_MAXNAMELEN]; |
/* 0 == it matches */ |
int (*match)(const struct sk_buff *skb, const struct net_device *in, |
const struct net_device *out, const void *matchdata, |
unsigned int datalen); |
/* 0 == let it in */ |
int (*check)(const char *tablename, unsigned int hookmask, |
const struct ebt_entry *e, void *matchdata, unsigned int datalen); |
void (*destroy)(void *matchdata, unsigned int datalen); |
struct module *me; |
}; |
struct ebt_watcher |
{ |
struct list_head list; |
const char name[EBT_FUNCTION_MAXNAMELEN]; |
void (*watcher)(const struct sk_buff *skb, const struct net_device *in, |
const struct net_device *out, const void *watcherdata, |
unsigned int datalen); |
/* 0 == let it in */ |
int (*check)(const char *tablename, unsigned int hookmask, |
const struct ebt_entry *e, void *watcherdata, unsigned int datalen); |
void (*destroy)(void *watcherdata, unsigned int datalen); |
struct module *me; |
}; |
struct ebt_target |
{ |
struct list_head list; |
const char name[EBT_FUNCTION_MAXNAMELEN]; |
/* returns one of the standard verdicts */ |
int (*target)(struct sk_buff **pskb, unsigned int hooknr, |
const struct net_device *in, const struct net_device *out, |
const void *targetdata, unsigned int datalen); |
/* 0 == let it in */ |
int (*check)(const char *tablename, unsigned int hookmask, |
const struct ebt_entry *e, void *targetdata, unsigned int datalen); |
void (*destroy)(void *targetdata, unsigned int datalen); |
struct module *me; |
}; |
/* used for jumping from and into user defined chains (udc) */ |
struct ebt_chainstack |
{ |
struct ebt_entries *chaininfo; /* pointer to chain data */ |
struct ebt_entry *e; /* pointer to entry data */ |
unsigned int n; /* n'th entry */ |
}; |
struct ebt_table_info |
{ |
/* total size of the entries */ |
unsigned int entries_size; |
unsigned int nentries; |
/* pointers to the start of the chains */ |
struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; |
/* room to maintain the stack used for jumping from and into udc */ |
struct ebt_chainstack **chainstack; |
char *entries; |
struct ebt_counter counters[0] ____cacheline_aligned; |
}; |
struct ebt_table |
{ |
struct list_head list; |
char name[EBT_TABLE_MAXNAMELEN]; |
struct ebt_replace *table; |
unsigned int valid_hooks; |
rwlock_t lock; |
/* e.g. could be the table explicitly only allows certain |
* matches, targets, ... 0 == let it in */ |
int (*check)(const struct ebt_table_info *info, |
unsigned int valid_hooks); |
/* the data used by the kernel */ |
struct ebt_table_info *private; |
struct module *me; |
}; |
#define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \ |
~(__alignof__(struct ebt_replace)-1)) |
extern int ebt_register_table(struct ebt_table *table); |
extern void ebt_unregister_table(struct ebt_table *table); |
extern int ebt_register_match(struct ebt_match *match); |
extern void ebt_unregister_match(struct ebt_match *match); |
extern int ebt_register_watcher(struct ebt_watcher *watcher); |
extern void ebt_unregister_watcher(struct ebt_watcher *watcher); |
extern int ebt_register_target(struct ebt_target *target); |
extern void ebt_unregister_target(struct ebt_target *target); |
extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff **pskb, |
const struct net_device *in, const struct net_device *out, |
struct ebt_table *table); |
/* Used in the kernel match() functions */ |
#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg)) |
/* True if the hook mask denotes that the rule is in a base chain, |
* used in the check() functions */ |
#define BASE_CHAIN (hookmask & (1 << NF_BR_NUMHOOKS)) |
/* Clear the bit in the hook mask that tells if the rule is on a base chain */ |
#define CLEAR_BASE_CHAIN_BIT (hookmask &= ~(1 << NF_BR_NUMHOOKS)) |
/* True if the target is not a standard target */ |
#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0) |
#endif /* __KERNEL__ */ |
/* blatently stolen from ip_tables.h |
* fn returns 0 to continue iteration */ |
#define EBT_MATCH_ITERATE(e, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ebt_entry_match *__match; \ |
\ |
for (__i = sizeof(struct ebt_entry); \ |
__i < (e)->watchers_offset; \ |
__i += __match->match_size + \ |
sizeof(struct ebt_entry_match)) { \ |
__match = (void *)(e) + __i; \ |
\ |
__ret = fn(__match , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
if (__ret == 0) { \ |
if (__i != (e)->watchers_offset) \ |
__ret = -EINVAL; \ |
} \ |
__ret; \ |
}) |
#define EBT_WATCHER_ITERATE(e, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ebt_entry_watcher *__watcher; \ |
\ |
for (__i = e->watchers_offset; \ |
__i < (e)->target_offset; \ |
__i += __watcher->watcher_size + \ |
sizeof(struct ebt_entry_watcher)) { \ |
__watcher = (void *)(e) + __i; \ |
\ |
__ret = fn(__watcher , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
if (__ret == 0) { \ |
if (__i != (e)->target_offset) \ |
__ret = -EINVAL; \ |
} \ |
__ret; \ |
}) |
#define EBT_ENTRY_ITERATE(entries, size, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ebt_entry *__entry; \ |
\ |
for (__i = 0; __i < (size);) { \ |
__entry = (void *)(entries) + __i; \ |
__ret = fn(__entry , ## args); \ |
if (__ret != 0) \ |
break; \ |
if (__entry->bitmask != 0) \ |
__i += __entry->next_offset; \ |
else \ |
__i += sizeof(struct ebt_entries); \ |
} \ |
if (__ret == 0) { \ |
if (__i != (size)) \ |
__ret = -EINVAL; \ |
} \ |
__ret; \ |
}) |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_ip.h |
---|
0,0 → 1,43 |
/* |
* ebt_ip |
* |
* Authors: |
* Bart De Schuymer <bart.de.schuymer@pandora.be> |
* |
* April, 2002 |
* |
* Changes: |
* added ip-sport and ip-dport |
* Innominate Security Technologies AG <mhopf@innominate.com> |
* September, 2002 |
*/ |
#ifndef __LINUX_BRIDGE_EBT_IP_H |
#define __LINUX_BRIDGE_EBT_IP_H |
#define EBT_IP_SOURCE 0x01 |
#define EBT_IP_DEST 0x02 |
#define EBT_IP_TOS 0x04 |
#define EBT_IP_PROTO 0x08 |
#define EBT_IP_SPORT 0x10 |
#define EBT_IP_DPORT 0x20 |
#define EBT_IP_MASK (EBT_IP_SOURCE | EBT_IP_DEST | EBT_IP_TOS | EBT_IP_PROTO |\ |
EBT_IP_SPORT | EBT_IP_DPORT ) |
#define EBT_IP_MATCH "ip" |
/* the same values are used for the invflags */ |
struct ebt_ip_info |
{ |
uint32_t saddr; |
uint32_t daddr; |
uint32_t smsk; |
uint32_t dmsk; |
uint8_t tos; |
uint8_t protocol; |
uint8_t bitmask; |
uint8_t invflags; |
uint16_t sport[2]; |
uint16_t dport[2]; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_802_3.h |
---|
0,0 → 1,60 |
#ifndef __LINUX_BRIDGE_EBT_802_3_H |
#define __LINUX_BRIDGE_EBT_802_3_H |
#define EBT_802_3_SAP 0x01 |
#define EBT_802_3_TYPE 0x02 |
#define EBT_802_3_MATCH "802_3" |
/* |
* If frame has DSAP/SSAP value 0xaa you must check the SNAP type |
* to discover what kind of packet we're carrying. |
*/ |
#define CHECK_TYPE 0xaa |
/* |
* Control field may be one or two bytes. If the first byte has |
* the value 0x03 then the entire length is one byte, otherwise it is two. |
* One byte controls are used in Unnumbered Information frames. |
* Two byte controls are used in Numbered Information frames. |
*/ |
#define IS_UI 0x03 |
#define EBT_802_3_MASK (EBT_802_3_SAP | EBT_802_3_TYPE | EBT_802_3) |
/* ui has one byte ctrl, ni has two */ |
struct hdr_ui { |
uint8_t dsap; |
uint8_t ssap; |
uint8_t ctrl; |
uint8_t orig[3]; |
uint16_t type; |
}; |
struct hdr_ni { |
uint8_t dsap; |
uint8_t ssap; |
uint16_t ctrl; |
uint8_t orig[3]; |
uint16_t type; |
}; |
struct ebt_802_3_hdr { |
uint8_t daddr[6]; |
uint8_t saddr[6]; |
uint16_t len; |
union { |
struct hdr_ui ui; |
struct hdr_ni ni; |
} llc; |
}; |
struct ebt_802_3_info |
{ |
uint8_t sap; |
uint16_t type; |
uint8_t bitmask; |
uint8_t invflags; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_mark_t.h |
---|
0,0 → 1,12 |
#ifndef __LINUX_BRIDGE_EBT_MARK_T_H |
#define __LINUX_BRIDGE_EBT_MARK_T_H |
struct ebt_mark_t_info |
{ |
unsigned long mark; |
/* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ |
int target; |
}; |
#define EBT_MARK_TARGET "mark" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_arpreply.h |
---|
0,0 → 1,11 |
#ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H |
#define __LINUX_BRIDGE_EBT_ARPREPLY_H |
struct ebt_arpreply_info |
{ |
unsigned char mac[ETH_ALEN]; |
int target; |
}; |
#define EBT_ARPREPLY_TARGET "arpreply" |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_bridge/ebt_limit.h |
---|
0,0 → 1,23 |
#ifndef __LINUX_BRIDGE_EBT_LIMIT_H |
#define __LINUX_BRIDGE_EBT_LIMIT_H |
#define EBT_LIMIT_MATCH "limit" |
/* timings are in milliseconds. */ |
#define EBT_LIMIT_SCALE 10000 |
/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 |
seconds, or one every 59 hours. */ |
struct ebt_limit_info |
{ |
u_int32_t avg; /* Average secs between packets * scale */ |
u_int32_t burst; /* Period multiplier for upper limit. */ |
/* Used internally by the kernel */ |
unsigned long prev; |
u_int32_t credit; |
u_int32_t credit_cap, cost; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/rpc_pipe_fs.h |
---|
0,0 → 1,47 |
#ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H |
#define _LINUX_SUNRPC_RPC_PIPE_FS_H |
#ifdef __KERNEL__ |
struct rpc_pipe_msg { |
struct list_head list; |
void *data; |
size_t len; |
size_t copied; |
int errno; |
}; |
struct rpc_pipe_ops { |
ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t); |
ssize_t (*downcall)(struct file *, const char __user *, size_t); |
void (*destroy_msg)(struct rpc_pipe_msg *); |
}; |
struct rpc_inode { |
struct inode vfs_inode; |
void *private; |
struct list_head pipe; |
int pipelen; |
int nreaders; |
wait_queue_head_t waitq; |
#define RPC_PIPE_WAIT_FOR_OPEN 1 |
int flags; |
struct rpc_pipe_ops *ops; |
}; |
static inline struct rpc_inode * |
RPC_I(struct inode *inode) |
{ |
return container_of(inode, struct rpc_inode, vfs_inode); |
} |
extern void rpc_inode_setowner(struct inode *, void *); |
extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *); |
extern struct dentry *rpc_mkdir(char *, struct rpc_clnt *); |
extern int rpc_rmdir(char *); |
extern struct dentry *rpc_mkpipe(char *, void *, struct rpc_pipe_ops *, int flags); |
extern int rpc_unlink(char *); |
#endif |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/msg_prot.h |
---|
0,0 → 1,80 |
/* |
* linux/include/net/sunrpc/msg_prot.h |
* |
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_MSGPROT_H_ |
#define _LINUX_SUNRPC_MSGPROT_H_ |
#ifdef __KERNEL__ /* user programs should get these from the rpc header files */ |
#define RPC_VERSION 2 |
/* spec defines authentication flavor as an unsigned 32 bit integer */ |
typedef u32 rpc_authflavor_t; |
enum rpc_auth_flavors { |
RPC_AUTH_NULL = 0, |
RPC_AUTH_UNIX = 1, |
RPC_AUTH_SHORT = 2, |
RPC_AUTH_DES = 3, |
RPC_AUTH_KRB = 4, |
RPC_AUTH_GSS = 6, |
RPC_AUTH_MAXFLAVOR = 8, |
/* pseudoflavors: */ |
RPC_AUTH_GSS_KRB5 = 390003, |
RPC_AUTH_GSS_KRB5I = 390004, |
RPC_AUTH_GSS_KRB5P = 390005, |
RPC_AUTH_GSS_LKEY = 390006, |
RPC_AUTH_GSS_LKEYI = 390007, |
RPC_AUTH_GSS_LKEYP = 390008, |
RPC_AUTH_GSS_SPKM = 390009, |
RPC_AUTH_GSS_SPKMI = 390010, |
RPC_AUTH_GSS_SPKMP = 390011, |
}; |
enum rpc_msg_type { |
RPC_CALL = 0, |
RPC_REPLY = 1 |
}; |
enum rpc_reply_stat { |
RPC_MSG_ACCEPTED = 0, |
RPC_MSG_DENIED = 1 |
}; |
enum rpc_accept_stat { |
RPC_SUCCESS = 0, |
RPC_PROG_UNAVAIL = 1, |
RPC_PROG_MISMATCH = 2, |
RPC_PROC_UNAVAIL = 3, |
RPC_GARBAGE_ARGS = 4, |
RPC_SYSTEM_ERR = 5 |
}; |
enum rpc_reject_stat { |
RPC_MISMATCH = 0, |
RPC_AUTH_ERROR = 1 |
}; |
enum rpc_auth_stat { |
RPC_AUTH_OK = 0, |
RPC_AUTH_BADCRED = 1, |
RPC_AUTH_REJECTEDCRED = 2, |
RPC_AUTH_BADVERF = 3, |
RPC_AUTH_REJECTEDVERF = 4, |
RPC_AUTH_TOOWEAK = 5, |
/* RPCSEC_GSS errors */ |
RPCSEC_GSS_CREDPROBLEM = 13, |
RPCSEC_GSS_CTXPROBLEM = 14 |
}; |
#define RPC_PMAP_PROGRAM 100000 |
#define RPC_PMAP_VERSION 2 |
#define RPC_PMAP_PORT 111 |
#define RPC_MAXNETNAMELEN 256 |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_MSGPROT_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/svc.h |
---|
0,0 → 1,296 |
/* |
* linux/include/linux/sunrpc/svc.h |
* |
* RPC server declarations. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef SUNRPC_SVC_H |
#define SUNRPC_SVC_H |
#include <linux/in.h> |
#include <linux/sunrpc/types.h> |
#include <linux/sunrpc/xdr.h> |
#include <linux/sunrpc/svcauth.h> |
#include <linux/wait.h> |
#include <linux/mm.h> |
/* |
* RPC service. |
* |
* An RPC service is a ``daemon,'' possibly multithreaded, which |
* receives and processes incoming RPC messages. |
* It has one or more transport sockets associated with it, and maintains |
* a list of idle threads waiting for input. |
* |
* We currently do not support more than one RPC program per daemon. |
*/ |
struct svc_serv { |
struct list_head sv_threads; /* idle server threads */ |
struct list_head sv_sockets; /* pending sockets */ |
struct svc_program * sv_program; /* RPC program */ |
struct svc_stat * sv_stats; /* RPC statistics */ |
spinlock_t sv_lock; |
unsigned int sv_nrthreads; /* # of server threads */ |
unsigned int sv_bufsz; /* datagram buffer size */ |
unsigned int sv_xdrsize; /* XDR buffer size */ |
struct list_head sv_permsocks; /* all permanent sockets */ |
struct list_head sv_tempsocks; /* all temporary sockets */ |
int sv_tmpcnt; /* count of temporary sockets */ |
char * sv_name; /* service name */ |
}; |
/* |
* Maximum payload size supported by a kernel RPC server. |
* This is use to determine the max number of pages nfsd is |
* willing to return in a single READ operation. |
*/ |
#define RPCSVC_MAXPAYLOAD (64*1024u) |
/* |
* RPC Requsts and replies are stored in one or more pages. |
* We maintain an array of pages for each server thread. |
* Requests are copied into these pages as they arrive. Remaining |
* pages are available to write the reply into. |
* |
* Pages are sent using ->sendpage so each server thread needs to |
* allocate more to replace those used in sending. To help keep track |
* of these pages we have a receive list where all pages initialy live, |
* and a send list where pages are moved to when there are to be part |
* of a reply. |
* |
* We use xdr_buf for holding responses as it fits well with NFS |
* read responses (that have a header, and some data pages, and possibly |
* a tail) and means we can share some client side routines. |
* |
* The xdr_buf.head iovec always points to the first page in the rq_*pages |
* list. The xdr_buf.pages pointer points to the second page on that |
* list. xdr_buf.tail points to the end of the first page. |
* This assumes that the non-page part of an rpc reply will fit |
* in a page - NFSd ensures this. lockd also has no trouble. |
* |
* Each request/reply pair can have at most one "payload", plus two pages, |
* one for the request, and one for the reply. |
*/ |
#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2) |
static inline u32 svc_getu32(struct iovec *iov) |
{ |
u32 val, *vp; |
vp = iov->iov_base; |
val = *vp++; |
iov->iov_base = (void*)vp; |
iov->iov_len -= sizeof(u32); |
return val; |
} |
static inline void svc_putu32(struct iovec *iov, u32 val) |
{ |
u32 *vp = iov->iov_base + iov->iov_len; |
*vp = val; |
iov->iov_len += sizeof(u32); |
} |
/* |
* The context of a single thread, including the request currently being |
* processed. |
* NOTE: First two items must be prev/next. |
*/ |
struct svc_rqst { |
struct list_head rq_list; /* idle list */ |
struct svc_sock * rq_sock; /* socket */ |
struct sockaddr_in rq_addr; /* peer address */ |
int rq_addrlen; |
struct svc_serv * rq_server; /* RPC service definition */ |
struct svc_procedure * rq_procinfo; /* procedure info */ |
struct auth_ops * rq_authop; /* authentication flavour */ |
struct svc_cred rq_cred; /* auth info */ |
struct sk_buff * rq_skbuff; /* fast recv inet buffer */ |
struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */ |
struct xdr_buf rq_arg; |
struct xdr_buf rq_res; |
struct page * rq_argpages[RPCSVC_MAXPAGES]; |
struct page * rq_respages[RPCSVC_MAXPAGES]; |
int rq_restailpage; |
short rq_argused; /* pages used for argument */ |
short rq_arghi; /* pages available in argument page list */ |
short rq_resused; /* pages used for result */ |
u32 rq_xid; /* transmission id */ |
u32 rq_prog; /* program number */ |
u32 rq_vers; /* program version */ |
u32 rq_proc; /* procedure number */ |
u32 rq_prot; /* IP protocol */ |
unsigned short |
rq_secure : 1; /* secure port */ |
__u32 rq_daddr; /* dest addr of request - reply from here */ |
void * rq_argp; /* decoded arguments */ |
void * rq_resp; /* xdr'd results */ |
int rq_reserved; /* space on socket outq |
* reserved for this request |
*/ |
struct cache_req rq_chandle; /* handle passed to caches for |
* request delaying |
*/ |
/* Catering to nfsd */ |
struct auth_domain * rq_client; /* RPC peer info */ |
struct svc_cacherep * rq_cacherep; /* cache info */ |
struct knfsd_fh * rq_reffh; /* Referrence filehandle, used to |
* determine what device number |
* to report (real or virtual) |
*/ |
wait_queue_head_t rq_wait; /* synchronization */ |
}; |
/* |
* Check buffer bounds after decoding arguments |
*/ |
static inline int |
xdr_argsize_check(struct svc_rqst *rqstp, u32 *p) |
{ |
char *cp = (char *)p; |
struct iovec *vec = &rqstp->rq_arg.head[0]; |
return cp - (char*)vec->iov_base <= vec->iov_len; |
} |
static inline int |
xdr_ressize_check(struct svc_rqst *rqstp, u32 *p) |
{ |
struct iovec *vec = &rqstp->rq_res.head[0]; |
char *cp = (char*)p; |
vec->iov_len = cp - (char*)vec->iov_base; |
return vec->iov_len <= PAGE_SIZE; |
} |
static inline int svc_take_page(struct svc_rqst *rqstp) |
{ |
if (rqstp->rq_arghi <= rqstp->rq_argused) |
return -ENOMEM; |
rqstp->rq_arghi--; |
rqstp->rq_respages[rqstp->rq_resused] = |
rqstp->rq_argpages[rqstp->rq_arghi]; |
rqstp->rq_resused++; |
return 0; |
} |
static inline void svc_pushback_allpages(struct svc_rqst *rqstp) |
{ |
while (rqstp->rq_resused) { |
if (rqstp->rq_respages[--rqstp->rq_resused] == NULL) |
continue; |
rqstp->rq_argpages[rqstp->rq_arghi++] = |
rqstp->rq_respages[rqstp->rq_resused]; |
rqstp->rq_respages[rqstp->rq_resused] = NULL; |
} |
} |
static inline void svc_pushback_unused_pages(struct svc_rqst *rqstp) |
{ |
while (rqstp->rq_resused && |
rqstp->rq_res.pages != &rqstp->rq_respages[rqstp->rq_resused]) { |
if (rqstp->rq_respages[--rqstp->rq_resused] != NULL) { |
rqstp->rq_argpages[rqstp->rq_arghi++] = |
rqstp->rq_respages[rqstp->rq_resused]; |
rqstp->rq_respages[rqstp->rq_resused] = NULL; |
} |
} |
} |
static inline void svc_free_allpages(struct svc_rqst *rqstp) |
{ |
while (rqstp->rq_resused) { |
if (rqstp->rq_respages[--rqstp->rq_resused] == NULL) |
continue; |
put_page(rqstp->rq_respages[rqstp->rq_resused]); |
rqstp->rq_respages[rqstp->rq_resused] = NULL; |
} |
} |
struct svc_deferred_req { |
u32 prot; /* protocol (UDP or TCP) */ |
struct sockaddr_in addr; |
struct svc_sock *svsk; /* where reply must go */ |
struct cache_deferred_req handle; |
int argslen; |
u32 args[0]; |
}; |
/* |
* RPC program |
*/ |
struct svc_program { |
u32 pg_prog; /* program number */ |
unsigned int pg_lovers; /* lowest version */ |
unsigned int pg_hivers; /* lowest version */ |
unsigned int pg_nvers; /* number of versions */ |
struct svc_version ** pg_vers; /* version array */ |
char * pg_name; /* service name */ |
char * pg_class; /* class name: services sharing authentication */ |
struct svc_stat * pg_stats; /* rpc statistics */ |
}; |
/* |
* RPC program version |
*/ |
struct svc_version { |
u32 vs_vers; /* version number */ |
u32 vs_nproc; /* number of procedures */ |
struct svc_procedure * vs_proc; /* per-procedure info */ |
u32 vs_xdrsize; /* xdrsize needed for this version */ |
/* Override dispatch function (e.g. when caching replies). |
* A return value of 0 means drop the request. |
* vs_dispatch == NULL means use default dispatcher. |
*/ |
int (*vs_dispatch)(struct svc_rqst *, u32 *); |
}; |
/* |
* RPC procedure info |
*/ |
typedef int (*svc_procfunc)(struct svc_rqst *, void *argp, void *resp); |
struct svc_procedure { |
svc_procfunc pc_func; /* process the request */ |
kxdrproc_t pc_decode; /* XDR decode args */ |
kxdrproc_t pc_encode; /* XDR encode result */ |
kxdrproc_t pc_release; /* XDR free result */ |
unsigned int pc_argsize; /* argument struct size */ |
unsigned int pc_ressize; /* result struct size */ |
unsigned int pc_count; /* call count */ |
unsigned int pc_cachetype; /* cache info (NFS) */ |
unsigned int pc_xdrressize; /* maximum size of XDR reply */ |
}; |
/* |
* This is the RPC server thread function prototype |
*/ |
typedef void (*svc_thread_fn)(struct svc_rqst *); |
/* |
* Function prototypes. |
*/ |
struct svc_serv * svc_create(struct svc_program *, unsigned int); |
int svc_create_thread(svc_thread_fn, struct svc_serv *); |
void svc_exit_thread(struct svc_rqst *); |
void svc_destroy(struct svc_serv *); |
int svc_process(struct svc_serv *, struct svc_rqst *); |
int svc_register(struct svc_serv *, int, unsigned short); |
void svc_wake_up(struct svc_serv *); |
void svc_reserve(struct svc_rqst *rqstp, int space); |
#endif /* SUNRPC_SVC_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/xdr.h |
---|
0,0 → 1,258 |
/* |
* include/linux/sunrpc/xdr.h |
* |
* Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _SUNRPC_XDR_H_ |
#define _SUNRPC_XDR_H_ |
#ifdef __KERNEL__ |
#include <linux/uio.h> |
#include <asm/byteorder.h> |
/* |
* Buffer adjustment |
*/ |
#define XDR_QUADLEN(l) (((l) + 3) >> 2) |
/* |
* Generic opaque `network object.' At the kernel level, this type |
* is used only by lockd. |
*/ |
#define XDR_MAX_NETOBJ 1024 |
struct xdr_netobj { |
unsigned int len; |
u8 * data; |
}; |
/* |
* This is the generic XDR function. rqstp is either a rpc_rqst (client |
* side) or svc_rqst pointer (server side). |
* Encode functions always assume there's enough room in the buffer. |
*/ |
typedef int (*kxdrproc_t)(void *rqstp, u32 *data, void *obj); |
/* |
* Basic structure for transmission/reception of a client XDR message. |
* Features a header (for a linear buffer containing RPC headers |
* and the data payload for short messages), and then an array of |
* pages. |
* The tail iovec allows you to append data after the page array. Its |
* main interest is for appending padding to the pages in order to |
* satisfy the int_32-alignment requirements in RFC1832. |
* |
* For the future, we might want to string several of these together |
* in a list if anybody wants to make use of NFSv4 COMPOUND |
* operations and/or has a need for scatter/gather involving pages. |
*/ |
struct xdr_buf { |
struct iovec head[1], /* RPC header + non-page data */ |
tail[1]; /* Appended after page data */ |
struct page ** pages; /* Array of contiguous pages */ |
unsigned int page_base, /* Start of page data */ |
page_len; /* Length of page data */ |
unsigned int len; /* Total length of data */ |
}; |
/* |
* pre-xdr'ed macros. |
*/ |
#define xdr_zero __constant_htonl(0) |
#define xdr_one __constant_htonl(1) |
#define xdr_two __constant_htonl(2) |
#define rpc_success __constant_htonl(RPC_SUCCESS) |
#define rpc_prog_unavail __constant_htonl(RPC_PROG_UNAVAIL) |
#define rpc_prog_mismatch __constant_htonl(RPC_PROG_MISMATCH) |
#define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL) |
#define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS) |
#define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR) |
#define rpc_auth_ok __constant_htonl(RPC_AUTH_OK) |
#define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED) |
#define rpc_autherr_rejectedcred __constant_htonl(RPC_AUTH_REJECTEDCRED) |
#define rpc_autherr_badverf __constant_htonl(RPC_AUTH_BADVERF) |
#define rpc_autherr_rejectedverf __constant_htonl(RPC_AUTH_REJECTEDVERF) |
#define rpc_autherr_tooweak __constant_htonl(RPC_AUTH_TOOWEAK) |
#define rpcsec_gsserr_credproblem __constant_htonl(RPCSEC_GSS_CREDPROBLEM) |
#define rpcsec_gsserr_ctxproblem __constant_htonl(RPCSEC_GSS_CTXPROBLEM) |
#define rpc_autherr_oldseqnum __constant_htonl(101) |
/* |
* Miscellaneous XDR helper functions |
*/ |
u32 * xdr_encode_array(u32 *p, const char *s, unsigned int len); |
u32 * xdr_encode_string(u32 *p, const char *s); |
u32 * xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen); |
u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen); |
u32 * xdr_encode_netobj(u32 *p, const struct xdr_netobj *); |
u32 * xdr_decode_netobj(u32 *p, struct xdr_netobj *); |
u32 * xdr_decode_netobj_fixed(u32 *p, void *obj, unsigned int len); |
void xdr_encode_pages(struct xdr_buf *, struct page **, unsigned int, |
unsigned int); |
void xdr_inline_pages(struct xdr_buf *, unsigned int, |
struct page **, unsigned int, unsigned int); |
/* |
* Decode 64bit quantities (NFSv3 support) |
*/ |
static inline u32 * |
xdr_encode_hyper(u32 *p, __u64 val) |
{ |
*p++ = htonl(val >> 32); |
*p++ = htonl(val & 0xFFFFFFFF); |
return p; |
} |
static inline u32 * |
xdr_decode_hyper(u32 *p, __u64 *valp) |
{ |
*valp = ((__u64) ntohl(*p++)) << 32; |
*valp |= ntohl(*p++); |
return p; |
} |
/* |
* Adjust iovec to reflect end of xdr'ed data (RPC client XDR) |
*/ |
static inline int |
xdr_adjust_iovec(struct iovec *iov, u32 *p) |
{ |
return iov->iov_len = ((u8 *) p - (u8 *) iov->iov_base); |
} |
void xdr_shift_iovec(struct iovec *, int, size_t); |
/* |
* Maximum number of iov's we use. |
*/ |
#define MAX_IOVEC (12) |
/* |
* XDR buffer helper functions |
*/ |
extern int xdr_kmap(struct iovec *, struct xdr_buf *, size_t); |
extern void xdr_kunmap(struct xdr_buf *, size_t); |
extern void xdr_shift_buf(struct xdr_buf *, size_t); |
/* |
* Helper structure for copying from an sk_buff. |
*/ |
typedef struct { |
struct sk_buff *skb; |
unsigned int offset; |
size_t count; |
unsigned int csum; |
} skb_reader_t; |
typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len); |
extern void xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int, |
skb_reader_t *, skb_read_actor_t); |
struct socket; |
struct sockaddr; |
extern int xdr_sendpages(struct socket *, struct sockaddr *, int, |
struct xdr_buf *, unsigned int, int); |
/* |
* Provide some simple tools for XDR buffer overflow-checking etc. |
*/ |
struct xdr_stream { |
uint32_t *p; /* start of available buffer */ |
struct xdr_buf *buf; /* XDR buffer to read/write */ |
uint32_t *end; /* end of available buffer space */ |
struct iovec *iov; /* pointer to the current iovec */ |
}; |
/* |
* Initialize an xdr_stream for encoding data. |
* |
* Note: at the moment the RPC client only passes the length of our |
* scratch buffer in the xdr_buf's header iovec. Previously this |
* meant we needed to call xdr_adjust_iovec() after encoding the |
* data. With the new scheme, the xdr_stream manages the details |
* of the buffer length, and takes care of adjusting the iovec |
* length for us. |
*/ |
static inline void |
xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) |
{ |
struct iovec *iov = buf->head; |
xdr->buf = buf; |
xdr->iov = iov; |
xdr->end = (uint32_t *)((char *)iov->iov_base + iov->iov_len); |
buf->len = iov->iov_len = (char *)p - (char *)iov->iov_base; |
xdr->p = p; |
} |
/* |
* Check that we have enough buffer space to encode 'nbytes' more |
* bytes of data. If so, update the total xdr_buf length, and |
* adjust the length of the current iovec. |
*/ |
static inline uint32_t * |
xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes) |
{ |
uint32_t *p = xdr->p; |
uint32_t *q; |
/* align nbytes on the next 32-bit boundary */ |
nbytes += 3; |
nbytes &= ~3; |
q = p + (nbytes >> 2); |
if (unlikely(q > xdr->end || q < p)) |
return NULL; |
xdr->p = q; |
xdr->iov->iov_len += nbytes; |
xdr->buf->len += nbytes; |
return p; |
} |
extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, |
unsigned int base, unsigned int len); |
extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); |
/* |
* Initialize an xdr_stream for decoding data. |
*/ |
static inline void |
xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) |
{ |
struct iovec *iov = buf->head; |
xdr->buf = buf; |
xdr->iov = iov; |
xdr->p = p; |
xdr->end = (uint32_t *)((char *)iov->iov_base + iov->iov_len); |
} |
/* |
* Check if the input buffer is long enough to enable us to decode |
* 'nbytes' more bytes of data starting at the current position. |
* If so return the current pointer, then update the current |
* position. |
*/ |
static inline uint32_t * |
xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) |
{ |
uint32_t *p = xdr->p; |
uint32_t *q = p + XDR_QUADLEN(nbytes); |
if (unlikely(q > xdr->end || q < p)) |
return NULL; |
xdr->p = q; |
return p; |
} |
#endif /* __KERNEL__ */ |
#endif /* _SUNRPC_XDR_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/xprt.h |
---|
0,0 → 1,212 |
/* |
* linux/include/linux/sunrpc/clnt_xprt.h |
* |
* Declarations for the RPC transport interface. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_XPRT_H |
#define _LINUX_SUNRPC_XPRT_H |
#include <linux/uio.h> |
#include <linux/socket.h> |
#include <linux/in.h> |
#include <linux/sunrpc/sched.h> |
#include <linux/sunrpc/xdr.h> |
/* |
* The transport code maintains an estimate on the maximum number of out- |
* standing RPC requests, using a smoothed version of the congestion |
* avoidance implemented in 44BSD. This is basically the Van Jacobson |
* congestion algorithm: If a retransmit occurs, the congestion window is |
* halved; otherwise, it is incremented by 1/cwnd when |
* |
* - a reply is received and |
* - a full number of requests are outstanding and |
* - the congestion window hasn't been updated recently. |
* |
* Upper procedures may check whether a request would block waiting for |
* a free RPC slot by using the RPC_CONGESTED() macro. |
* |
* Note: on machines with low memory we should probably use a smaller |
* MAXREQS value: At 32 outstanding reqs with 8 megs of RAM, fragment |
* reassembly will frequently run out of memory. |
*/ |
#define RPC_MAXCONG (16) |
#define RPC_MAXREQS RPC_MAXCONG |
#define RPC_CWNDSCALE (256) |
#define RPC_MAXCWND (RPC_MAXCONG * RPC_CWNDSCALE) |
#define RPC_INITCWND RPC_CWNDSCALE |
#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd) |
/* Default timeout values */ |
#define RPC_MAX_UDP_TIMEOUT (60*HZ) |
#define RPC_MAX_TCP_TIMEOUT (600*HZ) |
/* |
* Wait duration for an RPC TCP connection to be established. Solaris |
* NFS over TCP uses 60 seconds, for example, which is in line with how |
* long a server takes to reboot. |
*/ |
#define RPC_CONNECT_TIMEOUT (60*HZ) |
/* |
* Delay an arbitrary number of seconds before attempting to reconnect |
* after an error. |
*/ |
#define RPC_REESTABLISH_TIMEOUT (15*HZ) |
/* RPC call and reply header size as number of 32bit words (verifier |
* size computed separately) |
*/ |
#define RPC_CALLHDRSIZE 6 |
#define RPC_REPHDRSIZE 4 |
/* |
* This describes a timeout strategy |
*/ |
struct rpc_timeout { |
unsigned long to_current, /* current timeout */ |
to_initval, /* initial timeout */ |
to_maxval, /* max timeout */ |
to_increment; /* if !exponential */ |
unsigned int to_retries; /* max # of retries */ |
unsigned char to_exponential; |
}; |
/* |
* This describes a complete RPC request |
*/ |
struct rpc_rqst { |
/* |
* This is the user-visible part |
*/ |
struct rpc_xprt * rq_xprt; /* RPC client */ |
struct rpc_timeout rq_timeout; /* timeout parms */ |
struct xdr_buf rq_snd_buf; /* send buffer */ |
struct xdr_buf rq_rcv_buf; /* recv buffer */ |
/* |
* This is the private part |
*/ |
struct rpc_task * rq_task; /* RPC task data */ |
__u32 rq_xid; /* request XID */ |
struct rpc_rqst * rq_next; /* free list */ |
int rq_cong; /* has incremented xprt->cong */ |
int rq_received; /* receive completed */ |
struct list_head rq_list; |
struct xdr_buf rq_private_buf; /* The receive buffer |
* used in the softirq. |
*/ |
/* |
* For authentication (e.g. auth_des) |
*/ |
u32 rq_creddata[2]; |
/* |
* Partial send handling |
*/ |
u32 rq_bytes_sent; /* Bytes we have sent */ |
unsigned long rq_xtime; /* when transmitted */ |
int rq_ntimeo; |
int rq_ntrans; |
}; |
#define rq_svec rq_snd_buf.head |
#define rq_slen rq_snd_buf.len |
#define rq_rvec rq_rcv_buf.head |
#define rq_rlen rq_rcv_buf.len |
#define XPRT_LAST_FRAG (1 << 0) |
#define XPRT_COPY_RECM (1 << 1) |
#define XPRT_COPY_XID (1 << 2) |
#define XPRT_COPY_DATA (1 << 3) |
struct rpc_xprt { |
struct socket * sock; /* BSD socket layer */ |
struct sock * inet; /* INET layer */ |
struct rpc_timeout timeout; /* timeout parms */ |
struct sockaddr_in addr; /* server address */ |
int prot; /* IP protocol */ |
unsigned long cong; /* current congestion */ |
unsigned long cwnd; /* congestion window */ |
unsigned int rcvsize, /* socket receive buffer size */ |
sndsize; /* socket send buffer size */ |
struct rpc_wait_queue sending; /* requests waiting to send */ |
struct rpc_wait_queue resend; /* requests waiting to resend */ |
struct rpc_wait_queue pending; /* requests in flight */ |
struct rpc_wait_queue backlog; /* waiting for slot */ |
struct rpc_rqst * free; /* free slots */ |
struct rpc_rqst slot[RPC_MAXREQS]; |
unsigned long sockstate; /* Socket state */ |
unsigned char shutdown : 1, /* being shut down */ |
nocong : 1, /* no congestion control */ |
resvport : 1, /* use a reserved port */ |
stream : 1; /* TCP */ |
/* |
* State of TCP reply receive stuff |
*/ |
u32 tcp_recm, /* Fragment header */ |
tcp_xid, /* Current XID */ |
tcp_reclen, /* fragment length */ |
tcp_offset; /* fragment offset */ |
unsigned long tcp_copied, /* copied to request */ |
tcp_flags; |
/* |
* Send stuff |
*/ |
spinlock_t sock_lock; /* lock socket info */ |
spinlock_t xprt_lock; /* lock xprt info */ |
struct rpc_task * snd_task; /* Task blocked in send */ |
struct list_head recv; |
void (*old_data_ready)(struct sock *, int); |
void (*old_state_change)(struct sock *); |
void (*old_write_space)(struct sock *); |
wait_queue_head_t cong_wait; |
}; |
#ifdef __KERNEL__ |
struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, |
struct rpc_timeout *toparms); |
int xprt_destroy(struct rpc_xprt *); |
void xprt_shutdown(struct rpc_xprt *); |
void xprt_default_timeout(struct rpc_timeout *, int); |
void xprt_set_timeout(struct rpc_timeout *, unsigned int, |
unsigned long); |
void xprt_reserve(struct rpc_task *); |
int xprt_prepare_transmit(struct rpc_task *); |
void xprt_transmit(struct rpc_task *); |
void xprt_receive(struct rpc_task *); |
int xprt_adjust_timeout(struct rpc_timeout *); |
void xprt_release(struct rpc_task *); |
void xprt_connect(struct rpc_task *); |
int xprt_clear_backlog(struct rpc_xprt *); |
void xprt_sock_setbufsize(struct rpc_xprt *); |
#define XPRT_CONNECT 0 |
#define xprt_connected(xp) (test_bit(XPRT_CONNECT, &(xp)->sockstate)) |
#define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate)) |
#define xprt_test_and_set_connected(xp) (test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate)) |
#define xprt_clear_connected(xp) (clear_bit(XPRT_CONNECT, &(xp)->sockstate)) |
#endif /* __KERNEL__*/ |
#endif /* _LINUX_SUNRPC_XPRT_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/stats.h |
---|
0,0 → 1,78 |
/* |
* linux/include/linux/sunrpc/stats.h |
* |
* Client statistics collection for SUN RPC |
* |
* Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_STATS_H |
#define _LINUX_SUNRPC_STATS_H |
#include <linux/config.h> |
#include <linux/proc_fs.h> |
struct rpc_stat { |
struct rpc_program * program; |
unsigned int netcnt, |
netudpcnt, |
nettcpcnt, |
nettcpconn, |
netreconn; |
unsigned int rpccnt, |
rpcretrans, |
rpcauthrefresh, |
rpcgarbage; |
}; |
struct svc_stat { |
struct svc_program * program; |
unsigned int netcnt, |
netudpcnt, |
nettcpcnt, |
nettcpconn; |
unsigned int rpccnt, |
rpcbadfmt, |
rpcbadauth, |
rpcbadclnt; |
}; |
void rpc_proc_init(void); |
void rpc_proc_exit(void); |
#ifdef MODULE |
void rpc_modcount(struct inode *, int); |
#endif |
#ifdef CONFIG_PROC_FS |
struct proc_dir_entry * rpc_proc_register(struct rpc_stat *); |
void rpc_proc_unregister(const char *); |
int rpc_proc_read(char *, char **, off_t, int, |
int *, void *); |
void rpc_proc_zero(struct rpc_program *); |
struct proc_dir_entry * svc_proc_register(struct svc_stat *); |
void svc_proc_unregister(const char *); |
int svc_proc_read(char *, char **, off_t, int, |
int *, void *); |
void svc_proc_zero(struct svc_program *); |
extern struct proc_dir_entry *proc_net_rpc; |
#else |
static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; } |
static inline void rpc_proc_unregister(const char *p) {} |
static inline int rpc_proc_read(char *a, char **b, off_t c, int d, int *e, void *f) { return 0; } |
static inline void rpc_proc_zero(struct rpc_program *p) {} |
static inline struct proc_dir_entry *svc_proc_register(struct svc_stat *s) { return NULL; } |
static inline void svc_proc_unregister(const char *p) {} |
static inline int svc_proc_read(char *a, char **b, off_t c, int d, int *e, void *f) { return 0; } |
static inline void svc_proc_zero(struct svc_program *p) {} |
#define proc_net_rpc NULL |
#endif |
#endif /* _LINUX_SUNRPC_STATS_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/clnt.h |
---|
0,0 → 1,148 |
/* |
* linux/include/linux/sunrpc/clnt.h |
* |
* Declarations for the high-level RPC client interface |
* |
* Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_CLNT_H |
#define _LINUX_SUNRPC_CLNT_H |
#include <linux/sunrpc/msg_prot.h> |
#include <linux/sunrpc/sched.h> |
#include <linux/sunrpc/xprt.h> |
#include <linux/sunrpc/auth.h> |
#include <linux/sunrpc/stats.h> |
#include <linux/sunrpc/xdr.h> |
#include <linux/sunrpc/timer.h> |
#include <asm/signal.h> |
/* |
* This defines an RPC port mapping |
*/ |
struct rpc_portmap { |
__u32 pm_prog; |
__u32 pm_vers; |
__u32 pm_prot; |
__u16 pm_port; |
}; |
struct rpc_inode; |
/* |
* The high-level client handle |
*/ |
struct rpc_clnt { |
atomic_t cl_users; /* number of references */ |
struct rpc_xprt * cl_xprt; /* transport */ |
struct rpc_procinfo * cl_procinfo; /* procedure info */ |
u32 cl_maxproc; /* max procedure number */ |
char * cl_server; /* server machine name */ |
char * cl_protname; /* protocol name */ |
struct rpc_auth * cl_auth; /* authenticator */ |
struct rpc_stat * cl_stats; /* statistics */ |
unsigned int cl_softrtry : 1,/* soft timeouts */ |
cl_intr : 1,/* interruptible */ |
cl_chatty : 1,/* be verbose */ |
cl_autobind : 1,/* use getport() */ |
cl_binding : 1,/* doing a getport() */ |
cl_droppriv : 1,/* enable NFS suid hack */ |
cl_oneshot : 1,/* dispose after use */ |
cl_dead : 1;/* abandoned */ |
struct rpc_rtt cl_rtt; /* RTO estimator data */ |
struct rpc_portmap cl_pmap; /* port mapping */ |
struct rpc_wait_queue cl_bindwait; /* waiting on getport() */ |
int cl_nodelen; /* nodename length */ |
char cl_nodename[UNX_MAXNODENAME]; |
char cl_pathname[30];/* Path in rpc_pipe_fs */ |
struct dentry * cl_dentry; /* inode */ |
}; |
#define cl_timeout cl_xprt->timeout |
#define cl_prog cl_pmap.pm_prog |
#define cl_vers cl_pmap.pm_vers |
#define cl_port cl_pmap.pm_port |
#define cl_prot cl_pmap.pm_prot |
/* |
* General RPC program info |
*/ |
#define RPC_MAXVERSION 4 |
struct rpc_program { |
char * name; /* protocol name */ |
u32 number; /* program number */ |
unsigned int nrvers; /* number of versions */ |
struct rpc_version ** version; /* version array */ |
struct rpc_stat * stats; /* statistics */ |
char * pipe_dir_name; /* path to rpc_pipefs dir */ |
}; |
struct rpc_version { |
u32 number; /* version number */ |
unsigned int nrprocs; /* number of procs */ |
struct rpc_procinfo * procs; /* procedure array */ |
}; |
/* |
* Procedure information |
*/ |
struct rpc_procinfo { |
u32 p_proc; /* RPC procedure number */ |
kxdrproc_t p_encode; /* XDR encode function */ |
kxdrproc_t p_decode; /* XDR decode function */ |
unsigned int p_bufsiz; /* req. buffer size */ |
unsigned int p_count; /* call count */ |
unsigned int p_timer; /* Which RTT timer to use */ |
}; |
#define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt)) |
#define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr) |
#ifdef __KERNEL__ |
struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname, |
struct rpc_program *info, |
u32 version, rpc_authflavor_t authflavor); |
int rpc_shutdown_client(struct rpc_clnt *); |
int rpc_destroy_client(struct rpc_clnt *); |
void rpc_release_client(struct rpc_clnt *); |
void rpc_getport(struct rpc_task *, struct rpc_clnt *); |
int rpc_register(u32, u32, int, unsigned short, int *); |
void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); |
int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, |
int flags, rpc_action callback, void *clntdata); |
int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, |
int flags); |
void rpc_restart_call(struct rpc_task *); |
void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset); |
void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset); |
void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
static __inline__ |
int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) |
{ |
struct rpc_message msg = { |
.rpc_proc = &clnt->cl_procinfo[proc], |
.rpc_argp = argp, |
.rpc_resp = resp, |
.rpc_cred = NULL |
}; |
return rpc_call_sync(clnt, &msg, flags); |
} |
extern void rpciod_wake_up(void); |
/* |
* Helper function for NFSroot support |
*/ |
int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int); |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_CLNT_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/auth.h |
---|
0,0 → 1,142 |
/* |
* linux/include/linux/sunrpc/auth.h |
* |
* Declarations for the RPC client authentication machinery. |
* |
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_AUTH_H |
#define _LINUX_SUNRPC_AUTH_H |
#ifdef __KERNEL__ |
#include <linux/config.h> |
#include <linux/sunrpc/sched.h> |
#include <linux/sunrpc/msg_prot.h> |
#include <linux/sunrpc/xdr.h> |
#include <asm/atomic.h> |
/* size of the nodename buffer */ |
#define UNX_MAXNODENAME 32 |
/* Maximum size (in bytes) of an rpc credential or verifier */ |
#define RPC_MAX_AUTH_SIZE (400) |
/* Work around the lack of a VFS credential */ |
struct auth_cred { |
uid_t uid; |
gid_t gid; |
int ngroups; |
gid_t *groups; |
}; |
/* |
* Client user credentials |
*/ |
struct rpc_cred { |
struct list_head cr_hash; /* hash chain */ |
struct rpc_auth * cr_auth; |
struct rpc_credops * cr_ops; |
unsigned long cr_expire; /* when to gc */ |
atomic_t cr_count; /* ref count */ |
unsigned short cr_flags; /* various flags */ |
#ifdef RPC_DEBUG |
unsigned long cr_magic; /* 0x0f4aa4f0 */ |
#endif |
uid_t cr_uid; |
/* per-flavor data */ |
}; |
#define RPCAUTH_CRED_LOCKED 0x0001 |
#define RPCAUTH_CRED_UPTODATE 0x0002 |
#define RPCAUTH_CRED_DEAD 0x0004 |
#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0 |
/* |
* Client authentication handle |
*/ |
#define RPC_CREDCACHE_NR 8 |
#define RPC_CREDCACHE_MASK (RPC_CREDCACHE_NR - 1) |
struct rpc_auth { |
struct list_head au_credcache[RPC_CREDCACHE_NR]; |
unsigned long au_expire; /* cache expiry interval */ |
unsigned long au_nextgc; /* next garbage collection */ |
unsigned int au_cslack; /* call cred size estimate */ |
unsigned int au_rslack; /* reply verf size guess */ |
unsigned int au_flags; /* various flags */ |
struct rpc_authops * au_ops; /* operations */ |
rpc_authflavor_t au_flavor; /* pseudoflavor (note may |
* differ from the flavor in |
* au_ops->au_flavor in gss |
* case) */ |
/* per-flavor data */ |
}; |
#define RPC_AUTH_PROC_CREDS 0x0010 /* process creds (including |
* uid/gid, fs[ug]id, gids) |
*/ |
/* |
* Client authentication ops |
*/ |
struct rpc_authops { |
struct module *owner; |
rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */ |
#ifdef RPC_DEBUG |
char * au_name; |
#endif |
struct rpc_auth * (*create)(struct rpc_clnt *, rpc_authflavor_t); |
void (*destroy)(struct rpc_auth *); |
struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int); |
}; |
struct rpc_credops { |
void (*crdestroy)(struct rpc_cred *); |
int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
u32 * (*crmarshal)(struct rpc_task *, u32 *, int); |
int (*crrefresh)(struct rpc_task *); |
u32 * (*crvalidate)(struct rpc_task *, u32 *); |
}; |
extern struct rpc_authops authunix_ops; |
extern struct rpc_authops authnull_ops; |
#ifdef CONFIG_SUNRPC_SECURE |
extern struct rpc_authops authdes_ops; |
#endif |
u32 pseudoflavor_to_flavor(rpc_authflavor_t); |
int rpcauth_register(struct rpc_authops *); |
int rpcauth_unregister(struct rpc_authops *); |
struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *); |
void rpcauth_destroy(struct rpc_auth *); |
struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); |
struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
struct rpc_cred * rpcauth_bindcred(struct rpc_task *); |
void rpcauth_holdcred(struct rpc_task *); |
void put_rpccred(struct rpc_cred *); |
void rpcauth_unbindcred(struct rpc_task *); |
u32 * rpcauth_marshcred(struct rpc_task *, u32 *); |
u32 * rpcauth_checkverf(struct rpc_task *, u32 *); |
int rpcauth_refreshcred(struct rpc_task *); |
void rpcauth_invalcred(struct rpc_task *); |
int rpcauth_uptodatecred(struct rpc_task *); |
int rpcauth_deadcred(struct rpc_task *); |
void rpcauth_init_credcache(struct rpc_auth *); |
void rpcauth_free_credcache(struct rpc_auth *); |
static inline |
struct rpc_cred * get_rpccred(struct rpc_cred *cred) |
{ |
atomic_inc(&cred->cr_count); |
return cred; |
} |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_AUTH_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/cache.h |
---|
0,0 → 1,313 |
/* |
* include/linux/sunrpc/cache.h |
* |
* Generic code for various authentication-related caches |
* used by sunrpc clients and servers. |
* |
* Copyright (C) 2002 Neil Brown <neilb@cse.unsw.edu.au> |
* |
* Released under terms in GPL version 2. See COPYING. |
* |
*/ |
#ifndef _LINUX_SUNRPC_CACHE_H_ |
#define _LINUX_SUNRPC_CACHE_H_ |
#include <linux/slab.h> |
#include <asm/atomic.h> |
#include <linux/proc_fs.h> |
/* |
* Each cache requires: |
* - A 'struct cache_detail' which contains information specific to the cache |
* for common code to use. |
* - An item structure that must contain a "struct cache_head" |
* - A lookup function defined using DefineCacheLookup |
* - A 'put' function that can release a cache item. It will only |
* be called after cache_put has succeed, so there are guarantee |
* to be no references. |
* - A function to calculate a hash of an item's key. |
* |
* as well as assorted code fragments (e.g. compare keys) and numbers |
* (e.g. hash size, goal_age, etc). |
* |
* Each cache must be registered so that it can be cleaned regularly. |
* When the cache is unregistered, it is flushed completely. |
* |
* Entries have a ref count and a 'hashed' flag which counts the existance |
* in the hash table. |
* We only expire entries when refcount is zero. |
* Existance in the cache is not measured in refcount but rather in |
* CACHE_HASHED flag. |
*/ |
/* Every cache item has a common header that is used |
* for expiring and refreshing entries. |
* |
*/ |
struct cache_head { |
struct cache_head * next; |
time_t expiry_time; /* After time time, don't use the data */ |
time_t last_refresh; /* If CACHE_PENDING, this is when upcall |
* was sent, else this is when update was received |
*/ |
atomic_t refcnt; |
unsigned long flags; |
}; |
#define CACHE_VALID 0 /* Entry contains valid data */ |
#define CACHE_NEGATIVE 1 /* Negative entry - there is no match for the key */ |
#define CACHE_PENDING 2 /* An upcall has been sent but no reply received yet*/ |
#define CACHE_HASHED 3 /* Entry is in a hash table */ |
#define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ |
struct cache_detail { |
int hash_size; |
struct cache_head ** hash_table; |
rwlock_t hash_lock; |
atomic_t inuse; /* active user-space update or lookup */ |
char *name; |
void (*cache_put)(struct cache_head *, |
struct cache_detail*); |
void (*cache_request)(struct cache_detail *cd, |
struct cache_head *h, |
char **bpp, int *blen); |
int (*cache_parse)(struct cache_detail *, |
char *buf, int len); |
int (*cache_show)(struct seq_file *m, |
struct cache_detail *cd, |
struct cache_head *h); |
/* fields below this comment are for internal use |
* and should not be touched by cache owners |
*/ |
time_t flush_time; /* flush all cache items with last_refresh |
* earlier than this */ |
struct list_head others; |
time_t nextcheck; |
int entries; |
/* fields for communication over channel */ |
struct list_head queue; |
struct proc_dir_entry *proc_ent; |
atomic_t readers; /* how many time is /chennel open */ |
time_t last_close; /* it no readers, when did last close */ |
}; |
/* this must be embedded in any request structure that |
* identifies an object that will want a callback on |
* a cache fill |
*/ |
struct cache_req { |
struct cache_deferred_req *(*defer)(struct cache_req *req); |
}; |
/* this must be embedded in a deferred_request that is being |
* delayed awaiting cache-fill |
*/ |
struct cache_deferred_req { |
struct list_head hash; /* on hash chain */ |
struct list_head recent; /* on fifo */ |
struct cache_head *item; /* cache item we wait on */ |
time_t recv_time; |
void *owner; /* we might need to discard all defered requests |
* owned by someone */ |
void (*revisit)(struct cache_deferred_req *req, |
int too_many); |
}; |
/* |
* just like a template in C++, this macro does cache lookup |
* for us. |
* The function is passed some sort of HANDLE from which a cache_detail |
* structure can be determined (via SETUP, DETAIL), a template |
* cache entry (type RTN*), and a "set" flag. Using the HASHFN and the |
* TEST, the function will try to find a matching cache entry in the cache. |
* If "set" == 0 : |
* If an entry is found, it is returned |
* If no entry is found, a new non-VALID entry is created. |
* If "set" == 1 : |
* If no entry is found a new one is inserted with data from "template" |
* If a non-CACHE_VALID entry is found, it is updated from template using UPDATE |
* If a CACHE_VALID entry is found, a new entry is swapped in with data |
* from "template" |
* If set == 2, we UPDATE, but don't swap. i.e. update in place |
* |
* If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not |
* run but insteead CACHE_NEGATIVE is set in any new item. |
* In any case, the new entry is returned with a reference count. |
* |
* |
* RTN is a struct type for a cache entry |
* MEMBER is the member of the cache which is cache_head, which must be first |
* FNAME is the name for the function |
* ARGS are arguments to function and must contain RTN *item, int set. May |
* also contain something to be usedby SETUP or DETAIL to find cache_detail. |
* SETUP locates the cache detail and makes it available as... |
* DETAIL identifies the cache detail, possibly set up by SETUP |
* HASHFN returns a hash value of the cache entry "item" |
* TEST tests if "tmp" matches "item" |
* INIT copies key information from "item" to "new" |
* UPDATE copies content information from "item" to "tmp" |
* INPLACE is true if updates can happen inplace rather than allocating a new structure |
*/ |
#define DefineCacheLookup(RTN,MEMBER,FNAME,ARGS,SETUP,DETAIL,HASHFN,TEST,INIT,UPDATE,INPLACE) \ |
RTN *FNAME ARGS \ |
{ \ |
RTN *tmp, *new=NULL; \ |
struct cache_head **hp, **head; \ |
SETUP; \ |
retry: \ |
head = &(DETAIL)->hash_table[HASHFN]; \ |
if (set||new) write_lock(&(DETAIL)->hash_lock); \ |
else read_lock(&(DETAIL)->hash_lock); \ |
for(hp=head; *hp != NULL; hp = &tmp->MEMBER.next) { \ |
tmp = container_of(*hp, RTN, MEMBER); \ |
if (TEST) { /* found a match */ \ |
\ |
if (set && !INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags) && !new) \ |
break; \ |
\ |
cache_get(&tmp->MEMBER); \ |
if (set) { \ |
if (!INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags))\ |
{ /* need to swap in new */ \ |
RTN *t2; \ |
\ |
new->MEMBER.next = tmp->MEMBER.next; \ |
*hp = &new->MEMBER; \ |
tmp->MEMBER.next = NULL; \ |
set_bit(CACHE_HASHED, &new->MEMBER.flags); \ |
clear_bit(CACHE_HASHED, &tmp->MEMBER.flags); \ |
t2 = tmp; tmp = new; new = t2; \ |
} \ |
if (test_bit(CACHE_NEGATIVE, &item->MEMBER.flags)) \ |
set_bit(CACHE_NEGATIVE, &tmp->MEMBER.flags); \ |
else {UPDATE;} \ |
} \ |
if (set||new) write_unlock(&(DETAIL)->hash_lock); \ |
else read_unlock(&(DETAIL)->hash_lock); \ |
if (set) \ |
cache_fresh(DETAIL, &tmp->MEMBER, item->MEMBER.expiry_time); \ |
if (set && !INPLACE && new) cache_fresh(DETAIL, &new->MEMBER, 0); \ |
if (new) (DETAIL)->cache_put(&new->MEMBER, DETAIL); \ |
return tmp; \ |
} \ |
} \ |
/* Didn't find anything */ \ |
if (new) { \ |
new->MEMBER.next = *head; \ |
*head = &new->MEMBER; \ |
(DETAIL)->entries ++; \ |
set_bit(CACHE_HASHED, &new->MEMBER.flags); \ |
if (set) { \ |
tmp = new; \ |
if (test_bit(CACHE_NEGATIVE, &item->MEMBER.flags)) \ |
set_bit(CACHE_NEGATIVE, &tmp->MEMBER.flags); \ |
else {UPDATE;} \ |
} \ |
} \ |
if (set||new) write_unlock(&(DETAIL)->hash_lock); \ |
else read_unlock(&(DETAIL)->hash_lock); \ |
if (new && set) \ |
cache_fresh(DETAIL, &new->MEMBER, item->MEMBER.expiry_time); \ |
if (new) \ |
return new; \ |
new = kmalloc(sizeof(*new), GFP_KERNEL); \ |
if (new) { \ |
cache_init(&new->MEMBER); \ |
cache_get(&new->MEMBER); \ |
INIT; \ |
tmp = new; \ |
goto retry; \ |
} \ |
return NULL; \ |
} |
#define DefineSimpleCacheLookup(STRUCT,INPLACE) \ |
DefineCacheLookup(struct STRUCT, h, STRUCT##_lookup, (struct STRUCT *item, int set), /*no setup */, \ |
& STRUCT##_cache, STRUCT##_hash(item), STRUCT##_match(item, tmp),\ |
STRUCT##_init(new, item), STRUCT##_update(tmp, item),INPLACE) |
#define cache_for_each(pos, detail, index, member) \ |
for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \ |
({if (index==0)read_unlock(&(detail)->hash_lock); index--;}); \ |
) \ |
for (pos = container_of((detail)->hash_table[index], typeof(*pos), member); \ |
&pos->member; \ |
pos = container_of(pos->member.next, typeof(*pos), member)) |
extern void cache_defer_req(struct cache_req *req, struct cache_head *item); |
extern void cache_revisit_request(struct cache_head *item); |
extern void cache_clean_deferred(void *owner); |
static inline struct cache_head *cache_get(struct cache_head *h) |
{ |
atomic_inc(&h->refcnt); |
return h; |
} |
static inline int cache_put(struct cache_head *h, struct cache_detail *cd) |
{ |
atomic_dec(&h->refcnt); |
if (!atomic_read(&h->refcnt) && |
h->expiry_time < cd->nextcheck) |
cd->nextcheck = h->expiry_time; |
if (!test_bit(CACHE_HASHED, &h->flags) && |
!atomic_read(&h->refcnt)) |
return 1; |
return 0; |
} |
extern void cache_init(struct cache_head *h); |
extern void cache_fresh(struct cache_detail *detail, |
struct cache_head *head, time_t expiry); |
extern int cache_check(struct cache_detail *detail, |
struct cache_head *h, struct cache_req *rqstp); |
extern int cache_clean(void); |
extern void cache_flush(void); |
extern void cache_purge(struct cache_detail *detail); |
#define NEVER (0x7FFFFFFF) |
extern void cache_register(struct cache_detail *cd); |
extern int cache_unregister(struct cache_detail *cd); |
extern struct cache_detail *cache_find(char *name); |
extern void cache_drop(struct cache_detail *detail); |
extern void qword_add(char **bpp, int *lp, char *str); |
extern void qword_addhex(char **bpp, int *lp, char *buf, int blen); |
extern int qword_get(char **bpp, char *dest, int bufsize); |
static inline int get_int(char **bpp, int *anint) |
{ |
char buf[50]; |
char *ep; |
int rv; |
int len = qword_get(bpp, buf, 50); |
if (len < 0) return -EINVAL; |
if (len ==0) return -ENOENT; |
rv = simple_strtol(buf, &ep, 0); |
if (*ep) return -EINVAL; |
*anint = rv; |
return 0; |
} |
static inline time_t get_expiry(char **bpp) |
{ |
int rv; |
if (get_int(bpp, &rv)) |
return 0; |
if (rv < 0) |
return 0; |
return rv; |
} |
#endif /* _LINUX_SUNRPC_CACHE_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/types.h |
---|
0,0 → 1,22 |
/* |
* linux/include/linux/sunrpc/types.h |
* |
* Generic types and misc stuff for RPC. |
* |
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_TYPES_H_ |
#define _LINUX_SUNRPC_TYPES_H_ |
#include <linux/timer.h> |
#include <linux/workqueue.h> |
#include <linux/sunrpc/debug.h> |
#include <linux/list.h> |
/* |
* Shorthands |
*/ |
#define signalled() (signal_pending(current)) |
#endif /* _LINUX_SUNRPC_TYPES_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/gss_err.h |
---|
0,0 → 1,177 |
/* |
* linux/include/sunrpc/gss_err.h |
* |
* Adapted from MIT Kerberos 5-1.2.1 include/gssapi/gssapi.h |
* |
* Copyright (c) 2002 The Regents of the University of Michigan. |
* All rights reserved. |
* |
* Andy Adamson <andros@umich.edu> |
*/ |
/* |
* Copyright 1993 by OpenVision Technologies, Inc. |
* |
* Permission to use, copy, modify, distribute, and sell this software |
* and its documentation for any purpose is hereby granted without fee, |
* provided that the above copyright notice appears in all copies and |
* that both that copyright notice and this permission notice appear in |
* supporting documentation, and that the name of OpenVision not be used |
* in advertising or publicity pertaining to distribution of the software |
* without specific, written prior permission. OpenVision makes no |
* representations about the suitability of this software for any |
* purpose. It is provided "as is" without express or implied warranty. |
* |
* OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
* EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF |
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* PERFORMANCE OF THIS SOFTWARE. |
*/ |
#ifndef _LINUX_SUNRPC_GSS_ERR_H |
#define _LINUX_SUNRPC_GSS_ERR_H |
#ifdef __KERNEL__ |
typedef unsigned int OM_uint32; |
/* |
* Flag bits for context-level services. |
*/ |
#define GSS_C_DELEG_FLAG 1 |
#define GSS_C_MUTUAL_FLAG 2 |
#define GSS_C_REPLAY_FLAG 4 |
#define GSS_C_SEQUENCE_FLAG 8 |
#define GSS_C_CONF_FLAG 16 |
#define GSS_C_INTEG_FLAG 32 |
#define GSS_C_ANON_FLAG 64 |
#define GSS_C_PROT_READY_FLAG 128 |
#define GSS_C_TRANS_FLAG 256 |
/* |
* Credential usage options |
*/ |
#define GSS_C_BOTH 0 |
#define GSS_C_INITIATE 1 |
#define GSS_C_ACCEPT 2 |
/* |
* Status code types for gss_display_status |
*/ |
#define GSS_C_GSS_CODE 1 |
#define GSS_C_MECH_CODE 2 |
/* |
* Define the default Quality of Protection for per-message services. Note |
* that an implementation that offers multiple levels of QOP may either reserve |
* a value (for example zero, as assumed here) to mean "default protection", or |
* alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit |
* QOP value. However a value of 0 should always be interpreted by a GSSAPI |
* implementation as a request for the default protection level. |
*/ |
#define GSS_C_QOP_DEFAULT 0 |
/* |
* Expiration time of 2^32-1 seconds means infinite lifetime for a |
* credential or security context |
*/ |
#define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful) |
/* Major status codes */ |
#define GSS_S_COMPLETE 0 |
/* |
* Some "helper" definitions to make the status code macros obvious. |
*/ |
#define GSS_C_CALLING_ERROR_OFFSET 24 |
#define GSS_C_ROUTINE_ERROR_OFFSET 16 |
#define GSS_C_SUPPLEMENTARY_OFFSET 0 |
#define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul) |
#define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul) |
#define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul) |
/* |
* The macros that test status codes for error conditions. Note that the |
* GSS_ERROR() macro has changed slightly from the V1 GSSAPI so that it now |
* evaluates its argument only once. |
*/ |
#define GSS_CALLING_ERROR(x) \ |
((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET)) |
#define GSS_ROUTINE_ERROR(x) \ |
((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)) |
#define GSS_SUPPLEMENTARY_INFO(x) \ |
((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET)) |
#define GSS_ERROR(x) \ |
((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \ |
(GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))) |
/* |
* Now the actual status code definitions |
*/ |
/* |
* Calling errors: |
*/ |
#define GSS_S_CALL_INACCESSIBLE_READ \ |
(((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET) |
#define GSS_S_CALL_INACCESSIBLE_WRITE \ |
(((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET) |
#define GSS_S_CALL_BAD_STRUCTURE \ |
(((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET) |
/* |
* Routine errors: |
*/ |
#define GSS_S_BAD_MECH (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_NAME (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_NAMETYPE (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_BINDINGS (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_STATUS (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_SIG (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_NO_CRED (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_NO_CONTEXT (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_DEFECTIVE_TOKEN (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_DEFECTIVE_CREDENTIAL \ |
(((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_CREDENTIALS_EXPIRED \ |
(((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_CONTEXT_EXPIRED \ |
(((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_FAILURE (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_BAD_QOP (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_UNAUTHORIZED (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_UNAVAILABLE (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_DUPLICATE_ELEMENT \ |
(((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
#define GSS_S_NAME_NOT_MN \ |
(((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET) |
/* |
* Supplementary info bits: |
*/ |
#define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0)) |
#define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1)) |
#define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2)) |
#define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3)) |
#define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4)) |
/* XXXX these are not part of the GSSAPI C bindings! (but should be) */ |
#define GSS_CALLING_ERROR_FIELD(x) \ |
(((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK) |
#define GSS_ROUTINE_ERROR_FIELD(x) \ |
(((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK) |
#define GSS_SUPPLEMENTARY_INFO_FIELD(x) \ |
(((x) >> GSS_C_SUPPLEMENTARY_OFFSET) & GSS_C_SUPPLEMENTARY_MASK) |
/* XXXX This is a necessary evil until the spec is fixed */ |
#define GSS_S_CRED_UNAVAIL GSS_S_FAILURE |
#endif /* __KERNEL__ */ |
#endif /* __LINUX_SUNRPC_GSS_ERR_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/name_lookup.h |
---|
0,0 → 1,38 |
/* |
* map between user/group name and id for a given 'client' |
*/ |
struct name_ent { |
char name[20]; |
}; |
static inline int name_get_user(int uid, struct name_ent **namep) |
{ |
struct name_ent *n = kmalloc(sizeof(*n),GFP_KERNEL); |
if (n) sprintf(n->name, "%d",uid); |
*namep = n; |
return n ? 0 : -ENOMEM; |
} |
static inline int name_get_group(int uid, struct name_ent **namep) |
{ |
struct name_ent *n = kmalloc(sizeof(*n),GFP_KERNEL); |
if (n) sprintf(n->name, "%d",uid); |
*namep = n; |
return n ? 0 : -ENOMEM; |
} |
static inline int name_get_uid(char *name, int name_len, int *uidp) |
{ |
*uidp = simple_strtoul(name, NULL, 0); |
return 0; |
} |
static inline int name_get_gid(char *name, int name_len, int *gidp) |
{ |
*gidp = simple_strtoul(name, NULL, 0); |
return 0; |
} |
static inline void name_put(struct name_ent *ent) |
{ |
kfree(ent); |
} |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/svcsock.h |
---|
0,0 → 1,65 |
/* |
* linux/include/linux/sunrpc/svcsock.h |
* |
* RPC server socket I/O. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef SUNRPC_SVCSOCK_H |
#define SUNRPC_SVCSOCK_H |
#include <linux/sunrpc/svc.h> |
/* |
* RPC server socket. |
*/ |
struct svc_sock { |
struct list_head sk_ready; /* list of ready sockets */ |
struct list_head sk_list; /* list of all sockets */ |
struct socket * sk_sock; /* berkeley socket layer */ |
struct sock * sk_sk; /* INET layer */ |
struct svc_serv * sk_server; /* service for this socket */ |
unsigned int sk_inuse; /* use count */ |
unsigned long sk_flags; |
#define SK_BUSY 0 /* enqueued/receiving */ |
#define SK_CONN 1 /* conn pending */ |
#define SK_CLOSE 2 /* dead or dying */ |
#define SK_DATA 3 /* data pending */ |
#define SK_TEMP 4 /* temp (TCP) socket */ |
#define SK_DEAD 6 /* socket closed */ |
#define SK_CHNGBUF 7 /* need to change snd/rcv buffer sizes */ |
#define SK_DEFERRED 8 /* request on sk_deferred */ |
int sk_reserved; /* space on outq that is reserved */ |
struct list_head sk_deferred; /* deferred requests that need to |
* be revisted */ |
struct semaphore sk_sem; /* to serialize sending data */ |
int (*sk_recvfrom)(struct svc_rqst *rqstp); |
int (*sk_sendto)(struct svc_rqst *rqstp); |
/* We keep the old state_change and data_ready CB's here */ |
void (*sk_ostate)(struct sock *); |
void (*sk_odata)(struct sock *, int bytes); |
void (*sk_owspace)(struct sock *); |
/* private TCP part */ |
int sk_reclen; /* length of record */ |
int sk_tcplen; /* current read length */ |
time_t sk_lastrecv; /* time of last received request */ |
}; |
/* |
* Function prototypes. |
*/ |
int svc_makesock(struct svc_serv *, int, unsigned short); |
void svc_delete_socket(struct svc_sock *); |
int svc_recv(struct svc_serv *, struct svc_rqst *, long); |
int svc_send(struct svc_rqst *); |
void svc_drop(struct svc_rqst *); |
void svc_sock_update_bufs(struct svc_serv *serv); |
#endif /* SUNRPC_SVCSOCK_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/svcauth.h |
---|
0,0 → 1,157 |
/* |
* linux/include/linux/sunrpc/svcauth.h |
* |
* RPC server-side authentication stuff. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_SVCAUTH_H_ |
#define _LINUX_SUNRPC_SVCAUTH_H_ |
#ifdef __KERNEL__ |
#include <linux/string.h> |
#include <linux/sunrpc/msg_prot.h> |
#include <linux/sunrpc/cache.h> |
#include <linux/hash.h> |
struct svc_cred { |
uid_t cr_uid; |
gid_t cr_gid; |
gid_t cr_groups[NGROUPS]; |
}; |
struct svc_rqst; /* forward decl */ |
/* Authentication is done in the context of a domain. |
* For a server, a domain represents a group of clients using |
* a common mechanism for authentication and having a common mapping |
* between local identity (uid) and network identity. All clients |
* in a domain have similar general access rights. Each domain can |
* contain multiple principals which will have different specific right |
* based on normal Discretionary Access Control. |
* |
* For a client, a domain represents a number of servers which all |
* use a common authentication mechanism and network identity name space. |
* |
* A domain is created by an authentication flavour module based on name |
* only. Userspace then fills in detail on demand. |
* |
* The creation of a domain typically implies creation of one or |
* more caches for storing domain specific information. |
*/ |
struct auth_domain { |
struct cache_head h; |
char *name; |
int flavour; |
}; |
/* |
* Each authentication flavour registers an auth_ops |
* structure. |
* name is simply the name. |
* flavour gives the auth flavour. It determines where the flavour is registered |
* accept() is given a request and should verify it. |
* It should inspect the authenticator and verifier, and possibly the data. |
* If there is a problem with the authentication *authp should be set. |
* The return value of accept() can indicate: |
* OK - authorised. client and credential are set in rqstp. |
* reqbuf points to arguments |
* resbuf points to good place for results. verfier |
* is (probably) already in place. Certainly space is |
* reserved for it. |
* DROP - simply drop the request. It may have been deferred |
* GARBAGE - rpc garbage_args error |
* SYSERR - rpc system_err error |
* DENIED - authp holds reason for denial. |
* |
* accept is passed the proc number so that it can accept NULL rpc requests |
* even if it cannot authenticate the client (as is sometimes appropriate). |
* |
* release() is given a request after the procedure has been run. |
* It should sign/encrypt the results if needed |
* It should return: |
* OK - the resbuf is ready to be sent |
* DROP - the reply should be quitely dropped |
* DENIED - authp holds a reason for MSG_DENIED |
* SYSERR - rpc system_err |
* |
* domain_release() |
* This call releases a domain. |
*/ |
struct auth_ops { |
char * name; |
int flavour; |
int (*accept)(struct svc_rqst *rq, u32 *authp); |
int (*release)(struct svc_rqst *rq); |
void (*domain_release)(struct auth_domain *); |
}; |
extern struct auth_ops *authtab[RPC_AUTH_MAXFLAVOR]; |
#define SVC_GARBAGE 1 |
#define SVC_SYSERR 2 |
#define SVC_VALID 3 |
#define SVC_NEGATIVE 4 |
#define SVC_OK 5 |
#define SVC_DROP 6 |
#define SVC_DENIED 7 |
#define SVC_PENDING 8 |
extern int svc_authenticate(struct svc_rqst *rqstp, u32 *authp); |
extern int svc_authorise(struct svc_rqst *rqstp); |
extern int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops); |
extern void svc_auth_unregister(rpc_authflavor_t flavor); |
extern struct auth_domain *unix_domain_find(char *name); |
extern void auth_domain_put(struct auth_domain *item); |
extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom); |
extern struct auth_domain *auth_domain_lookup(struct auth_domain *item, int set); |
extern struct auth_domain *auth_domain_find(char *name); |
extern struct auth_domain *auth_unix_lookup(struct in_addr addr); |
extern int auth_unix_forget_old(struct auth_domain *dom); |
extern void svcauth_unix_purge(void); |
static inline unsigned long hash_str(char *name, int bits) |
{ |
unsigned long hash = 0; |
unsigned long l = 0; |
int len = 0; |
unsigned char c; |
do { |
if (unlikely(!(c = *name++))) { |
c = (char)len; len = -1; |
} |
l = (l << 8) | c; |
len++; |
if ((len & (BITS_PER_LONG/8-1))==0) |
hash = hash_long(hash^l, BITS_PER_LONG); |
} while (len); |
return hash >> (BITS_PER_LONG - bits); |
} |
static inline unsigned long hash_mem(char *buf, int length, int bits) |
{ |
unsigned long hash = 0; |
unsigned long l = 0; |
int len = 0; |
unsigned char c; |
do { |
if (len == length) { |
c = (char)len; len = -1; |
} else |
c = *buf++; |
l = (l << 8) | c; |
len++; |
if ((len & (BITS_PER_LONG/8-1))==0) |
hash = hash_long(hash^l, BITS_PER_LONG); |
} while (len); |
return hash >> (BITS_PER_LONG - bits); |
} |
extern struct cache_detail auth_domain_cache, ip_map_cache; |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_SVCAUTH_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/auth_gss.h |
---|
0,0 → 1,98 |
/* |
* linux/include/linux/auth_gss.h |
* |
* Declarations for RPCSEC_GSS |
* |
* Dug Song <dugsong@monkey.org> |
* Andy Adamson <andros@umich.edu> |
* Bruce Fields <bfields@umich.edu> |
* Copyright (c) 2000 The Regents of the University of Michigan |
* |
* $Id: auth_gss.h,v 1.1 2004-01-28 15:31:11 giacomo Exp $ |
*/ |
#ifndef _LINUX_SUNRPC_AUTH_GSS_H |
#define _LINUX_SUNRPC_AUTH_GSS_H |
#ifdef __KERNEL__ |
#ifdef __linux__ |
#include <linux/sunrpc/auth.h> |
#include <linux/sunrpc/svc.h> |
#include <linux/sunrpc/gss_api.h> |
#endif |
#define RPC_GSS_VERSION 1 |
#define MAXSEQ 0x80000000 /* maximum legal sequence number, from rfc 2203 */ |
enum rpc_gss_proc { |
RPC_GSS_PROC_DATA = 0, |
RPC_GSS_PROC_INIT = 1, |
RPC_GSS_PROC_CONTINUE_INIT = 2, |
RPC_GSS_PROC_DESTROY = 3 |
}; |
enum rpc_gss_svc { |
RPC_GSS_SVC_NONE = 1, |
RPC_GSS_SVC_INTEGRITY = 2, |
RPC_GSS_SVC_PRIVACY = 3 |
}; |
/* on-the-wire gss cred: */ |
struct rpc_gss_wire_cred { |
u32 gc_v; /* version */ |
u32 gc_proc; /* control procedure */ |
u32 gc_seq; /* sequence number */ |
u32 gc_svc; /* service */ |
struct xdr_netobj gc_ctx; /* context handle */ |
}; |
/* on-the-wire gss verifier: */ |
struct rpc_gss_wire_verf { |
u32 gv_flavor; |
struct xdr_netobj gv_verf; |
}; |
/* return from gss NULL PROC init sec context */ |
struct rpc_gss_init_res { |
struct xdr_netobj gr_ctx; /* context handle */ |
u32 gr_major; /* major status */ |
u32 gr_minor; /* minor status */ |
u32 gr_win; /* sequence window */ |
struct xdr_netobj gr_token; /* token */ |
}; |
#define GSS_SEQ_WIN 5 |
/* The gss_cl_ctx struct holds all the information the rpcsec_gss client |
* code needs to know about a single security context. In particular, |
* gc_gss_ctx is the context handle that is used to do gss-api calls, while |
* gc_wire_ctx is the context handle that is used to identify the context on |
* the wire when communicating with a server. */ |
struct gss_cl_ctx { |
atomic_t count; |
u32 gc_proc; |
u32 gc_seq; |
spinlock_t gc_seq_lock; |
struct gss_ctx *gc_gss_ctx; |
struct xdr_netobj gc_wire_ctx; |
u32 gc_win; |
}; |
struct gss_cred { |
struct rpc_cred gc_base; |
u32 gc_flavor; |
struct gss_cl_ctx *gc_ctx; |
}; |
#define gc_uid gc_base.cr_uid |
#define gc_count gc_base.cr_count |
#define gc_flags gc_base.cr_flags |
#define gc_expire gc_base.cr_expire |
void print_hexl(u32 *p, u_int length, u_int offset); |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_AUTH_GSS_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/gss_asn1.h |
---|
0,0 → 1,85 |
/* |
* linux/include/linux/sunrpc/gss_asn1.h |
* |
* minimal asn1 for generic encoding/decoding of gss tokens |
* |
* Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h, |
* lib/gssapi/krb5/gssapiP_krb5.h, and others |
* |
* Copyright (c) 2000 The Regents of the University of Michigan. |
* All rights reserved. |
* |
* Andy Adamson <andros@umich.edu> |
*/ |
/* |
* Copyright 1995 by the Massachusetts Institute of Technology. |
* All Rights Reserved. |
* |
* Export of this software from the United States of America may |
* require a specific license from the United States Government. |
* It is the responsibility of any person or organization contemplating |
* export to obtain such a license before exporting. |
* |
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and |
* distribute this software and its documentation for any purpose and |
* without fee is hereby granted, provided that the above copyright |
* notice appear in all copies and that both that copyright notice and |
* this permission notice appear in supporting documentation, and that |
* the name of M.I.T. not be used in advertising or publicity pertaining |
* to distribution of the software without specific, written prior |
* permission. Furthermore if you modify this software you must label |
* your software as modified software and not distribute it in such a |
* fashion that it might be confused with the original M.I.T. software. |
* M.I.T. makes no representations about the suitability of |
* this software for any purpose. It is provided "as is" without express |
* or implied warranty. |
* |
*/ |
#include <linux/sunrpc/gss_api.h> |
#define SIZEOF_INT 4 |
/* from gssapi_err_generic.h */ |
#define G_BAD_SERVICE_NAME (-2045022976L) |
#define G_BAD_STRING_UID (-2045022975L) |
#define G_NOUSER (-2045022974L) |
#define G_VALIDATE_FAILED (-2045022973L) |
#define G_BUFFER_ALLOC (-2045022972L) |
#define G_BAD_MSG_CTX (-2045022971L) |
#define G_WRONG_SIZE (-2045022970L) |
#define G_BAD_USAGE (-2045022969L) |
#define G_UNKNOWN_QOP (-2045022968L) |
#define G_NO_HOSTNAME (-2045022967L) |
#define G_BAD_HOSTNAME (-2045022966L) |
#define G_WRONG_MECH (-2045022965L) |
#define G_BAD_TOK_HEADER (-2045022964L) |
#define G_BAD_DIRECTION (-2045022963L) |
#define G_TOK_TRUNC (-2045022962L) |
#define G_REFLECT (-2045022961L) |
#define G_WRONG_TOKID (-2045022960L) |
#define g_OID_equal(o1,o2) \ |
(((o1)->len == (o2)->len) && \ |
(memcmp((o1)->data,(o2)->data,(int) (o1)->len) == 0)) |
u32 g_verify_token_header( |
struct xdr_netobj *mech, |
int *body_size, |
unsigned char **buf_in, |
int tok_type, |
int toksize); |
u32 g_get_mech_oid(struct xdr_netobj *mech, struct xdr_netobj * in_buf); |
int g_token_size( |
struct xdr_netobj *mech, |
unsigned int body_size); |
void g_make_token_header( |
struct xdr_netobj *mech, |
int body_size, |
unsigned char **buf, |
int tok_type); |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/gss_krb5.h |
---|
0,0 → 1,160 |
/* |
* linux/include/linux/sunrpc/gss_krb5_types.h |
* |
* Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h, |
* lib/gssapi/krb5/gssapiP_krb5.h, and others |
* |
* Copyright (c) 2000 The Regents of the University of Michigan. |
* All rights reserved. |
* |
* Andy Adamson <andros@umich.edu> |
* Bruce Fields <bfields@umich.edu> |
*/ |
/* |
* Copyright 1995 by the Massachusetts Institute of Technology. |
* All Rights Reserved. |
* |
* Export of this software from the United States of America may |
* require a specific license from the United States Government. |
* It is the responsibility of any person or organization contemplating |
* export to obtain such a license before exporting. |
* |
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and |
* distribute this software and its documentation for any purpose and |
* without fee is hereby granted, provided that the above copyright |
* notice appear in all copies and that both that copyright notice and |
* this permission notice appear in supporting documentation, and that |
* the name of M.I.T. not be used in advertising or publicity pertaining |
* to distribution of the software without specific, written prior |
* permission. Furthermore if you modify this software you must label |
* your software as modified software and not distribute it in such a |
* fashion that it might be confused with the original M.I.T. software. |
* M.I.T. makes no representations about the suitability of |
* this software for any purpose. It is provided "as is" without express |
* or implied warranty. |
* |
*/ |
#include <linux/sunrpc/auth_gss.h> |
#include <linux/sunrpc/gss_err.h> |
#include <linux/sunrpc/gss_asn1.h> |
struct krb5_ctx { |
int initiate; /* 1 = initiating, 0 = accepting */ |
int seed_init; |
unsigned char seed[16]; |
int signalg; |
int sealalg; |
struct crypto_tfm *enc; |
struct crypto_tfm *seq; |
s32 endtime; |
u32 seq_send; |
u32 seq_recv; |
struct xdr_netobj mech_used; |
}; |
#define KG_TOK_MIC_MSG 0x0101 |
#define KG_TOK_WRAP_MSG 0x0201 |
enum sgn_alg { |
SGN_ALG_DES_MAC_MD5 = 0x0000, |
SGN_ALG_MD2_5 = 0x0001, |
SGN_ALG_DES_MAC = 0x0002, |
SGN_ALG_3 = 0x0003, /* not published */ |
SGN_ALG_HMAC_MD5 = 0x0011, /* microsoft w2k; no support */ |
SGN_ALG_HMAC_SHA1_DES3_KD = 0x0004 |
}; |
enum seal_alg { |
SEAL_ALG_NONE = 0xffff, |
SEAL_ALG_DES = 0x0000, |
SEAL_ALG_1 = 0x0001, /* not published */ |
SEAL_ALG_MICROSOFT_RC4 = 0x0010,/* microsoft w2k; no support */ |
SEAL_ALG_DES3KD = 0x0002 |
}; |
#define RSA_MD5_CKSUM_LENGTH 16 |
#define CKSUMTYPE_CRC32 0x0001 |
#define CKSUMTYPE_RSA_MD4 0x0002 |
#define CKSUMTYPE_RSA_MD4_DES 0x0003 |
#define CKSUMTYPE_DESCBC 0x0004 |
#define CKSUMTYPE_RSA_MD5 0x0007 |
#define CKSUMTYPE_RSA_MD5_DES 0x0008 |
#define CKSUMTYPE_NIST_SHA 0x0009 |
#define CKSUMTYPE_HMAC_SHA1_DES3 0x000c |
/* from gssapi_err_krb5.h */ |
#define KG_CCACHE_NOMATCH (39756032L) |
#define KG_KEYTAB_NOMATCH (39756033L) |
#define KG_TGT_MISSING (39756034L) |
#define KG_NO_SUBKEY (39756035L) |
#define KG_CONTEXT_ESTABLISHED (39756036L) |
#define KG_BAD_SIGN_TYPE (39756037L) |
#define KG_BAD_LENGTH (39756038L) |
#define KG_CTX_INCOMPLETE (39756039L) |
#define KG_CONTEXT (39756040L) |
#define KG_CRED (39756041L) |
#define KG_ENC_DESC (39756042L) |
#define KG_BAD_SEQ (39756043L) |
#define KG_EMPTY_CCACHE (39756044L) |
#define KG_NO_CTYPES (39756045L) |
#define KV5M_PRINCIPAL (-1760647423L) |
#define KV5M_KEYBLOCK (-1760647421L) |
#define KV5M_CHECKSUM (-1760647420L) |
#define KV5M_ADDRESS (-1760647390L) |
#define KV5M_AUTHENTICATOR (-1760647410L) |
#define KV5M_AUTH_CONTEXT (-1760647383L) |
#define KV5M_AUTHDATA (-1760647414L) |
#define KV5M_GSS_OID (-1760647372L) |
#define KV5M_GSS_QUEUE (-1760647371L) |
/* per Kerberos v5 protocol spec crypto types from the wire. |
* these get mapped to linux kernel crypto routines. |
*/ |
#define ENCTYPE_NULL 0x0000 |
#define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */ |
#define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */ |
#define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */ |
#define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */ |
/* XXX deprecated? */ |
#define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */ |
#define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */ |
#define ENCTYPE_DES_HMAC_SHA1 0x0008 |
#define ENCTYPE_DES3_CBC_SHA1 0x0010 |
#define ENCTYPE_UNKNOWN 0x01ff |
s32 |
krb5_make_checksum(s32 cksumtype, |
struct xdr_netobj *input, |
struct xdr_netobj *cksum); |
u32 |
krb5_make_token(struct krb5_ctx *context_handle, int qop_req, |
struct xdr_netobj * input_message_buffer, |
struct xdr_netobj * output_message_buffer, int toktype); |
u32 |
krb5_read_token(struct krb5_ctx *context_handle, |
struct xdr_netobj *input_token_buffer, |
struct xdr_netobj *message_buffer, |
int *qop_state, int toktype); |
u32 |
krb5_encrypt(struct crypto_tfm * key, |
void *iv, void *in, void *out, int length); |
u32 |
krb5_decrypt(struct crypto_tfm * key, |
void *iv, void *in, void *out, int length); |
s32 |
krb5_make_seq_num(struct crypto_tfm * key, |
int direction, |
s32 seqnum, unsigned char *cksum, unsigned char *buf); |
s32 |
krb5_get_seq_num(struct crypto_tfm * key, |
unsigned char *cksum, |
unsigned char *buf, int *direction, s32 * seqnum); |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/timer.h |
---|
0,0 → 1,40 |
/* |
* linux/include/linux/sunrpc/timer.h |
* |
* Declarations for the RPC transport timer. |
* |
* Copyright (C) 2002 Trond Myklebust <trond.myklebust@fys.uio.no> |
*/ |
#ifndef _LINUX_SUNRPC_TIMER_H |
#define _LINUX_SUNRPC_TIMER_H |
#include <asm/atomic.h> |
struct rpc_rtt { |
unsigned long timeo; /* default timeout value */ |
unsigned long srtt[5]; /* smoothed round trip time << 3 */ |
unsigned long sdrtt[5]; /* smoothed medium deviation of RTT */ |
int ntimeouts[5]; /* Number of timeouts for the last request */ |
}; |
extern void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo); |
extern void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m); |
extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned timer); |
static inline void rpc_set_timeo(struct rpc_rtt *rt, int timer, int ntimeo) |
{ |
if (!timer) |
return; |
rt->ntimeouts[timer-1] = ntimeo; |
} |
static inline int rpc_ntimeo(struct rpc_rtt *rt, int timer) |
{ |
if (!timer) |
return 0; |
return rt->ntimeouts[timer-1]; |
} |
#endif /* _LINUX_SUNRPC_TIMER_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/gss_api.h |
---|
0,0 → 1,132 |
/* |
* linux/include/linux/gss_api.h |
* |
* Somewhat simplified version of the gss api. |
* |
* Dug Song <dugsong@monkey.org> |
* Andy Adamson <andros@umich.edu> |
* Bruce Fields <bfields@umich.edu> |
* Copyright (c) 2000 The Regents of the University of Michigan |
* |
* $Id: gss_api.h,v 1.1 2004-01-28 15:31:11 giacomo Exp $ |
*/ |
#ifndef _LINUX_SUNRPC_GSS_API_H |
#define _LINUX_SUNRPC_GSS_API_H |
#ifdef __KERNEL__ |
#include <linux/sunrpc/xdr.h> |
/* The mechanism-independent gss-api context: */ |
struct gss_ctx { |
struct gss_api_mech *mech_type; |
void *internal_ctx_id; |
}; |
#define GSS_C_NO_BUFFER ((struct xdr_netobj) 0) |
#define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0) |
#define GSS_C_NULL_OID ((struct xdr_netobj) 0) |
/*XXX arbitrary length - is this set somewhere? */ |
#define GSS_OID_MAX_LEN 32 |
/* gss-api prototypes; note that these are somewhat simplified versions of |
* the prototypes specified in RFC 2744. */ |
u32 gss_import_sec_context( |
struct xdr_netobj *input_token, |
struct gss_api_mech *mech, |
struct gss_ctx **ctx_id); |
u32 gss_get_mic( |
struct gss_ctx *ctx_id, |
u32 qop, |
struct xdr_netobj *message, |
struct xdr_netobj *mic_token); |
u32 gss_verify_mic( |
struct gss_ctx *ctx_id, |
struct xdr_netobj *message, |
struct xdr_netobj *mic_token, |
u32 *qstate); |
u32 gss_delete_sec_context( |
struct gss_ctx **ctx_id); |
/* We maintain a list of the pseudoflavors (equivalently, mechanism-qop-service |
* triples) that we currently support: */ |
struct sup_sec_triple { |
struct list_head triples; |
u32 pseudoflavor; |
struct gss_api_mech *mech; |
u32 qop; |
u32 service; |
}; |
int gss_register_triple(u32 pseudoflavor, struct gss_api_mech *mech, u32 qop, |
u32 service); |
int gss_unregister_triple(u32 pseudoflavor); |
int gss_pseudoflavor_supported(u32 pseudoflavor); |
u32 gss_cmp_triples(u32 oid_len, char *oid_data, u32 qop, u32 service); |
u32 gss_get_pseudoflavor(struct gss_ctx *ctx_id, u32 qop, u32 service); |
u32 gss_pseudoflavor_to_service(u32 pseudoflavor); |
/* Both return NULL on failure: */ |
struct gss_api_mech * gss_pseudoflavor_to_mech(u32 pseudoflavor); |
int gss_pseudoflavor_to_mechOID(u32 pseudoflavor, struct xdr_netobj *mech); |
/* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and |
* mechanisms may be dynamically registered or unregistered by modules. |
* Our only built-in mechanism is a trivial debugging mechanism that provides |
* no actual security; the following function registers that mechanism: */ |
void gss_mech_register_debug(void); |
/* Each mechanism is described by the following struct: */ |
struct gss_api_mech { |
struct xdr_netobj gm_oid; |
struct list_head gm_list; |
atomic_t gm_count; |
struct gss_api_ops *gm_ops; |
}; |
/* and must provide the following operations: */ |
struct gss_api_ops { |
char *name; |
u32 (*gss_import_sec_context)( |
struct xdr_netobj *input_token, |
struct gss_ctx *ctx_id); |
u32 (*gss_get_mic)( |
struct gss_ctx *ctx_id, |
u32 qop, |
struct xdr_netobj *message, |
struct xdr_netobj *mic_token); |
u32 (*gss_verify_mic)( |
struct gss_ctx *ctx_id, |
struct xdr_netobj *message, |
struct xdr_netobj *mic_token, |
u32 *qstate); |
void (*gss_delete_sec_context)( |
void *internal_ctx_id); |
}; |
/* Returns nonzero on failure. */ |
int gss_mech_register(struct xdr_netobj *, struct gss_api_ops *); |
/* Returns nonzero iff someone still has a reference to this mech. */ |
int gss_mech_unregister(struct gss_api_mech *); |
/* Returns nonzer iff someone still has a reference to some mech. */ |
int gss_mech_unregister_all(void); |
/* returns a mechanism descriptor given an OID, an increments the mechanism's |
* reference count. */ |
struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *); |
/* Just increments the mechanism's reference count and returns its input: */ |
struct gss_api_mech * gss_mech_get(struct gss_api_mech *); |
/* Returns nonzero iff you've released the last reference to this mech. |
* Note that for every succesful gss_get_mech call there must be exactly |
* one corresponding call to gss_mech_put.*/ |
int gss_mech_put(struct gss_api_mech *); |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_SUNRPC_GSS_API_H */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/debug.h |
---|
0,0 → 1,97 |
/* |
* linux/include/linux/sunrpc/debug.h |
* |
* Debugging support for sunrpc module |
* |
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_DEBUG_H_ |
#define _LINUX_SUNRPC_DEBUG_H_ |
#include <linux/config.h> |
#include <linux/timer.h> |
#include <linux/workqueue.h> |
/* |
* Enable RPC debugging/profiling. |
*/ |
#ifdef CONFIG_SYSCTL |
#define RPC_DEBUG |
#endif |
/* #define RPC_PROFILE */ |
/* |
* RPC debug facilities |
*/ |
#define RPCDBG_XPRT 0x0001 |
#define RPCDBG_CALL 0x0002 |
#define RPCDBG_DEBUG 0x0004 |
#define RPCDBG_NFS 0x0008 |
#define RPCDBG_AUTH 0x0010 |
#define RPCDBG_PMAP 0x0020 |
#define RPCDBG_SCHED 0x0040 |
#define RPCDBG_SVCSOCK 0x0100 |
#define RPCDBG_SVCDSP 0x0200 |
#define RPCDBG_MISC 0x0400 |
#define RPCDBG_CACHE 0x0800 |
#define RPCDBG_ALL 0x7fff |
#ifdef __KERNEL__ |
/* |
* Debugging macros etc |
*/ |
#ifdef RPC_DEBUG |
extern unsigned int rpc_debug; |
extern unsigned int nfs_debug; |
extern unsigned int nfsd_debug; |
extern unsigned int nlm_debug; |
#endif |
#define dprintk(args...) dfprintk(FACILITY, ## args) |
#undef ifdebug |
#ifdef RPC_DEBUG |
# define ifdebug(fac) if (rpc_debug & RPCDBG_##fac) |
# define dfprintk(fac, args...) do { ifdebug(fac) printk(args); } while(0) |
# define RPC_IFDEBUG(x) x |
#else |
# define ifdebug(fac) if (0) |
# define dfprintk(fac, args...) do ; while (0) |
# define RPC_IFDEBUG(x) |
#endif |
#ifdef RPC_PROFILE |
# define pprintk(args...) printk(## args) |
#else |
# define pprintk(args...) do ; while (0) |
#endif |
/* |
* Sysctl interface for RPC debugging |
*/ |
#ifdef RPC_DEBUG |
void rpc_register_sysctl(void); |
void rpc_unregister_sysctl(void); |
#endif |
#endif /* __KERNEL__ */ |
/* |
* Declarations for the sysctl debug interface, which allows to read or |
* change the debug flags for rpc, nfs, nfsd, and lockd. Since the sunrpc |
* module currently registers its sysctl table dynamically, the sysctl path |
* for module FOO is <CTL_SUNRPC, CTL_FOODEBUG>. |
*/ |
#define CTL_SUNRPC 7249 /* arbitrary and hopefully unused */ |
enum { |
CTL_RPCDEBUG = 1, |
CTL_NFSDEBUG, |
CTL_NFSDDEBUG, |
CTL_NLMDEBUG, |
}; |
#endif /* _LINUX_SUNRPC_DEBUG_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/sunrpc/sched.h |
---|
0,0 → 1,212 |
/* |
* linux/include/linux/sunrpc/sched.h |
* |
* Scheduling primitives for kernel Sun RPC. |
* |
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_SUNRPC_SCHED_H_ |
#define _LINUX_SUNRPC_SCHED_H_ |
#include <linux/timer.h> |
#include <linux/sunrpc/types.h> |
#include <linux/wait.h> |
#include <linux/sunrpc/xdr.h> |
/* |
* This is the actual RPC procedure call info. |
*/ |
struct rpc_procinfo; |
struct rpc_message { |
struct rpc_procinfo * rpc_proc; /* Procedure information */ |
void * rpc_argp; /* Arguments */ |
void * rpc_resp; /* Result */ |
struct rpc_cred * rpc_cred; /* Credentials */ |
}; |
/* |
* This is the RPC task struct |
*/ |
struct rpc_task { |
struct list_head tk_list; /* wait queue links */ |
#ifdef RPC_DEBUG |
unsigned long tk_magic; /* 0xf00baa */ |
#endif |
struct list_head tk_task; /* global list of tasks */ |
struct rpc_clnt * tk_client; /* RPC client */ |
struct rpc_rqst * tk_rqstp; /* RPC request */ |
int tk_status; /* result of last operation */ |
struct rpc_wait_queue * tk_rpcwait; /* RPC wait queue we're on */ |
/* |
* RPC call state |
*/ |
struct rpc_message tk_msg; /* RPC call info */ |
__u32 * tk_buffer; /* XDR buffer */ |
size_t tk_bufsize; |
__u8 tk_garb_retry, |
tk_cred_retry, |
tk_suid_retry; |
u32 tk_gss_seqno; /* rpcsec_gss sequence number |
used on this request */ |
/* |
* timeout_fn to be executed by timer bottom half |
* callback to be executed after waking up |
* action next procedure for async tasks |
* exit exit async task and report to caller |
*/ |
void (*tk_timeout_fn)(struct rpc_task *); |
void (*tk_callback)(struct rpc_task *); |
void (*tk_action)(struct rpc_task *); |
void (*tk_exit)(struct rpc_task *); |
void (*tk_release)(struct rpc_task *); |
void * tk_calldata; |
/* |
* tk_timer is used for async processing by the RPC scheduling |
* primitives. You should not access this directly unless |
* you have a pathological interest in kernel oopses. |
*/ |
struct timer_list tk_timer; /* kernel timer */ |
wait_queue_head_t tk_wait; /* sync: sleep on this q */ |
unsigned long tk_timeout; /* timeout for rpc_sleep() */ |
unsigned short tk_flags; /* misc flags */ |
unsigned char tk_active : 1;/* Task has been activated */ |
unsigned long tk_runstate; /* Task run status */ |
#ifdef RPC_DEBUG |
unsigned short tk_pid; /* debugging aid */ |
#endif |
}; |
#define tk_auth tk_client->cl_auth |
#define tk_xprt tk_client->cl_xprt |
/* support walking a list of tasks on a wait queue */ |
#define task_for_each(task, pos, head) \ |
list_for_each(pos, head) \ |
if ((task=list_entry(pos, struct rpc_task, tk_list)),1) |
#define task_for_first(task, head) \ |
if (!list_empty(head) && \ |
((task=list_entry((head)->next, struct rpc_task, tk_list)),1)) |
/* .. and walking list of all tasks */ |
#define alltask_for_each(task, pos, head) \ |
list_for_each(pos, head) \ |
if ((task=list_entry(pos, struct rpc_task, tk_task)),1) |
typedef void (*rpc_action)(struct rpc_task *); |
/* |
* RPC task flags |
*/ |
#define RPC_TASK_ASYNC 0x0001 /* is an async task */ |
#define RPC_TASK_SWAPPER 0x0002 /* is swapping in/out */ |
#define RPC_TASK_SETUID 0x0004 /* is setuid process */ |
#define RPC_TASK_CHILD 0x0008 /* is child of other task */ |
#define RPC_CALL_REALUID 0x0010 /* try using real uid */ |
#define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */ |
#define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */ |
#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ |
#define RPC_TASK_KILLED 0x0100 /* task was killed */ |
#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) |
#define RPC_IS_SETUID(t) ((t)->tk_flags & RPC_TASK_SETUID) |
#define RPC_IS_CHILD(t) ((t)->tk_flags & RPC_TASK_CHILD) |
#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) |
#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) |
#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) |
#define RPC_IS_ACTIVATED(t) ((t)->tk_active) |
#define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL) |
#define RPC_TASK_SLEEPING 0 |
#define RPC_TASK_RUNNING 1 |
#define RPC_IS_SLEEPING(t) (test_bit(RPC_TASK_SLEEPING, &(t)->tk_runstate)) |
#define RPC_IS_RUNNING(t) (test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) |
#define rpc_set_running(t) (set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) |
#define rpc_clear_running(t) (clear_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) |
#define rpc_set_sleeping(t) (set_bit(RPC_TASK_SLEEPING, &(t)->tk_runstate)) |
#define rpc_clear_sleeping(t) \ |
do { \ |
smp_mb__before_clear_bit(); \ |
clear_bit(RPC_TASK_SLEEPING, &(t)->tk_runstate); \ |
smp_mb__after_clear_bit(); \ |
} while(0) |
/* |
* RPC synchronization objects |
*/ |
struct rpc_wait_queue { |
struct list_head tasks; |
#ifdef RPC_DEBUG |
char * name; |
#endif |
}; |
#ifndef RPC_DEBUG |
# define RPC_WAITQ_INIT(var,qname) ((struct rpc_wait_queue) {LIST_HEAD_INIT(var)}) |
# define RPC_WAITQ(var,qname) struct rpc_wait_queue var = RPC_WAITQ_INIT(var.tasks,qname) |
# define INIT_RPC_WAITQ(ptr,qname) do { \ |
INIT_LIST_HEAD(&(ptr)->tasks); \ |
} while(0) |
#else |
# define RPC_WAITQ_INIT(var,qname) ((struct rpc_wait_queue) {LIST_HEAD_INIT(var.tasks), qname}) |
# define RPC_WAITQ(var,qname) struct rpc_wait_queue var = RPC_WAITQ_INIT(var,qname) |
# define INIT_RPC_WAITQ(ptr,qname) do { \ |
INIT_LIST_HEAD(&(ptr)->tasks); (ptr)->name = qname; \ |
} while(0) |
#endif |
/* |
* Function prototypes |
*/ |
struct rpc_task *rpc_new_task(struct rpc_clnt *, rpc_action, int flags); |
struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent); |
void rpc_init_task(struct rpc_task *, struct rpc_clnt *, |
rpc_action exitfunc, int flags); |
void rpc_release_task(struct rpc_task *); |
void rpc_killall_tasks(struct rpc_clnt *); |
int rpc_execute(struct rpc_task *); |
void rpc_run_child(struct rpc_task *parent, struct rpc_task *child, |
rpc_action action); |
int rpc_add_wait_queue(struct rpc_wait_queue *, struct rpc_task *); |
void rpc_remove_wait_queue(struct rpc_task *); |
void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *, |
rpc_action action, rpc_action timer); |
void rpc_add_timer(struct rpc_task *, rpc_action); |
void rpc_wake_up_task(struct rpc_task *); |
void rpc_wake_up(struct rpc_wait_queue *); |
struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *); |
void rpc_wake_up_status(struct rpc_wait_queue *, int); |
void rpc_delay(struct rpc_task *, unsigned long); |
void * rpc_malloc(struct rpc_task *, size_t); |
void rpc_free(struct rpc_task *); |
int rpciod_up(void); |
void rpciod_down(void); |
void rpciod_wake_up(void); |
#ifdef RPC_DEBUG |
void rpc_show_tasks(void); |
#endif |
int rpc_init_mempool(void); |
void rpc_destroy_mempool(void); |
static __inline__ void |
rpc_exit(struct rpc_task *task, int status) |
{ |
task->tk_status = status; |
task->tk_action = NULL; |
} |
#ifdef RPC_DEBUG |
static __inline__ char * |
rpc_qname(struct rpc_wait_queue *q) |
{ |
return q->name? q->name : "unknown"; |
} |
#endif |
#endif /* _LINUX_SUNRPC_SCHED_H_ */ |
/shark/trunk/drivers/linuxc26/include/linux/raid/linear.h |
---|
0,0 → 1,32 |
#ifndef _LINEAR_H |
#define _LINEAR_H |
#include <linux/raid/md.h> |
struct dev_info { |
mdk_rdev_t *rdev; |
unsigned long size; |
unsigned long offset; |
}; |
typedef struct dev_info dev_info_t; |
struct linear_hash |
{ |
dev_info_t *dev0, *dev1; |
}; |
struct linear_private_data |
{ |
struct linear_hash *hash_table; |
dev_info_t *smallest; |
int nr_zones; |
dev_info_t disks[0]; |
}; |
typedef struct linear_private_data linear_conf_t; |
#define mddev_to_conf(mddev) ((linear_conf_t *) mddev->private) |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/md_k.h |
---|
0,0 → 1,368 |
/* |
md_k.h : kernel internal structure of the Linux MD driver |
Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2, or (at your option) |
any later version. |
You should have received a copy of the GNU General Public License |
(for example /usr/src/linux/COPYING); if not, write to the Free |
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef _MD_K_H |
#define _MD_K_H |
#define MD_RESERVED 0UL |
#define LINEAR 1UL |
#define RAID0 2UL |
#define RAID1 3UL |
#define RAID5 4UL |
#define TRANSLUCENT 5UL |
#define HSM 6UL |
#define MULTIPATH 7UL |
#define MAX_PERSONALITY 8UL |
#define LEVEL_MULTIPATH (-4) |
#define LEVEL_LINEAR (-1) |
#define MaxSector (~(sector_t)0) |
#define MD_THREAD_NAME_MAX 14 |
static inline int pers_to_level (int pers) |
{ |
switch (pers) { |
case MULTIPATH: return LEVEL_MULTIPATH; |
case HSM: return -3; |
case TRANSLUCENT: return -2; |
case LINEAR: return LEVEL_LINEAR; |
case RAID0: return 0; |
case RAID1: return 1; |
case RAID5: return 5; |
} |
BUG(); |
return MD_RESERVED; |
} |
static inline int level_to_pers (int level) |
{ |
switch (level) { |
case LEVEL_MULTIPATH: return MULTIPATH; |
case -3: return HSM; |
case -2: return TRANSLUCENT; |
case LEVEL_LINEAR: return LINEAR; |
case 0: return RAID0; |
case 1: return RAID1; |
case 4: |
case 5: return RAID5; |
} |
return MD_RESERVED; |
} |
typedef struct mddev_s mddev_t; |
typedef struct mdk_rdev_s mdk_rdev_t; |
#define MAX_MD_DEVS 256 /* Max number of md dev */ |
/* |
* options passed in raidrun: |
*/ |
#define MAX_CHUNK_SIZE (4096*1024) |
/* |
* default readahead |
*/ |
static inline int disk_faulty(mdp_disk_t * d) |
{ |
return d->state & (1 << MD_DISK_FAULTY); |
} |
static inline int disk_active(mdp_disk_t * d) |
{ |
return d->state & (1 << MD_DISK_ACTIVE); |
} |
static inline int disk_sync(mdp_disk_t * d) |
{ |
return d->state & (1 << MD_DISK_SYNC); |
} |
static inline int disk_spare(mdp_disk_t * d) |
{ |
return !disk_sync(d) && !disk_active(d) && !disk_faulty(d); |
} |
static inline int disk_removed(mdp_disk_t * d) |
{ |
return d->state & (1 << MD_DISK_REMOVED); |
} |
static inline void mark_disk_faulty(mdp_disk_t * d) |
{ |
d->state |= (1 << MD_DISK_FAULTY); |
} |
static inline void mark_disk_active(mdp_disk_t * d) |
{ |
d->state |= (1 << MD_DISK_ACTIVE); |
} |
static inline void mark_disk_sync(mdp_disk_t * d) |
{ |
d->state |= (1 << MD_DISK_SYNC); |
} |
static inline void mark_disk_spare(mdp_disk_t * d) |
{ |
d->state = 0; |
} |
static inline void mark_disk_removed(mdp_disk_t * d) |
{ |
d->state = (1 << MD_DISK_FAULTY) | (1 << MD_DISK_REMOVED); |
} |
static inline void mark_disk_inactive(mdp_disk_t * d) |
{ |
d->state &= ~(1 << MD_DISK_ACTIVE); |
} |
static inline void mark_disk_nonsync(mdp_disk_t * d) |
{ |
d->state &= ~(1 << MD_DISK_SYNC); |
} |
/* |
* MD's 'extended' device |
*/ |
struct mdk_rdev_s |
{ |
struct list_head same_set; /* RAID devices within the same set */ |
sector_t size; /* Device size (in blocks) */ |
mddev_t *mddev; /* RAID array if running */ |
unsigned long last_events; /* IO event timestamp */ |
struct block_device *bdev; /* block device handle */ |
struct page *sb_page; |
int sb_loaded; |
sector_t data_offset; /* start of data in array */ |
sector_t sb_offset; |
int preferred_minor; /* autorun support */ |
/* A device can be in one of three states based on two flags: |
* Not working: faulty==1 in_sync==0 |
* Fully working: faulty==0 in_sync==1 |
* Working, but not |
* in sync with array |
* faulty==0 in_sync==0 |
* |
* It can never have faulty==1, in_sync==1 |
* This reduces the burden of testing multiple flags in many cases |
*/ |
int faulty; /* if faulty do not issue IO requests */ |
int in_sync; /* device is a full member of the array */ |
int desc_nr; /* descriptor index in the superblock */ |
int raid_disk; /* role of device in array */ |
atomic_t nr_pending; /* number of pending requests. |
* only maintained for arrays that |
* support hot removal |
*/ |
}; |
typedef struct mdk_personality_s mdk_personality_t; |
struct mddev_s |
{ |
void *private; |
mdk_personality_t *pers; |
int __minor; |
struct list_head disks; |
int sb_dirty; |
int ro; |
/* Superblock information */ |
int major_version, |
minor_version, |
patch_version; |
int persistent; |
int chunk_size; |
time_t ctime, utime; |
int level, layout; |
int raid_disks; |
int max_disks; |
sector_t size; /* used size of component devices */ |
sector_t array_size; /* exported array size */ |
__u64 events; |
char uuid[16]; |
struct mdk_thread_s *thread; /* management thread */ |
struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ |
unsigned long curr_resync; /* blocks scheduled */ |
unsigned long resync_mark; /* a recent timestamp */ |
unsigned long resync_mark_cnt;/* blocks written at resync_mark */ |
/* recovery/resync flags |
* NEEDED: we might need to start a resync/recover |
* RUNNING: a thread is running, or about to be started |
* SYNC: actually doing a resync, not a recovery |
* ERR: and IO error was detected - abort the resync/recovery |
* INTR: someone requested a (clean) early abort. |
* DONE: thread is done and is waiting to be reaped |
*/ |
#define MD_RECOVERY_RUNNING 0 |
#define MD_RECOVERY_SYNC 1 |
#define MD_RECOVERY_ERR 2 |
#define MD_RECOVERY_INTR 3 |
#define MD_RECOVERY_DONE 4 |
#define MD_RECOVERY_NEEDED 5 |
unsigned long recovery; |
int in_sync; /* know to not need resync */ |
struct semaphore reconfig_sem; |
atomic_t active; |
int degraded; /* whether md should consider |
* adding a spare |
*/ |
atomic_t recovery_active; /* blocks scheduled, but not written */ |
wait_queue_head_t recovery_wait; |
sector_t recovery_cp; |
unsigned int safemode; /* if set, update "clean" superblock |
* when no writes pending. |
*/ |
unsigned int safemode_delay; |
struct timer_list safemode_timer; |
atomic_t writes_pending; |
request_queue_t *queue; /* for plugging ... */ |
struct list_head all_mddevs; |
}; |
struct mdk_personality_s |
{ |
char *name; |
struct module *owner; |
int (*make_request)(request_queue_t *q, struct bio *bio); |
int (*run)(mddev_t *mddev); |
int (*stop)(mddev_t *mddev); |
void (*status)(struct seq_file *seq, mddev_t *mddev); |
/* error_handler must set ->faulty and clear ->in_sync |
* if appropriate, and should abort recovery if needed |
*/ |
void (*error_handler)(mddev_t *mddev, mdk_rdev_t *rdev); |
int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev); |
int (*hot_remove_disk) (mddev_t *mddev, int number); |
int (*spare_active) (mddev_t *mddev); |
int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster); |
}; |
/* |
* Currently we index md_array directly, based on the minor |
* number. This will have to change to dynamic allocation |
* once we start supporting partitioning of md devices. |
*/ |
static inline int mdidx (mddev_t * mddev) |
{ |
return mddev->__minor; |
} |
extern mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr); |
/* |
* iterates through some rdev ringlist. It's safe to remove the |
* current 'rdev'. Dont touch 'tmp' though. |
*/ |
#define ITERATE_RDEV_GENERIC(head,rdev,tmp) \ |
\ |
for ((tmp) = (head).next; \ |
(rdev) = (list_entry((tmp), mdk_rdev_t, same_set)), \ |
(tmp) = (tmp)->next, (tmp)->prev != &(head) \ |
; ) |
/* |
* iterates through the 'same array disks' ringlist |
*/ |
#define ITERATE_RDEV(mddev,rdev,tmp) \ |
ITERATE_RDEV_GENERIC((mddev)->disks,rdev,tmp) |
/* |
* Iterates through 'pending RAID disks' |
*/ |
#define ITERATE_RDEV_PENDING(rdev,tmp) \ |
ITERATE_RDEV_GENERIC(pending_raid_disks,rdev,tmp) |
typedef struct mdk_thread_s { |
void (*run) (mddev_t *mddev); |
mddev_t *mddev; |
wait_queue_head_t wqueue; |
unsigned long flags; |
struct completion *event; |
struct task_struct *tsk; |
const char *name; |
} mdk_thread_t; |
#define THREAD_WAKEUP 0 |
#define __wait_event_lock_irq(wq, condition, lock) \ |
do { \ |
wait_queue_t __wait; \ |
init_waitqueue_entry(&__wait, current); \ |
\ |
add_wait_queue(&wq, &__wait); \ |
for (;;) { \ |
set_current_state(TASK_UNINTERRUPTIBLE); \ |
if (condition) \ |
break; \ |
spin_unlock_irq(&lock); \ |
blk_run_queues(); \ |
schedule(); \ |
spin_lock_irq(&lock); \ |
} \ |
current->state = TASK_RUNNING; \ |
remove_wait_queue(&wq, &__wait); \ |
} while (0) |
#define wait_event_lock_irq(wq, condition, lock) \ |
do { \ |
if (condition) \ |
break; \ |
__wait_event_lock_irq(wq, condition, lock); \ |
} while (0) |
#define __wait_disk_event(wq, condition) \ |
do { \ |
wait_queue_t __wait; \ |
init_waitqueue_entry(&__wait, current); \ |
\ |
add_wait_queue(&wq, &__wait); \ |
for (;;) { \ |
set_current_state(TASK_UNINTERRUPTIBLE); \ |
if (condition) \ |
break; \ |
blk_run_queues(); \ |
schedule(); \ |
} \ |
current->state = TASK_RUNNING; \ |
remove_wait_queue(&wq, &__wait); \ |
} while (0) |
#define wait_disk_event(wq, condition) \ |
do { \ |
if (condition) \ |
break; \ |
__wait_disk_event(wq, condition); \ |
} while (0) |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/md_p.h |
---|
0,0 → 1,230 |
/* |
md_p.h : physical layout of Linux RAID devices |
Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2, or (at your option) |
any later version. |
You should have received a copy of the GNU General Public License |
(for example /usr/src/linux/COPYING); if not, write to the Free |
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef _MD_P_H |
#define _MD_P_H |
/* |
* RAID superblock. |
* |
* The RAID superblock maintains some statistics on each RAID configuration. |
* Each real device in the RAID set contains it near the end of the device. |
* Some of the ideas are copied from the ext2fs implementation. |
* |
* We currently use 4096 bytes as follows: |
* |
* word offset function |
* |
* 0 - 31 Constant generic RAID device information. |
* 32 - 63 Generic state information. |
* 64 - 127 Personality specific information. |
* 128 - 511 12 32-words descriptors of the disks in the raid set. |
* 512 - 911 Reserved. |
* 912 - 1023 Disk specific descriptor. |
*/ |
/* |
* If x is the real device size in bytes, we return an apparent size of: |
* |
* y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES |
* |
* and place the 4kB superblock at offset y. |
*/ |
#define MD_RESERVED_BYTES (64 * 1024) |
#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512) |
#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE) |
#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS) |
#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS) |
#define MD_SB_BYTES 4096 |
#define MD_SB_WORDS (MD_SB_BYTES / 4) |
#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE) |
#define MD_SB_SECTORS (MD_SB_BYTES / 512) |
/* |
* The following are counted in 32-bit words |
*/ |
#define MD_SB_GENERIC_OFFSET 0 |
#define MD_SB_PERSONALITY_OFFSET 64 |
#define MD_SB_DISKS_OFFSET 128 |
#define MD_SB_DESCRIPTOR_OFFSET 992 |
#define MD_SB_GENERIC_CONSTANT_WORDS 32 |
#define MD_SB_GENERIC_STATE_WORDS 32 |
#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS) |
#define MD_SB_PERSONALITY_WORDS 64 |
#define MD_SB_DESCRIPTOR_WORDS 32 |
#define MD_SB_DISKS 27 |
#define MD_SB_DISKS_WORDS (MD_SB_DISKS*MD_SB_DESCRIPTOR_WORDS) |
#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS) |
#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS) |
/* |
* Device "operational" state bits |
*/ |
#define MD_DISK_FAULTY 0 /* disk is faulty / operational */ |
#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */ |
#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */ |
#define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */ |
typedef struct mdp_device_descriptor_s { |
__u32 number; /* 0 Device number in the entire set */ |
__u32 major; /* 1 Device major number */ |
__u32 minor; /* 2 Device minor number */ |
__u32 raid_disk; /* 3 The role of the device in the raid set */ |
__u32 state; /* 4 Operational state */ |
__u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5]; |
} mdp_disk_t; |
#define MD_SB_MAGIC 0xa92b4efc |
/* |
* Superblock state bits |
*/ |
#define MD_SB_CLEAN 0 |
#define MD_SB_ERRORS 1 |
typedef struct mdp_superblock_s { |
/* |
* Constant generic information |
*/ |
__u32 md_magic; /* 0 MD identifier */ |
__u32 major_version; /* 1 major version to which the set conforms */ |
__u32 minor_version; /* 2 minor version ... */ |
__u32 patch_version; /* 3 patchlevel version ... */ |
__u32 gvalid_words; /* 4 Number of used words in this section */ |
__u32 set_uuid0; /* 5 Raid set identifier */ |
__u32 ctime; /* 6 Creation time */ |
__u32 level; /* 7 Raid personality */ |
__u32 size; /* 8 Apparent size of each individual disk */ |
__u32 nr_disks; /* 9 total disks in the raid set */ |
__u32 raid_disks; /* 10 disks in a fully functional raid set */ |
__u32 md_minor; /* 11 preferred MD minor device number */ |
__u32 not_persistent; /* 12 does it have a persistent superblock */ |
__u32 set_uuid1; /* 13 Raid set identifier #2 */ |
__u32 set_uuid2; /* 14 Raid set identifier #3 */ |
__u32 set_uuid3; /* 15 Raid set identifier #4 */ |
__u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16]; |
/* |
* Generic state information |
*/ |
__u32 utime; /* 0 Superblock update time */ |
__u32 state; /* 1 State bits (clean, ...) */ |
__u32 active_disks; /* 2 Number of currently active disks */ |
__u32 working_disks; /* 3 Number of working disks */ |
__u32 failed_disks; /* 4 Number of failed disks */ |
__u32 spare_disks; /* 5 Number of spare disks */ |
__u32 sb_csum; /* 6 checksum of the whole superblock */ |
#ifdef __BIG_ENDIAN |
__u32 events_hi; /* 7 high-order of superblock update count */ |
__u32 events_lo; /* 8 low-order of superblock update count */ |
__u32 cp_events_hi; /* 9 high-order of checkpoint update count */ |
__u32 cp_events_lo; /* 10 low-order of checkpoint update count */ |
#else |
__u32 events_lo; /* 7 low-order of superblock update count */ |
__u32 events_hi; /* 8 high-order of superblock update count */ |
__u32 cp_events_lo; /* 9 low-order of checkpoint update count */ |
__u32 cp_events_hi; /* 10 high-order of checkpoint update count */ |
#endif |
__u32 recovery_cp; /* 11 recovery checkpoint sector count */ |
__u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 12]; |
/* |
* Personality information |
*/ |
__u32 layout; /* 0 the array's physical layout */ |
__u32 chunk_size; /* 1 chunk size in bytes */ |
__u32 root_pv; /* 2 LV root PV */ |
__u32 root_block; /* 3 LV root block */ |
__u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4]; |
/* |
* Disks information |
*/ |
mdp_disk_t disks[MD_SB_DISKS]; |
/* |
* Reserved |
*/ |
__u32 reserved[MD_SB_RESERVED_WORDS]; |
/* |
* Active descriptor |
*/ |
mdp_disk_t this_disk; |
} mdp_super_t; |
static inline __u64 md_event(mdp_super_t *sb) { |
__u64 ev = sb->events_hi; |
return (ev<<32)| sb->events_lo; |
} |
/* |
* The version-1 superblock : |
* All numeric fields are little-endian. |
* |
* total size: 256 bytes plus 2 per device. |
* 1K allows 384 devices. |
*/ |
struct mdp_superblock_1 { |
/* constant array information - 128 bytes */ |
__u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ |
__u32 major_version; /* 1 */ |
__u32 feature_map; /* 0 for now */ |
__u32 pad0; /* always set to 0 when writing */ |
__u8 set_uuid[16]; /* user-space generated. */ |
char set_name[32]; /* set and interpreted by user-space */ |
__u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ |
__u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ |
__u32 layout; /* only for raid5 currently */ |
__u64 size; /* used size of component devices, in 512byte sectors */ |
__u32 chunksize; /* in 512byte sectors */ |
__u32 raid_disks; |
__u8 pad1[128-92]; /* set to 0 when written */ |
/* constant this-device information - 64 bytes */ |
__u64 data_offset; /* sector start of data, often 0 */ |
__u64 data_size; /* sectors in this device that can be used for data */ |
__u64 super_offset; /* sector start of this superblock */ |
__u64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */ |
__u32 dev_number; /* permanent identifier of this device - not role in raid */ |
__u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ |
__u8 device_uuid[16]; /* user-space setable, ignored by kernel */ |
__u8 pad2[64-56]; /* set to 0 when writing */ |
/* array state information - 64 bytes */ |
__u64 utime; /* 40 bits second, 24 btes microseconds */ |
__u64 events; /* incremented when superblock updated */ |
__u64 resync_offset; /* data before this offset (from data_offset) known to be in sync */ |
__u32 sb_csum; /* checksum upto devs[max_dev] */ |
__u32 max_dev; /* size of devs[] array to consider */ |
__u8 pad3[64-40]; /* set to 0 when writing */ |
/* device state information. Indexed by dev_number. |
* 2 bytes per device |
* Note there are no per-device state flags. State information is rolled |
* into the 'roles' value. If a device is spare or faulty, then it doesn't |
* have a meaningful role. |
*/ |
__u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/raid0.h |
---|
0,0 → 1,30 |
#ifndef _RAID0_H |
#define _RAID0_H |
#include <linux/raid/md.h> |
struct strip_zone |
{ |
sector_t zone_offset; /* Zone offset in md_dev */ |
sector_t dev_offset; /* Zone offset in real dev */ |
sector_t size; /* Zone size */ |
int nb_dev; /* # of devices attached to the zone */ |
mdk_rdev_t **dev; /* Devices attached to the zone */ |
}; |
struct raid0_private_data |
{ |
struct strip_zone **hash_table; /* Table of indexes into strip_zone */ |
struct strip_zone *strip_zone; |
mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */ |
int nr_strip_zones; |
sector_t hash_spacing; |
int preshift; /* shift this before divide by hash_spacing */ |
}; |
typedef struct raid0_private_data raid0_conf_t; |
#define mddev_to_conf(mddev) ((raid0_conf_t *) mddev->private) |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/md.h |
---|
0,0 → 1,85 |
/* |
md.h : Multiple Devices driver for Linux |
Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman |
Copyright (C) 1994-96 Marc ZYNGIER |
<zyngier@ufr-info-p7.ibp.fr> or |
<maz@gloups.fdn.fr> |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2, or (at your option) |
any later version. |
You should have received a copy of the GNU General Public License |
(for example /usr/src/linux/COPYING); if not, write to the Free |
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef _MD_H |
#define _MD_H |
#include <linux/blkdev.h> |
#include <asm/semaphore.h> |
#include <linux/major.h> |
#include <linux/ioctl.h> |
#include <linux/types.h> |
#include <linux/bitops.h> |
#include <linux/module.h> |
#include <linux/hdreg.h> |
#include <linux/proc_fs.h> |
#include <linux/seq_file.h> |
#include <linux/smp_lock.h> |
#include <linux/delay.h> |
#include <net/checksum.h> |
#include <linux/random.h> |
#include <linux/kernel_stat.h> |
#include <asm/io.h> |
#include <linux/completion.h> |
#include <linux/mempool.h> |
#include <linux/list.h> |
#include <linux/reboot.h> |
#include <linux/vmalloc.h> |
#include <linux/blkpg.h> |
#include <linux/bio.h> |
/* |
* 'md_p.h' holds the 'physical' layout of RAID devices |
* 'md_u.h' holds the user <=> kernel API |
* |
* 'md_k.h' holds kernel internal definitions |
*/ |
#include <linux/raid/md_p.h> |
#include <linux/raid/md_u.h> |
#include <linux/raid/md_k.h> |
/* |
* Different major versions are not compatible. |
* Different minor versions are only downward compatible. |
* Different patchlevel versions are downward and upward compatible. |
*/ |
#define MD_MAJOR_VERSION 0 |
#define MD_MINOR_VERSION 90 |
#define MD_PATCHLEVEL_VERSION 0 |
extern int register_md_personality (int p_num, mdk_personality_t *p); |
extern int unregister_md_personality (int p_num); |
extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), |
mddev_t *mddev, const char *name); |
extern void md_unregister_thread (mdk_thread_t *thread); |
extern void md_wakeup_thread(mdk_thread_t *thread); |
extern void md_check_recovery(mddev_t *mddev); |
extern void md_interrupt_thread (mdk_thread_t *thread); |
extern void md_write_start(mddev_t *mddev); |
extern void md_write_end(mddev_t *mddev); |
extern void md_handle_safemode(mddev_t *mddev); |
extern void md_done_sync(mddev_t *mddev, int blocks, int ok); |
extern void md_sync_acct(mdk_rdev_t *rdev, unsigned long nr_sectors); |
extern void md_error (mddev_t *mddev, mdk_rdev_t *rdev); |
extern void md_print_devices (void); |
#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); } |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/raid1.h |
---|
0,0 → 1,83 |
#ifndef _RAID1_H |
#define _RAID1_H |
#include <linux/raid/md.h> |
typedef struct mirror_info mirror_info_t; |
struct mirror_info { |
mdk_rdev_t *rdev; |
sector_t head_position; |
}; |
typedef struct r1bio_s r1bio_t; |
struct r1_private_data_s { |
mddev_t *mddev; |
mirror_info_t *mirrors; |
int raid_disks; |
int working_disks; |
int last_used; |
sector_t next_seq_sect; |
spinlock_t device_lock; |
/* for use when syncing mirrors: */ |
spinlock_t resync_lock; |
int nr_pending; |
int barrier; |
sector_t next_resync; |
wait_queue_head_t wait_idle; |
wait_queue_head_t wait_resume; |
mempool_t *r1bio_pool; |
mempool_t *r1buf_pool; |
}; |
typedef struct r1_private_data_s conf_t; |
/* |
* this is the only point in the RAID code where we violate |
* C type safety. mddev->private is an 'opaque' pointer. |
*/ |
#define mddev_to_conf(mddev) ((conf_t *) mddev->private) |
/* |
* this is our 'private' RAID1 bio. |
* |
* it contains information about what kind of IO operations were started |
* for this RAID1 operation, and about their status: |
*/ |
struct r1bio_s { |
atomic_t remaining; /* 'have we finished' count, |
* used from IRQ handlers |
*/ |
int cmd; |
sector_t sector; |
unsigned long state; |
mddev_t *mddev; |
/* |
* original bio going to /dev/mdx |
*/ |
struct bio *master_bio; |
/* |
* if the IO is in READ direction, then this bio is used: |
*/ |
struct bio *read_bio; |
int read_disk; |
r1bio_t *next_r1; /* next for retry or in free list */ |
struct list_head retry_list; |
/* |
* if the IO is in WRITE direction, then multiple bios are used. |
* We choose the number when they are allocated. |
*/ |
struct bio *write_bios[0]; |
}; |
/* bits for r1bio.state */ |
#define R1BIO_Uptodate 1 |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/raid5.h |
---|
0,0 → 1,241 |
#ifndef _RAID5_H |
#define _RAID5_H |
#include <linux/raid/md.h> |
#include <linux/raid/xor.h> |
/* |
* |
* Each stripe contains one buffer per disc. Each buffer can be in |
* one of a number of states stored in "flags". Changes between |
* these states happen *almost* exclusively under a per-stripe |
* spinlock. Some very specific changes can happen in bi_end_io, and |
* these are not protected by the spin lock. |
* |
* The flag bits that are used to represent these states are: |
* R5_UPTODATE and R5_LOCKED |
* |
* State Empty == !UPTODATE, !LOCK |
* We have no data, and there is no active request |
* State Want == !UPTODATE, LOCK |
* A read request is being submitted for this block |
* State Dirty == UPTODATE, LOCK |
* Some new data is in this buffer, and it is being written out |
* State Clean == UPTODATE, !LOCK |
* We have valid data which is the same as on disc |
* |
* The possible state transitions are: |
* |
* Empty -> Want - on read or write to get old data for parity calc |
* Empty -> Dirty - on compute_parity to satisfy write/sync request.(RECONSTRUCT_WRITE) |
* Empty -> Clean - on compute_block when computing a block for failed drive |
* Want -> Empty - on failed read |
* Want -> Clean - on successful completion of read request |
* Dirty -> Clean - on successful completion of write request |
* Dirty -> Clean - on failed write |
* Clean -> Dirty - on compute_parity to satisfy write/sync (RECONSTRUCT or RMW) |
* |
* The Want->Empty, Want->Clean, Dirty->Clean, transitions |
* all happen in b_end_io at interrupt time. |
* Each sets the Uptodate bit before releasing the Lock bit. |
* This leaves one multi-stage transition: |
* Want->Dirty->Clean |
* This is safe because thinking that a Clean buffer is actually dirty |
* will at worst delay some action, and the stripe will be scheduled |
* for attention after the transition is complete. |
* |
* There is one possibility that is not covered by these states. That |
* is if one drive has failed and there is a spare being rebuilt. We |
* can't distinguish between a clean block that has been generated |
* from parity calculations, and a clean block that has been |
* successfully written to the spare ( or to parity when resyncing). |
* To distingush these states we have a stripe bit STRIPE_INSYNC that |
* is set whenever a write is scheduled to the spare, or to the parity |
* disc if there is no spare. A sync request clears this bit, and |
* when we find it set with no buffers locked, we know the sync is |
* complete. |
* |
* Buffers for the md device that arrive via make_request are attached |
* to the appropriate stripe in one of two lists linked on b_reqnext. |
* One list (bh_read) for read requests, one (bh_write) for write. |
* There should never be more than one buffer on the two lists |
* together, but we are not guaranteed of that so we allow for more. |
* |
* If a buffer is on the read list when the associated cache buffer is |
* Uptodate, the data is copied into the read buffer and it's b_end_io |
* routine is called. This may happen in the end_request routine only |
* if the buffer has just successfully been read. end_request should |
* remove the buffers from the list and then set the Uptodate bit on |
* the buffer. Other threads may do this only if they first check |
* that the Uptodate bit is set. Once they have checked that they may |
* take buffers off the read queue. |
* |
* When a buffer on the write list is committed for write is it copied |
* into the cache buffer, which is then marked dirty, and moved onto a |
* third list, the written list (bh_written). Once both the parity |
* block and the cached buffer are successfully written, any buffer on |
* a written list can be returned with b_end_io. |
* |
* The write list and read list both act as fifos. The read list is |
* protected by the device_lock. The write and written lists are |
* protected by the stripe lock. The device_lock, which can be |
* claimed while the stipe lock is held, is only for list |
* manipulations and will only be held for a very short time. It can |
* be claimed from interrupts. |
* |
* |
* Stripes in the stripe cache can be on one of two lists (or on |
* neither). The "inactive_list" contains stripes which are not |
* currently being used for any request. They can freely be reused |
* for another stripe. The "handle_list" contains stripes that need |
* to be handled in some way. Both of these are fifo queues. Each |
* stripe is also (potentially) linked to a hash bucket in the hash |
* table so that it can be found by sector number. Stripes that are |
* not hashed must be on the inactive_list, and will normally be at |
* the front. All stripes start life this way. |
* |
* The inactive_list, handle_list and hash bucket lists are all protected by the |
* device_lock. |
* - stripes on the inactive_list never have their stripe_lock held. |
* - stripes have a reference counter. If count==0, they are on a list. |
* - If a stripe might need handling, STRIPE_HANDLE is set. |
* - When refcount reaches zero, then if STRIPE_HANDLE it is put on |
* handle_list else inactive_list |
* |
* This, combined with the fact that STRIPE_HANDLE is only ever |
* cleared while a stripe has a non-zero count means that if the |
* refcount is 0 and STRIPE_HANDLE is set, then it is on the |
* handle_list and if recount is 0 and STRIPE_HANDLE is not set, then |
* the stripe is on inactive_list. |
* |
* The possible transitions are: |
* activate an unhashed/inactive stripe (get_active_stripe()) |
* lockdev check-hash unlink-stripe cnt++ clean-stripe hash-stripe unlockdev |
* activate a hashed, possibly active stripe (get_active_stripe()) |
* lockdev check-hash if(!cnt++)unlink-stripe unlockdev |
* attach a request to an active stripe (add_stripe_bh()) |
* lockdev attach-buffer unlockdev |
* handle a stripe (handle_stripe()) |
* lockstripe clrSTRIPE_HANDLE ... (lockdev check-buffers unlockdev) .. change-state .. record io needed unlockstripe schedule io |
* release an active stripe (release_stripe()) |
* lockdev if (!--cnt) { if STRIPE_HANDLE, add to handle_list else add to inactive-list } unlockdev |
* |
* The refcount counts each thread that have activated the stripe, |
* plus raid5d if it is handling it, plus one for each active request |
* on a cached buffer. |
*/ |
struct stripe_head { |
struct stripe_head *hash_next, **hash_pprev; /* hash pointers */ |
struct list_head lru; /* inactive_list or handle_list */ |
struct raid5_private_data *raid_conf; |
sector_t sector; /* sector of this row */ |
int pd_idx; /* parity disk index */ |
unsigned long state; /* state flags */ |
atomic_t count; /* nr of active thread/requests */ |
spinlock_t lock; |
struct r5dev { |
struct bio req; |
struct bio_vec vec; |
struct page *page; |
struct bio *toread, *towrite, *written; |
sector_t sector; /* sector of this page */ |
unsigned long flags; |
} dev[1]; /* allocated with extra space depending of RAID geometry */ |
}; |
/* Flags */ |
#define R5_UPTODATE 0 /* page contains current data */ |
#define R5_LOCKED 1 /* IO has been submitted on "req" */ |
#define R5_OVERWRITE 2 /* towrite covers whole page */ |
/* and some that are internal to handle_stripe */ |
#define R5_Insync 3 /* rdev && rdev->in_sync at start */ |
#define R5_Wantread 4 /* want to schedule a read */ |
#define R5_Wantwrite 5 |
#define R5_Syncio 6 /* this io need to be accounted as resync io */ |
/* |
* Write method |
*/ |
#define RECONSTRUCT_WRITE 1 |
#define READ_MODIFY_WRITE 2 |
/* not a write method, but a compute_parity mode */ |
#define CHECK_PARITY 3 |
/* |
* Stripe state |
*/ |
#define STRIPE_ERROR 1 |
#define STRIPE_HANDLE 2 |
#define STRIPE_SYNCING 3 |
#define STRIPE_INSYNC 4 |
#define STRIPE_PREREAD_ACTIVE 5 |
#define STRIPE_DELAYED 6 |
/* |
* Plugging: |
* |
* To improve write throughput, we need to delay the handling of some |
* stripes until there has been a chance that several write requests |
* for the one stripe have all been collected. |
* In particular, any write request that would require pre-reading |
* is put on a "delayed" queue until there are no stripes currently |
* in a pre-read phase. Further, if the "delayed" queue is empty when |
* a stripe is put on it then we "plug" the queue and do not process it |
* until an unplug call is made. (blk_run_queues is run). |
* |
* When preread is initiated on a stripe, we set PREREAD_ACTIVE and add |
* it to the count of prereading stripes. |
* When write is initiated, or the stripe refcnt == 0 (just in case) we |
* clear the PREREAD_ACTIVE flag and decrement the count |
* Whenever the delayed queue is empty and the device is not plugged, we |
* move any strips from delayed to handle and clear the DELAYED flag and set PREREAD_ACTIVE. |
* In stripe_handle, if we find pre-reading is necessary, we do it if |
* PREREAD_ACTIVE is set, else we set DELAYED which will send it to the delayed queue. |
* HANDLE gets cleared if stripe_handle leave nothing locked. |
*/ |
struct disk_info { |
mdk_rdev_t *rdev; |
}; |
struct raid5_private_data { |
struct stripe_head **stripe_hashtbl; |
mddev_t *mddev; |
struct disk_info *spare; |
int chunk_size, level, algorithm; |
int raid_disks, working_disks, failed_disks; |
int max_nr_stripes; |
struct list_head handle_list; /* stripes needing handling */ |
struct list_head delayed_list; /* stripes that have plugged requests */ |
atomic_t preread_active_stripes; /* stripes with scheduled io */ |
char cache_name[20]; |
kmem_cache_t *slab_cache; /* for allocating stripes */ |
/* |
* Free stripes pool |
*/ |
atomic_t active_stripes; |
struct list_head inactive_list; |
wait_queue_head_t wait_for_stripe; |
int inactive_blocked; /* release of inactive stripes blocked, |
* waiting for 25% to be free |
*/ |
spinlock_t device_lock; |
struct disk_info disks[0]; |
}; |
typedef struct raid5_private_data raid5_conf_t; |
#define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private) |
/* |
* Our supported algorithms |
*/ |
#define ALGORITHM_LEFT_ASYMMETRIC 0 |
#define ALGORITHM_RIGHT_ASYMMETRIC 1 |
#define ALGORITHM_LEFT_SYMMETRIC 2 |
#define ALGORITHM_RIGHT_SYMMETRIC 3 |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/md_u.h |
---|
0,0 → 1,117 |
/* |
md_u.h : user <=> kernel API between Linux raidtools and RAID drivers |
Copyright (C) 1998 Ingo Molnar |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2, or (at your option) |
any later version. |
You should have received a copy of the GNU General Public License |
(for example /usr/src/linux/COPYING); if not, write to the Free |
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef _MD_U_H |
#define _MD_U_H |
/* ioctls */ |
/* status */ |
#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t) |
#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t) |
#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t) |
#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13) |
#define RAID_AUTORUN _IO (MD_MAJOR, 0x14) |
/* configuration */ |
#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20) |
#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t) |
#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22) |
#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t) |
#define SET_DISK_INFO _IO (MD_MAJOR, 0x24) |
#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25) |
#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26) |
#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27) |
#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28) |
#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29) |
#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a) |
/* usage */ |
#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t) |
#define START_ARRAY _IO (MD_MAJOR, 0x31) |
#define STOP_ARRAY _IO (MD_MAJOR, 0x32) |
#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) |
#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) |
typedef struct mdu_version_s { |
int major; |
int minor; |
int patchlevel; |
} mdu_version_t; |
typedef struct mdu_array_info_s { |
/* |
* Generic constant information |
*/ |
int major_version; |
int minor_version; |
int patch_version; |
int ctime; |
int level; |
int size; |
int nr_disks; |
int raid_disks; |
int md_minor; |
int not_persistent; |
/* |
* Generic state information |
*/ |
int utime; /* 0 Superblock update time */ |
int state; /* 1 State bits (clean, ...) */ |
int active_disks; /* 2 Number of currently active disks */ |
int working_disks; /* 3 Number of working disks */ |
int failed_disks; /* 4 Number of failed disks */ |
int spare_disks; /* 5 Number of spare disks */ |
/* |
* Personality information |
*/ |
int layout; /* 0 the array's physical layout */ |
int chunk_size; /* 1 chunk size in bytes */ |
} mdu_array_info_t; |
typedef struct mdu_disk_info_s { |
/* |
* configuration/status of one particular disk |
*/ |
int number; |
int major; |
int minor; |
int raid_disk; |
int state; |
} mdu_disk_info_t; |
typedef struct mdu_start_info_s { |
/* |
* configuration/status of one particular disk |
*/ |
int major; |
int minor; |
int raid_disk; |
int state; |
} mdu_start_info_t; |
typedef struct mdu_param_s |
{ |
int personality; /* 1,2,3,4 */ |
int chunk_size; /* in bytes */ |
int max_fault; /* unused for now */ |
} mdu_param_t; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/multipath.h |
---|
0,0 → 1,41 |
#ifndef _MULTIPATH_H |
#define _MULTIPATH_H |
#include <linux/raid/md.h> |
struct multipath_info { |
mdk_rdev_t *rdev; |
}; |
struct multipath_private_data { |
mddev_t *mddev; |
struct multipath_info *multipaths; |
int raid_disks; |
int working_disks; |
spinlock_t device_lock; |
mempool_t *pool; |
}; |
typedef struct multipath_private_data multipath_conf_t; |
/* |
* this is the only point in the RAID code where we violate |
* C type safety. mddev->private is an 'opaque' pointer. |
*/ |
#define mddev_to_conf(mddev) ((multipath_conf_t *) mddev->private) |
/* |
* this is our 'private' 'collective' MULTIPATH buffer head. |
* it contains information about what kind of IO operations were started |
* for this MULTIPATH operation, and about their status: |
*/ |
struct multipath_bh { |
mddev_t *mddev; |
struct bio *master_bio; |
struct bio bio; |
int path; |
struct multipath_bh *next_mp; /* next for retry */ |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/raid/xor.h |
---|
0,0 → 1,23 |
#ifndef _XOR_H |
#define _XOR_H |
#include <linux/raid/md.h> |
#define MAX_XOR_BLOCKS 5 |
extern void xor_block(unsigned int count, unsigned int bytes, void **ptr); |
struct xor_block_template { |
struct xor_block_template *next; |
const char *name; |
int speed; |
void (*do_2)(unsigned long, unsigned long *, unsigned long *); |
void (*do_3)(unsigned long, unsigned long *, unsigned long *, |
unsigned long *); |
void (*do_4)(unsigned long, unsigned long *, unsigned long *, |
unsigned long *, unsigned long *); |
void (*do_5)(unsigned long, unsigned long *, unsigned long *, |
unsigned long *, unsigned long *, unsigned long *); |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_arp/arpt_mangle.h |
---|
0,0 → 1,26 |
#ifndef _ARPT_MANGLE_H |
#define _ARPT_MANGLE_H |
#include <linux/netfilter_arp/arp_tables.h> |
#define ARPT_MANGLE_ADDR_LEN_MAX sizeof(struct in_addr) |
struct arpt_mangle |
{ |
char src_devaddr[ARPT_DEV_ADDR_LEN_MAX]; |
char tgt_devaddr[ARPT_DEV_ADDR_LEN_MAX]; |
union { |
struct in_addr src_ip; |
} u_s; |
union { |
struct in_addr tgt_ip; |
} u_t; |
u_int8_t flags; |
int target; |
}; |
#define ARPT_MANGLE_SDEV 0x01 |
#define ARPT_MANGLE_TDEV 0x02 |
#define ARPT_MANGLE_SIP 0x04 |
#define ARPT_MANGLE_TIP 0x08 |
#define ARPT_MANGLE_MASK 0x0f |
#endif /* _ARPT_MANGLE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_arp/arp_tables.h |
---|
0,0 → 1,342 |
/* |
* Format of an ARP firewall descriptor |
* |
* src, tgt, src_mask, tgt_mask, arpop, arpop_mask are always stored in |
* network byte order. |
* flags are stored in host byte order (of course). |
*/ |
#ifndef _ARPTABLES_H |
#define _ARPTABLES_H |
#ifdef __KERNEL__ |
#include <linux/if.h> |
#include <linux/types.h> |
#include <linux/in.h> |
#include <linux/if_arp.h> |
#include <linux/skbuff.h> |
#endif |
#include <linux/netfilter_arp.h> |
#define ARPT_FUNCTION_MAXNAMELEN 30 |
#define ARPT_TABLE_MAXNAMELEN 32 |
#define ARPT_DEV_ADDR_LEN_MAX 16 |
struct arpt_devaddr_info { |
char addr[ARPT_DEV_ADDR_LEN_MAX]; |
char mask[ARPT_DEV_ADDR_LEN_MAX]; |
}; |
/* Yes, Virginia, you have to zero the padding. */ |
struct arpt_arp { |
/* Source and target IP addr */ |
struct in_addr src, tgt; |
/* Mask for src and target IP addr */ |
struct in_addr smsk, tmsk; |
/* Device hw address length, src+target device addresses */ |
u_int8_t arhln, arhln_mask; |
struct arpt_devaddr_info src_devaddr; |
struct arpt_devaddr_info tgt_devaddr; |
/* ARP operation code. */ |
u_int16_t arpop, arpop_mask; |
/* ARP hardware address and protocol address format. */ |
u_int16_t arhrd, arhrd_mask; |
u_int16_t arpro, arpro_mask; |
/* The protocol address length is only accepted if it is 4 |
* so there is no use in offering a way to do filtering on it. |
*/ |
char iniface[IFNAMSIZ], outiface[IFNAMSIZ]; |
unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ]; |
/* Flags word */ |
u_int8_t flags; |
/* Inverse flags */ |
u_int16_t invflags; |
}; |
struct arpt_entry_target |
{ |
union { |
struct { |
u_int16_t target_size; |
/* Used by userspace */ |
char name[ARPT_FUNCTION_MAXNAMELEN]; |
} user; |
struct { |
u_int16_t target_size; |
/* Used inside the kernel */ |
struct arpt_target *target; |
} kernel; |
/* Total length */ |
u_int16_t target_size; |
} u; |
unsigned char data[0]; |
}; |
struct arpt_standard_target |
{ |
struct arpt_entry_target target; |
int verdict; |
}; |
struct arpt_counters |
{ |
u_int64_t pcnt, bcnt; /* Packet and byte counters */ |
}; |
/* Values for "flag" field in struct arpt_ip (general arp structure). |
* No flags defined yet. |
*/ |
#define ARPT_F_MASK 0x00 /* All possible flag bits mask. */ |
/* Values for "inv" field in struct arpt_arp. */ |
#define ARPT_INV_VIA_IN 0x0001 /* Invert the sense of IN IFACE. */ |
#define ARPT_INV_VIA_OUT 0x0002 /* Invert the sense of OUT IFACE */ |
#define ARPT_INV_SRCIP 0x0004 /* Invert the sense of SRC IP. */ |
#define ARPT_INV_TGTIP 0x0008 /* Invert the sense of TGT IP. */ |
#define ARPT_INV_SRCDEVADDR 0x0010 /* Invert the sense of SRC DEV ADDR. */ |
#define ARPT_INV_TGTDEVADDR 0x0020 /* Invert the sense of TGT DEV ADDR. */ |
#define ARPT_INV_ARPOP 0x0040 /* Invert the sense of ARP OP. */ |
#define ARPT_INV_ARPHRD 0x0080 /* Invert the sense of ARP HRD. */ |
#define ARPT_INV_ARPPRO 0x0100 /* Invert the sense of ARP PRO. */ |
#define ARPT_INV_ARPHLN 0x0200 /* Invert the sense of ARP HLN. */ |
#define ARPT_INV_MASK 0x03FF /* All possible flag bits mask. */ |
/* This structure defines each of the firewall rules. Consists of 3 |
parts which are 1) general ARP header stuff 2) match specific |
stuff 3) the target to perform if the rule matches */ |
struct arpt_entry |
{ |
struct arpt_arp arp; |
/* Size of arpt_entry + matches */ |
u_int16_t target_offset; |
/* Size of arpt_entry + matches + target */ |
u_int16_t next_offset; |
/* Back pointer */ |
unsigned int comefrom; |
/* Packet and byte counters. */ |
struct arpt_counters counters; |
/* The matches (if any), then the target. */ |
unsigned char elems[0]; |
}; |
/* |
* New IP firewall options for [gs]etsockopt at the RAW IP level. |
* Unlike BSD Linux inherits IP options so you don't have to use a raw |
* socket for this. Instead we check rights in the calls. |
*/ |
#define ARPT_BASE_CTL 96 /* base for firewall socket options */ |
#define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) |
#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1) |
#define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS |
#define ARPT_SO_GET_INFO (ARPT_BASE_CTL) |
#define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) |
#define ARPT_SO_GET_MAX ARPT_SO_GET_ENTRIES |
/* CONTINUE verdict for targets */ |
#define ARPT_CONTINUE 0xFFFFFFFF |
/* For standard target */ |
#define ARPT_RETURN (-NF_MAX_VERDICT - 1) |
/* The argument to ARPT_SO_GET_INFO */ |
struct arpt_getinfo |
{ |
/* Which table: caller fills this in. */ |
char name[ARPT_TABLE_MAXNAMELEN]; |
/* Kernel fills these in. */ |
/* Which hook entry points are valid: bitmask */ |
unsigned int valid_hooks; |
/* Hook entry points: one per netfilter hook. */ |
unsigned int hook_entry[NF_ARP_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_ARP_NUMHOOKS]; |
/* Number of entries */ |
unsigned int num_entries; |
/* Size of entries. */ |
unsigned int size; |
}; |
/* The argument to ARPT_SO_SET_REPLACE. */ |
struct arpt_replace |
{ |
/* Which table. */ |
char name[ARPT_TABLE_MAXNAMELEN]; |
/* Which hook entry points are valid: bitmask. You can't |
change this. */ |
unsigned int valid_hooks; |
/* Number of entries */ |
unsigned int num_entries; |
/* Total size of new entries */ |
unsigned int size; |
/* Hook entry points. */ |
unsigned int hook_entry[NF_ARP_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_ARP_NUMHOOKS]; |
/* Information about old entries: */ |
/* Number of counters (must be equal to current number of entries). */ |
unsigned int num_counters; |
/* The old entries' counters. */ |
struct arpt_counters *counters; |
/* The entries (hang off end: not really an array). */ |
struct arpt_entry entries[0]; |
}; |
/* The argument to ARPT_SO_ADD_COUNTERS. */ |
struct arpt_counters_info |
{ |
/* Which table. */ |
char name[ARPT_TABLE_MAXNAMELEN]; |
unsigned int num_counters; |
/* The counters (actually `number' of these). */ |
struct arpt_counters counters[0]; |
}; |
/* The argument to ARPT_SO_GET_ENTRIES. */ |
struct arpt_get_entries |
{ |
/* Which table: user fills this in. */ |
char name[ARPT_TABLE_MAXNAMELEN]; |
/* User fills this in: total entry size. */ |
unsigned int size; |
/* The entries. */ |
struct arpt_entry entrytable[0]; |
}; |
/* Standard return verdict, or do jump. */ |
#define ARPT_STANDARD_TARGET "" |
/* Error verdict. */ |
#define ARPT_ERROR_TARGET "ERROR" |
/* Helper functions */ |
static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e) |
{ |
return (void *)e + e->target_offset; |
} |
/* fn returns 0 to continue iteration */ |
#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct arpt_entry *__entry; \ |
\ |
for (__i = 0; __i < (size); __i += __entry->next_offset) { \ |
__entry = (void *)(entries) + __i; \ |
\ |
__ret = fn(__entry , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
__ret; \ |
}) |
/* |
* Main firewall chains definitions and global var's definitions. |
*/ |
#ifdef __KERNEL__ |
/* Registration hooks for targets. */ |
struct arpt_target |
{ |
struct list_head list; |
const char name[ARPT_FUNCTION_MAXNAMELEN]; |
/* Returns verdict. */ |
unsigned int (*target)(struct sk_buff **pskb, |
unsigned int hooknum, |
const struct net_device *in, |
const struct net_device *out, |
const void *targinfo, |
void *userdata); |
/* Called when user tries to insert an entry of this type: |
hook_mask is a bitmask of hooks from which it can be |
called. */ |
/* Should return true or false. */ |
int (*checkentry)(const char *tablename, |
const struct arpt_entry *e, |
void *targinfo, |
unsigned int targinfosize, |
unsigned int hook_mask); |
/* Called when entry of this type deleted. */ |
void (*destroy)(void *targinfo, unsigned int targinfosize); |
/* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
struct module *me; |
}; |
extern int arpt_register_target(struct arpt_target *target); |
extern void arpt_unregister_target(struct arpt_target *target); |
/* Furniture shopping... */ |
struct arpt_table |
{ |
struct list_head list; |
/* A unique name... */ |
char name[ARPT_TABLE_MAXNAMELEN]; |
/* Seed table: copied in register_table */ |
struct arpt_replace *table; |
/* What hooks you will enter on */ |
unsigned int valid_hooks; |
/* Lock for the curtain */ |
rwlock_t lock; |
/* Man behind the curtain... */ |
struct arpt_table_info *private; |
/* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
struct module *me; |
}; |
extern int arpt_register_table(struct arpt_table *table); |
extern void arpt_unregister_table(struct arpt_table *table); |
extern unsigned int arpt_do_table(struct sk_buff **pskb, |
unsigned int hook, |
const struct net_device *in, |
const struct net_device *out, |
struct arpt_table *table, |
void *userdata); |
#define ARPT_ALIGN(s) (((s) + (__alignof__(struct arpt_entry)-1)) & ~(__alignof__(struct arpt_entry)-1)) |
#endif /*__KERNEL__*/ |
#endif /* _ARPTABLES_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/nfsd.h |
---|
0,0 → 1,294 |
/* |
* linux/include/linux/nfsd/nfsd.h |
* |
* Hodge-podge collection of knfsd-related stuff. |
* I will sort this out later. |
* |
* Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef LINUX_NFSD_NFSD_H |
#define LINUX_NFSD_NFSD_H |
#include <linux/config.h> |
#include <linux/types.h> |
#include <linux/unistd.h> |
#include <linux/dirent.h> |
#include <linux/fs.h> |
#include <linux/mount.h> |
#include <linux/nfsd/debug.h> |
#include <linux/nfsd/nfsfh.h> |
#include <linux/nfsd/export.h> |
#include <linux/nfsd/auth.h> |
#include <linux/nfsd/stats.h> |
#include <linux/nfsd/interface.h> |
/* |
* nfsd version |
*/ |
#define NFSD_VERSION "0.5" |
#define NFSD_SUPPORTED_MINOR_VERSION 0 |
#ifdef __KERNEL__ |
/* |
* Special flags for nfsd_permission. These must be different from MAY_READ, |
* MAY_WRITE, and MAY_EXEC. |
*/ |
#define MAY_NOP 0 |
#define MAY_SATTR 8 |
#define MAY_TRUNC 16 |
#define MAY_LOCK 32 |
#define MAY_OWNER_OVERRIDE 64 |
#define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/ |
#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC) |
# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_LOCAL_ACCESS or MAY_OWNER_OVERRIDE." |
#endif |
#define MAY_CREATE (MAY_EXEC|MAY_WRITE) |
#define MAY_REMOVE (MAY_EXEC|MAY_WRITE|MAY_TRUNC) |
/* |
* Callback function for readdir |
*/ |
struct readdir_cd { |
int err; /* 0, nfserr, or nfserr_eof */ |
}; |
typedef int (*encode_dent_fn)(struct readdir_cd *, const char *, |
int, loff_t, ino_t, unsigned int); |
typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int); |
extern struct svc_program nfsd_program; |
extern struct svc_version nfsd_version2, nfsd_version3, |
nfsd_version4; |
/* |
* Function prototypes. |
*/ |
int nfsd_svc(unsigned short port, int nrservs); |
int nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp); |
/* nfsd/vfs.c */ |
int fh_lock_parent(struct svc_fh *, struct dentry *); |
int nfsd_racache_init(int); |
void nfsd_racache_shutdown(void); |
int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, |
struct svc_export **expp); |
int nfsd_lookup(struct svc_rqst *, struct svc_fh *, |
const char *, int, struct svc_fh *); |
int nfsd_setattr(struct svc_rqst *, struct svc_fh *, |
struct iattr *, int, time_t); |
int nfsd_create(struct svc_rqst *, struct svc_fh *, |
char *name, int len, struct iattr *attrs, |
int type, dev_t rdev, struct svc_fh *res); |
#ifdef CONFIG_NFSD_V3 |
int nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *); |
int nfsd_create_v3(struct svc_rqst *, struct svc_fh *, |
char *name, int len, struct iattr *attrs, |
struct svc_fh *res, int createmode, |
u32 *verifier, int *truncp); |
int nfsd_commit(struct svc_rqst *, struct svc_fh *, |
off_t, unsigned long); |
#endif /* CONFIG_NFSD_V3 */ |
int nfsd_open(struct svc_rqst *, struct svc_fh *, int, |
int, struct file *); |
void nfsd_close(struct file *); |
int nfsd_read(struct svc_rqst *, struct svc_fh *, |
loff_t, struct iovec *,int, unsigned long *); |
int nfsd_write(struct svc_rqst *, struct svc_fh *, |
loff_t, struct iovec *,int, unsigned long, int *); |
int nfsd_readlink(struct svc_rqst *, struct svc_fh *, |
char *, int *); |
int nfsd_symlink(struct svc_rqst *, struct svc_fh *, |
char *name, int len, char *path, int plen, |
struct svc_fh *res, struct iattr *); |
int nfsd_link(struct svc_rqst *, struct svc_fh *, |
char *, int, struct svc_fh *); |
int nfsd_rename(struct svc_rqst *, |
struct svc_fh *, char *, int, |
struct svc_fh *, char *, int); |
int nfsd_remove(struct svc_rqst *, |
struct svc_fh *, char *, int); |
int nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type, |
char *name, int len); |
int nfsd_truncate(struct svc_rqst *, struct svc_fh *, |
unsigned long size); |
int nfsd_readdir(struct svc_rqst *, struct svc_fh *, |
loff_t *, struct readdir_cd *, encode_dent_fn); |
int nfsd_statfs(struct svc_rqst *, struct svc_fh *, |
struct kstatfs *); |
int nfsd_notify_change(struct inode *, struct iattr *); |
int nfsd_permission(struct svc_export *, struct dentry *, int); |
/* |
* NFSv4 State |
*/ |
#ifdef CONFIG_NFSD_V4 |
void nfs4_state_init(void); |
void nfs4_state_shutdown(void); |
#else |
void static inline nfs4_state_init(void){} |
void static inline nfs4_state_shutdown(void){} |
#endif |
/* |
* lockd binding |
*/ |
void nfsd_lockd_init(void); |
void nfsd_lockd_shutdown(void); |
/* |
* These macros provide pre-xdr'ed values for faster operation. |
*/ |
#define nfs_ok __constant_htonl(NFS_OK) |
#define nfserr_perm __constant_htonl(NFSERR_PERM) |
#define nfserr_noent __constant_htonl(NFSERR_NOENT) |
#define nfserr_io __constant_htonl(NFSERR_IO) |
#define nfserr_nxio __constant_htonl(NFSERR_NXIO) |
#define nfserr_eagain __constant_htonl(NFSERR_EAGAIN) |
#define nfserr_acces __constant_htonl(NFSERR_ACCES) |
#define nfserr_exist __constant_htonl(NFSERR_EXIST) |
#define nfserr_xdev __constant_htonl(NFSERR_XDEV) |
#define nfserr_nodev __constant_htonl(NFSERR_NODEV) |
#define nfserr_notdir __constant_htonl(NFSERR_NOTDIR) |
#define nfserr_isdir __constant_htonl(NFSERR_ISDIR) |
#define nfserr_inval __constant_htonl(NFSERR_INVAL) |
#define nfserr_fbig __constant_htonl(NFSERR_FBIG) |
#define nfserr_nospc __constant_htonl(NFSERR_NOSPC) |
#define nfserr_rofs __constant_htonl(NFSERR_ROFS) |
#define nfserr_mlink __constant_htonl(NFSERR_MLINK) |
#define nfserr_opnotsupp __constant_htonl(NFSERR_OPNOTSUPP) |
#define nfserr_nametoolong __constant_htonl(NFSERR_NAMETOOLONG) |
#define nfserr_notempty __constant_htonl(NFSERR_NOTEMPTY) |
#define nfserr_dquot __constant_htonl(NFSERR_DQUOT) |
#define nfserr_stale __constant_htonl(NFSERR_STALE) |
#define nfserr_remote __constant_htonl(NFSERR_REMOTE) |
#define nfserr_wflush __constant_htonl(NFSERR_WFLUSH) |
#define nfserr_badhandle __constant_htonl(NFSERR_BADHANDLE) |
#define nfserr_notsync __constant_htonl(NFSERR_NOT_SYNC) |
#define nfserr_badcookie __constant_htonl(NFSERR_BAD_COOKIE) |
#define nfserr_notsupp __constant_htonl(NFSERR_NOTSUPP) |
#define nfserr_toosmall __constant_htonl(NFSERR_TOOSMALL) |
#define nfserr_serverfault __constant_htonl(NFSERR_SERVERFAULT) |
#define nfserr_badtype __constant_htonl(NFSERR_BADTYPE) |
#define nfserr_jukebox __constant_htonl(NFSERR_JUKEBOX) |
#define nfserr_denied __constant_htonl(NFSERR_DENIED) |
#define nfserr_deadlock __constant_htonl(NFSERR_DEADLOCK) |
#define nfserr_expired __constant_htonl(NFSERR_EXPIRED) |
#define nfserr_bad_cookie __constant_htonl(NFSERR_BAD_COOKIE) |
#define nfserr_same __constant_htonl(NFSERR_SAME) |
#define nfserr_clid_inuse __constant_htonl(NFSERR_CLID_INUSE) |
#define nfserr_stale_clientid __constant_htonl(NFSERR_STALE_CLIENTID) |
#define nfserr_resource __constant_htonl(NFSERR_RESOURCE) |
#define nfserr_nofilehandle __constant_htonl(NFSERR_NOFILEHANDLE) |
#define nfserr_minor_vers_mismatch __constant_htonl(NFSERR_MINOR_VERS_MISMATCH) |
#define nfserr_share_denied __constant_htonl(NFSERR_SHARE_DENIED) |
#define nfserr_stale_stateid __constant_htonl(NFSERR_STALE_STATEID) |
#define nfserr_old_stateid __constant_htonl(NFSERR_OLD_STATEID) |
#define nfserr_bad_stateid __constant_htonl(NFSERR_BAD_STATEID) |
#define nfserr_bad_seqid __constant_htonl(NFSERR_BAD_SEQID) |
#define nfserr_symlink __constant_htonl(NFSERR_SYMLINK) |
#define nfserr_not_same __constant_htonl(NFSERR_NOT_SAME) |
#define nfserr_readdir_nospc __constant_htonl(NFSERR_READDIR_NOSPC) |
#define nfserr_bad_xdr __constant_htonl(NFSERR_BAD_XDR) |
#define nfserr_openmode __constant_htonl(NFSERR_OPENMODE) |
/* error codes for internal use */ |
/* if a request fails due to kmalloc failure, it gets dropped. |
* Client should resend eventually |
*/ |
#define nfserr_dropit __constant_htonl(30000) |
/* end-of-file indicator in readdir */ |
#define nfserr_eof __constant_htonl(30001) |
/* Check for dir entries '.' and '..' */ |
#define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) |
/* |
* Time of server startup |
*/ |
extern struct timeval nfssvc_boot; |
static inline int is_fsid(struct svc_fh *fh, struct knfsd_fh *reffh) |
{ |
if (fh->fh_export->ex_flags & NFSEXP_FSID) { |
struct vfsmount *mnt = fh->fh_export->ex_mnt; |
if (!old_valid_dev(mnt->mnt_sb->s_dev) || |
(reffh->fh_version == 1 && reffh->fh_fsid_type == 1)) |
return 1; |
} |
return 0; |
} |
#ifdef CONFIG_NFSD_V4 |
/* before processing a COMPOUND operation, we have to check that there |
* is enough space in the buffer for XDR encode to succeed. otherwise, |
* we might process an operation with side effects, and be unable to |
* tell the client that the operation succeeded. |
* |
* COMPOUND_SLACK_SPACE - this is the minimum amount of buffer space |
* needed to encode an "ordinary" _successful_ operation. (GETATTR, |
* READ, READDIR, and READLINK have their own buffer checks.) if we |
* fall below this level, we fail the next operation with NFS4ERR_RESOURCE. |
* |
* COMPOUND_ERR_SLACK_SPACE - this is the minimum amount of buffer space |
* needed to encode an operation which has failed with NFS4ERR_RESOURCE. |
* care is taken to ensure that we never fall below this level for any |
* reason. |
*/ |
#define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */ |
#define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */ |
#define NFSD_LEASE_TIME 60 /* seconds */ |
#define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */ |
/* |
* The following attributes are currently not supported by the NFSv4 server: |
* ACL (will be supported in a forthcoming patch) |
* ARCHIVE (deprecated anyway) |
* FS_LOCATIONS (will be supported eventually) |
* HIDDEN (unlikely to be supported any time soon) |
* MIMETYPE (unlikely to be supported any time soon) |
* QUOTA_* (will be supported in a forthcoming patch) |
* SYSTEM (unlikely to be supported any time soon) |
* TIME_BACKUP (unlikely to be supported any time soon) |
* TIME_CREATE (unlikely to be supported any time soon) |
*/ |
#define NFSD_SUPPORTED_ATTRS_WORD0 \ |
(FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \ |
| FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \ |
| FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \ |
| FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \ |
| FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \ |
| FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \ |
| FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \ |
| FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_HOMOGENEOUS \ |
| FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \ |
| FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE) |
#define NFSD_SUPPORTED_ATTRS_WORD1 \ |
(FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \ |
| FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \ |
| FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \ |
| FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \ |
| FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA \ |
| FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET) |
/* These will return ERR_INVAL if specified in GETATTR or READDIR. */ |
#define NFSD_WRITEONLY_ATTRS_WORD1 \ |
(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET) |
/* These are the only attrs allowed in CREATE/OPEN/SETATTR. */ |
#define NFSD_WRITEABLE_ATTRS_WORD0 FATTR4_WORD0_SIZE |
#define NFSD_WRITEABLE_ATTRS_WORD1 \ |
(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \ |
| FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY_SET) |
#endif /* CONFIG_NFSD_V4 */ |
#endif /* __KERNEL__ */ |
#endif /* LINUX_NFSD_NFSD_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/syscall.h |
---|
0,0 → 1,126 |
/* |
* include/linux/nfsd/syscall.h |
* |
* This file holds all declarations for the knfsd syscall interface. |
* |
* Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef NFSD_SYSCALL_H |
#define NFSD_SYSCALL_H |
#include <asm/types.h> |
#ifdef __KERNEL__ |
# include <linux/config.h> |
# include <linux/types.h> |
# include <linux/in.h> |
#endif |
#include <linux/posix_types.h> |
#include <linux/nfsd/const.h> |
#include <linux/nfsd/export.h> |
#include <linux/nfsd/nfsfh.h> |
#include <linux/nfsd/auth.h> |
/* |
* Version of the syscall interface |
*/ |
#define NFSCTL_VERSION 0x0201 |
/* |
* These are the commands understood by nfsctl(). |
*/ |
#define NFSCTL_SVC 0 /* This is a server process. */ |
#define NFSCTL_ADDCLIENT 1 /* Add an NFS client. */ |
#define NFSCTL_DELCLIENT 2 /* Remove an NFS client. */ |
#define NFSCTL_EXPORT 3 /* export a file system. */ |
#define NFSCTL_UNEXPORT 4 /* unexport a file system. */ |
/*#define NFSCTL_UGIDUPDATE 5 / * update a client's uid/gid map. DISCARDED */ |
/*#define NFSCTL_GETFH 6 / * get an fh by ino DISCARDED */ |
#define NFSCTL_GETFD 7 /* get an fh by path (used by mountd) */ |
#define NFSCTL_GETFS 8 /* get an fh by path with max FH len */ |
/* SVC */ |
struct nfsctl_svc { |
unsigned short svc_port; |
int svc_nthreads; |
}; |
/* ADDCLIENT/DELCLIENT */ |
struct nfsctl_client { |
char cl_ident[NFSCLNT_IDMAX+1]; |
int cl_naddr; |
struct in_addr cl_addrlist[NFSCLNT_ADDRMAX]; |
int cl_fhkeytype; |
int cl_fhkeylen; |
unsigned char cl_fhkey[NFSCLNT_KEYMAX]; |
}; |
/* EXPORT/UNEXPORT */ |
struct nfsctl_export { |
char ex_client[NFSCLNT_IDMAX+1]; |
char ex_path[NFS_MAXPATHLEN+1]; |
__kernel_old_dev_t ex_dev; |
__kernel_ino_t ex_ino; |
int ex_flags; |
__kernel_uid_t ex_anon_uid; |
__kernel_gid_t ex_anon_gid; |
}; |
/* GETFD */ |
struct nfsctl_fdparm { |
struct sockaddr gd_addr; |
char gd_path[NFS_MAXPATHLEN+1]; |
int gd_version; |
}; |
/* GETFS - GET Filehandle with Size */ |
struct nfsctl_fsparm { |
struct sockaddr gd_addr; |
char gd_path[NFS_MAXPATHLEN+1]; |
int gd_maxlen; |
}; |
/* |
* This is the argument union. |
*/ |
struct nfsctl_arg { |
int ca_version; /* safeguard */ |
union { |
struct nfsctl_svc u_svc; |
struct nfsctl_client u_client; |
struct nfsctl_export u_export; |
struct nfsctl_fdparm u_getfd; |
struct nfsctl_fsparm u_getfs; |
/* |
* The following dummy member is needed to preserve binary compatibility |
* on platforms where alignof(void*)>alignof(int). It's needed because |
* this union used to contain a member (u_umap) which contained a |
* pointer. |
*/ |
void *u_ptr; |
} u; |
#define ca_svc u.u_svc |
#define ca_client u.u_client |
#define ca_export u.u_export |
#define ca_getfd u.u_getfd |
#define ca_getfs u.u_getfs |
}; |
union nfsctl_res { |
__u8 cr_getfh[NFS_FHSIZE]; |
struct knfsd_fh cr_getfs; |
}; |
#ifdef __KERNEL__ |
/* |
* Kernel syscall implementation. |
*/ |
extern asmlinkage long sys_nfsservctl(int, struct nfsctl_arg __user *, void __user *); |
extern int exp_addclient(struct nfsctl_client *ncp); |
extern int exp_delclient(struct nfsctl_client *ncp); |
extern int exp_export(struct nfsctl_export *nxp); |
extern int exp_unexport(struct nfsctl_export *nxp); |
#endif /* __KERNEL__ */ |
#endif /* NFSD_SYSCALL_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/xdr.h |
---|
0,0 → 1,172 |
/* |
* linux/inxlude/linux/nfsd/xdr.h |
* |
* XDR types for nfsd. This is mainly a typing exercise. |
*/ |
#ifndef LINUX_NFSD_H |
#define LINUX_NFSD_H |
#include <linux/fs.h> |
#include <linux/vfs.h> |
#include <linux/nfs.h> |
struct nfsd_fhandle { |
struct svc_fh fh; |
}; |
struct nfsd_sattrargs { |
struct svc_fh fh; |
struct iattr attrs; |
}; |
struct nfsd_diropargs { |
struct svc_fh fh; |
char * name; |
int len; |
}; |
struct nfsd_readargs { |
struct svc_fh fh; |
__u32 offset; |
__u32 count; |
struct iovec vec[RPCSVC_MAXPAGES]; |
int vlen; |
}; |
struct nfsd_writeargs { |
svc_fh fh; |
__u32 offset; |
int len; |
struct iovec vec[RPCSVC_MAXPAGES]; |
int vlen; |
}; |
struct nfsd_createargs { |
struct svc_fh fh; |
char * name; |
int len; |
struct iattr attrs; |
}; |
struct nfsd_renameargs { |
struct svc_fh ffh; |
char * fname; |
int flen; |
struct svc_fh tfh; |
char * tname; |
int tlen; |
}; |
struct nfsd_readlinkargs { |
struct svc_fh fh; |
char * buffer; |
}; |
struct nfsd_linkargs { |
struct svc_fh ffh; |
struct svc_fh tfh; |
char * tname; |
int tlen; |
}; |
struct nfsd_symlinkargs { |
struct svc_fh ffh; |
char * fname; |
int flen; |
char * tname; |
int tlen; |
struct iattr attrs; |
}; |
struct nfsd_readdirargs { |
struct svc_fh fh; |
__u32 cookie; |
__u32 count; |
u32 * buffer; |
}; |
struct nfsd_attrstat { |
struct svc_fh fh; |
}; |
struct nfsd_diropres { |
struct svc_fh fh; |
}; |
struct nfsd_readlinkres { |
int len; |
}; |
struct nfsd_readres { |
struct svc_fh fh; |
unsigned long count; |
}; |
struct nfsd_readdirres { |
int count; |
struct readdir_cd common; |
u32 * buffer; |
int buflen; |
u32 * offset; |
}; |
struct nfsd_statfsres { |
struct kstatfs stats; |
}; |
/* |
* Storage requirements for XDR arguments and results. |
*/ |
union nfsd_xdrstore { |
struct nfsd_sattrargs sattr; |
struct nfsd_diropargs dirop; |
struct nfsd_readargs read; |
struct nfsd_writeargs write; |
struct nfsd_createargs create; |
struct nfsd_renameargs rename; |
struct nfsd_linkargs link; |
struct nfsd_symlinkargs symlink; |
struct nfsd_readdirargs readdir; |
}; |
#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) |
int nfssvc_decode_void(struct svc_rqst *, u32 *, void *); |
int nfssvc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); |
int nfssvc_decode_sattrargs(struct svc_rqst *, u32 *, |
struct nfsd_sattrargs *); |
int nfssvc_decode_diropargs(struct svc_rqst *, u32 *, |
struct nfsd_diropargs *); |
int nfssvc_decode_readargs(struct svc_rqst *, u32 *, |
struct nfsd_readargs *); |
int nfssvc_decode_writeargs(struct svc_rqst *, u32 *, |
struct nfsd_writeargs *); |
int nfssvc_decode_createargs(struct svc_rqst *, u32 *, |
struct nfsd_createargs *); |
int nfssvc_decode_renameargs(struct svc_rqst *, u32 *, |
struct nfsd_renameargs *); |
int nfssvc_decode_readlinkargs(struct svc_rqst *, u32 *, |
struct nfsd_readlinkargs *); |
int nfssvc_decode_linkargs(struct svc_rqst *, u32 *, |
struct nfsd_linkargs *); |
int nfssvc_decode_symlinkargs(struct svc_rqst *, u32 *, |
struct nfsd_symlinkargs *); |
int nfssvc_decode_readdirargs(struct svc_rqst *, u32 *, |
struct nfsd_readdirargs *); |
int nfssvc_encode_void(struct svc_rqst *, u32 *, void *); |
int nfssvc_encode_attrstat(struct svc_rqst *, u32 *, struct nfsd_attrstat *); |
int nfssvc_encode_diropres(struct svc_rqst *, u32 *, struct nfsd_diropres *); |
int nfssvc_encode_readlinkres(struct svc_rqst *, u32 *, struct nfsd_readlinkres *); |
int nfssvc_encode_readres(struct svc_rqst *, u32 *, struct nfsd_readres *); |
int nfssvc_encode_statfsres(struct svc_rqst *, u32 *, struct nfsd_statfsres *); |
int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *); |
int nfssvc_encode_entry(struct readdir_cd *, const char *name, |
int namlen, loff_t offset, ino_t ino, unsigned int); |
int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); |
#endif /* LINUX_NFSD_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/stats.h |
---|
0,0 → 1,44 |
/* |
* linux/include/nfsd/stats.h |
* |
* Statistics for NFS server. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef LINUX_NFSD_STATS_H |
#define LINUX_NFSD_STATS_H |
struct nfsd_stats { |
unsigned int rchits; /* repcache hits */ |
unsigned int rcmisses; /* repcache hits */ |
unsigned int rcnocache; /* uncached reqs */ |
unsigned int fh_stale; /* FH stale error */ |
unsigned int fh_lookup; /* dentry cached */ |
unsigned int fh_anon; /* anon file dentry returned */ |
unsigned int fh_nocache_dir; /* filehandle not found in dcache */ |
unsigned int fh_nocache_nondir; /* filehandle not found in dcache */ |
unsigned int io_read; /* bytes returned to read requests */ |
unsigned int io_write; /* bytes passed in write requests */ |
unsigned int th_cnt; /* number of available threads */ |
unsigned int th_usage[10]; /* number of ticks during which n perdeciles |
* of available threads were in use */ |
unsigned int th_fullcnt; /* number of times last free thread was used */ |
unsigned int ra_size; /* size of ra cache */ |
unsigned int ra_depth[11]; /* number of times ra entry was found that deep |
* in the cache (10percentiles). [10] = not found */ |
}; |
/* thread usage wraps very million seconds (approx one fortnight) */ |
#define NFSD_USAGE_WRAP (HZ*1000000) |
#ifdef __KERNEL__ |
extern struct nfsd_stats nfsdstats; |
extern struct svc_stat nfsd_svcstats; |
void nfsd_stat_init(void); |
void nfsd_stat_shutdown(void); |
#endif /* __KERNEL__ */ |
#endif /* LINUX_NFSD_STATS_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/xdr3.h |
---|
0,0 → 1,320 |
/* |
* linux/include/linux/nfsd/xdr3.h |
* |
* XDR types for NFSv3 in nfsd. |
* |
* Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_NFSD_XDR3_H |
#define _LINUX_NFSD_XDR3_H |
#include <linux/nfsd/xdr.h> |
struct nfsd3_sattrargs { |
struct svc_fh fh; |
struct iattr attrs; |
int check_guard; |
time_t guardtime; |
}; |
struct nfsd3_diropargs { |
struct svc_fh fh; |
char * name; |
int len; |
}; |
struct nfsd3_accessargs { |
struct svc_fh fh; |
unsigned int access; |
}; |
struct nfsd3_readargs { |
struct svc_fh fh; |
__u64 offset; |
__u32 count; |
struct iovec vec[RPCSVC_MAXPAGES]; |
int vlen; |
}; |
struct nfsd3_writeargs { |
svc_fh fh; |
__u64 offset; |
__u32 count; |
int stable; |
int len; |
struct iovec vec[RPCSVC_MAXPAGES]; |
int vlen; |
}; |
struct nfsd3_createargs { |
struct svc_fh fh; |
char * name; |
int len; |
int createmode; |
struct iattr attrs; |
__u32 * verf; |
}; |
struct nfsd3_mknodargs { |
struct svc_fh fh; |
char * name; |
int len; |
__u32 ftype; |
__u32 major, minor; |
struct iattr attrs; |
}; |
struct nfsd3_renameargs { |
struct svc_fh ffh; |
char * fname; |
int flen; |
struct svc_fh tfh; |
char * tname; |
int tlen; |
}; |
struct nfsd3_readlinkargs { |
struct svc_fh fh; |
char * buffer; |
}; |
struct nfsd3_linkargs { |
struct svc_fh ffh; |
struct svc_fh tfh; |
char * tname; |
int tlen; |
}; |
struct nfsd3_symlinkargs { |
struct svc_fh ffh; |
char * fname; |
int flen; |
char * tname; |
int tlen; |
struct iattr attrs; |
}; |
struct nfsd3_readdirargs { |
struct svc_fh fh; |
__u64 cookie; |
__u32 dircount; |
__u32 count; |
__u32 * verf; |
u32 * buffer; |
}; |
struct nfsd3_commitargs { |
struct svc_fh fh; |
__u64 offset; |
__u32 count; |
}; |
struct nfsd3_attrstat { |
__u32 status; |
struct svc_fh fh; |
}; |
/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ |
struct nfsd3_diropres { |
__u32 status; |
struct svc_fh dirfh; |
struct svc_fh fh; |
}; |
struct nfsd3_accessres { |
__u32 status; |
struct svc_fh fh; |
__u32 access; |
}; |
struct nfsd3_readlinkres { |
__u32 status; |
struct svc_fh fh; |
__u32 len; |
}; |
struct nfsd3_readres { |
__u32 status; |
struct svc_fh fh; |
unsigned long count; |
int eof; |
}; |
struct nfsd3_writeres { |
__u32 status; |
struct svc_fh fh; |
unsigned long count; |
int committed; |
}; |
struct nfsd3_renameres { |
__u32 status; |
struct svc_fh ffh; |
struct svc_fh tfh; |
}; |
struct nfsd3_linkres { |
__u32 status; |
struct svc_fh tfh; |
struct svc_fh fh; |
}; |
struct nfsd3_readdirres { |
__u32 status; |
struct svc_fh fh; |
int count; |
__u32 verf[2]; |
struct readdir_cd common; |
u32 * buffer; |
int buflen; |
u32 * offset; |
struct svc_rqst * rqstp; |
}; |
struct nfsd3_fsstatres { |
__u32 status; |
struct kstatfs stats; |
__u32 invarsec; |
}; |
struct nfsd3_fsinfores { |
__u32 status; |
__u32 f_rtmax; |
__u32 f_rtpref; |
__u32 f_rtmult; |
__u32 f_wtmax; |
__u32 f_wtpref; |
__u32 f_wtmult; |
__u32 f_dtpref; |
__u64 f_maxfilesize; |
__u32 f_properties; |
}; |
struct nfsd3_pathconfres { |
__u32 status; |
__u32 p_link_max; |
__u32 p_name_max; |
__u32 p_no_trunc; |
__u32 p_chown_restricted; |
__u32 p_case_insensitive; |
__u32 p_case_preserving; |
}; |
struct nfsd3_commitres { |
__u32 status; |
struct svc_fh fh; |
}; |
/* dummy type for release */ |
struct nfsd3_fhandle_pair { |
__u32 dummy; |
struct svc_fh fh1; |
struct svc_fh fh2; |
}; |
/* |
* Storage requirements for XDR arguments and results. |
*/ |
union nfsd3_xdrstore { |
struct nfsd3_sattrargs sattrargs; |
struct nfsd3_diropargs diropargs; |
struct nfsd3_readargs readargs; |
struct nfsd3_writeargs writeargs; |
struct nfsd3_createargs createargs; |
struct nfsd3_renameargs renameargs; |
struct nfsd3_linkargs linkargs; |
struct nfsd3_symlinkargs symlinkargs; |
struct nfsd3_readdirargs readdirargs; |
struct nfsd3_diropres diropres; |
struct nfsd3_accessres accessres; |
struct nfsd3_readlinkres readlinkres; |
struct nfsd3_readres readres; |
struct nfsd3_writeres writeres; |
struct nfsd3_renameres renameres; |
struct nfsd3_linkres linkres; |
struct nfsd3_readdirres readdirres; |
struct nfsd3_fsstatres fsstatres; |
struct nfsd3_fsinfores fsinfores; |
struct nfsd3_pathconfres pathconfres; |
struct nfsd3_commitres commitres; |
}; |
#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) |
int nfs3svc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); |
int nfs3svc_decode_sattrargs(struct svc_rqst *, u32 *, |
struct nfsd3_sattrargs *); |
int nfs3svc_decode_diropargs(struct svc_rqst *, u32 *, |
struct nfsd3_diropargs *); |
int nfs3svc_decode_accessargs(struct svc_rqst *, u32 *, |
struct nfsd3_accessargs *); |
int nfs3svc_decode_readargs(struct svc_rqst *, u32 *, |
struct nfsd3_readargs *); |
int nfs3svc_decode_writeargs(struct svc_rqst *, u32 *, |
struct nfsd3_writeargs *); |
int nfs3svc_decode_createargs(struct svc_rqst *, u32 *, |
struct nfsd3_createargs *); |
int nfs3svc_decode_mkdirargs(struct svc_rqst *, u32 *, |
struct nfsd3_createargs *); |
int nfs3svc_decode_mknodargs(struct svc_rqst *, u32 *, |
struct nfsd3_mknodargs *); |
int nfs3svc_decode_renameargs(struct svc_rqst *, u32 *, |
struct nfsd3_renameargs *); |
int nfs3svc_decode_readlinkargs(struct svc_rqst *, u32 *, |
struct nfsd3_readlinkargs *); |
int nfs3svc_decode_linkargs(struct svc_rqst *, u32 *, |
struct nfsd3_linkargs *); |
int nfs3svc_decode_symlinkargs(struct svc_rqst *, u32 *, |
struct nfsd3_symlinkargs *); |
int nfs3svc_decode_readdirargs(struct svc_rqst *, u32 *, |
struct nfsd3_readdirargs *); |
int nfs3svc_decode_readdirplusargs(struct svc_rqst *, u32 *, |
struct nfsd3_readdirargs *); |
int nfs3svc_decode_commitargs(struct svc_rqst *, u32 *, |
struct nfsd3_commitargs *); |
int nfs3svc_encode_voidres(struct svc_rqst *, u32 *, void *); |
int nfs3svc_encode_attrstat(struct svc_rqst *, u32 *, |
struct nfsd3_attrstat *); |
int nfs3svc_encode_wccstat(struct svc_rqst *, u32 *, |
struct nfsd3_attrstat *); |
int nfs3svc_encode_diropres(struct svc_rqst *, u32 *, |
struct nfsd3_diropres *); |
int nfs3svc_encode_accessres(struct svc_rqst *, u32 *, |
struct nfsd3_accessres *); |
int nfs3svc_encode_readlinkres(struct svc_rqst *, u32 *, |
struct nfsd3_readlinkres *); |
int nfs3svc_encode_readres(struct svc_rqst *, u32 *, struct nfsd3_readres *); |
int nfs3svc_encode_writeres(struct svc_rqst *, u32 *, struct nfsd3_writeres *); |
int nfs3svc_encode_createres(struct svc_rqst *, u32 *, |
struct nfsd3_diropres *); |
int nfs3svc_encode_renameres(struct svc_rqst *, u32 *, |
struct nfsd3_renameres *); |
int nfs3svc_encode_linkres(struct svc_rqst *, u32 *, |
struct nfsd3_linkres *); |
int nfs3svc_encode_readdirres(struct svc_rqst *, u32 *, |
struct nfsd3_readdirres *); |
int nfs3svc_encode_fsstatres(struct svc_rqst *, u32 *, |
struct nfsd3_fsstatres *); |
int nfs3svc_encode_fsinfores(struct svc_rqst *, u32 *, |
struct nfsd3_fsinfores *); |
int nfs3svc_encode_pathconfres(struct svc_rqst *, u32 *, |
struct nfsd3_pathconfres *); |
int nfs3svc_encode_commitres(struct svc_rqst *, u32 *, |
struct nfsd3_commitres *); |
int nfs3svc_release_fhandle(struct svc_rqst *, u32 *, |
struct nfsd3_attrstat *); |
int nfs3svc_release_fhandle2(struct svc_rqst *, u32 *, |
struct nfsd3_fhandle_pair *); |
int nfs3svc_encode_entry(struct readdir_cd *, const char *name, |
int namlen, loff_t offset, ino_t ino, |
unsigned int); |
int nfs3svc_encode_entry_plus(struct readdir_cd *, const char *name, |
int namlen, loff_t offset, ino_t ino, |
unsigned int); |
#endif /* _LINUX_NFSD_XDR3_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/interface.h |
---|
0,0 → 1,13 |
/* |
* include/linux/nfsd/interface.h |
* |
* defines interface between nfsd and other bits of |
* the kernel. Particularly filesystems (eventually). |
* |
* Copyright (C) 2000 Neil Brown <neilb@cse.unsw.edu.au> |
*/ |
#ifndef LINUX_NFSD_INTERFACE_H |
#define LINUX_NFSD_INTERFACE_H |
#endif /* LINUX_NFSD_INTERFACE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/state.h |
---|
0,0 → 1,205 |
/* |
* linux/include/nfsd/state.h |
* |
* Copyright (c) 2001 The Regents of the University of Michigan. |
* All rights reserved. |
* |
* Kendrick Smith <kmsmith@umich.edu> |
* Andy Adamson <andros@umich.edu> |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. Neither the name of the University nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
*/ |
#ifndef _NFSD4_STATE_H |
#define _NFSD4_STATE_H |
#include <linux/list.h> |
#define NFS4_OPAQUE_LIMIT 1024 |
typedef struct { |
u32 cl_boot; |
u32 cl_id; |
} clientid_t; |
typedef struct { |
u32 so_boot; |
u32 so_stateownerid; |
u32 so_fileid; |
} stateid_opaque_t; |
typedef struct { |
u32 si_generation; |
stateid_opaque_t si_opaque; |
} stateid_t; |
#define si_boot si_opaque.so_boot |
#define si_stateownerid si_opaque.so_stateownerid |
#define si_fileid si_opaque.so_fileid |
extern stateid_t zerostateid; |
extern stateid_t onestateid; |
#define ZERO_STATEID(stateid) (!memcmp((stateid), &zerostateid, sizeof(stateid_t))) |
#define ONE_STATEID(stateid) (!memcmp((stateid), &onestateid, sizeof(stateid_t))) |
/* |
* struct nfs4_client - one per client. Clientids live here. |
* o Each nfs4_client is hashed by clientid. |
* |
* o Each nfs4_clients is also hashed by name |
* (the opaque quantity initially sent by the client to identify itself). |
* |
* o cl_perclient list is used to ensure no dangling stateowner references |
* when we expire the nfs4_client |
*/ |
struct nfs4_client { |
struct list_head cl_idhash; /* hash by cl_clientid.id */ |
struct list_head cl_strhash; /* hash by cl_name */ |
struct list_head cl_perclient; /* list: stateowners */ |
struct list_head cl_lru; /* tail queue */ |
struct xdr_netobj cl_name; /* id generated by client */ |
nfs4_verifier cl_verifier; /* generated by client */ |
time_t cl_time; /* time of last lease renewal */ |
u32 cl_addr; /* client ipaddress */ |
struct svc_cred cl_cred; /* setclientid principal */ |
clientid_t cl_clientid; /* generated by server */ |
nfs4_verifier cl_confirm; /* generated by server */ |
}; |
static inline void |
update_stateid(stateid_t *stateid) |
{ |
stateid->si_generation++; |
} |
/* A reasonable value for REPLAY_ISIZE was estimated as follows: |
* The OPEN response, typically the largest, requires |
* 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) + |
* 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) + |
* 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes |
*/ |
#define NFSD4_REPLAY_ISIZE 112 |
/* |
* Replay buffer, where the result of the last seqid-mutating operation |
* is cached. |
*/ |
struct nfs4_replay { |
u32 rp_status; |
unsigned int rp_buflen; |
char *rp_buf; |
unsigned intrp_allocated; |
char rp_ibuf[NFSD4_REPLAY_ISIZE]; |
}; |
/* |
* nfs4_stateowner can either be an open_owner, or a lock_owner |
* |
* so_idhash: stateid_hashtbl[] for open owner, lockstateid_hashtbl[] |
* for lock_owner |
* so_strhash: ownerstr_hashtbl[] for open_owner, lock_ownerstr_hashtbl[] |
* for lock_owner |
* so_perclient: nfs4_client->cl_perclient entry - used when nfs4_client |
* struct is reaped. |
* so_perfilestate: heads the list of nfs4_stateid (either open or lock) |
* and is used to ensure no dangling nfs4_stateid references when we |
* release a stateowner. |
*/ |
struct nfs4_stateowner { |
struct list_head so_idhash; /* hash by so_id */ |
struct list_head so_strhash; /* hash by op_name */ |
struct list_head so_perclient; /* nfs4_client->cl_perclient */ |
struct list_head so_perfilestate; /* list: nfs4_stateid */ |
int so_is_open_owner; /* 1=openowner,0=lockowner */ |
u32 so_id; |
struct nfs4_client * so_client; |
u32 so_seqid; |
struct xdr_netobj so_owner; /* open owner name */ |
int so_confirmed; /* successful OPEN_CONFIRM? */ |
struct nfs4_replay so_replay; |
}; |
/* |
* nfs4_file: a file opened by some number of (open) nfs4_stateowners. |
* o fi_perfile list is used to search for conflicting |
* share_acces, share_deny on the file. |
*/ |
struct nfs4_file { |
struct list_head fi_hash; /* hash by "struct inode *" */ |
struct list_head fi_perfile; /* list: nfs4_stateid */ |
struct inode *fi_inode; |
u32 fi_id; /* used with stateowner->so_id |
* for stateid_hashtbl hash */ |
}; |
/* |
* nfs4_stateid can either be an open stateid or (eventually) a lock stateid |
* |
* (open)nfs4_stateid: one per (open)nfs4_stateowner, nfs4_file |
* |
* st_hash: stateid_hashtbl[] entry or lockstateid_hashtbl entry |
* st_perfile: file_hashtbl[] entry. |
* st_perfile_state: nfs4_stateowner->so_perfilestate |
* st_share_access: used only for open stateid |
* st_share_deny: used only for open stateid |
*/ |
struct nfs4_stateid { |
struct list_head st_hash; |
struct list_head st_perfile; |
struct list_head st_perfilestate; |
struct nfs4_stateowner * st_stateowner; |
struct nfs4_file * st_file; |
stateid_t st_stateid; |
struct file st_vfs_file; |
int st_vfs_set; |
unsigned int st_share_access; |
unsigned int st_share_deny; |
}; |
/* flags for preprocess_seqid_op() */ |
#define CHECK_FH 0x00000001 |
#define CONFIRM 0x00000002 |
#define OPEN_STATE 0x00000004 |
#define LOCK_STATE 0x00000008 |
#define RDWR_STATE 0x00000010 |
#define seqid_mutating_err(err) \ |
(((err) != nfserr_stale_clientid) && \ |
((err) != nfserr_bad_seqid) && \ |
((err) != nfserr_stale_stateid) && \ |
((err) != nfserr_bad_stateid)) |
extern time_t nfs4_laundromat(void); |
extern int nfsd4_renew(clientid_t *clid); |
extern int nfs4_preprocess_stateid_op(struct svc_fh *current_fh, |
stateid_t *stateid, int flags, struct nfs4_stateid **stpp); |
extern int nfs4_share_conflict(struct svc_fh *current_fh, |
unsigned int deny_type); |
extern void nfs4_lock_state(void); |
extern void nfs4_unlock_state(void); |
#endif /* NFSD4_STATE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/auth.h |
---|
0,0 → 1,27 |
/* |
* include/linux/nfsd/auth.h |
* |
* nfsd-specific authentication stuff. |
* uid/gid mapping not yet implemented. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef LINUX_NFSD_AUTH_H |
#define LINUX_NFSD_AUTH_H |
#ifdef __KERNEL__ |
#define nfsd_luid(rq, uid) ((u32)(uid)) |
#define nfsd_lgid(rq, gid) ((u32)(gid)) |
#define nfsd_ruid(rq, uid) ((u32)(uid)) |
#define nfsd_rgid(rq, gid) ((u32)(gid)) |
/* |
* Set the current process's fsuid/fsgid etc to those of the NFS |
* client user |
*/ |
void nfsd_setuser(struct svc_rqst *, struct svc_export *); |
#endif /* __KERNEL__ */ |
#endif /* LINUX_NFSD_AUTH_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/export.h |
---|
0,0 → 1,134 |
/* |
* include/linux/nfsd/export.h |
* |
* Public declarations for NFS exports. The definitions for the |
* syscall interface are in nfsctl.h |
* |
* Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef NFSD_EXPORT_H |
#define NFSD_EXPORT_H |
#include <asm/types.h> |
#ifdef __KERNEL__ |
# include <linux/types.h> |
# include <linux/in.h> |
#endif |
/* |
* Important limits for the exports stuff. |
*/ |
#define NFSCLNT_IDMAX 1024 |
#define NFSCLNT_ADDRMAX 16 |
#define NFSCLNT_KEYMAX 32 |
/* |
* Export flags. |
*/ |
#define NFSEXP_READONLY 0x0001 |
#define NFSEXP_INSECURE_PORT 0x0002 |
#define NFSEXP_ROOTSQUASH 0x0004 |
#define NFSEXP_ALLSQUASH 0x0008 |
#define NFSEXP_ASYNC 0x0010 |
#define NFSEXP_GATHERED_WRITES 0x0020 |
/* 40 80 100 currently unused */ |
#define NFSEXP_NOHIDE 0x0200 |
#define NFSEXP_NOSUBTREECHECK 0x0400 |
#define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */ |
#define NFSEXP_MSNFS 0x1000 /* do silly things that MS clients expect */ |
#define NFSEXP_FSID 0x2000 |
#define NFSEXP_CROSSMOUNT 0x4000 |
#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */ |
#define NFSEXP_ALLFLAGS 0xFE3F |
#ifdef __KERNEL__ |
struct svc_export { |
struct cache_head h; |
struct auth_domain * ex_client; |
int ex_flags; |
struct vfsmount * ex_mnt; |
struct dentry * ex_dentry; |
uid_t ex_anon_uid; |
gid_t ex_anon_gid; |
int ex_fsid; |
}; |
/* an "export key" (expkey) maps a filehandlefragement to an |
* svc_export for a given client. There can be two per export, one |
* for type 0 (dev/ino), one for type 1 (fsid) |
*/ |
struct svc_expkey { |
struct cache_head h; |
struct auth_domain * ek_client; |
int ek_fsidtype; |
u32 ek_fsid[3]; |
struct svc_export * ek_export; |
}; |
#define EX_SECURE(exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT)) |
#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) |
#define EX_RDONLY(exp) ((exp)->ex_flags & NFSEXP_READONLY) |
#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE) |
#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES) |
/* |
* Function declarations |
*/ |
void nfsd_export_init(void); |
void nfsd_export_shutdown(void); |
void nfsd_export_flush(void); |
void exp_readlock(void); |
void exp_readunlock(void); |
struct svc_expkey * exp_find_key(struct auth_domain *clp, |
int fsid_type, u32 *fsidv, |
struct cache_req *reqp); |
struct svc_export * exp_get_by_name(struct auth_domain *clp, |
struct vfsmount *mnt, |
struct dentry *dentry, |
struct cache_req *reqp); |
struct svc_export * exp_parent(struct auth_domain *clp, |
struct vfsmount *mnt, |
struct dentry *dentry, |
struct cache_req *reqp); |
int exp_rootfh(struct auth_domain *, |
char *path, struct knfsd_fh *, int maxsize); |
int exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq); |
int nfserrno(int errno); |
extern void expkey_put(struct cache_head *item, struct cache_detail *cd); |
extern void svc_export_put(struct cache_head *item, struct cache_detail *cd); |
extern struct cache_detail svc_export_cache, svc_expkey_cache; |
static inline void exp_put(struct svc_export *exp) |
{ |
svc_export_put(&exp->h, &svc_export_cache); |
} |
static inline struct svc_export * |
exp_find(struct auth_domain *clp, int fsid_type, u32 *fsidv, |
struct cache_req *reqp) |
{ |
struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp); |
if (ek && !IS_ERR(ek)) { |
struct svc_export *exp = ek->ek_export; |
int err; |
cache_get(&exp->h); |
expkey_put(&ek->h, &svc_expkey_cache); |
if (exp && |
(err = cache_check(&svc_export_cache, &exp->h, reqp))) |
exp = ERR_PTR(err); |
return exp; |
} else |
return ERR_PTR(PTR_ERR(ek)); |
} |
#endif /* __KERNEL__ */ |
#endif /* NFSD_EXPORT_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/xdr4.h |
---|
0,0 → 1,448 |
/* |
* include/linux/nfsd/xdr4.h |
* |
* Server-side types for NFSv4. |
* |
* Copyright (c) 2002 The Regents of the University of Michigan. |
* All rights reserved. |
* |
* Kendrick Smith <kmsmith@umich.edu> |
* Andy Adamson <andros@umich.edu> |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. Neither the name of the University nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
*/ |
#ifndef _LINUX_NFSD_XDR4_H |
#define _LINUX_NFSD_XDR4_H |
#define NFSD4_MAX_TAGLEN 128 |
#define XDR_LEN(n) (((n) + 3) & ~3) |
typedef u32 delegation_zero_t; |
typedef u32 delegation_boot_t; |
typedef u64 delegation_id_t; |
typedef struct { |
delegation_zero_t ds_zero; |
delegation_boot_t ds_boot; |
delegation_id_t ds_id; |
} delegation_stateid_t; |
struct nfsd4_change_info { |
u32 atomic; |
u32 before_size; |
u32 before_ctime; |
u32 after_size; |
u32 after_ctime; |
}; |
struct nfsd4_access { |
u32 ac_req_access; /* request */ |
u32 ac_supported; /* response */ |
u32 ac_resp_access; /* response */ |
}; |
struct nfsd4_close { |
u32 cl_seqid; /* request */ |
stateid_t cl_stateid; /* request+response */ |
struct nfs4_stateowner * cl_stateowner; /* response */ |
}; |
struct nfsd4_commit { |
u64 co_offset; /* request */ |
u32 co_count; /* request */ |
nfs4_verifier co_verf; /* response */ |
}; |
struct nfsd4_create { |
u32 cr_namelen; /* request */ |
char * cr_name; /* request */ |
u32 cr_type; /* request */ |
union { /* request */ |
struct { |
u32 namelen; |
char *name; |
} link; /* NF4LNK */ |
struct { |
u32 specdata1; |
u32 specdata2; |
} dev; /* NF4BLK, NF4CHR */ |
} u; |
u32 cr_bmval[2]; /* request */ |
struct iattr cr_iattr; /* request */ |
struct nfsd4_change_info cr_cinfo; /* response */ |
}; |
#define cr_linklen u.link.namelen |
#define cr_linkname u.link.name |
#define cr_specdata1 u.dev.specdata1 |
#define cr_specdata2 u.dev.specdata2 |
struct nfsd4_getattr { |
u32 ga_bmval[2]; /* request */ |
struct svc_fh *ga_fhp; /* response */ |
}; |
struct nfsd4_link { |
u32 li_namelen; /* request */ |
char * li_name; /* request */ |
struct nfsd4_change_info li_cinfo; /* response */ |
}; |
struct nfsd4_lock_denied { |
struct nfs4_stateowner *ld_sop; |
u64 ld_start; |
u64 ld_length; |
u32 ld_type; |
}; |
struct nfsd4_lock { |
/* request */ |
u32 lk_type; |
u32 lk_reclaim; /* boolean */ |
u64 lk_offset; |
u64 lk_length; |
u32 lk_is_new; |
union { |
struct { |
u32 open_seqid; |
stateid_t open_stateid; |
u32 lock_seqid; |
clientid_t clientid; |
struct xdr_netobj owner; |
} new; |
struct { |
stateid_t lock_stateid; |
u32 lock_seqid; |
} old; |
} v; |
/* response */ |
union { |
struct { |
stateid_t stateid; |
} ok; |
struct nfsd4_lock_denied denied; |
} u; |
struct nfs4_stateowner *lk_stateowner; |
}; |
#define lk_new_open_seqid v.new.open_seqid |
#define lk_new_open_stateid v.new.open_stateid |
#define lk_new_lock_seqid v.new.lock_seqid |
#define lk_new_clientid v.new.clientid |
#define lk_new_owner v.new.owner |
#define lk_old_lock_stateid v.old.lock_stateid |
#define lk_old_lock_seqid v.old.lock_seqid |
#define lk_rflags u.ok.rflags |
#define lk_resp_stateid u.ok.stateid |
#define lk_denied u.denied |
struct nfsd4_lockt { |
u32 lt_type; |
clientid_t lt_clientid; |
struct xdr_netobj lt_owner; |
u64 lt_offset; |
u64 lt_length; |
struct nfs4_stateowner * lt_stateowner; |
struct nfsd4_lock_denied lt_denied; |
}; |
struct nfsd4_locku { |
u32 lu_type; |
u32 lu_seqid; |
stateid_t lu_stateid; |
u64 lu_offset; |
u64 lu_length; |
struct nfs4_stateowner *lu_stateowner; |
}; |
struct nfsd4_lookup { |
u32 lo_len; /* request */ |
char * lo_name; /* request */ |
}; |
struct nfsd4_putfh { |
u32 pf_fhlen; /* request */ |
char *pf_fhval; /* request */ |
}; |
struct nfsd4_open { |
u32 op_claim_type; /* request */ |
struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */ |
u32 op_delegate_type; /* request - CLAIM_PREV only */ |
delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */ |
u32 op_create; /* request */ |
u32 op_createmode; /* request */ |
u32 op_bmval[2]; /* request */ |
union { /* request */ |
struct iattr iattr; /* UNCHECKED4,GUARDED4 */ |
nfs4_verifier verf; /* EXCLUSIVE4 */ |
} u; |
clientid_t op_clientid; /* request */ |
struct xdr_netobj op_owner; /* request */ |
u32 op_seqid; /* request */ |
u32 op_share_access; /* request */ |
u32 op_share_deny; /* request */ |
stateid_t op_stateid; /* response */ |
struct nfsd4_change_info op_cinfo; /* response */ |
u32 op_rflags; /* response */ |
int op_truncate; /* used during processing */ |
struct nfs4_stateowner *op_stateowner; /* used during processing */ |
}; |
#define op_iattr u.iattr |
#define op_verf u.verf |
struct nfsd4_open_confirm { |
stateid_t oc_req_stateid /* request */; |
u32 oc_seqid /* request */; |
stateid_t oc_resp_stateid /* response */; |
struct nfs4_stateowner * oc_stateowner; /* response */ |
}; |
struct nfsd4_open_downgrade { |
stateid_t od_stateid; |
u32 od_seqid; |
u32 od_share_access; |
u32 od_share_deny; |
struct nfs4_stateowner *od_stateowner; |
}; |
struct nfsd4_read { |
stateid_t rd_stateid; /* request */ |
u64 rd_offset; /* request */ |
u32 rd_length; /* request */ |
struct iovec rd_iov[RPCSVC_MAXPAGES]; |
int rd_vlen; |
struct svc_rqst *rd_rqstp; /* response */ |
struct svc_fh * rd_fhp; /* response */ |
}; |
struct nfsd4_readdir { |
u64 rd_cookie; /* request */ |
nfs4_verifier rd_verf; /* request */ |
u32 rd_dircount; /* request */ |
u32 rd_maxcount; /* request */ |
u32 rd_bmval[2]; /* request */ |
struct svc_rqst *rd_rqstp; /* response */ |
struct svc_fh * rd_fhp; /* response */ |
struct readdir_cd common; |
u32 * buffer; |
int buflen; |
u32 * offset; |
}; |
struct nfsd4_readlink { |
struct svc_rqst *rl_rqstp; /* request */ |
struct svc_fh * rl_fhp; /* request */ |
}; |
struct nfsd4_remove { |
u32 rm_namelen; /* request */ |
char * rm_name; /* request */ |
struct nfsd4_change_info rm_cinfo; /* response */ |
}; |
struct nfsd4_rename { |
u32 rn_snamelen; /* request */ |
char * rn_sname; /* request */ |
u32 rn_tnamelen; /* request */ |
char * rn_tname; /* request */ |
struct nfsd4_change_info rn_sinfo; /* response */ |
struct nfsd4_change_info rn_tinfo; /* response */ |
}; |
struct nfsd4_setattr { |
stateid_t sa_stateid; /* request */ |
u32 sa_bmval[2]; /* request */ |
struct iattr sa_iattr; /* request */ |
}; |
struct nfsd4_setclientid { |
nfs4_verifier se_verf; /* request */ |
u32 se_namelen; /* request */ |
char * se_name; /* request */ |
u32 se_callback_prog; /* request */ |
u32 se_callback_netid_len; /* request */ |
char * se_callback_netid_val; /* request */ |
u32 se_callback_addr_len; /* request */ |
char * se_callback_addr_val; /* request */ |
u32 se_callback_ident; /* request */ |
clientid_t se_clientid; /* response */ |
nfs4_verifier se_confirm; /* response */ |
}; |
struct nfsd4_setclientid_confirm { |
clientid_t sc_clientid; |
nfs4_verifier sc_confirm; |
}; |
/* also used for NVERIFY */ |
struct nfsd4_verify { |
u32 ve_bmval[2]; /* request */ |
u32 ve_attrlen; /* request */ |
char * ve_attrval; /* request */ |
}; |
struct nfsd4_write { |
stateid_t wr_stateid; /* request */ |
u64 wr_offset; /* request */ |
u32 wr_stable_how; /* request */ |
u32 wr_buflen; /* request */ |
struct iovec wr_vec[RPCSVC_MAXPAGES]; /* request */ |
int wr_vlen; |
u32 wr_bytes_written; /* response */ |
u32 wr_how_written; /* response */ |
nfs4_verifier wr_verifier; /* response */ |
}; |
struct nfsd4_op { |
int opnum; |
int status; |
union { |
struct nfsd4_access access; |
struct nfsd4_close close; |
struct nfsd4_commit commit; |
struct nfsd4_create create; |
struct nfsd4_getattr getattr; |
struct svc_fh * getfh; |
struct nfsd4_link link; |
struct nfsd4_lock lock; |
struct nfsd4_lockt lockt; |
struct nfsd4_locku locku; |
struct nfsd4_lookup lookup; |
struct nfsd4_verify nverify; |
struct nfsd4_open open; |
struct nfsd4_open_confirm open_confirm; |
struct nfsd4_open_downgrade open_downgrade; |
struct nfsd4_putfh putfh; |
struct nfsd4_read read; |
struct nfsd4_readdir readdir; |
struct nfsd4_readlink readlink; |
struct nfsd4_remove remove; |
struct nfsd4_rename rename; |
clientid_t renew; |
struct nfsd4_setattr setattr; |
struct nfsd4_setclientid setclientid; |
struct nfsd4_setclientid_confirm setclientid_confirm; |
struct nfsd4_verify verify; |
struct nfsd4_write write; |
} u; |
struct nfs4_replay * replay; |
}; |
struct nfsd4_compoundargs { |
/* scratch variables for XDR decode */ |
u32 * p; |
u32 * end; |
struct page ** pagelist; |
int pagelen; |
u32 tmp[8]; |
u32 * tmpp; |
struct tmpbuf { |
struct tmpbuf *next; |
void *buf; |
} *to_free; |
u32 taglen; |
char * tag; |
u32 minorversion; |
u32 opcnt; |
struct nfsd4_op *ops; |
struct nfsd4_op iops[8]; |
}; |
struct nfsd4_compoundres { |
/* scratch variables for XDR encode */ |
u32 * p; |
u32 * end; |
struct xdr_buf * xbuf; |
struct svc_rqst * rqstp; |
u32 taglen; |
char * tag; |
u32 opcnt; |
u32 * tagp; /* where to encode tag and opcount */ |
}; |
#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) |
static inline void |
set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) |
{ |
BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved); |
cinfo->atomic = 1; |
cinfo->before_size = fhp->fh_pre_size; |
cinfo->before_ctime = fhp->fh_pre_ctime.tv_sec; |
cinfo->after_size = fhp->fh_post_size; |
cinfo->after_ctime = fhp->fh_post_ctime.tv_sec; |
} |
int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *); |
int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *, |
struct nfsd4_compoundargs *); |
int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *, |
struct nfsd4_compoundres *); |
void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); |
void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); |
int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, |
struct dentry *dentry, u32 *buffer, int *countp, |
u32 *bmval); |
extern int nfsd4_setclientid(struct svc_rqst *rqstp, |
struct nfsd4_setclientid *setclid); |
extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp, |
struct nfsd4_setclientid_confirm *setclientid_confirm); |
extern int nfsd4_process_open1(struct nfsd4_open *open); |
extern int nfsd4_process_open2(struct svc_rqst *rqstp, |
struct svc_fh *current_fh, struct nfsd4_open *open); |
extern int nfsd4_open_confirm(struct svc_rqst *rqstp, |
struct svc_fh *current_fh, struct nfsd4_open_confirm *oc); |
extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
struct nfsd4_close *close); |
extern int nfsd4_open_downgrade(struct svc_rqst *rqstp, |
struct svc_fh *current_fh, struct nfsd4_open_downgrade *od); |
extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
struct nfsd4_lock *lock); |
extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
struct nfsd4_lockt *lockt); |
extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
struct nfsd4_locku *locku); |
#endif |
/* |
* Local variables: |
* c-basic-offset: 8 |
* End: |
*/ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/cache.h |
---|
0,0 → 1,82 |
/* |
* include/linux/nfsd/cache.h |
* |
* Request reply cache. This was heavily inspired by the |
* implementation in 4.3BSD/4.4BSD. |
* |
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef NFSCACHE_H |
#define NFSCACHE_H |
#ifdef __KERNEL__ |
#include <linux/in.h> |
#include <linux/uio.h> |
/* |
* Representation of a reply cache entry. The first two members *must* |
* be hash_next and hash_prev. |
*/ |
struct svc_cacherep { |
struct svc_cacherep * c_hash_next; |
struct svc_cacherep * c_hash_prev; |
struct svc_cacherep * c_lru_next; |
struct svc_cacherep * c_lru_prev; |
unsigned char c_state, /* unused, inprog, done */ |
c_type, /* status, buffer */ |
c_secure : 1; /* req came from port < 1024 */ |
struct sockaddr_in c_addr; |
u32 c_xid; |
u32 c_prot; |
u32 c_proc; |
u32 c_vers; |
unsigned long c_timestamp; |
union { |
struct iovec u_vec; |
u32 u_status; |
} c_u; |
}; |
#define c_replvec c_u.u_vec |
#define c_replstat c_u.u_status |
/* cache entry states */ |
enum { |
RC_UNUSED, |
RC_INPROG, |
RC_DONE |
}; |
/* return values */ |
enum { |
RC_DROPIT, |
RC_REPLY, |
RC_DOIT, |
RC_INTR |
}; |
/* |
* Cache types. |
* We may want to add more types one day, e.g. for diropres and |
* attrstat replies. Using cache entries with fixed length instead |
* of buffer pointers may be more efficient. |
*/ |
enum { |
RC_NOCACHE, |
RC_REPLSTAT, |
RC_REPLBUFF, |
}; |
/* |
* If requests are retransmitted within this interval, they're dropped. |
*/ |
#define RC_DELAY (HZ/5) |
void nfsd_cache_init(void); |
void nfsd_cache_shutdown(void); |
int nfsd_cache_lookup(struct svc_rqst *, int); |
void nfsd_cache_update(struct svc_rqst *, int, u32 *); |
#endif /* __KERNEL__ */ |
#endif /* NFSCACHE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/nfsfh.h |
---|
0,0 → 1,345 |
/* |
* include/linux/nfsd/nfsfh.h |
* |
* This file describes the layout of the file handles as passed |
* over the wire. |
* |
* Earlier versions of knfsd used to sign file handles using keyed MD5 |
* or SHA. I've removed this code, because it doesn't give you more |
* security than blocking external access to port 2049 on your firewall. |
* |
* Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_NFSD_FH_H |
#define _LINUX_NFSD_FH_H |
#include <asm/types.h> |
#ifdef __KERNEL__ |
# include <linux/config.h> |
# include <linux/types.h> |
# include <linux/string.h> |
# include <linux/fs.h> |
#endif |
#include <linux/nfsd/const.h> |
#include <linux/nfsd/debug.h> |
/* |
* This is the old "dentry style" Linux NFSv2 file handle. |
* |
* The xino and xdev fields are currently used to transport the |
* ino/dev of the exported inode. |
*/ |
struct nfs_fhbase_old { |
__u32 fb_dcookie; /* dentry cookie - always 0xfeebbaca */ |
__u32 fb_ino; /* our inode number */ |
__u32 fb_dirino; /* dir inode number, 0 for directories */ |
__u32 fb_dev; /* our device */ |
__u32 fb_xdev; |
__u32 fb_xino; |
__u32 fb_generation; |
}; |
/* |
* This is the new flexible, extensible style NFSv2/v3 file handle. |
* by Neil Brown <neilb@cse.unsw.edu.au> - March 2000 |
* |
* The file handle is seens as a list of 4byte words. |
* The first word contains a version number (1) and four descriptor bytes |
* that tell how the remaining 3 variable length fields should be handled. |
* These three bytes are auth_type, fsid_type and fileid_type. |
* |
* All 4byte values are in host-byte-order. |
* |
* The auth_type field specifies how the filehandle can be authenticated |
* This might allow a file to be confirmed to be in a writable part of a |
* filetree without checking the path from it upto the root. |
* Current values: |
* 0 - No authentication. fb_auth is 0 bytes long |
* Possible future values: |
* 1 - 4 bytes taken from MD5 hash of the remainer of the file handle |
* prefixed by a secret and with the important export flags. |
* |
* The fsid_type identifies how the filesystem (or export point) is |
* encoded. |
* Current values: |
* 0 - 4 byte device id (ms-2-bytes major, ls-2-bytes minor), 4byte inode number |
* NOTE: we cannot use the kdev_t device id value, because kdev_t.h |
* says we mustn't. We must break it up and reassemble. |
* Possible future encodings: |
* 1 - 4 byte user specified identifier |
* |
* The fileid_type identified how the file within the filesystem is encoded. |
* This is (will be) passed to, and set by, the underlying filesystem if it supports |
* filehandle operations. The filesystem must not use the value '0' or '0xff' and may |
* only use the values 1 and 2 as defined below: |
* Current values: |
* 0 - The root, or export point, of the filesystem. fb_fileid is 0 bytes. |
* 1 - 32bit inode number, 32 bit generation number. |
* 2 - 32bit inode number, 32 bit generation number, 32 bit parent directory inode number. |
* |
*/ |
struct nfs_fhbase_new { |
__u8 fb_version; /* == 1, even => nfs_fhbase_old */ |
__u8 fb_auth_type; |
__u8 fb_fsid_type; |
__u8 fb_fileid_type; |
__u32 fb_auth[1]; |
/* __u32 fb_fsid[0]; floating */ |
/* __u32 fb_fileid[0]; floating */ |
}; |
struct knfsd_fh { |
unsigned int fh_size; /* significant for NFSv3. |
* Points to the current size while building |
* a new file handle |
*/ |
union { |
struct nfs_fhbase_old fh_old; |
__u32 fh_pad[NFS4_FHSIZE/4]; |
struct nfs_fhbase_new fh_new; |
} fh_base; |
}; |
#define ofh_dcookie fh_base.fh_old.fb_dcookie |
#define ofh_ino fh_base.fh_old.fb_ino |
#define ofh_dirino fh_base.fh_old.fb_dirino |
#define ofh_dev fh_base.fh_old.fb_dev |
#define ofh_xdev fh_base.fh_old.fb_xdev |
#define ofh_xino fh_base.fh_old.fb_xino |
#define ofh_generation fh_base.fh_old.fb_generation |
#define fh_version fh_base.fh_new.fb_version |
#define fh_fsid_type fh_base.fh_new.fb_fsid_type |
#define fh_auth_type fh_base.fh_new.fb_auth_type |
#define fh_fileid_type fh_base.fh_new.fb_fileid_type |
#define fh_auth fh_base.fh_new.fb_auth |
#ifdef __KERNEL__ |
static inline __u32 ino_t_to_u32(ino_t ino) |
{ |
return (__u32) ino; |
} |
static inline ino_t u32_to_ino_t(__u32 uino) |
{ |
return (ino_t) uino; |
} |
/* |
* This is the internal representation of an NFS handle used in knfsd. |
* pre_mtime/post_version will be used to support wcc_attr's in NFSv3. |
*/ |
typedef struct svc_fh { |
struct knfsd_fh fh_handle; /* FH data */ |
struct dentry * fh_dentry; /* validated dentry */ |
struct svc_export * fh_export; /* export pointer */ |
int fh_maxsize; /* max size for fh_handle */ |
unsigned char fh_locked; /* inode locked by us */ |
#ifdef CONFIG_NFSD_V3 |
unsigned char fh_post_saved; /* post-op attrs saved */ |
unsigned char fh_pre_saved; /* pre-op attrs saved */ |
/* Pre-op attributes saved during fh_lock */ |
__u64 fh_pre_size; /* size before operation */ |
struct timespec fh_pre_mtime; /* mtime before oper */ |
struct timespec fh_pre_ctime; /* ctime before oper */ |
/* Post-op attributes saved in fh_unlock */ |
umode_t fh_post_mode; /* i_mode */ |
nlink_t fh_post_nlink; /* i_nlink */ |
uid_t fh_post_uid; /* i_uid */ |
gid_t fh_post_gid; /* i_gid */ |
__u64 fh_post_size; /* i_size */ |
unsigned long fh_post_blocks; /* i_blocks */ |
unsigned long fh_post_blksize;/* i_blksize */ |
__u32 fh_post_rdev[2];/* i_rdev */ |
struct timespec fh_post_atime; /* i_atime */ |
struct timespec fh_post_mtime; /* i_mtime */ |
struct timespec fh_post_ctime; /* i_ctime */ |
#endif /* CONFIG_NFSD_V3 */ |
} svc_fh; |
static inline void mk_fsid_v0(u32 *fsidv, dev_t dev, ino_t ino) |
{ |
fsidv[0] = htonl((MAJOR(dev)<<16) | |
MINOR(dev)); |
fsidv[1] = ino_t_to_u32(ino); |
} |
static inline void mk_fsid_v1(u32 *fsidv, u32 fsid) |
{ |
fsidv[0] = fsid; |
} |
static inline void mk_fsid_v2(u32 *fsidv, dev_t dev, ino_t ino) |
{ |
fsidv[0] = htonl(MAJOR(dev)); |
fsidv[1] = htonl(MINOR(dev)); |
fsidv[2] = ino_t_to_u32(ino); |
} |
/* |
* Shorthand for dprintk()'s |
*/ |
inline static char * SVCFH_fmt(struct svc_fh *fhp) |
{ |
struct knfsd_fh *fh = &fhp->fh_handle; |
static char buf[80]; |
sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x", |
fh->fh_size, |
fh->fh_base.fh_pad[0], |
fh->fh_base.fh_pad[1], |
fh->fh_base.fh_pad[2], |
fh->fh_base.fh_pad[3], |
fh->fh_base.fh_pad[4], |
fh->fh_base.fh_pad[5]); |
return buf; |
} |
/* |
* Function prototypes |
*/ |
u32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int); |
int fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *); |
int fh_update(struct svc_fh *); |
void fh_put(struct svc_fh *); |
static __inline__ struct svc_fh * |
fh_copy(struct svc_fh *dst, struct svc_fh *src) |
{ |
if (src->fh_dentry || src->fh_locked) { |
struct dentry *dentry = src->fh_dentry; |
printk(KERN_ERR "fh_copy: copying %s/%s, already verified!\n", |
dentry->d_parent->d_name.name, dentry->d_name.name); |
} |
*dst = *src; |
return dst; |
} |
static __inline__ void |
fh_dup2(struct svc_fh *dst, struct svc_fh *src) |
{ |
fh_put(dst); |
dget(src->fh_dentry); |
*dst = *src; |
} |
static __inline__ struct svc_fh * |
fh_init(struct svc_fh *fhp, int maxsize) |
{ |
memset(fhp, 0, sizeof(*fhp)); |
fhp->fh_maxsize = maxsize; |
return fhp; |
} |
#ifdef CONFIG_NFSD_V3 |
/* |
* Fill in the pre_op attr for the wcc data |
*/ |
static inline void |
fill_pre_wcc(struct svc_fh *fhp) |
{ |
struct inode *inode; |
inode = fhp->fh_dentry->d_inode; |
if (!fhp->fh_pre_saved) { |
fhp->fh_pre_mtime = inode->i_mtime; |
fhp->fh_pre_ctime = inode->i_ctime; |
fhp->fh_pre_size = inode->i_size; |
fhp->fh_pre_saved = 1; |
} |
} |
/* |
* Fill in the post_op attr for the wcc data |
*/ |
static inline void |
fill_post_wcc(struct svc_fh *fhp) |
{ |
struct inode *inode = fhp->fh_dentry->d_inode; |
if (fhp->fh_post_saved) |
printk("nfsd: inode locked twice during operation.\n"); |
fhp->fh_post_mode = inode->i_mode; |
fhp->fh_post_nlink = inode->i_nlink; |
fhp->fh_post_uid = inode->i_uid; |
fhp->fh_post_gid = inode->i_gid; |
fhp->fh_post_size = inode->i_size; |
if (inode->i_blksize) { |
fhp->fh_post_blksize = inode->i_blksize; |
fhp->fh_post_blocks = inode->i_blocks; |
} else { |
fhp->fh_post_blksize = BLOCK_SIZE; |
/* how much do we care for accuracy with MinixFS? */ |
fhp->fh_post_blocks = (inode->i_size+511) >> 9; |
} |
fhp->fh_post_rdev[0] = htonl((u32)imajor(inode)); |
fhp->fh_post_rdev[1] = htonl((u32)iminor(inode)); |
fhp->fh_post_atime = inode->i_atime; |
fhp->fh_post_mtime = inode->i_mtime; |
fhp->fh_post_ctime = inode->i_ctime; |
fhp->fh_post_saved = 1; |
} |
#else |
#define fill_pre_wcc(ignored) |
#define fill_post_wcc(notused) |
#endif /* CONFIG_NFSD_V3 */ |
/* |
* Lock a file handle/inode |
* NOTE: both fh_lock and fh_unlock are done "by hand" in |
* vfs.c:nfsd_rename as it needs to grab 2 i_sem's at once |
* so, any changes here should be reflected there. |
*/ |
static inline void |
fh_lock(struct svc_fh *fhp) |
{ |
struct dentry *dentry = fhp->fh_dentry; |
struct inode *inode; |
dfprintk(FILEOP, "nfsd: fh_lock(%s) locked = %d\n", |
SVCFH_fmt(fhp), fhp->fh_locked); |
if (!fhp->fh_dentry) { |
printk(KERN_ERR "fh_lock: fh not verified!\n"); |
return; |
} |
if (fhp->fh_locked) { |
printk(KERN_WARNING "fh_lock: %s/%s already locked!\n", |
dentry->d_parent->d_name.name, dentry->d_name.name); |
return; |
} |
inode = dentry->d_inode; |
down(&inode->i_sem); |
fill_pre_wcc(fhp); |
fhp->fh_locked = 1; |
} |
/* |
* Unlock a file handle/inode |
*/ |
static inline void |
fh_unlock(struct svc_fh *fhp) |
{ |
if (!fhp->fh_dentry) |
printk(KERN_ERR "fh_unlock: fh not verified!\n"); |
if (fhp->fh_locked) { |
fill_post_wcc(fhp); |
up(&fhp->fh_dentry->d_inode->i_sem); |
fhp->fh_locked = 0; |
} |
} |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_NFSD_FH_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/debug.h |
---|
0,0 → 1,48 |
/* |
* linux/include/linux/nfsd/debug.h |
* |
* Debugging-related stuff for nfsd |
* |
* Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef LINUX_NFSD_DEBUG_H |
#define LINUX_NFSD_DEBUG_H |
#include <linux/sunrpc/debug.h> |
/* |
* Enable debugging for nfsd. |
* Requires RPC_DEBUG. |
*/ |
#ifdef RPC_DEBUG |
# define NFSD_DEBUG 1 |
#endif |
/* |
* knfsd debug flags |
*/ |
#define NFSDDBG_SOCK 0x0001 |
#define NFSDDBG_FH 0x0002 |
#define NFSDDBG_EXPORT 0x0004 |
#define NFSDDBG_SVC 0x0008 |
#define NFSDDBG_PROC 0x0010 |
#define NFSDDBG_FILEOP 0x0020 |
#define NFSDDBG_AUTH 0x0040 |
#define NFSDDBG_REPCACHE 0x0080 |
#define NFSDDBG_XDR 0x0100 |
#define NFSDDBG_LOCKD 0x0200 |
#define NFSDDBG_ALL 0x7FFF |
#define NFSDDBG_NOCHANGE 0xFFFF |
#ifdef __KERNEL__ |
# undef ifdebug |
# ifdef NFSD_DEBUG |
# define ifdebug(flag) if (nfsd_debug & NFSDDBG_##flag) |
# else |
# define ifdebug(flag) if (0) |
# endif |
#endif /* __KERNEL__ */ |
#endif /* LINUX_NFSD_DEBUG_H */ |
/shark/trunk/drivers/linuxc26/include/linux/nfsd/const.h |
---|
0,0 → 1,45 |
/* |
* include/linux/nfsd/const.h |
* |
* Various constants related to NFS. |
* |
* Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
*/ |
#ifndef _LINUX_NFSD_CONST_H |
#define _LINUX_NFSD_CONST_H |
#include <linux/nfs.h> |
#include <linux/nfs2.h> |
#include <linux/nfs3.h> |
#include <linux/nfs4.h> |
/* |
* Maximum protocol version supported by knfsd |
*/ |
#define NFSSVC_MAXVERS 3 |
/* |
* Maximum blocksize supported by daemon currently at 32K |
*/ |
#define NFSSVC_MAXBLKSIZE (32*1024) |
#ifdef __KERNEL__ |
#ifndef NFS_SUPER_MAGIC |
# define NFS_SUPER_MAGIC 0x6969 |
#endif |
#define NFSD_BUFSIZE (1024 + NFSSVC_MAXBLKSIZE) |
#ifdef CONFIG_NFSD_V4 |
# define NFSSVC_XDRSIZE NFS4_SVC_XDRSIZE |
#elif defined(CONFIG_NFSD_V3) |
# define NFSSVC_XDRSIZE NFS3_SVC_XDRSIZE |
#else |
# define NFSSVC_XDRSIZE NFS2_SVC_XDRSIZE |
#endif |
#endif /* __KERNEL__ */ |
#endif /* _LINUX_NFSD_CONST_H */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/nand_ecc.h |
---|
0,0 → 1,28 |
/* |
* drivers/mtd/nand_ecc.h |
* |
* Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) |
* |
* $Id: nand_ecc.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License version 2 as |
* published by the Free Software Foundation. |
* |
* This file is the header for the ECC algorithm. |
*/ |
/* |
* Creates non-inverted ECC code from line parity |
*/ |
void nand_trans_result(u_char reg2, u_char reg3, u_char *ecc_code); |
/* |
* Calculate 3 byte ECC code for 256 byte block |
*/ |
void nand_calculate_ecc (const u_char *dat, u_char *ecc_code); |
/* |
* Detect and correct a 1 bit error for 256 byte block |
*/ |
int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc); |
/shark/trunk/drivers/linuxc26/include/linux/mtd/partitions.h |
---|
0,0 → 1,76 |
/* |
* MTD partitioning layer definitions |
* |
* (C) 2000 Nicolas Pitre <nico@cam.org> |
* |
* This code is GPL |
* |
* $Id: partitions.h,v 1.1 2004-01-28 15:30:51 giacomo Exp $ |
*/ |
#ifndef MTD_PARTITIONS_H |
#define MTD_PARTITIONS_H |
#include <linux/types.h> |
/* |
* Partition definition structure: |
* |
* An array of struct partition is passed along with a MTD object to |
* add_mtd_partitions() to create them. |
* |
* For each partition, these fields are available: |
* name: string that will be used to label the partition's MTD device. |
* size: the partition size; if defined as MTDPART_SIZ_FULL, the partition |
* will extend to the end of the master MTD device. |
* offset: absolute starting position within the master MTD device; if |
* defined as MTDPART_OFS_APPEND, the partition will start where the |
* previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block. |
* mask_flags: contains flags that have to be masked (removed) from the |
* master MTD flag set for the corresponding MTD partition. |
* For example, to force a read-only partition, simply adding |
* MTD_WRITEABLE to the mask_flags will do the trick. |
* |
* Note: writeable partitions require their size and offset be |
* erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK). |
*/ |
struct mtd_partition { |
char *name; /* identifier string */ |
u_int32_t size; /* partition size */ |
u_int32_t offset; /* offset within the master MTD space */ |
u_int32_t mask_flags; /* master MTD flags to mask out for this partition */ |
struct nand_oobinfo *oobsel; /* out of band layout for this partition (NAND only)*/ |
struct mtd_info **mtdp; /* pointer to store the MTD object */ |
}; |
#define MTDPART_OFS_NXTBLK (-2) |
#define MTDPART_OFS_APPEND (-1) |
#define MTDPART_SIZ_FULL (0) |
int add_mtd_partitions(struct mtd_info *, struct mtd_partition *, int); |
int del_mtd_partitions(struct mtd_info *); |
/* |
* Functions dealing with the various ways of partitioning the space |
*/ |
struct mtd_part_parser { |
struct list_head list; |
struct module *owner; |
const char *name; |
int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long); |
}; |
extern struct mtd_part_parser *get_partition_parser(const char *name); |
extern int register_mtd_parser(struct mtd_part_parser *parser); |
extern int deregister_mtd_parser(struct mtd_part_parser *parser); |
extern int parse_mtd_partitions(struct mtd_info *master, const char **types, |
struct mtd_partition **pparts, unsigned long origin); |
#define put_partition_parser(p) do { module_put((p)->owner); } while(0) |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/mtd/gen_probe.h |
---|
0,0 → 1,23 |
/* |
* (C) 2001, 2001 Red Hat, Inc. |
* GPL'd |
* $Id: gen_probe.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ |
*/ |
#ifndef __LINUX_MTD_GEN_PROBE_H__ |
#define __LINUX_MTD_GEN_PROBE_H__ |
#include <linux/mtd/flashchip.h> |
#include <linux/mtd/map.h> |
#include <linux/mtd/cfi.h> |
struct chip_probe { |
char *name; |
int (*probe_chip)(struct map_info *map, __u32 base, |
struct flchip *chips, struct cfi_private *cfi); |
}; |
struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp); |
#endif /* __LINUX_MTD_GEN_PROBE_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/cfi.h |
---|
0,0 → 1,483 |
/* Common Flash Interface structures |
* See http://support.intel.com/design/flash/technote/index.htm |
* $Id: cfi.h,v 1.1 2004-01-28 15:30:48 giacomo Exp $ |
*/ |
#ifndef __MTD_CFI_H__ |
#define __MTD_CFI_H__ |
#include <linux/config.h> |
#include <linux/version.h> |
#include <linux/delay.h> |
#include <linux/types.h> |
#include <linux/interrupt.h> |
#include <linux/mtd/flashchip.h> |
#include <linux/mtd/cfi_endian.h> |
/* |
* You can optimize the code size and performance by defining only |
* the geometry(ies) available on your hardware. |
* CFIDEV_INTERLEAVE_n, where represents the interleave (number of chips to fill the bus width) |
* CFIDEV_BUSWIDTH_n, where n is the bus width in bytes (1, 2, 4 or 8 bytes) |
* |
* By default, all (known) geometries are supported. |
*/ |
#ifndef CONFIG_MTD_CFI_GEOMETRY |
/* The default case - support all but 64-bit, which has |
a performance penalty */ |
#define CFIDEV_INTERLEAVE_1 (1) |
#define CFIDEV_INTERLEAVE_2 (2) |
#define CFIDEV_INTERLEAVE_4 (4) |
#define CFIDEV_BUSWIDTH_1 (1) |
#define CFIDEV_BUSWIDTH_2 (2) |
#define CFIDEV_BUSWIDTH_4 (4) |
typedef __u32 cfi_word; |
#else |
/* Explicitly configured buswidth/interleave support */ |
#ifdef CONFIG_MTD_CFI_I1 |
#define CFIDEV_INTERLEAVE_1 (1) |
#endif |
#ifdef CONFIG_MTD_CFI_I2 |
#define CFIDEV_INTERLEAVE_2 (2) |
#endif |
#ifdef CONFIG_MTD_CFI_I4 |
#define CFIDEV_INTERLEAVE_4 (4) |
#endif |
#ifdef CONFIG_MTD_CFI_I8 |
#define CFIDEV_INTERLEAVE_8 (8) |
#endif |
#ifdef CONFIG_MTD_CFI_B1 |
#define CFIDEV_BUSWIDTH_1 (1) |
#endif |
#ifdef CONFIG_MTD_CFI_B2 |
#define CFIDEV_BUSWIDTH_2 (2) |
#endif |
#ifdef CONFIG_MTD_CFI_B4 |
#define CFIDEV_BUSWIDTH_4 (4) |
#endif |
#ifdef CONFIG_MTD_CFI_B8 |
#define CFIDEV_BUSWIDTH_8 (8) |
#endif |
/* pick the largest necessary */ |
#ifdef CONFIG_MTD_CFI_B8 |
typedef __u64 cfi_word; |
/* This only works if asm/io.h is included first */ |
#ifndef __raw_readll |
#define __raw_readll(addr) (*(volatile __u64 *)(addr)) |
#endif |
#ifndef __raw_writell |
#define __raw_writell(v, addr) (*(volatile __u64 *)(addr) = (v)) |
#endif |
#define CFI_WORD_64 |
#else /* CONFIG_MTD_CFI_B8 */ |
/* All others can use 32-bits. It's probably more efficient than |
the smaller types anyway */ |
typedef __u32 cfi_word; |
#endif /* CONFIG_MTD_CFI_B8 */ |
#endif |
/* |
* The following macros are used to select the code to execute: |
* cfi_buswidth_is_*() |
* cfi_interleave_is_*() |
* [where * is either 1, 2, 4, or 8] |
* Those macros should be used with 'if' statements. If only one of few |
* geometry arrangements are selected, they expand to constants thus allowing |
* the compiler (most of them being 0) to optimize away all the unneeded code, |
* while still validating the syntax (which is not possible with embedded |
* #if ... #endif constructs). |
* The exception to this is the 64-bit versions, which need an extension |
* to the cfi_word type, and cause compiler warnings about shifts being |
* out of range. |
*/ |
#ifdef CFIDEV_INTERLEAVE_1 |
# ifdef CFIDEV_INTERLEAVE |
# undef CFIDEV_INTERLEAVE |
# define CFIDEV_INTERLEAVE (cfi->interleave) |
# else |
# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_1 |
# endif |
# define cfi_interleave_is_1() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_1) |
#else |
# define cfi_interleave_is_1() (0) |
#endif |
#ifdef CFIDEV_INTERLEAVE_2 |
# ifdef CFIDEV_INTERLEAVE |
# undef CFIDEV_INTERLEAVE |
# define CFIDEV_INTERLEAVE (cfi->interleave) |
# else |
# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_2 |
# endif |
# define cfi_interleave_is_2() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_2) |
#else |
# define cfi_interleave_is_2() (0) |
#endif |
#ifdef CFIDEV_INTERLEAVE_4 |
# ifdef CFIDEV_INTERLEAVE |
# undef CFIDEV_INTERLEAVE |
# define CFIDEV_INTERLEAVE (cfi->interleave) |
# else |
# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_4 |
# endif |
# define cfi_interleave_is_4() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_4) |
#else |
# define cfi_interleave_is_4() (0) |
#endif |
#ifdef CFIDEV_INTERLEAVE_8 |
# ifdef CFIDEV_INTERLEAVE |
# undef CFIDEV_INTERLEAVE |
# define CFIDEV_INTERLEAVE (cfi->interleave) |
# else |
# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_8 |
# endif |
# define cfi_interleave_is_8() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_8) |
#else |
# define cfi_interleave_is_8() (0) |
#endif |
#ifndef CFIDEV_INTERLEAVE |
#error You must define at least one interleave to support! |
#endif |
#ifdef CFIDEV_BUSWIDTH_1 |
# ifdef CFIDEV_BUSWIDTH |
# undef CFIDEV_BUSWIDTH |
# define CFIDEV_BUSWIDTH (map->buswidth) |
# else |
# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_1 |
# endif |
# define cfi_buswidth_is_1() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_1) |
#else |
# define cfi_buswidth_is_1() (0) |
#endif |
#ifdef CFIDEV_BUSWIDTH_2 |
# ifdef CFIDEV_BUSWIDTH |
# undef CFIDEV_BUSWIDTH |
# define CFIDEV_BUSWIDTH (map->buswidth) |
# else |
# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_2 |
# endif |
# define cfi_buswidth_is_2() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_2) |
#else |
# define cfi_buswidth_is_2() (0) |
#endif |
#ifdef CFIDEV_BUSWIDTH_4 |
# ifdef CFIDEV_BUSWIDTH |
# undef CFIDEV_BUSWIDTH |
# define CFIDEV_BUSWIDTH (map->buswidth) |
# else |
# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_4 |
# endif |
# define cfi_buswidth_is_4() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_4) |
#else |
# define cfi_buswidth_is_4() (0) |
#endif |
#ifdef CFIDEV_BUSWIDTH_8 |
# ifdef CFIDEV_BUSWIDTH |
# undef CFIDEV_BUSWIDTH |
# define CFIDEV_BUSWIDTH (map->buswidth) |
# else |
# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_8 |
# endif |
# define cfi_buswidth_is_8() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_8) |
#else |
# define cfi_buswidth_is_8() (0) |
#endif |
#ifndef CFIDEV_BUSWIDTH |
#error You must define at least one bus width to support! |
#endif |
/* NB: these values must represents the number of bytes needed to meet the |
* device type (x8, x16, x32). Eg. a 32 bit device is 4 x 8 bytes. |
* These numbers are used in calculations. |
*/ |
#define CFI_DEVICETYPE_X8 (8 / 8) |
#define CFI_DEVICETYPE_X16 (16 / 8) |
#define CFI_DEVICETYPE_X32 (32 / 8) |
#define CFI_DEVICETYPE_X64 (64 / 8) |
/* NB: We keep these structures in memory in HOST byteorder, except |
* where individually noted. |
*/ |
/* Basic Query Structure */ |
struct cfi_ident { |
__u8 qry[3]; |
__u16 P_ID; |
__u16 P_ADR; |
__u16 A_ID; |
__u16 A_ADR; |
__u8 VccMin; |
__u8 VccMax; |
__u8 VppMin; |
__u8 VppMax; |
__u8 WordWriteTimeoutTyp; |
__u8 BufWriteTimeoutTyp; |
__u8 BlockEraseTimeoutTyp; |
__u8 ChipEraseTimeoutTyp; |
__u8 WordWriteTimeoutMax; |
__u8 BufWriteTimeoutMax; |
__u8 BlockEraseTimeoutMax; |
__u8 ChipEraseTimeoutMax; |
__u8 DevSize; |
__u16 InterfaceDesc; |
__u16 MaxBufWriteSize; |
__u8 NumEraseRegions; |
__u32 EraseRegionInfo[0]; /* Not host ordered */ |
} __attribute__((packed)); |
/* Extended Query Structure for both PRI and ALT */ |
struct cfi_extquery { |
__u8 pri[3]; |
__u8 MajorVersion; |
__u8 MinorVersion; |
} __attribute__((packed)); |
/* Vendor-Specific PRI for Intel/Sharp Extended Command Set (0x0001) */ |
struct cfi_pri_intelext { |
__u8 pri[3]; |
__u8 MajorVersion; |
__u8 MinorVersion; |
__u32 FeatureSupport; |
__u8 SuspendCmdSupport; |
__u16 BlkStatusRegMask; |
__u8 VccOptimal; |
__u8 VppOptimal; |
__u8 NumProtectionFields; |
__u16 ProtRegAddr; |
__u8 FactProtRegSize; |
__u8 UserProtRegSize; |
} __attribute__((packed)); |
struct cfi_pri_query { |
__u8 NumFields; |
__u32 ProtField[1]; /* Not host ordered */ |
} __attribute__((packed)); |
struct cfi_bri_query { |
__u8 PageModeReadCap; |
__u8 NumFields; |
__u32 ConfField[1]; /* Not host ordered */ |
} __attribute__((packed)); |
#define P_ID_NONE 0 |
#define P_ID_INTEL_EXT 1 |
#define P_ID_AMD_STD 2 |
#define P_ID_INTEL_STD 3 |
#define P_ID_AMD_EXT 4 |
#define P_ID_MITSUBISHI_STD 256 |
#define P_ID_MITSUBISHI_EXT 257 |
#define P_ID_RESERVED 65535 |
#define CFI_MODE_CFI 1 |
#define CFI_MODE_JEDEC 0 |
struct cfi_private { |
__u16 cmdset; |
void *cmdset_priv; |
int interleave; |
int device_type; |
int cfi_mode; /* Are we a JEDEC device pretending to be CFI? */ |
int addr_unlock1; |
int addr_unlock2; |
int fast_prog; |
struct mtd_info *(*cmdset_setup)(struct map_info *); |
struct cfi_ident *cfiq; /* For now only one. We insist that all devs |
must be of the same type. */ |
int mfr, id; |
int numchips; |
unsigned long chipshift; /* Because they're of the same type */ |
const char *im_name; /* inter_module name for cmdset_setup */ |
struct flchip chips[0]; /* per-chip data structure for each chip */ |
}; |
#define MAX_CFI_CHIPS 8 /* Entirely arbitrary to avoid realloc() */ |
/* |
* Returns the command address according to the given geometry. |
*/ |
static inline __u32 cfi_build_cmd_addr(__u32 cmd_ofs, int interleave, int type) |
{ |
return (cmd_ofs * type) * interleave; |
} |
/* |
* Transforms the CFI command for the given geometry (bus width & interleave. |
*/ |
static inline cfi_word cfi_build_cmd(u_char cmd, struct map_info *map, struct cfi_private *cfi) |
{ |
cfi_word val = 0; |
if (cfi_buswidth_is_1()) { |
/* 1 x8 device */ |
val = cmd; |
} else if (cfi_buswidth_is_2()) { |
if (cfi_interleave_is_1()) { |
/* 1 x16 device in x16 mode */ |
val = cpu_to_cfi16(cmd); |
} else if (cfi_interleave_is_2()) { |
/* 2 (x8, x16 or x32) devices in x8 mode */ |
val = cpu_to_cfi16((cmd << 8) | cmd); |
} |
} else if (cfi_buswidth_is_4()) { |
if (cfi_interleave_is_1()) { |
/* 1 x32 device in x32 mode */ |
val = cpu_to_cfi32(cmd); |
} else if (cfi_interleave_is_2()) { |
/* 2 x16 device in x16 mode */ |
val = cpu_to_cfi32((cmd << 16) | cmd); |
} else if (cfi_interleave_is_4()) { |
/* 4 (x8, x16 or x32) devices in x8 mode */ |
val = (cmd << 16) | cmd; |
val = cpu_to_cfi32((val << 8) | val); |
} |
#ifdef CFI_WORD_64 |
} else if (cfi_buswidth_is_8()) { |
if (cfi_interleave_is_1()) { |
/* 1 x64 device in x64 mode */ |
val = cpu_to_cfi64(cmd); |
} else if (cfi_interleave_is_2()) { |
/* 2 x32 device in x32 mode */ |
val = cmd; |
val = cpu_to_cfi64((val << 32) | val); |
} else if (cfi_interleave_is_4()) { |
/* 4 (x16, x32 or x64) devices in x16 mode */ |
val = (cmd << 16) | cmd; |
val = cpu_to_cfi64((val << 32) | val); |
} else if (cfi_interleave_is_8()) { |
/* 8 (x8, x16 or x32) devices in x8 mode */ |
val = (cmd << 8) | cmd; |
val = (val << 16) | val; |
val = (val << 32) | val; |
val = cpu_to_cfi64(val); |
} |
#endif /* CFI_WORD_64 */ |
} |
return val; |
} |
#define CMD(x) cfi_build_cmd((x), map, cfi) |
/* |
* Read a value according to the bus width. |
*/ |
static inline cfi_word cfi_read(struct map_info *map, __u32 addr) |
{ |
if (cfi_buswidth_is_1()) { |
return map_read8(map, addr); |
} else if (cfi_buswidth_is_2()) { |
return map_read16(map, addr); |
} else if (cfi_buswidth_is_4()) { |
return map_read32(map, addr); |
} else if (cfi_buswidth_is_8()) { |
return map_read64(map, addr); |
} else { |
return 0; |
} |
} |
/* |
* Write a value according to the bus width. |
*/ |
static inline void cfi_write(struct map_info *map, cfi_word val, __u32 addr) |
{ |
if (cfi_buswidth_is_1()) { |
map_write8(map, val, addr); |
} else if (cfi_buswidth_is_2()) { |
map_write16(map, val, addr); |
} else if (cfi_buswidth_is_4()) { |
map_write32(map, val, addr); |
} else if (cfi_buswidth_is_8()) { |
map_write64(map, val, addr); |
} |
} |
/* |
* Sends a CFI command to a bank of flash for the given geometry. |
* |
* Returns the offset in flash where the command was written. |
* If prev_val is non-null, it will be set to the value at the command address, |
* before the command was written. |
*/ |
static inline __u32 cfi_send_gen_cmd(u_char cmd, __u32 cmd_addr, __u32 base, |
struct map_info *map, struct cfi_private *cfi, |
int type, cfi_word *prev_val) |
{ |
cfi_word val; |
__u32 addr = base + cfi_build_cmd_addr(cmd_addr, CFIDEV_INTERLEAVE, type); |
val = cfi_build_cmd(cmd, map, cfi); |
if (prev_val) |
*prev_val = cfi_read(map, addr); |
cfi_write(map, val, addr); |
return addr - base; |
} |
static inline __u8 cfi_read_query(struct map_info *map, __u32 addr) |
{ |
if (cfi_buswidth_is_1()) { |
return map_read8(map, addr); |
} else if (cfi_buswidth_is_2()) { |
return cfi16_to_cpu(map_read16(map, addr)); |
} else if (cfi_buswidth_is_4()) { |
return cfi32_to_cpu(map_read32(map, addr)); |
} else if (cfi_buswidth_is_8()) { |
return cfi64_to_cpu(map_read64(map, addr)); |
} else { |
return 0; |
} |
} |
static inline void cfi_udelay(int us) |
{ |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) |
unsigned long t = us * HZ / 1000000; |
if (t) { |
set_current_state(TASK_UNINTERRUPTIBLE); |
schedule_timeout(t); |
return; |
} |
#endif |
udelay(us); |
cond_resched(); |
} |
static inline void cfi_spin_lock(spinlock_t *mutex) |
{ |
spin_lock_bh(mutex); |
} |
static inline void cfi_spin_unlock(spinlock_t *mutex) |
{ |
spin_unlock_bh(mutex); |
} |
#endif /* __MTD_CFI_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/flashchip.h |
---|
0,0 → 1,76 |
/* |
* struct flchip definition |
* |
* Contains information about the location and state of a given flash device |
* |
* (C) 2000 Red Hat. GPLd. |
* |
* $Id: flashchip.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ |
* |
*/ |
#ifndef __MTD_FLASHCHIP_H__ |
#define __MTD_FLASHCHIP_H__ |
/* For spinlocks. sched.h includes spinlock.h from whichever directory it |
* happens to be in - so we don't have to care whether we're on 2.2, which |
* has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
*/ |
#include <linux/sched.h> |
typedef enum { |
FL_READY, |
FL_STATUS, |
FL_CFI_QUERY, |
FL_JEDEC_QUERY, |
FL_ERASING, |
FL_ERASE_SUSPENDING, |
FL_ERASE_SUSPENDED, |
FL_WRITING, |
FL_WRITING_TO_BUFFER, |
FL_WRITE_SUSPENDING, |
FL_WRITE_SUSPENDED, |
FL_PM_SUSPENDED, |
FL_SYNCING, |
FL_UNLOADING, |
FL_LOCKING, |
FL_UNLOCKING, |
FL_POINT, |
FL_UNKNOWN |
} flstate_t; |
/* NOTE: confusingly, this can be used to refer to more than one chip at a time, |
if they're interleaved. */ |
struct flchip { |
unsigned long start; /* Offset within the map */ |
// unsigned long len; |
/* We omit len for now, because when we group them together |
we insist that they're all of the same size, and the chip size |
is held in the next level up. If we get more versatile later, |
it'll make it a damn sight harder to find which chip we want from |
a given offset, and we'll want to add the per-chip length field |
back in. |
*/ |
int ref_point_counter; |
flstate_t state; |
flstate_t oldstate; |
int write_suspended:1; |
int erase_suspended:1; |
spinlock_t *mutex; |
spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */ |
wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
to be ready */ |
int word_write_time; |
int buffer_write_time; |
int erase_time; |
}; |
#endif /* __MTD_FLASHCHIP_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/nftl.h |
---|
0,0 → 1,119 |
/* |
* $Id: nftl.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ |
* |
* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> |
*/ |
#ifndef __MTD_NFTL_H__ |
#define __MTD_NFTL_H__ |
#include <linux/mtd/mtd.h> |
#include <linux/mtd/blktrans.h> |
/* Block Control Information */ |
struct nftl_bci { |
unsigned char ECCSig[6]; |
__u8 Status; |
__u8 Status1; |
}__attribute__((packed)); |
/* Unit Control Information */ |
struct nftl_uci0 { |
__u16 VirtUnitNum; |
__u16 ReplUnitNum; |
__u16 SpareVirtUnitNum; |
__u16 SpareReplUnitNum; |
} __attribute__((packed)); |
struct nftl_uci1 { |
__u32 WearInfo; |
__u16 EraseMark; |
__u16 EraseMark1; |
} __attribute__((packed)); |
struct nftl_uci2 { |
__u16 FoldMark; |
__u16 FoldMark1; |
__u32 unused; |
} __attribute__((packed)); |
union nftl_uci { |
struct nftl_uci0 a; |
struct nftl_uci1 b; |
struct nftl_uci2 c; |
}; |
struct nftl_oob { |
struct nftl_bci b; |
union nftl_uci u; |
}; |
/* NFTL Media Header */ |
struct NFTLMediaHeader { |
char DataOrgID[6]; |
__u16 NumEraseUnits; |
__u16 FirstPhysicalEUN; |
__u32 FormattedSize; |
unsigned char UnitSizeFactor; |
} __attribute__((packed)); |
#define MAX_ERASE_ZONES (8192 - 512) |
#define ERASE_MARK 0x3c69 |
#define SECTOR_FREE 0xff |
#define SECTOR_USED 0x55 |
#define SECTOR_IGNORE 0x11 |
#define SECTOR_DELETED 0x00 |
#define FOLD_MARK_IN_PROGRESS 0x5555 |
#define ZONE_GOOD 0xff |
#define ZONE_BAD_ORIGINAL 0 |
#define ZONE_BAD_MARKED 7 |
#ifdef __KERNEL__ |
/* these info are used in ReplUnitTable */ |
#define BLOCK_NIL 0xffff /* last block of a chain */ |
#define BLOCK_FREE 0xfffe /* free block */ |
#define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */ |
#define BLOCK_RESERVED 0xfffc /* bios block or bad block */ |
struct NFTLrecord { |
struct mtd_blktrans_dev mbd; |
__u16 MediaUnit, SpareMediaUnit; |
__u32 EraseSize; |
struct NFTLMediaHeader MediaHdr; |
int usecount; |
unsigned char heads; |
unsigned char sectors; |
unsigned short cylinders; |
__u16 numvunits; |
__u16 lastEUN; /* should be suppressed */ |
__u16 numfreeEUNs; |
__u16 LastFreeEUN; /* To speed up finding a free EUN */ |
int head,sect,cyl; |
__u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */ |
__u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */ |
unsigned int nb_blocks; /* number of physical blocks */ |
unsigned int nb_boot_blocks; /* number of blocks used by the bios */ |
struct erase_info instr; |
}; |
int NFTL_mount(struct NFTLrecord *s); |
int NFTL_formatblock(struct NFTLrecord *s, int block); |
#ifndef NFTL_MAJOR |
#define NFTL_MAJOR 93 |
#endif |
#define MAX_NFTLS 16 |
#define MAX_SECTORS_PER_UNIT 64 |
#define NFTL_PARTN_BITS 4 |
#endif /* __KERNEL__ */ |
#endif /* __MTD_NFTL_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/compatmac.h |
---|
0,0 → 1,10 |
#ifndef __LINUX_MTD_COMPATMAC_H__ |
#define __LINUX_MTD_COMPATMAC_H__ |
/* Nothing to see here. We write 2.5-compatible code and this |
file makes it all OK in older kernels, but it's empty in _current_ |
kernels. Include guard just to make GCC ignore it in future inclusions |
anyway... */ |
#endif /* __LINUX_MTD_COMPATMAC_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/iflash.h |
---|
0,0 → 1,98 |
/* $Id: iflash.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ */ |
#ifndef __MTD_IFLASH_H__ |
#define __MTD_IFLASH_H__ |
/* Extended CIS registers for Series 2 and 2+ cards */ |
/* The registers are all offsets from 0x4000 */ |
#define CISREG_CSR 0x0100 |
#define CISREG_WP 0x0104 |
#define CISREG_RDYBSY 0x0140 |
/* Extended CIS registers for Series 2 cards */ |
#define CISREG_SLEEP 0x0118 |
#define CISREG_RDY_MASK 0x0120 |
#define CISREG_RDY_STATUS 0x0130 |
/* Extended CIS registers for Series 2+ cards */ |
#define CISREG_VCR 0x010c |
/* Card Status Register */ |
#define CSR_SRESET 0x20 /* Soft reset */ |
#define CSR_CMWP 0x10 /* Common memory write protect */ |
#define CSR_PWRDOWN 0x08 /* Power down status */ |
#define CSR_CISWP 0x04 /* Common memory CIS WP */ |
#define CSR_WP 0x02 /* Mechanical write protect */ |
#define CSR_READY 0x01 /* Ready/busy status */ |
/* Write Protection Register */ |
#define WP_BLKEN 0x04 /* Enable block locking */ |
#define WP_CMWP 0x02 /* Common memory write protect */ |
#define WP_CISWP 0x01 /* Common memory CIS WP */ |
/* Voltage Control Register */ |
#define VCR_VCC_LEVEL 0x80 /* 0 = 5V, 1 = 3.3V */ |
#define VCR_VPP_VALID 0x02 /* Vpp Valid */ |
#define VCR_VPP_GEN 0x01 /* Integrated Vpp generator */ |
/* Ready/Busy Mode Register */ |
#define RDYBSY_RACK 0x02 /* Ready acknowledge */ |
#define RDYBSY_MODE 0x01 /* 1 = high performance */ |
#define LOW(x) ((x) & 0xff) |
/* 28F008SA-Compatible Command Set */ |
#define IF_READ_ARRAY 0xffff |
#define IF_INTEL_ID 0x9090 |
#define IF_READ_CSR 0x7070 |
#define IF_CLEAR_CSR 0x5050 |
#define IF_WRITE 0x4040 |
#define IF_BLOCK_ERASE 0x2020 |
#define IF_ERASE_SUSPEND 0xb0b0 |
#define IF_CONFIRM 0xd0d0 |
/* 28F016SA Performance Enhancement Commands */ |
#define IF_READ_PAGE 0x7575 |
#define IF_PAGE_SWAP 0x7272 |
#define IF_SINGLE_LOAD 0x7474 |
#define IF_SEQ_LOAD 0xe0e0 |
#define IF_PAGE_WRITE 0x0c0c |
#define IF_RDY_MODE 0x9696 |
#define IF_RDY_LEVEL 0x0101 |
#define IF_RDY_PULSE_WRITE 0x0202 |
#define IF_RDY_PULSE_ERASE 0x0303 |
#define IF_RDY_DISABLE 0x0404 |
#define IF_LOCK_BLOCK 0x7777 |
#define IF_UPLOAD_STATUS 0x9797 |
#define IF_READ_ESR 0x7171 |
#define IF_ERASE_UNLOCKED 0xa7a7 |
#define IF_SLEEP 0xf0f0 |
#define IF_ABORT 0x8080 |
#define IF_UPLOAD_DEVINFO 0x9999 |
/* Definitions for Compatible Status Register */ |
#define CSR_WR_READY 0x8080 /* Write state machine status */ |
#define CSR_ERA_SUSPEND 0x4040 /* Erase suspend status */ |
#define CSR_ERA_ERR 0x2020 /* Erase status */ |
#define CSR_WR_ERR 0x1010 /* Data write status */ |
#define CSR_VPP_LOW 0x0808 /* Vpp status */ |
/* Definitions for Global Status Register */ |
#define GSR_WR_READY 0x8080 /* Write state machine status */ |
#define GSR_OP_SUSPEND 0x4040 /* Operation suspend status */ |
#define GSR_OP_ERR 0x2020 /* Device operation status */ |
#define GSR_SLEEP 0x1010 /* Device sleep status */ |
#define GSR_QUEUE_FULL 0x0808 /* Queue status */ |
#define GSR_PAGE_AVAIL 0x0404 /* Page buffer available status */ |
#define GSR_PAGE_READY 0x0202 /* Page buffer status */ |
#define GSR_PAGE_SELECT 0x0101 /* Page buffer select status */ |
/* Definitions for Block Status Register */ |
#define BSR_READY 0x8080 /* Block status */ |
#define BSR_UNLOCK 0x4040 /* Block lock status */ |
#define BSR_FAILED 0x2020 /* Block operation status */ |
#define BSR_ABORTED 0x1010 /* Operation abort status */ |
#define BSR_QUEUE_FULL 0x0808 /* Queue status */ |
#define BSR_VPP_LOW 0x0404 /* Vpp status */ |
#endif /* __MTD_IFLASH_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/concat.h |
---|
0,0 → 1,23 |
/* |
* MTD device concatenation layer definitions |
* |
* (C) 2002 Robert Kaiser <rkaiser@sysgo.de> |
* |
* This code is GPL |
* |
* $Id: concat.h,v 1.1 2004-01-28 15:30:48 giacomo Exp $ |
*/ |
#ifndef MTD_CONCAT_H |
#define MTD_CONCAT_H |
struct mtd_info *mtd_concat_create( |
struct mtd_info *subdev[], /* subdevices to concatenate */ |
int num_devs, /* number of subdevices */ |
char *name); /* name for the new device */ |
void mtd_concat_destroy(struct mtd_info *mtd); |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/mtd/doc2000.h |
---|
0,0 → 1,186 |
/* Linux driver for Disk-On-Chip 2000 */ |
/* (c) 1999 Machine Vision Holdings, Inc. */ |
/* Author: David Woodhouse <dwmw2@mvhi.com> */ |
/* $Id: doc2000.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ */ |
#ifndef __MTD_DOC2000_H__ |
#define __MTD_DOC2000_H__ |
#include <linux/mtd/mtd.h> |
#define DoC_Sig1 0 |
#define DoC_Sig2 1 |
#define DoC_ChipID 0x1000 |
#define DoC_DOCStatus 0x1001 |
#define DoC_DOCControl 0x1002 |
#define DoC_FloorSelect 0x1003 |
#define DoC_CDSNControl 0x1004 |
#define DoC_CDSNDeviceSelect 0x1005 |
#define DoC_ECCConf 0x1006 |
#define DoC_2k_ECCStatus 0x1007 |
#define DoC_CDSNSlowIO 0x100d |
#define DoC_ECCSyndrome0 0x1010 |
#define DoC_ECCSyndrome1 0x1011 |
#define DoC_ECCSyndrome2 0x1012 |
#define DoC_ECCSyndrome3 0x1013 |
#define DoC_ECCSyndrome4 0x1014 |
#define DoC_ECCSyndrome5 0x1015 |
#define DoC_AliasResolution 0x101b |
#define DoC_ConfigInput 0x101c |
#define DoC_ReadPipeInit 0x101d |
#define DoC_WritePipeTerm 0x101e |
#define DoC_LastDataRead 0x101f |
#define DoC_NOP 0x1020 |
#define DoC_Mil_CDSN_IO 0x0800 |
#define DoC_2k_CDSN_IO 0x1800 |
#define DoC_Mplus_NOP 0x1002 |
#define DoC_Mplus_AliasResolution 0x1004 |
#define DoC_Mplus_DOCControl 0x1006 |
#define DoC_Mplus_AccessStatus 0x1008 |
#define DoC_Mplus_DeviceSelect 0x1008 |
#define DoC_Mplus_Configuration 0x100a |
#define DoC_Mplus_OutputControl 0x100c |
#define DoC_Mplus_FlashControl 0x1020 |
#define DoC_Mplus_FlashSelect 0x1022 |
#define DoC_Mplus_FlashCmd 0x1024 |
#define DoC_Mplus_FlashAddress 0x1026 |
#define DoC_Mplus_FlashData0 0x1028 |
#define DoC_Mplus_FlashData1 0x1029 |
#define DoC_Mplus_ReadPipeInit 0x102a |
#define DoC_Mplus_LastDataRead 0x102c |
#define DoC_Mplus_LastDataRead1 0x102d |
#define DoC_Mplus_WritePipeTerm 0x102e |
#define DoC_Mplus_ECCSyndrome0 0x1040 |
#define DoC_Mplus_ECCSyndrome1 0x1041 |
#define DoC_Mplus_ECCSyndrome2 0x1042 |
#define DoC_Mplus_ECCSyndrome3 0x1043 |
#define DoC_Mplus_ECCSyndrome4 0x1044 |
#define DoC_Mplus_ECCSyndrome5 0x1045 |
#define DoC_Mplus_ECCConf 0x1046 |
#define DoC_Mplus_Toggle 0x1046 |
#define DoC_Mplus_DownloadStatus 0x1074 |
#define DoC_Mplus_CtrlConfirm 0x1076 |
#define DoC_Mplus_Power 0x1fff |
/* How to access the device? |
* On ARM, it'll be mmap'd directly with 32-bit wide accesses. |
* On PPC, it's mmap'd and 16-bit wide. |
* Others use readb/writeb |
*/ |
#if defined(__arm__) |
#define ReadDOC_(adr, reg) ((unsigned char)(*(__u32 *)(((unsigned long)adr)+((reg)<<2)))) |
#define WriteDOC_(d, adr, reg) do{ *(__u32 *)(((unsigned long)adr)+((reg)<<2)) = (__u32)d; wmb();} while(0) |
#define DOC_IOREMAP_LEN 0x8000 |
#elif defined(__ppc__) |
#define ReadDOC_(adr, reg) ((unsigned char)(*(__u16 *)(((unsigned long)adr)+((reg)<<1)))) |
#define WriteDOC_(d, adr, reg) do{ *(__u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0) |
#define DOC_IOREMAP_LEN 0x4000 |
#else |
#define ReadDOC_(adr, reg) readb(((unsigned long)adr) + (reg)) |
#define WriteDOC_(d, adr, reg) writeb(d, ((unsigned long)adr) + (reg)) |
#define DOC_IOREMAP_LEN 0x2000 |
#endif |
#if defined(__i386__) || defined(__x86_64__) |
#define USE_MEMCPY |
#endif |
/* These are provided to directly use the DoC_xxx defines */ |
#define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg) |
#define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg) |
#define DOC_MODE_RESET 0 |
#define DOC_MODE_NORMAL 1 |
#define DOC_MODE_RESERVED1 2 |
#define DOC_MODE_RESERVED2 3 |
#define DOC_MODE_CLR_ERR 0x80 |
#define DOC_MODE_RST_LAT 0x10 |
#define DOC_MODE_BDECT 0x08 |
#define DOC_MODE_MDWREN 0x04 |
#define DOC_ChipID_Doc2k 0x20 |
#define DOC_ChipID_DocMil 0x30 |
#define DOC_ChipID_DocMilPlus32 0x40 |
#define DOC_ChipID_DocMilPlus16 0x41 |
#define CDSN_CTRL_FR_B 0x80 |
#define CDSN_CTRL_FR_B0 0x40 |
#define CDSN_CTRL_FR_B1 0x80 |
#define CDSN_CTRL_ECC_IO 0x20 |
#define CDSN_CTRL_FLASH_IO 0x10 |
#define CDSN_CTRL_WP 0x08 |
#define CDSN_CTRL_ALE 0x04 |
#define CDSN_CTRL_CLE 0x02 |
#define CDSN_CTRL_CE 0x01 |
#define DOC_ECC_RESET 0 |
#define DOC_ECC_ERROR 0x80 |
#define DOC_ECC_RW 0x20 |
#define DOC_ECC__EN 0x08 |
#define DOC_TOGGLE_BIT 0x04 |
#define DOC_ECC_RESV 0x02 |
#define DOC_ECC_IGNORE 0x01 |
#define DOC_FLASH_CE 0x80 |
#define DOC_FLASH_WP 0x40 |
#define DOC_FLASH_BANK 0x02 |
/* We have to also set the reserved bit 1 for enable */ |
#define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV) |
#define DOC_ECC_DIS (DOC_ECC_RESV) |
struct Nand { |
char floor, chip; |
unsigned long curadr; |
unsigned char curmode; |
/* Also some erase/write/pipeline info when we get that far */ |
}; |
#define MAX_FLOORS 4 |
#define MAX_CHIPS 4 |
#define MAX_FLOORS_MIL 4 |
#define MAX_CHIPS_MIL 1 |
#define MAX_FLOORS_MPLUS 1 |
#define MAX_CHIPS_MPLUS 1 |
#define ADDR_COLUMN 1 |
#define ADDR_PAGE 2 |
#define ADDR_COLUMN_PAGE 3 |
struct DiskOnChip { |
unsigned long physadr; |
unsigned long virtadr; |
unsigned long totlen; |
char ChipID; /* Type of DiskOnChip */ |
int ioreg; |
unsigned long mfr; /* Flash IDs - only one type of flash per device */ |
unsigned long id; |
int chipshift; |
char page256; |
char pageadrlen; |
char interleave; /* Internal interleaving - Millennium Plus style */ |
unsigned long erasesize; |
int curfloor; |
int curchip; |
int numchips; |
struct Nand *chips; |
struct mtd_info *nextdoc; |
struct semaphore lock; |
}; |
int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); |
#endif /* __MTD_DOC2000_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/pmc551.h |
---|
0,0 → 1,79 |
/* |
* $Id: pmc551.h,v 1.1 2004-01-28 15:30:51 giacomo Exp $ |
* |
* PMC551 PCI Mezzanine Ram Device |
* |
* Author: |
* Mark Ferrell |
* Copyright 1999,2000 Nortel Networks |
* |
* License: |
* As part of this driver was derrived from the slram.c driver it falls |
* under the same license, which is GNU General Public License v2 |
*/ |
#ifndef __MTD_PMC551_H__ |
#define __MTD_PMC551_H__ |
#include <linux/mtd/mtd.h> |
#define PMC551_VERSION "$Id: pmc551.h,v 1.1 2004-01-28 15:30:51 giacomo Exp $\n"\ |
"Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n" |
/* |
* Our personal and private information |
*/ |
struct mypriv { |
struct pci_dev *dev; |
u_char *start; |
u32 base_map0; |
u32 curr_map0; |
u32 asize; |
struct mtd_info *nextpmc551; |
}; |
/* |
* Function Prototypes |
*/ |
static int pmc551_erase(struct mtd_info *, struct erase_info *); |
static void pmc551_unpoint(struct mtd_info *, u_char *, loff_t, size_t); |
static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); |
static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); |
/* |
* Define the PCI ID's if the kernel doesn't define them for us |
*/ |
#ifndef PCI_VENDOR_ID_V3_SEMI |
#define PCI_VENDOR_ID_V3_SEMI 0x11b0 |
#endif |
#ifndef PCI_DEVICE_ID_V3_SEMI_V370PDC |
#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200 |
#endif |
#define PMC551_PCI_MEM_MAP0 0x50 |
#define PMC551_PCI_MEM_MAP1 0x54 |
#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000 |
#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0 |
#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002 |
#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001 |
#define PMC551_SDRAM_MA 0x60 |
#define PMC551_SDRAM_CMD 0x62 |
#define PMC551_DRAM_CFG 0x64 |
#define PMC551_SYS_CTRL_REG 0x78 |
#define PMC551_DRAM_BLK0 0x68 |
#define PMC551_DRAM_BLK1 0x6c |
#define PMC551_DRAM_BLK2 0x70 |
#define PMC551_DRAM_BLK3 0x74 |
#define PMC551_DRAM_BLK_GET_SIZE(x) (524288<<((x>>4)&0x0f)) |
#define PMC551_DRAM_BLK_SET_COL_MUX(x,v) (((x) & ~0x00007000) | (((v) & 0x7) << 12)) |
#define PMC551_DRAM_BLK_SET_ROW_MUX(x,v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8)) |
#endif /* __MTD_PMC551_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/jedec.h |
---|
0,0 → 1,66 |
/* JEDEC Flash Interface. |
* This is an older type of interface for self programming flash. It is |
* commonly use in older AMD chips and is obsolete compared with CFI. |
* It is called JEDEC because the JEDEC association distributes the ID codes |
* for the chips. |
* |
* See the AMD flash databook for information on how to operate the interface. |
* |
* $Id: jedec.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ |
*/ |
#ifndef __LINUX_MTD_JEDEC_H__ |
#define __LINUX_MTD_JEDEC_H__ |
#include <linux/types.h> |
#define MAX_JEDEC_CHIPS 16 |
// Listing of all supported chips and their information |
struct JEDECTable |
{ |
__u16 jedec; |
char *name; |
unsigned long size; |
unsigned long sectorsize; |
__u32 capabilities; |
}; |
// JEDEC being 0 is the end of the chip array |
struct jedec_flash_chip |
{ |
__u16 jedec; |
unsigned long size; |
unsigned long sectorsize; |
// *(__u8*)(base + (adder << addrshift)) = data << datashift |
// Address size = size << addrshift |
unsigned long base; // Byte 0 of the flash, will be unaligned |
unsigned int datashift; // Useful for 32bit/16bit accesses |
unsigned int addrshift; |
unsigned long offset; // linerized start. base==offset for unbanked, uninterleaved flash |
__u32 capabilities; |
// These markers are filled in by the flash_chip_scan function |
unsigned long start; |
unsigned long length; |
}; |
struct jedec_private |
{ |
unsigned long size; // Total size of all the devices |
/* Bank handling. If sum(bank_fill) == size then this is linear flash. |
Otherwise the mapping has holes in it. bank_fill may be used to |
find the holes, but in the common symetric case |
bank_fill[0] == bank_fill[*], thus addresses may be computed |
mathmatically. bank_fill must be powers of two */ |
unsigned is_banked; |
unsigned long bank_fill[MAX_JEDEC_CHIPS]; |
struct jedec_flash_chip chips[MAX_JEDEC_CHIPS]; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/mtd/inftl.h |
---|
0,0 → 1,129 |
/* |
* inftl.h -- defines to support the Inverse NAND Flash Translation Layer |
* |
* (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) |
* |
* $Id: inftl.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ |
*/ |
#ifndef __MTD_INFTL_H__ |
#define __MTD_INFTL_H__ |
#include <linux/mtd/blktrans.h> |
#include <linux/mtd/mtd.h> |
#include <linux/mtd/nftl.h> |
#define OSAK_VERSION 0x5120 |
#define PERCENTUSED 98 |
#define SECTORSIZE 512 |
#ifndef INFTL_MAJOR |
#define INFTL_MAJOR 93 /* FIXME */ |
#endif |
#define INFTL_PARTN_BITS 4 |
/* Block Control Information */ |
struct inftl_bci { |
__u8 ECCsig[6]; |
__u8 Status; |
__u8 Status1; |
} __attribute__((packed)); |
struct inftl_unithead1 { |
__u16 virtualUnitNo; |
__u16 prevUnitNo; |
__u8 ANAC; |
__u8 NACs; |
__u8 parityPerField; |
__u8 discarded; |
} __attribute__((packed)); |
struct inftl_unithead2 { |
__u8 parityPerField; |
__u8 ANAC; |
__u16 prevUnitNo; |
__u16 virtualUnitNo; |
__u8 NACs; |
__u8 discarded; |
} __attribute__((packed)); |
struct inftl_unittail { |
__u8 Reserved[4]; |
__u16 EraseMark; |
__u16 EraseMark1; |
} __attribute__((packed)); |
union inftl_uci { |
struct inftl_unithead1 a; |
struct inftl_unithead2 b; |
struct inftl_unittail c; |
}; |
struct inftl_oob { |
struct inftl_bci b; |
union inftl_uci u; |
}; |
/* INFTL Media Header */ |
struct INFTLPartition { |
__u32 virtualUnits; |
__u32 firstUnit; |
__u32 lastUnit; |
__u32 flags; |
__u32 spareUnits; |
__u32 Reserved0; |
__u32 Reserved1; |
} __attribute__((packed)); |
struct INFTLMediaHeader { |
char bootRecordID[8]; |
__u32 NoOfBootImageBlocks; |
__u32 NoOfBinaryPartitions; |
__u32 NoOfBDTLPartitions; |
__u32 BlockMultiplierBits; |
__u32 FormatFlags; |
__u32 OsakVersion; |
__u32 PercentUsed; |
struct INFTLPartition Partitions[4]; |
} __attribute__((packed)); |
/* Partition flag types */ |
#define INFTL_BINARY 0x20000000 |
#define INFTL_BDTL 0x40000000 |
#define INFTL_LAST 0x80000000 |
#ifdef __KERNEL__ |
struct INFTLrecord { |
struct mtd_blktrans_dev mbd; |
__u16 MediaUnit, SpareMediaUnit; |
__u32 EraseSize; |
struct INFTLMediaHeader MediaHdr; |
int usecount; |
unsigned char heads; |
unsigned char sectors; |
unsigned short cylinders; |
__u16 numvunits; |
__u16 firstEUN; |
__u16 lastEUN; |
__u16 numfreeEUNs; |
__u16 LastFreeEUN; /* To speed up finding a free EUN */ |
int head,sect,cyl; |
__u16 *PUtable; /* Physical Unit Table */ |
__u16 *VUtable; /* Virtual Unit Table */ |
unsigned int nb_blocks; /* number of physical blocks */ |
unsigned int nb_boot_blocks; /* number of blocks used by the bios */ |
struct erase_info instr; |
}; |
int INFTL_mount(struct INFTLrecord *s); |
int INFTL_formatblock(struct INFTLrecord *s, int block); |
#endif /* __KERNEL__ */ |
#endif /* __MTD_INFTL_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/map.h |
---|
0,0 → 1,172 |
/* Overhauled routines for dealing with different mmap regions of flash */ |
/* $Id: map.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ */ |
#ifndef __LINUX_MTD_MAP_H__ |
#define __LINUX_MTD_MAP_H__ |
#include <linux/config.h> |
#include <linux/types.h> |
#include <linux/list.h> |
#include <asm/system.h> |
#include <asm/io.h> |
/* The map stuff is very simple. You fill in your struct map_info with |
a handful of routines for accessing the device, making sure they handle |
paging etc. correctly if your device needs it. Then you pass it off |
to a chip driver which deals with a mapped device - generally either |
do_cfi_probe() or do_ram_probe(), either of which will return a |
struct mtd_info if they liked what they saw. At which point, you |
fill in the mtd->module with your own module address, and register |
it. |
The mtd->priv field will point to the struct map_info, and any further |
private data required by the chip driver is linked from the |
mtd->priv->fldrv_priv field. This allows the map driver to get at |
the destructor function map->fldrv_destroy() when it's tired |
of living. |
*/ |
struct map_info { |
char *name; |
unsigned long size; |
unsigned long phys; |
#define NO_XIP (-1UL) |
unsigned long virt; |
void *cached; |
int buswidth; /* in octets */ |
#ifdef CONFIG_MTD_COMPLEX_MAPPINGS |
u8 (*read8)(struct map_info *, unsigned long); |
u16 (*read16)(struct map_info *, unsigned long); |
u32 (*read32)(struct map_info *, unsigned long); |
u64 (*read64)(struct map_info *, unsigned long); |
/* If it returned a 'long' I'd call it readl. |
* It doesn't. |
* I won't. |
* dwmw2 */ |
void (*copy_from)(struct map_info *, void *, unsigned long, ssize_t); |
void (*write8)(struct map_info *, u8, unsigned long); |
void (*write16)(struct map_info *, u16, unsigned long); |
void (*write32)(struct map_info *, u32, unsigned long); |
void (*write64)(struct map_info *, u64, unsigned long); |
void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t); |
/* We can perhaps put in 'point' and 'unpoint' methods, if we really |
want to enable XIP for non-linear mappings. Not yet though. */ |
#endif |
/* set_vpp() must handle being reentered -- enable, enable, disable |
must leave it enabled. */ |
void (*set_vpp)(struct map_info *, int); |
unsigned long map_priv_1; |
unsigned long map_priv_2; |
void *fldrv_priv; |
struct mtd_chip_driver *fldrv; |
}; |
struct mtd_chip_driver { |
struct mtd_info *(*probe)(struct map_info *map); |
void (*destroy)(struct mtd_info *); |
struct module *module; |
char *name; |
struct list_head list; |
}; |
void register_mtd_chip_driver(struct mtd_chip_driver *); |
void unregister_mtd_chip_driver(struct mtd_chip_driver *); |
struct mtd_info *do_map_probe(const char *name, struct map_info *map); |
void map_destroy(struct mtd_info *mtd); |
#define ENABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 1); } while(0) |
#define DISABLE_VPP(map) do { if(map->set_vpp) map->set_vpp(map, 0); } while(0) |
#ifdef CONFIG_MTD_COMPLEX_MAPPINGS |
#define map_read8(map, ofs) (map)->read8(map, ofs) |
#define map_read16(map, ofs) (map)->read16(map, ofs) |
#define map_read32(map, ofs) (map)->read32(map, ofs) |
#define map_read64(map, ofs) (map)->read64(map, ofs) |
#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len) |
#define map_write8(map, datum, ofs) (map)->write8(map, datum, ofs) |
#define map_write16(map, datum, ofs) (map)->write16(map, datum, ofs) |
#define map_write32(map, datum, ofs) (map)->write32(map, datum, ofs) |
#define map_write64(map, datum, ofs) (map)->write64(map, datum, ofs) |
#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len) |
extern void simple_map_init(struct map_info *); |
#define map_is_linear(map) (map->phys != NO_XIP) |
#else |
static inline u8 map_read8(struct map_info *map, unsigned long ofs) |
{ |
return __raw_readb(map->virt + ofs); |
} |
static inline u16 map_read16(struct map_info *map, unsigned long ofs) |
{ |
return __raw_readw(map->virt + ofs); |
} |
static inline u32 map_read32(struct map_info *map, unsigned long ofs) |
{ |
return __raw_readl(map->virt + ofs); |
} |
static inline u64 map_read64(struct map_info *map, unsigned long ofs) |
{ |
#ifndef CONFIG_MTD_CFI_B8 /* 64-bit mappings */ |
BUG(); |
return 0; |
#else |
return __raw_readll(map->virt + ofs); |
#endif |
} |
static inline void map_write8(struct map_info *map, u8 datum, unsigned long ofs) |
{ |
__raw_writeb(datum, map->virt + ofs); |
mb(); |
} |
static inline void map_write16(struct map_info *map, u16 datum, unsigned long ofs) |
{ |
__raw_writew(datum, map->virt + ofs); |
mb(); |
} |
static inline void map_write32(struct map_info *map, u32 datum, unsigned long ofs) |
{ |
__raw_writel(datum, map->virt + ofs); |
mb(); |
} |
static inline void map_write64(struct map_info *map, u64 datum, unsigned long ofs) |
{ |
#ifndef CONFIG_MTD_CFI_B8 /* 64-bit mappings */ |
BUG(); |
#else |
__raw_writell(datum, map->virt + ofs); |
mb(); |
#endif /* CFI_B8 */ |
} |
static inline void map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) |
{ |
memcpy_fromio(to, map->virt + from, len); |
} |
static inline void map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) |
{ |
memcpy_toio(map->virt + to, from, len); |
} |
#define simple_map_init(map) do { } while (0) |
#define map_is_linear(map) (1) |
#endif /* !CONFIG_MTD_COMPLEX_MAPPINGS */ |
#endif /* __LINUX_MTD_MAP_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/cfi_endian.h |
---|
0,0 → 1,57 |
/* |
* $Id: cfi_endian.h,v 1.1 2004-01-28 15:30:48 giacomo Exp $ |
* |
*/ |
#include <asm/byteorder.h> |
#ifndef CONFIG_MTD_CFI_ADV_OPTIONS |
#define CFI_HOST_ENDIAN |
#else |
#ifdef CONFIG_MTD_CFI_NOSWAP |
#define CFI_HOST_ENDIAN |
#endif |
#ifdef CONFIG_MTD_CFI_LE_BYTE_SWAP |
#define CFI_LITTLE_ENDIAN |
#endif |
#ifdef CONFIG_MTD_CFI_BE_BYTE_SWAP |
#define CFI_BIG_ENDIAN |
#endif |
#endif |
#if defined(CFI_LITTLE_ENDIAN) |
#define cpu_to_cfi8(x) (x) |
#define cfi8_to_cpu(x) (x) |
#define cpu_to_cfi16(x) cpu_to_le16(x) |
#define cpu_to_cfi32(x) cpu_to_le32(x) |
#define cpu_to_cfi64(x) cpu_to_le64(x) |
#define cfi16_to_cpu(x) le16_to_cpu(x) |
#define cfi32_to_cpu(x) le32_to_cpu(x) |
#define cfi64_to_cpu(x) le64_to_cpu(x) |
#elif defined (CFI_BIG_ENDIAN) |
#define cpu_to_cfi8(x) (x) |
#define cfi8_to_cpu(x) (x) |
#define cpu_to_cfi16(x) cpu_to_be16(x) |
#define cpu_to_cfi32(x) cpu_to_be32(x) |
#define cpu_to_cfi64(x) cpu_to_be64(x) |
#define cfi16_to_cpu(x) be16_to_cpu(x) |
#define cfi32_to_cpu(x) be32_to_cpu(x) |
#define cfi64_to_cpu(x) be64_to_cpu(x) |
#elif defined (CFI_HOST_ENDIAN) |
#define cpu_to_cfi8(x) (x) |
#define cfi8_to_cpu(x) (x) |
#define cpu_to_cfi16(x) (x) |
#define cpu_to_cfi32(x) (x) |
#define cpu_to_cfi64(x) (x) |
#define cfi16_to_cpu(x) (x) |
#define cfi32_to_cpu(x) (x) |
#define cfi64_to_cpu(x) (x) |
#else |
#error No CFI endianness defined |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/mtd/nand.h |
---|
0,0 → 1,244 |
/* |
* linux/include/linux/mtd/nand.h |
* |
* Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com> |
* Steven J. Hill <sjhill@realitydiluted.com> |
* Thomas Gleixner <tglx@linutronix.de> |
* |
* $Id: nand.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License version 2 as |
* published by the Free Software Foundation. |
* |
* Info: |
* Contains standard defines and IDs for NAND flash devices |
* |
* Changelog: |
* 01-31-2000 DMW Created |
* 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers |
* so it can be used by other NAND flash device |
* drivers. I also changed the copyright since none |
* of the original contents of this file are specific |
* to DoC devices. David can whack me with a baseball |
* bat later if I did something naughty. |
* 10-11-2000 SJH Added private NAND flash structure for driver |
* 10-24-2000 SJH Added prototype for 'nand_scan' function |
* 10-29-2001 TG changed nand_chip structure to support |
* hardwarespecific function for accessing control lines |
* 02-21-2002 TG added support for different read/write adress and |
* ready/busy line access function |
* 02-26-2002 TG added chip_delay to nand_chip structure to optimize |
* command delay times for different chips |
* 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate |
* defines in jffs2/wbuf.c |
* 08-07-2002 TG forced bad block location to byte 5 of OOB, even if |
* CONFIG_MTD_NAND_ECC_JFFS2 is not set |
* 08-10-2002 TG extensions to nand_chip structure to support HW-ECC |
* |
* 08-29-2002 tglx nand_chip structure: data_poi for selecting |
* internal / fs-driver buffer |
* support for 6byte/512byte hardware ECC |
* read_ecc, write_ecc extended for different oob-layout |
* oob layout selections: NAND_NONE_OOB, NAND_JFFS2_OOB, |
* NAND_YAFFS_OOB |
* 11-25-2002 tglx Added Manufacturer code FUJITSU, NATIONAL |
* Split manufacturer and device ID structures |
*/ |
#ifndef __LINUX_MTD_NAND_H |
#define __LINUX_MTD_NAND_H |
#include <linux/config.h> |
#include <linux/wait.h> |
#include <linux/spinlock.h> |
struct mtd_info; |
/* |
* Searches for a NAND device |
*/ |
extern int nand_scan (struct mtd_info *mtd); |
/* |
* Constants for hardware specific CLE/ALE/NCE function |
*/ |
#define NAND_CTL_SETNCE 1 |
#define NAND_CTL_CLRNCE 2 |
#define NAND_CTL_SETCLE 3 |
#define NAND_CTL_CLRCLE 4 |
#define NAND_CTL_SETALE 5 |
#define NAND_CTL_CLRALE 6 |
/* |
* Standard NAND flash commands |
*/ |
#define NAND_CMD_READ0 0 |
#define NAND_CMD_READ1 1 |
#define NAND_CMD_PAGEPROG 0x10 |
#define NAND_CMD_READOOB 0x50 |
#define NAND_CMD_ERASE1 0x60 |
#define NAND_CMD_STATUS 0x70 |
#define NAND_CMD_SEQIN 0x80 |
#define NAND_CMD_READID 0x90 |
#define NAND_CMD_ERASE2 0xd0 |
#define NAND_CMD_RESET 0xff |
/* |
* Constants for ECC_MODES |
* |
* NONE: No ECC |
* SOFT: Software ECC 3 byte ECC per 256 Byte data |
* HW3_256: Hardware ECC 3 byte ECC per 256 Byte data |
* HW3_512: Hardware ECC 3 byte ECC per 512 Byte data |
* |
* |
*/ |
#define NAND_ECC_NONE 0 |
#define NAND_ECC_SOFT 1 |
#define NAND_ECC_HW3_256 2 |
#define NAND_ECC_HW3_512 3 |
#define NAND_ECC_HW6_512 4 |
#define NAND_ECC_DISKONCHIP 5 |
/* |
* Constants for Hardware ECC |
*/ |
#define NAND_ECC_READ 0 |
#define NAND_ECC_WRITE 1 |
/* |
* Enumeration for NAND flash chip state |
*/ |
typedef enum { |
FL_READY, |
FL_READING, |
FL_WRITING, |
FL_ERASING, |
FL_SYNCING |
} nand_state_t; |
/* |
* NAND Private Flash Chip Data |
* |
* Structure overview: |
* |
* IO_ADDR_R - address to read the 8 I/O lines of the flash device |
* |
* IO_ADDR_W - address to write the 8 I/O lines of the flash device |
* |
* hwcontrol - hardwarespecific function for accesing control-lines |
* |
* dev_ready - hardwarespecific function for accesing device ready/busy line |
* |
* waitfunc - hardwarespecific function for wait on ready |
* |
* calculate_ecc - function for ecc calculation or readback from ecc hardware |
* |
* correct_data - function for ecc correction, matching to ecc generator (sw/hw) |
* |
* enable_hwecc - function to enable (reset) hardware ecc generator |
* |
* eccmod - mode of ecc: see constants |
* |
* eccsize - databytes used per ecc-calculation |
* |
* chip_delay - chip dependent delay for transfering data from array to read regs (tR) |
* |
* chip_lock - spinlock used to protect access to this structure |
* |
* wq - wait queue to sleep on if a NAND operation is in progress |
* |
* state - give the current state of the NAND device |
* |
* page_shift - number of address bits in a page (column address bits) |
* |
* data_buf - data buffer passed to/from MTD user modules |
* |
* data_cache - data cache for redundant page access and shadow for |
* ECC failure |
* |
* cache_page - number of last valid page in page_cache |
*/ |
struct nand_chip { |
unsigned long IO_ADDR_R; |
unsigned long IO_ADDR_W; |
void (*hwcontrol)(int cmd); |
int (*dev_ready)(void); |
void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); |
int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); |
void (*calculate_ecc)(const u_char *dat, u_char *ecc_code); |
int (*correct_data)(u_char *dat, u_char *read_ecc, u_char *calc_ecc); |
void (*enable_hwecc)(int mode); |
int eccmode; |
int eccsize; |
int chip_delay; |
spinlock_t chip_lock; |
wait_queue_head_t wq; |
nand_state_t state; |
int page_shift; |
u_char *data_buf; |
u_char *data_poi; |
}; |
/* |
* NAND Flash Manufacturer ID Codes |
*/ |
#define NAND_MFR_TOSHIBA 0x98 |
#define NAND_MFR_SAMSUNG 0xec |
#define NAND_MFR_FUJITSU 0x04 |
#define NAND_MFR_NATIONAL 0x8f |
/* |
* NAND Flash Device ID Structure |
* |
* Structure overview: |
* |
* name - Identify the device type |
* |
* id - device ID code |
* |
* chipshift - total number of address bits for the device which |
* is used to calculate address offsets and the total |
* number of bytes the device is capable of. |
* |
* page256 - denotes if flash device has 256 byte pages or not. |
* |
* pageadrlen - number of bytes minus one needed to hold the |
* complete address into the flash array. Keep in |
* mind that when a read or write is done to a |
* specific address, the address is input serially |
* 8 bits at a time. This structure member is used |
* by the read/write routines as a loop index for |
* shifting the address out 8 bits at a time. |
* |
* erasesize - size of an erase block in the flash device. |
*/ |
struct nand_flash_dev { |
char * name; |
int id; |
int chipshift; |
unsigned long erasesize; |
char page256; |
}; |
/* |
* NAND Flash Manufacturer ID Structure |
* |
* name - Manufacturer name |
* |
* id - manufacturer ID code of device. |
*/ |
struct nand_manufacturers { |
int id; |
char * name; |
}; |
extern struct nand_flash_dev nand_flash_ids[]; |
extern struct nand_manufacturers nand_manuf_ids[]; |
/* |
* Constants for oob configuration |
*/ |
#define NAND_BADBLOCK_POS 5 |
#endif /* __LINUX_MTD_NAND_H */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/blktrans.h |
---|
0,0 → 1,72 |
/* |
* $Id: blktrans.h,v 1.1 2004-01-28 15:30:48 giacomo Exp $ |
* |
* (C) 2003 David Woodhouse <dwmw2@infradead.org> |
* |
* Interface to Linux block layer for MTD 'translation layers'. |
* |
*/ |
#ifndef __MTD_TRANS_H__ |
#define __MTD_TRANS_H__ |
#include <asm/semaphore.h> |
struct hd_geometry; |
struct mtd_info; |
struct mtd_blktrans_ops; |
struct file; |
struct inode; |
struct mtd_blktrans_dev { |
struct mtd_blktrans_ops *tr; |
struct list_head list; |
struct mtd_info *mtd; |
struct semaphore sem; |
int devnum; |
int blksize; |
unsigned long size; |
int readonly; |
void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */ |
}; |
struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */ |
struct mtd_blktrans_ops { |
char *name; |
int major; |
int part_bits; |
/* Access functions */ |
int (*readsect)(struct mtd_blktrans_dev *dev, |
unsigned long block, char *buffer); |
int (*writesect)(struct mtd_blktrans_dev *dev, |
unsigned long block, char *buffer); |
/* Block layer ioctls */ |
int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); |
int (*flush)(struct mtd_blktrans_dev *dev); |
/* Called with mtd_table_mutex held; no race with add/remove */ |
int (*open)(struct mtd_blktrans_dev *dev); |
int (*release)(struct mtd_blktrans_dev *dev); |
/* Called on {de,}registration and on subsequent addition/removal |
of devices, with mtd_table_mutex held. */ |
void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd); |
void (*remove_dev)(struct mtd_blktrans_dev *dev); |
struct list_head devs; |
struct list_head list; |
struct module *owner; |
struct mtd_blkcore_priv *blkcore_priv; |
}; |
extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr); |
extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); |
extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
#endif /* __MTD_TRANS_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/mtd.h |
---|
0,0 → 1,293 |
/* $Id: mtd.h,v 1.1 2004-01-28 15:30:50 giacomo Exp $ */ |
#ifndef __MTD_MTD_H__ |
#define __MTD_MTD_H__ |
#ifdef __KERNEL__ |
#include <linux/config.h> |
#include <linux/version.h> |
#include <linux/types.h> |
#include <linux/module.h> |
#include <linux/uio.h> |
#endif /* __KERNEL__ */ |
struct erase_info_user { |
u_int32_t start; |
u_int32_t length; |
}; |
struct mtd_oob_buf { |
u_int32_t start; |
u_int32_t length; |
unsigned char *ptr; |
}; |
#define MTD_CHAR_MAJOR 90 |
#define MTD_BLOCK_MAJOR 31 |
#define MAX_MTD_DEVICES 16 |
#define MTD_ABSENT 0 |
#define MTD_RAM 1 |
#define MTD_ROM 2 |
#define MTD_NORFLASH 3 |
#define MTD_NANDFLASH 4 |
#define MTD_PEROM 5 |
#define MTD_OTHER 14 |
#define MTD_UNKNOWN 15 |
#define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) |
#define MTD_SET_BITS 2 // Bits can be set |
#define MTD_ERASEABLE 4 // Has an erase function |
#define MTD_WRITEB_WRITEABLE 8 // Direct IO is possible |
#define MTD_VOLATILE 16 // Set for RAMs |
#define MTD_XIP 32 // eXecute-In-Place possible |
#define MTD_OOB 64 // Out-of-band data (NAND flash) |
#define MTD_ECC 128 // Device capable of automatic ECC |
// Some common devices / combinations of capabilities |
#define MTD_CAP_ROM 0 |
#define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE) |
#define MTD_CAP_NORFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE) |
#define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB) |
#define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS) |
// Types of automatic ECC/Checksum available |
#define MTD_ECC_NONE 0 // No automatic ECC available |
#define MTD_ECC_RS_DiskOnChip 1 // Automatic ECC on DiskOnChip |
#define MTD_ECC_SW 2 // SW ECC for Toshiba & Samsung devices |
struct mtd_info_user { |
u_char type; |
u_int32_t flags; |
u_int32_t size; // Total size of the MTD |
u_int32_t erasesize; |
u_int32_t oobblock; // Size of OOB blocks (e.g. 512) |
u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) |
u_int32_t ecctype; |
u_int32_t eccsize; |
}; |
struct region_info_user { |
u_int32_t offset; /* At which this region starts, |
* from the beginning of the MTD */ |
u_int32_t erasesize; /* For this region */ |
u_int32_t numblocks; /* Number of blocks in this region */ |
u_int32_t regionindex; |
}; |
#define MEMGETINFO _IOR('M', 1, struct mtd_info_user) |
#define MEMERASE _IOW('M', 2, struct erase_info_user) |
#define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) |
#define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) |
#define MEMLOCK _IOW('M', 5, struct erase_info_user) |
#define MEMUNLOCK _IOW('M', 6, struct erase_info_user) |
#define MEMGETREGIONCOUNT _IOR('M', 7, int) |
#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) |
#define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) |
struct nand_oobinfo { |
int useecc; |
int eccpos[6]; |
}; |
#ifndef __KERNEL__ |
typedef struct mtd_info_user mtd_info_t; |
typedef struct erase_info_user erase_info_t; |
typedef struct region_info_user region_info_t; |
typedef struct nand_oobinfo nand_oobinfo_t; |
/* User-space ioctl definitions */ |
#else /* __KERNEL__ */ |
#define MTD_ERASE_PENDING 0x01 |
#define MTD_ERASING 0x02 |
#define MTD_ERASE_SUSPEND 0x04 |
#define MTD_ERASE_DONE 0x08 |
#define MTD_ERASE_FAILED 0x10 |
struct erase_info { |
struct mtd_info *mtd; |
u_int32_t addr; |
u_int32_t len; |
u_long time; |
u_long retries; |
u_int dev; |
u_int cell; |
void (*callback) (struct erase_info *self); |
u_long priv; |
u_char state; |
struct erase_info *next; |
}; |
struct mtd_erase_region_info { |
u_int32_t offset; /* At which this region starts, from the beginning of the MTD */ |
u_int32_t erasesize; /* For this region */ |
u_int32_t numblocks; /* Number of blocks of erasesize in this region */ |
}; |
struct mtd_info { |
u_char type; |
u_int32_t flags; |
u_int32_t size; // Total size of the MTD |
/* "Major" erase size for the device. Naïve users may take this |
* to be the only erase size available, or may use the more detailed |
* information below if they desire |
*/ |
u_int32_t erasesize; |
u_int32_t oobblock; // Size of OOB blocks (e.g. 512) |
u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) |
u_int32_t ecctype; |
u_int32_t eccsize; |
// Kernel-only stuff starts here. |
char *name; |
int index; |
// oobinfo is a nand_oobinfo structure, which can be set by iotcl (MEMSETOOBINFO) |
struct nand_oobinfo oobinfo; |
/* Data for variable erase regions. If numeraseregions is zero, |
* it means that the whole device has erasesize as given above. |
*/ |
int numeraseregions; |
struct mtd_erase_region_info *eraseregions; |
/* This really shouldn't be here. It can go away in 2.5 */ |
u_int32_t bank_size; |
int (*erase) (struct mtd_info *mtd, struct erase_info *instr); |
/* This stuff for eXecute-In-Place */ |
int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); |
/* We probably shouldn't allow XIP if the unpoint isn't a NULL */ |
void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len); |
int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
int (*read_ecc) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
int (*write_ecc) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
int (*read_oob) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
int (*write_oob) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
/* |
* Methods to access the protection register area, present in some |
* flash devices. The user data is one time programmable but the |
* factory data is read only. |
*/ |
int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
/* This function is not yet implemented */ |
int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
/* iovec-based read/write methods. We need these especially for NAND flash, |
with its limited number of write cycles per erase. |
NB: The 'count' parameter is the number of _vectors_, each of |
which contains an (ofs, len) tuple. |
*/ |
int (*readv) (struct mtd_info *mtd, struct iovec *vecs, unsigned long count, loff_t from, size_t *retlen); |
int (*readv_ecc) (struct mtd_info *mtd, struct iovec *vecs, unsigned long count, loff_t from, |
size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); |
int (*writev) (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen); |
int (*writev_ecc) (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, loff_t to, |
size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); |
/* Sync */ |
void (*sync) (struct mtd_info *mtd); |
/* Chip-supported device locking */ |
int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len); |
int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len); |
/* Power Management functions */ |
int (*suspend) (struct mtd_info *mtd); |
void (*resume) (struct mtd_info *mtd); |
void *priv; |
struct module *owner; |
int usecount; |
}; |
/* Kernel-side ioctl definitions */ |
extern int add_mtd_device(struct mtd_info *mtd); |
extern int del_mtd_device (struct mtd_info *mtd); |
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num); |
extern void put_mtd_device(struct mtd_info *mtd); |
struct mtd_notifier { |
void (*add)(struct mtd_info *mtd); |
void (*remove)(struct mtd_info *mtd); |
struct list_head list; |
}; |
extern void register_mtd_user (struct mtd_notifier *new); |
extern int unregister_mtd_user (struct mtd_notifier *old); |
int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs, |
unsigned long count, loff_t to, size_t *retlen); |
int default_mtd_readv(struct mtd_info *mtd, struct iovec *vecs, |
unsigned long count, loff_t from, size_t *retlen); |
#define MTD_ERASE(mtd, args...) (*(mtd->erase))(mtd, args) |
#define MTD_POINT(mtd, a,b,c,d) (*(mtd->point))(mtd, a,b,c, (u_char **)(d)) |
#define MTD_UNPOINT(mtd, arg) (*(mtd->unpoint))(mtd, (u_char *)arg) |
#define MTD_READ(mtd, args...) (*(mtd->read))(mtd, args) |
#define MTD_WRITE(mtd, args...) (*(mtd->write))(mtd, args) |
#define MTD_READV(mtd, args...) (*(mtd->readv))(mtd, args) |
#define MTD_WRITEV(mtd, args...) (*(mtd->writev))(mtd, args) |
#define MTD_READECC(mtd, args...) (*(mtd->read_ecc))(mtd, args) |
#define MTD_WRITEECC(mtd, args...) (*(mtd->write_ecc))(mtd, args) |
#define MTD_READOOB(mtd, args...) (*(mtd->read_oob))(mtd, args) |
#define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args) |
#define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd); } while (0) |
/* |
* Debugging macro and defines |
*/ |
#define MTD_DEBUG_LEVEL0 (0) /* Quiet */ |
#define MTD_DEBUG_LEVEL1 (1) /* Audible */ |
#define MTD_DEBUG_LEVEL2 (2) /* Loud */ |
#define MTD_DEBUG_LEVEL3 (3) /* Noisy */ |
#ifdef CONFIG_MTD_DEBUG |
#define DEBUG(n, args...) \ |
do { \ |
if (n <= CONFIG_MTD_DEBUG_VERBOSE) \ |
printk(KERN_INFO args); \ |
} while(0) |
#else /* CONFIG_MTD_DEBUG */ |
#define DEBUG(n, args...) do { } while(0) |
#endif /* CONFIG_MTD_DEBUG */ |
#endif /* __KERNEL__ */ |
#endif /* __MTD_MTD_H__ */ |
/shark/trunk/drivers/linuxc26/include/linux/mtd/ftl.h |
---|
0,0 → 1,76 |
/* |
* $Id: ftl.h,v 1.1 2004-01-28 15:30:49 giacomo Exp $ |
* |
* Derived from (and probably identical to): |
* ftl.h 1.7 1999/10/25 20:23:17 |
* |
* The contents of this file are subject to the Mozilla Public License |
* Version 1.1 (the "License"); you may not use this file except in |
* compliance with the License. You may obtain a copy of the License |
* at http://www.mozilla.org/MPL/ |
* |
* Software distributed under the License is distributed on an "AS IS" |
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
* the License for the specific language governing rights and |
* limitations under the License. |
* |
* The initial developer of the original code is David A. Hinds |
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds |
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved. |
* |
* Alternatively, the contents of this file may be used under the |
* terms of the GNU General Public License version 2 (the "GPL"), in |
* which case the provisions of the GPL are applicable instead of the |
* above. If you wish to allow the use of your version of this file |
* only under the terms of the GPL and not to allow others to use |
* your version of this file under the MPL, indicate your decision by |
* deleting the provisions above and replace them with the notice and |
* other provisions required by the GPL. If you do not delete the |
* provisions above, a recipient may use your version of this file |
* under either the MPL or the GPL. |
*/ |
#ifndef _LINUX_FTL_H |
#define _LINUX_FTL_H |
typedef struct erase_unit_header_t { |
u_int8_t LinkTargetTuple[5]; |
u_int8_t DataOrgTuple[10]; |
u_int8_t NumTransferUnits; |
u_int32_t EraseCount; |
u_int16_t LogicalEUN; |
u_int8_t BlockSize; |
u_int8_t EraseUnitSize; |
u_int16_t FirstPhysicalEUN; |
u_int16_t NumEraseUnits; |
u_int32_t FormattedSize; |
u_int32_t FirstVMAddress; |
u_int16_t NumVMPages; |
u_int8_t Flags; |
u_int8_t Code; |
u_int32_t SerialNumber; |
u_int32_t AltEUHOffset; |
u_int32_t BAMOffset; |
u_int8_t Reserved[12]; |
u_int8_t EndTuple[2]; |
} erase_unit_header_t; |
/* Flags in erase_unit_header_t */ |
#define HIDDEN_AREA 0x01 |
#define REVERSE_POLARITY 0x02 |
#define DOUBLE_BAI 0x04 |
/* Definitions for block allocation information */ |
#define BLOCK_FREE(b) ((b) == 0xffffffff) |
#define BLOCK_DELETED(b) (((b) == 0) || ((b) == 0xfffffffe)) |
#define BLOCK_TYPE(b) ((b) & 0x7f) |
#define BLOCK_ADDRESS(b) ((b) & ~0x7f) |
#define BLOCK_NUMBER(b) ((b) >> 9) |
#define BLOCK_CONTROL 0x30 |
#define BLOCK_DATA 0x40 |
#define BLOCK_REPLACEMENT 0x60 |
#define BLOCK_BAD 0x70 |
#endif /* _LINUX_FTL_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_limit.h |
---|
0,0 → 1,21 |
#ifndef _IPT_RATE_H |
#define _IPT_RATE_H |
/* timings are in milliseconds. */ |
#define IPT_LIMIT_SCALE 10000 |
/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 |
seconds, or one every 59 hours. */ |
struct ipt_rateinfo { |
u_int32_t avg; /* Average secs between packets * scale */ |
u_int32_t burst; /* Period multiplier for upper limit. */ |
/* Used internally by the kernel */ |
unsigned long prev; |
u_int32_t credit; |
u_int32_t credit_cap, cost; |
/* Ugly, ugly fucker. */ |
struct ipt_rateinfo *master; |
}; |
#endif /*_IPT_RATE_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_nat_protocol.h |
---|
0,0 → 1,58 |
/* Header for use in defining a given protocol. */ |
#ifndef _IP_NAT_PROTOCOL_H |
#define _IP_NAT_PROTOCOL_H |
#include <linux/init.h> |
#include <linux/list.h> |
struct iphdr; |
struct ip_nat_range; |
struct ip_nat_protocol |
{ |
struct list_head list; |
/* Protocol name */ |
const char *name; |
/* Protocol number. */ |
unsigned int protonum; |
/* Do a packet translation according to the ip_nat_proto_manip |
* and manip type. Return true if succeeded. */ |
int (*manip_pkt)(struct sk_buff **pskb, |
unsigned int hdroff, |
const struct ip_conntrack_manip *manip, |
enum ip_nat_manip_type maniptype); |
/* Is the manipable part of the tuple between min and max incl? */ |
int (*in_range)(const struct ip_conntrack_tuple *tuple, |
enum ip_nat_manip_type maniptype, |
const union ip_conntrack_manip_proto *min, |
const union ip_conntrack_manip_proto *max); |
/* Alter the per-proto part of the tuple (depending on |
maniptype), to give a unique tuple in the given range if |
possible; return false if not. Per-protocol part of tuple |
is initialized to the incoming packet. */ |
int (*unique_tuple)(struct ip_conntrack_tuple *tuple, |
const struct ip_nat_range *range, |
enum ip_nat_manip_type maniptype, |
const struct ip_conntrack *conntrack); |
unsigned int (*print)(char *buffer, |
const struct ip_conntrack_tuple *match, |
const struct ip_conntrack_tuple *mask); |
unsigned int (*print_range)(char *buffer, |
const struct ip_nat_range *range); |
}; |
/* Protocol registration. */ |
extern int ip_nat_protocol_register(struct ip_nat_protocol *proto); |
extern void ip_nat_protocol_unregister(struct ip_nat_protocol *proto); |
extern int init_protocols(void) __init; |
extern void cleanup_protocols(void); |
extern struct ip_nat_protocol *find_nat_proto(u_int16_t protonum); |
#endif /*_IP_NAT_PROTO_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_helper.h |
---|
0,0 → 1,8 |
#ifndef _IPT_HELPER_H |
#define _IPT_HELPER_H |
struct ipt_helper_info { |
int invert; |
char name[30]; |
}; |
#endif /* _IPT_HELPER_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_state.h |
---|
0,0 → 1,11 |
#ifndef _IPT_STATE_H |
#define _IPT_STATE_H |
#define IPT_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) |
#define IPT_STATE_INVALID (1 << 0) |
struct ipt_state_info |
{ |
unsigned int statemask; |
}; |
#endif /*_IPT_STATE_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_recent.h |
---|
0,0 → 1,27 |
#ifndef _IPT_RECENT_H |
#define _IPT_RECENT_H |
#define RECENT_NAME "ipt_recent" |
#define RECENT_VER "v0.3.1" |
#define IPT_RECENT_CHECK 1 |
#define IPT_RECENT_SET 2 |
#define IPT_RECENT_UPDATE 4 |
#define IPT_RECENT_REMOVE 8 |
#define IPT_RECENT_TTL 16 |
#define IPT_RECENT_SOURCE 0 |
#define IPT_RECENT_DEST 1 |
#define IPT_RECENT_NAME_LEN 200 |
struct ipt_recent_info { |
u_int32_t seconds; |
u_int32_t hit_count; |
u_int8_t check_set; |
u_int8_t invert; |
char name[IPT_RECENT_NAME_LEN]; |
u_int8_t side; |
}; |
#endif /*_IPT_RECENT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipfwadm_core.h |
---|
0,0 → 1,256 |
#ifndef _IPFWADM_CORE_H |
#define _IPFWADM_CORE_H |
/* Minor modifications to fit on compatibility framework: |
Rusty.Russell@rustcorp.com.au |
*/ |
/* |
* IP firewalling code. This is taken from 4.4BSD. Please note the |
* copyright message below. As per the GPL it must be maintained |
* and the licenses thus do not conflict. While this port is subject |
* to the GPL I also place my modifications under the original |
* license in recognition of the original copyright. |
* |
* Ported from BSD to Linux, |
* Alan Cox 22/Nov/1994. |
* Merged and included the FreeBSD-Current changes at Ugen's request |
* (but hey it's a lot cleaner now). Ugen would prefer in some ways |
* we waited for his final product but since Linux 1.2.0 is about to |
* appear it's not practical - Read: It works, it's not clean but please |
* don't consider it to be his standard of finished work. |
* Alan. |
* |
* Fixes: |
* Pauline Middelink : Added masquerading. |
* Jos Vos : Separate input and output firewall |
* chains, new "insert" and "append" |
* commands to replace "add" commands, |
* add ICMP header to struct ip_fwpkt. |
* Jos Vos : Add support for matching device names. |
* Willy Konynenberg : Add transparent proxying support. |
* Jos Vos : Add options for input/output accounting. |
* |
* All the real work was done by ..... |
*/ |
/* |
* Copyright (c) 1993 Daniel Boulet |
* Copyright (c) 1994 Ugen J.S.Antsilevich |
* |
* Redistribution and use in source forms, with and without modification, |
* are permitted provided that this entire comment appears intact. |
* |
* Redistribution in binary form may occur without any restrictions. |
* Obviously, it would be nice if you gave credit where credit is due |
* but requiring it would be too onerous. |
* |
* This software is provided ``AS IS'' without any warranties of any kind. |
*/ |
/* |
* Format of an IP firewall descriptor |
* |
* src, dst, src_mask, dst_mask are always stored in network byte order. |
* flags and num_*_ports are stored in host byte order (of course). |
* Port numbers are stored in HOST byte order. |
*/ |
#ifdef __KERNEL__ |
#include <linux/icmp.h> |
#include <linux/in.h> |
#include <linux/ip.h> |
#include <linux/tcp.h> |
#include <linux/udp.h> |
#endif |
struct ip_fw |
{ |
struct ip_fw *fw_next; /* Next firewall on chain */ |
struct in_addr fw_src, fw_dst; /* Source and destination IP addr */ |
struct in_addr fw_smsk, fw_dmsk; /* Mask for src and dest IP addr */ |
struct in_addr fw_via; /* IP address of interface "via" */ |
struct net_device *fw_viadev; /* device of interface "via" */ |
__u16 fw_flg; /* Flags word */ |
__u16 fw_nsp, fw_ndp; /* N'of src ports and # of dst ports */ |
/* in ports array (dst ports follow */ |
/* src ports; max of 10 ports in all; */ |
/* count of 0 means match all ports) */ |
#define IP_FW_MAX_PORTS 10 /* A reasonable maximum */ |
__u16 fw_pts[IP_FW_MAX_PORTS]; /* Array of port numbers to match */ |
unsigned long fw_pcnt,fw_bcnt; /* Packet and byte counters */ |
__u8 fw_tosand, fw_tosxor; /* Revised packet priority */ |
char fw_vianame[IFNAMSIZ]; /* name of interface "via" */ |
}; |
/* |
* Values for "flags" field . |
*/ |
#define IP_FW_F_ALL 0x0000 /* This is a universal packet firewall*/ |
#define IP_FW_F_TCP 0x0001 /* This is a TCP packet firewall */ |
#define IP_FW_F_UDP 0x0002 /* This is a UDP packet firewall */ |
#define IP_FW_F_ICMP 0x0003 /* This is a ICMP packet firewall */ |
#define IP_FW_F_KIND 0x0003 /* Mask to isolate firewall kind */ |
#define IP_FW_F_ACCEPT 0x0004 /* This is an accept firewall (as * |
* opposed to a deny firewall)* |
* */ |
#define IP_FW_F_SRNG 0x0008 /* The first two src ports are a min * |
* and max range (stored in host byte * |
* order). * |
* */ |
#define IP_FW_F_DRNG 0x0010 /* The first two dst ports are a min * |
* and max range (stored in host byte * |
* order). * |
* (ports[0] <= port <= ports[1]) * |
* */ |
#define IP_FW_F_PRN 0x0020 /* In verbose mode print this firewall*/ |
#define IP_FW_F_BIDIR 0x0040 /* For bidirectional firewalls */ |
#define IP_FW_F_TCPSYN 0x0080 /* For tcp packets-check SYN only */ |
#define IP_FW_F_ICMPRPL 0x0100 /* Send back icmp unreachable packet */ |
#define IP_FW_F_MASQ 0x0200 /* Masquerading */ |
#define IP_FW_F_TCPACK 0x0400 /* For tcp-packets match if ACK is set*/ |
#define IP_FW_F_REDIR 0x0800 /* Redirect to local port fw_pts[n] */ |
#define IP_FW_F_ACCTIN 0x1000 /* Account incoming packets only. */ |
#define IP_FW_F_ACCTOUT 0x2000 /* Account outgoing packets only. */ |
#define IP_FW_F_MASK 0x3FFF /* All possible flag bits mask */ |
/* |
* New IP firewall options for [gs]etsockopt at the RAW IP level. |
* Unlike BSD Linux inherits IP options so you don't have to use |
* a raw socket for this. Instead we check rights in the calls. |
*/ |
#define IP_FW_BASE_CTL 64 /* base for firewall socket options */ |
#define IP_FW_COMMAND 0x00FF /* mask for command without chain */ |
#define IP_FW_TYPE 0x0300 /* mask for type (chain) */ |
#define IP_FW_SHIFT 8 /* shift count for type (chain) */ |
#define IP_FW_FWD 0 |
#define IP_FW_IN 1 |
#define IP_FW_OUT 2 |
#define IP_FW_ACCT 3 |
#define IP_FW_CHAINS 4 /* total number of ip_fw chains */ |
#define IP_FW_MASQ 5 |
#define IP_FW_INSERT (IP_FW_BASE_CTL) |
#define IP_FW_APPEND (IP_FW_BASE_CTL+1) |
#define IP_FW_DELETE (IP_FW_BASE_CTL+2) |
#define IP_FW_FLUSH (IP_FW_BASE_CTL+3) |
#define IP_FW_ZERO (IP_FW_BASE_CTL+4) |
#define IP_FW_POLICY (IP_FW_BASE_CTL+5) |
#define IP_FW_CHECK (IP_FW_BASE_CTL+6) |
#define IP_FW_MASQ_TIMEOUTS (IP_FW_BASE_CTL+7) |
#define IP_FW_INSERT_FWD (IP_FW_INSERT | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_APPEND_FWD (IP_FW_APPEND | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_DELETE_FWD (IP_FW_DELETE | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_FLUSH_FWD (IP_FW_FLUSH | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_ZERO_FWD (IP_FW_ZERO | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_POLICY_FWD (IP_FW_POLICY | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_CHECK_FWD (IP_FW_CHECK | (IP_FW_FWD << IP_FW_SHIFT)) |
#define IP_FW_INSERT_IN (IP_FW_INSERT | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_APPEND_IN (IP_FW_APPEND | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_DELETE_IN (IP_FW_DELETE | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_FLUSH_IN (IP_FW_FLUSH | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_ZERO_IN (IP_FW_ZERO | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_POLICY_IN (IP_FW_POLICY | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_CHECK_IN (IP_FW_CHECK | (IP_FW_IN << IP_FW_SHIFT)) |
#define IP_FW_INSERT_OUT (IP_FW_INSERT | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_APPEND_OUT (IP_FW_APPEND | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_DELETE_OUT (IP_FW_DELETE | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_FLUSH_OUT (IP_FW_FLUSH | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_ZERO_OUT (IP_FW_ZERO | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_POLICY_OUT (IP_FW_POLICY | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_FW_CHECK_OUT (IP_FW_CHECK | (IP_FW_OUT << IP_FW_SHIFT)) |
#define IP_ACCT_INSERT (IP_FW_INSERT | (IP_FW_ACCT << IP_FW_SHIFT)) |
#define IP_ACCT_APPEND (IP_FW_APPEND | (IP_FW_ACCT << IP_FW_SHIFT)) |
#define IP_ACCT_DELETE (IP_FW_DELETE | (IP_FW_ACCT << IP_FW_SHIFT)) |
#define IP_ACCT_FLUSH (IP_FW_FLUSH | (IP_FW_ACCT << IP_FW_SHIFT)) |
#define IP_ACCT_ZERO (IP_FW_ZERO | (IP_FW_ACCT << IP_FW_SHIFT)) |
#define IP_FW_MASQ_INSERT (IP_FW_INSERT | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_ADD (IP_FW_APPEND | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_DEL (IP_FW_DELETE | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_FLUSH (IP_FW_FLUSH | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_INSERT (IP_FW_INSERT | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_ADD (IP_FW_APPEND | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_DEL (IP_FW_DELETE | (IP_FW_MASQ << IP_FW_SHIFT)) |
#define IP_FW_MASQ_FLUSH (IP_FW_FLUSH | (IP_FW_MASQ << IP_FW_SHIFT)) |
struct ip_fwpkt |
{ |
struct iphdr fwp_iph; /* IP header */ |
union { |
struct tcphdr fwp_tcph; /* TCP header or */ |
struct udphdr fwp_udph; /* UDP header */ |
struct icmphdr fwp_icmph; /* ICMP header */ |
} fwp_protoh; |
struct in_addr fwp_via; /* interface address */ |
char fwp_vianame[IFNAMSIZ]; /* interface name */ |
}; |
#define IP_FW_MASQCTL_MAX 256 |
#define IP_MASQ_MOD_NMAX 32 |
struct ip_fw_masqctl |
{ |
int mctl_action; |
union { |
struct { |
char name[IP_MASQ_MOD_NMAX]; |
char data[1]; |
} mod; |
} u; |
}; |
/* |
* timeouts for ip masquerading |
*/ |
struct ip_fw_masq; |
/* |
* Main firewall chains definitions and global var's definitions. |
*/ |
#ifdef __KERNEL__ |
/* Modes used in the ip_fw_chk() routine. */ |
#define IP_FW_MODE_FW 0x00 /* kernel firewall check */ |
#define IP_FW_MODE_ACCT_IN 0x01 /* accounting (incoming) */ |
#define IP_FW_MODE_ACCT_OUT 0x02 /* accounting (outgoing) */ |
#define IP_FW_MODE_CHK 0x04 /* check requested by user */ |
#include <linux/config.h> |
#ifdef CONFIG_IP_FIREWALL |
extern struct ip_fw *ip_fw_in_chain; |
extern struct ip_fw *ip_fw_out_chain; |
extern struct ip_fw *ip_fw_fwd_chain; |
extern int ip_fw_in_policy; |
extern int ip_fw_out_policy; |
extern int ip_fw_fwd_policy; |
extern int ip_fw_ctl(int, void *, int); |
#endif |
#ifdef CONFIG_IP_ACCT |
extern struct ip_fw *ip_acct_chain; |
extern int ip_acct_ctl(int, void *, int); |
#endif |
#ifdef CONFIG_IP_MASQUERADE |
extern int ip_masq_ctl(int, void *, int); |
#endif |
#ifdef CONFIG_IP_MASQUERADE |
extern int ip_masq_ctl(int, void *, int); |
#endif |
extern int ip_fw_masq_timeouts(void *user, int len); |
extern int ip_fw_chk(struct sk_buff **, struct net_device *, __u16 *, |
struct ip_fw *, int, int); |
#endif /* KERNEL */ |
#endif /* _IP_FW_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/lockhelp.h |
---|
0,0 → 1,129 |
#ifndef _LOCKHELP_H |
#define _LOCKHELP_H |
#include <linux/config.h> |
#include <linux/spinlock.h> |
#include <asm/atomic.h> |
#include <linux/interrupt.h> |
#include <linux/smp.h> |
/* Header to do help in lock debugging. */ |
#ifdef CONFIG_NETFILTER_DEBUG |
struct spinlock_debug |
{ |
spinlock_t l; |
atomic_t locked_by; |
}; |
struct rwlock_debug |
{ |
rwlock_t l; |
long read_locked_map; |
long write_locked_map; |
}; |
#define DECLARE_LOCK(l) \ |
struct spinlock_debug l = { SPIN_LOCK_UNLOCKED, ATOMIC_INIT(-1) } |
#define DECLARE_LOCK_EXTERN(l) \ |
extern struct spinlock_debug l |
#define DECLARE_RWLOCK(l) \ |
struct rwlock_debug l = { RW_LOCK_UNLOCKED, 0, 0 } |
#define DECLARE_RWLOCK_EXTERN(l) \ |
extern struct rwlock_debug l |
#define MUST_BE_LOCKED(l) \ |
do { if (atomic_read(&(l)->locked_by) != smp_processor_id()) \ |
printk("ASSERT %s:%u %s unlocked\n", __FILE__, __LINE__, #l); \ |
} while(0) |
#define MUST_BE_UNLOCKED(l) \ |
do { if (atomic_read(&(l)->locked_by) == smp_processor_id()) \ |
printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, #l); \ |
} while(0) |
/* Write locked OK as well. */ |
#define MUST_BE_READ_LOCKED(l) \ |
do { if (!((l)->read_locked_map & (1UL << smp_processor_id())) \ |
&& !((l)->write_locked_map & (1UL << smp_processor_id()))) \ |
printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, #l); \ |
} while(0) |
#define MUST_BE_WRITE_LOCKED(l) \ |
do { if (!((l)->write_locked_map & (1UL << smp_processor_id()))) \ |
printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, #l); \ |
} while(0) |
#define MUST_BE_READ_WRITE_UNLOCKED(l) \ |
do { if ((l)->read_locked_map & (1UL << smp_processor_id())) \ |
printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, #l); \ |
else if ((l)->write_locked_map & (1UL << smp_processor_id())) \ |
printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, #l); \ |
} while(0) |
#define LOCK_BH(lk) \ |
do { \ |
MUST_BE_UNLOCKED(lk); \ |
spin_lock_bh(&(lk)->l); \ |
atomic_set(&(lk)->locked_by, smp_processor_id()); \ |
} while(0) |
#define UNLOCK_BH(lk) \ |
do { \ |
MUST_BE_LOCKED(lk); \ |
atomic_set(&(lk)->locked_by, -1); \ |
spin_unlock_bh(&(lk)->l); \ |
} while(0) |
#define READ_LOCK(lk) \ |
do { \ |
MUST_BE_READ_WRITE_UNLOCKED(lk); \ |
read_lock_bh(&(lk)->l); \ |
set_bit(smp_processor_id(), &(lk)->read_locked_map); \ |
} while(0) |
#define WRITE_LOCK(lk) \ |
do { \ |
MUST_BE_READ_WRITE_UNLOCKED(lk); \ |
write_lock_bh(&(lk)->l); \ |
set_bit(smp_processor_id(), &(lk)->write_locked_map); \ |
} while(0) |
#define READ_UNLOCK(lk) \ |
do { \ |
if (!((lk)->read_locked_map & (1UL << smp_processor_id()))) \ |
printk("ASSERT: %s:%u %s not readlocked\n", \ |
__FILE__, __LINE__, #lk); \ |
clear_bit(smp_processor_id(), &(lk)->read_locked_map); \ |
read_unlock_bh(&(lk)->l); \ |
} while(0) |
#define WRITE_UNLOCK(lk) \ |
do { \ |
MUST_BE_WRITE_LOCKED(lk); \ |
clear_bit(smp_processor_id(), &(lk)->write_locked_map); \ |
write_unlock_bh(&(lk)->l); \ |
} while(0) |
#else |
#define DECLARE_LOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED |
#define DECLARE_LOCK_EXTERN(l) extern spinlock_t l |
#define DECLARE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED |
#define DECLARE_RWLOCK_EXTERN(l) extern rwlock_t l |
#define MUST_BE_LOCKED(l) |
#define MUST_BE_UNLOCKED(l) |
#define MUST_BE_READ_LOCKED(l) |
#define MUST_BE_WRITE_LOCKED(l) |
#define MUST_BE_READ_WRITE_UNLOCKED(l) |
#define LOCK_BH(l) spin_lock_bh(l) |
#define UNLOCK_BH(l) spin_unlock_bh(l) |
#define READ_LOCK(l) read_lock_bh(l) |
#define WRITE_LOCK(l) write_lock_bh(l) |
#define READ_UNLOCK(l) read_unlock_bh(l) |
#define WRITE_UNLOCK(l) write_unlock_bh(l) |
#endif /*CONFIG_NETFILTER_DEBUG*/ |
#endif /* _LOCKHELP_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_SAME.h |
---|
0,0 → 1,19 |
#ifndef _IPT_SAME_H |
#define _IPT_SAME_H |
#define IPT_SAME_MAX_RANGE 10 |
#define IPT_SAME_NODST 0x01 |
struct ipt_same_info |
{ |
unsigned char info; |
u_int32_t rangesize; |
u_int32_t ipnum; |
u_int32_t *iparray; |
/* hangs off end. */ |
struct ip_nat_range range[IPT_SAME_MAX_RANGE]; |
}; |
#endif /*_IPT_SAME_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_iprange.h |
---|
0,0 → 1,23 |
#ifndef _IPT_IPRANGE_H |
#define _IPT_IPRANGE_H |
#define IPRANGE_SRC 0x01 /* Match source IP address */ |
#define IPRANGE_DST 0x02 /* Match destination IP address */ |
#define IPRANGE_SRC_INV 0x10 /* Negate the condition */ |
#define IPRANGE_DST_INV 0x20 /* Negate the condition */ |
struct ipt_iprange { |
/* Inclusive: network order. */ |
u_int32_t min_ip, max_ip; |
}; |
struct ipt_iprange_info |
{ |
struct ipt_iprange src; |
struct ipt_iprange dst; |
/* Flags from above */ |
u_int8_t flags; |
}; |
#endif /* _IPT_IPRANGE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_esp.h |
---|
0,0 → 1,16 |
#ifndef _IPT_ESP_H |
#define _IPT_ESP_H |
struct ipt_esp |
{ |
u_int32_t spis[2]; /* Security Parameter Index */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "invflags" field in struct ipt_esp. */ |
#define IPT_ESP_INV_SPI 0x01 /* Invert the sense of spi. */ |
#define IPT_ESP_INV_MASK 0x01 /* All possible flags. */ |
#endif /*_IPT_ESP_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_ah.h |
---|
0,0 → 1,16 |
#ifndef _IPT_AH_H |
#define _IPT_AH_H |
struct ipt_ah |
{ |
u_int32_t spis[2]; /* Security Parameter Index */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "invflags" field in struct ipt_ah. */ |
#define IPT_AH_INV_SPI 0x01 /* Invert the sense of spi. */ |
#define IPT_AH_INV_MASK 0x01 /* All possible flags. */ |
#endif /*_IPT_AH_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_owner.h |
---|
0,0 → 1,20 |
#ifndef _IPT_OWNER_H |
#define _IPT_OWNER_H |
/* match and invert flags */ |
#define IPT_OWNER_UID 0x01 |
#define IPT_OWNER_GID 0x02 |
#define IPT_OWNER_PID 0x04 |
#define IPT_OWNER_SID 0x08 |
#define IPT_OWNER_COMM 0x10 |
struct ipt_owner_info { |
uid_t uid; |
gid_t gid; |
pid_t pid; |
pid_t sid; |
char comm[16]; |
u_int8_t match, invert; /* flags */ |
}; |
#endif /*_IPT_OWNER_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipchains_core.h |
---|
0,0 → 1,189 |
/* |
* This code is heavily based on the code in ip_fw.h; see that file for |
* copyrights and attributions. This code is basically GPL. |
* |
* 15-Feb-1997: Major changes to allow graphs for firewall rules. |
* Paul Russell <Paul.Russell@rustcorp.com.au> and |
* Michael Neuling <Michael.Neuling@rustcorp.com.au> |
* 2-Nov-1997: Changed types to __u16, etc. |
* Removed IP_FW_F_TCPACK & IP_FW_F_BIDIR. |
* Added inverse flags field. |
* Removed multiple port specs. |
*/ |
/* |
* Format of an IP firewall descriptor |
* |
* src, dst, src_mask, dst_mask are always stored in network byte order. |
* flags are stored in host byte order (of course). |
* Port numbers are stored in HOST byte order. |
*/ |
#ifndef _IP_FWCHAINS_H |
#define _IP_FWCHAINS_H |
#ifdef __KERNEL__ |
#include <linux/icmp.h> |
#include <linux/in.h> |
#include <linux/ip.h> |
#include <linux/tcp.h> |
#include <linux/udp.h> |
#endif /* __KERNEL__ */ |
#define IP_FW_MAX_LABEL_LENGTH 8 |
typedef char ip_chainlabel[IP_FW_MAX_LABEL_LENGTH+1]; |
struct ip_fw |
{ |
struct in_addr fw_src, fw_dst; /* Source and destination IP addr */ |
struct in_addr fw_smsk, fw_dmsk; /* Mask for src and dest IP addr */ |
__u32 fw_mark; /* ID to stamp on packet */ |
__u16 fw_proto; /* Protocol, 0 = ANY */ |
__u16 fw_flg; /* Flags word */ |
__u16 fw_invflg; /* Inverse flags */ |
__u16 fw_spts[2]; /* Source port range. */ |
__u16 fw_dpts[2]; /* Destination port range. */ |
__u16 fw_redirpt; /* Port to redirect to. */ |
__u16 fw_outputsize; /* Max amount to output to |
NETLINK */ |
char fw_vianame[IFNAMSIZ]; /* name of interface "via" */ |
__u8 fw_tosand, fw_tosxor; /* Revised packet priority */ |
}; |
struct ip_fwuser |
{ |
struct ip_fw ipfw; |
ip_chainlabel label; |
}; |
/* Values for "fw_flg" field . */ |
#define IP_FW_F_PRN 0x0001 /* Print packet if it matches */ |
#define IP_FW_F_TCPSYN 0x0002 /* For tcp packets-check SYN only */ |
#define IP_FW_F_FRAG 0x0004 /* Set if rule is a fragment rule */ |
#define IP_FW_F_MARKABS 0x0008 /* Set the mark to fw_mark, not add. */ |
#define IP_FW_F_WILDIF 0x0010 /* Need only match start of interface name. */ |
#define IP_FW_F_NETLINK 0x0020 /* Redirect to netlink: 2.1.x only */ |
#define IP_FW_F_MASK 0x003F /* All possible flag bits mask */ |
/* Values for "fw_invflg" field. */ |
#define IP_FW_INV_SRCIP 0x0001 /* Invert the sense of fw_src. */ |
#define IP_FW_INV_DSTIP 0x0002 /* Invert the sense of fw_dst. */ |
#define IP_FW_INV_PROTO 0x0004 /* Invert the sense of fw_proto. */ |
#define IP_FW_INV_SRCPT 0x0008 /* Invert the sense of source ports. */ |
#define IP_FW_INV_DSTPT 0x0010 /* Invert the sense of destination ports. */ |
#define IP_FW_INV_VIA 0x0020 /* Invert the sense of fw_vianame. */ |
#define IP_FW_INV_SYN 0x0040 /* Invert the sense of IP_FW_F_TCPSYN. */ |
#define IP_FW_INV_FRAG 0x0080 /* Invert the sense of IP_FW_F_FRAG. */ |
/* |
* New IP firewall options for [gs]etsockopt at the RAW IP level. |
* Unlike BSD Linux inherits IP options so you don't have to use |
* a raw socket for this. Instead we check rights in the calls. */ |
#define IP_FW_BASE_CTL 64 /* base for firewall socket options */ |
#define IP_FW_APPEND (IP_FW_BASE_CTL) /* Takes ip_fwchange */ |
#define IP_FW_REPLACE (IP_FW_BASE_CTL+1) /* Takes ip_fwnew */ |
#define IP_FW_DELETE_NUM (IP_FW_BASE_CTL+2) /* Takes ip_fwdelnum */ |
#define IP_FW_DELETE (IP_FW_BASE_CTL+3) /* Takes ip_fwchange */ |
#define IP_FW_INSERT (IP_FW_BASE_CTL+4) /* Takes ip_fwnew */ |
#define IP_FW_FLUSH (IP_FW_BASE_CTL+5) /* Takes ip_chainlabel */ |
#define IP_FW_ZERO (IP_FW_BASE_CTL+6) /* Takes ip_chainlabel */ |
#define IP_FW_CHECK (IP_FW_BASE_CTL+7) /* Takes ip_fwtest */ |
#define IP_FW_MASQ_TIMEOUTS (IP_FW_BASE_CTL+8) /* Takes 3 ints */ |
#define IP_FW_CREATECHAIN (IP_FW_BASE_CTL+9) /* Takes ip_chainlabel */ |
#define IP_FW_DELETECHAIN (IP_FW_BASE_CTL+10) /* Takes ip_chainlabel */ |
#define IP_FW_POLICY (IP_FW_BASE_CTL+11) /* Takes ip_fwpolicy */ |
/* Masquerade control, only 1 optname */ |
#define IP_FW_MASQ_CTL (IP_FW_BASE_CTL+12) /* General ip_masq ctl */ |
/* Builtin chain labels */ |
#define IP_FW_LABEL_FORWARD "forward" |
#define IP_FW_LABEL_INPUT "input" |
#define IP_FW_LABEL_OUTPUT "output" |
/* Special targets */ |
#define IP_FW_LABEL_MASQUERADE "MASQ" |
#define IP_FW_LABEL_REDIRECT "REDIRECT" |
#define IP_FW_LABEL_ACCEPT "ACCEPT" |
#define IP_FW_LABEL_BLOCK "DENY" |
#define IP_FW_LABEL_REJECT "REJECT" |
#define IP_FW_LABEL_RETURN "RETURN" |
#define IP_FW_LABEL_QUEUE "QUEUE" |
/* Files in /proc/net */ |
#define IP_FW_PROC_CHAINS "ip_fwchains" |
#define IP_FW_PROC_CHAIN_NAMES "ip_fwnames" |
struct ip_fwpkt |
{ |
struct iphdr fwp_iph; /* IP header */ |
union { |
struct tcphdr fwp_tcph; /* TCP header or */ |
struct udphdr fwp_udph; /* UDP header */ |
struct icmphdr fwp_icmph; /* ICMP header */ |
} fwp_protoh; |
struct in_addr fwp_via; /* interface address */ |
char fwp_vianame[IFNAMSIZ]; /* interface name */ |
}; |
/* The argument to IP_FW_DELETE and IP_FW_APPEND */ |
struct ip_fwchange |
{ |
struct ip_fwuser fwc_rule; |
ip_chainlabel fwc_label; |
}; |
/* The argument to IP_FW_CHECK. */ |
struct ip_fwtest |
{ |
struct ip_fwpkt fwt_packet; /* Packet to be tested */ |
ip_chainlabel fwt_label; /* Block to start test in */ |
}; |
/* The argument to IP_FW_DELETE_NUM */ |
struct ip_fwdelnum |
{ |
__u32 fwd_rulenum; |
ip_chainlabel fwd_label; |
}; |
/* The argument to IP_FW_REPLACE and IP_FW_INSERT */ |
struct ip_fwnew |
{ |
__u32 fwn_rulenum; |
struct ip_fwuser fwn_rule; |
ip_chainlabel fwn_label; |
}; |
/* The argument to IP_FW_POLICY */ |
struct ip_fwpolicy |
{ |
ip_chainlabel fwp_policy; |
ip_chainlabel fwp_label; |
}; |
/* |
* timeouts for ip masquerading |
*/ |
extern int ip_fw_masq_timeouts(void *, int); |
/* |
* Main firewall chains definitions and global var's definitions. |
*/ |
#ifdef __KERNEL__ |
#include <linux/config.h> |
#include <linux/version.h> |
#include <linux/init.h> |
extern void ip_fw_init(void) __init; |
extern int ip_fw_ctl(int, void *, int); |
#ifdef CONFIG_IP_MASQUERADE |
extern int ip_masq_uctl(int, char *, int); |
#endif |
#endif /* KERNEL */ |
#endif /* _IP_FWCHAINS_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_irc.h |
---|
0,0 → 1,45 |
/* IRC extension for IP connection tracking. |
* (C) 2000 by Harald Welte <laforge@gnumonks.org> |
* based on RR's ip_conntrack_ftp.h |
* |
* ip_conntrack_irc.h,v 1.6 2000/11/07 18:26:42 laforge Exp |
* |
* This program is free software; you can redistribute it and/or |
* modify it under the terms of the GNU General Public License |
* as published by the Free Software Foundation; either version |
* 2 of the License, or (at your option) any later version. |
* |
* |
*/ |
#ifndef _IP_CONNTRACK_IRC_H |
#define _IP_CONNTRACK_IRC_H |
/* We record seq number and length of irc ip/port text here: all in |
host order. */ |
/* This structure is per expected connection */ |
struct ip_ct_irc_expect |
{ |
/* length of IP address */ |
u_int32_t len; |
/* Port that was to be used */ |
u_int16_t port; |
}; |
/* This structure exists only once per master */ |
struct ip_ct_irc_master { |
}; |
#ifdef __KERNEL__ |
#include <linux/netfilter_ipv4/lockhelp.h> |
#define IRC_PORT 6667 |
/* Protects irc part of conntracks */ |
DECLARE_LOCK_EXTERN(ip_irc_lock); |
#endif /* __KERNEL__ */ |
#endif /* _IP_CONNTRACK_IRC_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_tftp.h |
---|
0,0 → 1,13 |
#ifndef _IP_CT_TFTP |
#define _IP_CT_TFTP |
#define TFTP_PORT 69 |
struct tftphdr { |
u_int16_t opcode; |
}; |
#define TFTP_OPCODE_READ 1 |
#define TFTP_OPCODE_WRITE 2 |
#endif /* _IP_CT_TFTP */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/compat_firewall.h |
---|
0,0 → 1,45 |
/* Minor modifications to fit on compatibility framework: |
Rusty.Russell@rustcorp.com.au |
*/ |
#ifndef __LINUX_FIREWALL_H |
#define __LINUX_FIREWALL_H |
/* |
* Definitions for loadable firewall modules |
*/ |
#define FW_QUEUE 0 |
#define FW_BLOCK 1 |
#define FW_ACCEPT 2 |
#define FW_REJECT (-1) |
#define FW_REDIRECT 3 |
#define FW_MASQUERADE 4 |
#define FW_SKIP 5 |
struct firewall_ops |
{ |
struct firewall_ops *next; |
int (*fw_forward)(struct firewall_ops *this, int pf, |
struct net_device *dev, void *arg, |
struct sk_buff **pskb); |
int (*fw_input)(struct firewall_ops *this, int pf, |
struct net_device *dev, void *arg, |
struct sk_buff **pskb); |
int (*fw_output)(struct firewall_ops *this, int pf, |
struct net_device *dev, void *arg, |
struct sk_buff **pskb); |
/* These may be NULL. */ |
int (*fw_acct_in)(struct firewall_ops *this, int pf, |
struct net_device *dev, void *arg, |
struct sk_buff **pskb); |
int (*fw_acct_out)(struct firewall_ops *this, int pf, |
struct net_device *dev, void *arg, |
struct sk_buff **pskb); |
}; |
extern int register_firewall(int pf, struct firewall_ops *fw); |
extern int unregister_firewall(int pf, struct firewall_ops *fw); |
extern int ip_fw_masq_timeouts(void *user, int len); |
#endif /* __LINUX_FIREWALL_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_nat_helper.h |
---|
0,0 → 1,64 |
#ifndef _IP_NAT_HELPER_H |
#define _IP_NAT_HELPER_H |
/* NAT protocol helper routines. */ |
#include <linux/netfilter_ipv4/ip_conntrack.h> |
#include <linux/module.h> |
struct sk_buff; |
/* Flags */ |
/* NAT helper must be called on every packet (for TCP) */ |
#define IP_NAT_HELPER_F_ALWAYS 0x01 |
struct ip_nat_helper |
{ |
struct list_head list; /* Internal use */ |
const char *name; /* name of the module */ |
unsigned char flags; /* Flags (see above) */ |
struct module *me; /* pointer to self */ |
/* Mask of things we will help: vs. tuple from server */ |
struct ip_conntrack_tuple tuple; |
struct ip_conntrack_tuple mask; |
/* Helper function: returns verdict */ |
unsigned int (*help)(struct ip_conntrack *ct, |
struct ip_conntrack_expect *exp, |
struct ip_nat_info *info, |
enum ip_conntrack_info ctinfo, |
unsigned int hooknum, |
struct sk_buff **pskb); |
/* Returns verdict and sets up NAT for this connection */ |
unsigned int (*expect)(struct sk_buff **pskb, |
unsigned int hooknum, |
struct ip_conntrack *ct, |
struct ip_nat_info *info); |
}; |
extern struct list_head helpers; |
extern int ip_nat_helper_register(struct ip_nat_helper *me); |
extern void ip_nat_helper_unregister(struct ip_nat_helper *me); |
/* These return true or false. */ |
extern int ip_nat_mangle_tcp_packet(struct sk_buff **skb, |
struct ip_conntrack *ct, |
enum ip_conntrack_info ctinfo, |
unsigned int match_offset, |
unsigned int match_len, |
const char *rep_buffer, |
unsigned int rep_len); |
extern int ip_nat_mangle_udp_packet(struct sk_buff **skb, |
struct ip_conntrack *ct, |
enum ip_conntrack_info ctinfo, |
unsigned int match_offset, |
unsigned int match_len, |
const char *rep_buffer, |
unsigned int rep_len); |
extern int ip_nat_seq_adjust(struct sk_buff **pskb, |
struct ip_conntrack *ct, |
enum ip_conntrack_info ctinfo); |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack.h |
---|
0,0 → 1,282 |
#ifndef _IP_CONNTRACK_H |
#define _IP_CONNTRACK_H |
/* Connection state tracking for netfilter. This is separated from, |
but required by, the NAT layer; it can also be used by an iptables |
extension. */ |
#include <linux/config.h> |
#include <linux/netfilter_ipv4/ip_conntrack_tuple.h> |
#include <linux/bitops.h> |
#include <linux/compiler.h> |
#include <asm/atomic.h> |
enum ip_conntrack_info |
{ |
/* Part of an established connection (either direction). */ |
IP_CT_ESTABLISHED, |
/* Like NEW, but related to an existing connection, or ICMP error |
(in either direction). */ |
IP_CT_RELATED, |
/* Started a new connection to track (only |
IP_CT_DIR_ORIGINAL); may be a retransmission. */ |
IP_CT_NEW, |
/* >= this indicates reply direction */ |
IP_CT_IS_REPLY, |
/* Number of distinct IP_CT types (no NEW in reply dirn). */ |
IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1 |
}; |
/* Bitset representing status of connection. */ |
enum ip_conntrack_status { |
/* It's an expected connection: bit 0 set. This bit never changed */ |
IPS_EXPECTED_BIT = 0, |
IPS_EXPECTED = (1 << IPS_EXPECTED_BIT), |
/* We've seen packets both ways: bit 1 set. Can be set, not unset. */ |
IPS_SEEN_REPLY_BIT = 1, |
IPS_SEEN_REPLY = (1 << IPS_SEEN_REPLY_BIT), |
/* Conntrack should never be early-expired. */ |
IPS_ASSURED_BIT = 2, |
IPS_ASSURED = (1 << IPS_ASSURED_BIT), |
/* Connection is confirmed: originating packet has left box */ |
IPS_CONFIRMED_BIT = 3, |
IPS_CONFIRMED = (1 << IPS_CONFIRMED_BIT), |
}; |
#include <linux/netfilter_ipv4/ip_conntrack_tcp.h> |
#include <linux/netfilter_ipv4/ip_conntrack_icmp.h> |
/* per conntrack: protocol private data */ |
union ip_conntrack_proto { |
/* insert conntrack proto private data here */ |
struct ip_ct_tcp tcp; |
struct ip_ct_icmp icmp; |
}; |
union ip_conntrack_expect_proto { |
/* insert expect proto private data here */ |
}; |
/* Add protocol helper include file here */ |
#include <linux/netfilter_ipv4/ip_conntrack_amanda.h> |
#include <linux/netfilter_ipv4/ip_conntrack_ftp.h> |
#include <linux/netfilter_ipv4/ip_conntrack_irc.h> |
/* per expectation: application helper private data */ |
union ip_conntrack_expect_help { |
/* insert conntrack helper private data (expect) here */ |
struct ip_ct_amanda_expect exp_amanda_info; |
struct ip_ct_ftp_expect exp_ftp_info; |
struct ip_ct_irc_expect exp_irc_info; |
#ifdef CONFIG_IP_NF_NAT_NEEDED |
union { |
/* insert nat helper private data (expect) here */ |
} nat; |
#endif |
}; |
/* per conntrack: application helper private data */ |
union ip_conntrack_help { |
/* insert conntrack helper private data (master) here */ |
struct ip_ct_ftp_master ct_ftp_info; |
struct ip_ct_irc_master ct_irc_info; |
}; |
#ifdef CONFIG_IP_NF_NAT_NEEDED |
#include <linux/netfilter_ipv4/ip_nat.h> |
/* per conntrack: nat application helper private data */ |
union ip_conntrack_nat_help { |
/* insert nat helper private data here */ |
}; |
#endif |
#ifdef __KERNEL__ |
#include <linux/types.h> |
#include <linux/skbuff.h> |
#ifdef CONFIG_NF_DEBUG |
#define IP_NF_ASSERT(x) \ |
do { \ |
if (!(x)) \ |
/* Wooah! I'm tripping my conntrack in a frenzy of \ |
netplay... */ \ |
printk("NF_IP_ASSERT: %s:%i(%s)\n", \ |
__FILE__, __LINE__, __FUNCTION__); \ |
} while(0) |
#else |
#define IP_NF_ASSERT(x) |
#endif |
struct ip_conntrack_expect |
{ |
/* Internal linked list (global expectation list) */ |
struct list_head list; |
/* reference count */ |
atomic_t use; |
/* expectation list for this master */ |
struct list_head expected_list; |
/* The conntrack of the master connection */ |
struct ip_conntrack *expectant; |
/* The conntrack of the sibling connection, set after |
* expectation arrived */ |
struct ip_conntrack *sibling; |
/* Tuple saved for conntrack */ |
struct ip_conntrack_tuple ct_tuple; |
/* Timer function; deletes the expectation. */ |
struct timer_list timeout; |
/* Data filled out by the conntrack helpers follow: */ |
/* We expect this tuple, with the following mask */ |
struct ip_conntrack_tuple tuple, mask; |
/* Function to call after setup and insertion */ |
int (*expectfn)(struct ip_conntrack *new); |
/* At which sequence number did this expectation occur */ |
u_int32_t seq; |
union ip_conntrack_expect_proto proto; |
union ip_conntrack_expect_help help; |
}; |
#include <linux/netfilter_ipv4/ip_conntrack_helper.h> |
struct ip_conntrack |
{ |
/* Usage count in here is 1 for hash table/destruct timer, 1 per skb, |
plus 1 for any connection(s) we are `master' for */ |
struct nf_conntrack ct_general; |
/* These are my tuples; original and reply */ |
struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; |
/* Have we seen traffic both ways yet? (bitset) */ |
unsigned long status; |
/* Timer function; drops refcnt when it goes off. */ |
struct timer_list timeout; |
/* If we're expecting another related connection, this will be |
in expected linked list */ |
struct list_head sibling_list; |
/* Current number of expected connections */ |
unsigned int expecting; |
/* If we were expected by an expectation, this will be it */ |
struct ip_conntrack_expect *master; |
/* Helper, if any. */ |
struct ip_conntrack_helper *helper; |
/* Our various nf_ct_info structs specify *what* relation this |
packet has to the conntrack */ |
struct nf_ct_info infos[IP_CT_NUMBER]; |
/* Storage reserved for other modules: */ |
union ip_conntrack_proto proto; |
union ip_conntrack_help help; |
#ifdef CONFIG_IP_NF_NAT_NEEDED |
struct { |
struct ip_nat_info info; |
union ip_conntrack_nat_help help; |
#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ |
defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) |
int masq_index; |
#endif |
} nat; |
#endif /* CONFIG_IP_NF_NAT_NEEDED */ |
}; |
/* get master conntrack via master expectation */ |
#define master_ct(conntr) (conntr->master ? conntr->master->expectant : NULL) |
/* Alter reply tuple (maybe alter helper). If it's already taken, |
return 0 and don't do alteration. */ |
extern int |
ip_conntrack_alter_reply(struct ip_conntrack *conntrack, |
const struct ip_conntrack_tuple *newreply); |
/* Is this tuple taken? (ignoring any belonging to the given |
conntrack). */ |
extern int |
ip_conntrack_tuple_taken(const struct ip_conntrack_tuple *tuple, |
const struct ip_conntrack *ignored_conntrack); |
/* Return conntrack_info and tuple hash for given skb. */ |
extern struct ip_conntrack * |
ip_conntrack_get(struct sk_buff *skb, enum ip_conntrack_info *ctinfo); |
/* decrement reference count on a conntrack */ |
extern inline void ip_conntrack_put(struct ip_conntrack *ct); |
/* find unconfirmed expectation based on tuple */ |
struct ip_conntrack_expect * |
ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple); |
/* decrement reference count on an expectation */ |
void ip_conntrack_expect_put(struct ip_conntrack_expect *exp); |
/* call to create an explicit dependency on ip_conntrack. */ |
extern void need_ip_conntrack(void); |
extern int invert_tuplepr(struct ip_conntrack_tuple *inverse, |
const struct ip_conntrack_tuple *orig); |
/* Refresh conntrack for this many jiffies */ |
extern void ip_ct_refresh(struct ip_conntrack *ct, |
unsigned long extra_jiffies); |
/* These are for NAT. Icky. */ |
/* Call me when a conntrack is destroyed. */ |
extern void (*ip_conntrack_destroyed)(struct ip_conntrack *conntrack); |
/* Returns new sk_buff, or NULL */ |
struct sk_buff * |
ip_ct_gather_frags(struct sk_buff *skb); |
/* Delete all conntracks which match. */ |
extern void |
ip_ct_selective_cleanup(int (*kill)(const struct ip_conntrack *i, void *data), |
void *data); |
/* It's confirmed if it is, or has been in the hash table. */ |
static inline int is_confirmed(struct ip_conntrack *ct) |
{ |
return test_bit(IPS_CONFIRMED_BIT, &ct->status); |
} |
extern unsigned int ip_conntrack_htable_size; |
/* eg. PROVIDES_CONNTRACK(ftp); */ |
#define PROVIDES_CONNTRACK(name) \ |
int needs_ip_conntrack_##name; \ |
EXPORT_SYMBOL(needs_ip_conntrack_##name) |
/*. eg. NEEDS_CONNTRACK(ftp); */ |
#define NEEDS_CONNTRACK(name) \ |
extern int needs_ip_conntrack_##name; \ |
static int *need_ip_conntrack_##name __attribute_used__ = &needs_ip_conntrack_##name |
#endif /* __KERNEL__ */ |
#endif /* _IP_CONNTRACK_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_pkttype.h |
---|
0,0 → 1,8 |
#ifndef _IPT_PKTTYPE_H |
#define _IPT_PKTTYPE_H |
struct ipt_pkttype_info { |
int pkttype; |
int invert; |
}; |
#endif /*_IPT_PKTTYPE_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_tos.h |
---|
0,0 → 1,13 |
#ifndef _IPT_TOS_H |
#define _IPT_TOS_H |
struct ipt_tos_info { |
u_int8_t tos; |
u_int8_t invert; |
}; |
#ifndef IPTOS_NORMALSVC |
#define IPTOS_NORMALSVC 0 |
#endif |
#endif /*_IPT_TOS_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_ECN.h |
---|
0,0 → 1,31 |
/* Header file for iptables ipt_ECN target |
* |
* (C) 2002 by Harald Welte <laforge@gnumonks.org> |
* |
* This software is distributed under GNU GPL v2, 1991 |
* |
* ipt_ECN.h,v 1.3 2002/05/29 12:17:40 laforge Exp |
*/ |
#ifndef _IPT_ECN_TARGET_H |
#define _IPT_ECN_TARGET_H |
#include <linux/netfilter_ipv4/ipt_DSCP.h> |
#define IPT_ECN_IP_MASK (~IPT_DSCP_MASK) |
#define IPT_ECN_OP_SET_IP 0x01 /* set ECN bits of IPv4 header */ |
#define IPT_ECN_OP_SET_ECE 0x10 /* set ECE bit of TCP header */ |
#define IPT_ECN_OP_SET_CWR 0x20 /* set CWR bit of TCP header */ |
#define IPT_ECN_OP_MASK 0xce |
struct ipt_ECN_info { |
u_int8_t operation; /* bitset of operations */ |
u_int8_t ip_ect; /* ECT codepoint of IPv4 header, pre-shifted */ |
union { |
struct { |
u_int8_t ece:1, cwr:1; /* TCP ECT bits */ |
} tcp; |
} proto; |
}; |
#endif /* _IPT_ECN_TARGET_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_core.h |
---|
0,0 → 1,54 |
#ifndef _IP_CONNTRACK_CORE_H |
#define _IP_CONNTRACK_CORE_H |
#include <linux/netfilter.h> |
#include <linux/netfilter_ipv4/lockhelp.h> |
/* This header is used to share core functionality between the |
standalone connection tracking module, and the compatibility layer's use |
of connection tracking. */ |
extern unsigned int ip_conntrack_in(unsigned int hooknum, |
struct sk_buff **pskb, |
const struct net_device *in, |
const struct net_device *out, |
int (*okfn)(struct sk_buff *)); |
extern int ip_conntrack_init(void); |
extern void ip_conntrack_cleanup(void); |
struct ip_conntrack_protocol; |
extern struct ip_conntrack_protocol *ip_ct_find_proto(u_int8_t protocol); |
/* Like above, but you already have conntrack read lock. */ |
extern struct ip_conntrack_protocol *__ip_ct_find_proto(u_int8_t protocol); |
extern struct list_head protocol_list; |
/* Returns conntrack if it dealt with ICMP, and filled in skb->nfct */ |
extern struct ip_conntrack *icmp_error_track(struct sk_buff *skb, |
enum ip_conntrack_info *ctinfo, |
unsigned int hooknum); |
extern int get_tuple(const struct iphdr *iph, |
const struct sk_buff *skb, |
unsigned int dataoff, |
struct ip_conntrack_tuple *tuple, |
const struct ip_conntrack_protocol *protocol); |
/* Find a connection corresponding to a tuple. */ |
struct ip_conntrack_tuple_hash * |
ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple, |
const struct ip_conntrack *ignored_conntrack); |
extern int __ip_conntrack_confirm(struct nf_ct_info *nfct); |
/* Confirm a connection: returns NF_DROP if packet must be dropped. */ |
static inline int ip_conntrack_confirm(struct sk_buff *skb) |
{ |
if (skb->nfct |
&& !is_confirmed((struct ip_conntrack *)skb->nfct->master)) |
return __ip_conntrack_confirm(skb->nfct); |
return NF_ACCEPT; |
} |
extern struct list_head *ip_conntrack_hash; |
extern struct list_head ip_conntrack_expect_list; |
DECLARE_RWLOCK_EXTERN(ip_conntrack_lock); |
#endif /* _IP_CONNTRACK_CORE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_ULOG.h |
---|
0,0 → 1,46 |
/* Header file for IP tables userspace logging, Version 1.8 |
* |
* (C) 2000-2002 by Harald Welte <laforge@gnumonks.org> |
* |
* Distributed under the terms of GNU GPL */ |
#ifndef _IPT_ULOG_H |
#define _IPT_ULOG_H |
#ifndef NETLINK_NFLOG |
#define NETLINK_NFLOG 5 |
#endif |
#define ULOG_MAC_LEN 80 |
#define ULOG_PREFIX_LEN 32 |
#define ULOG_MAX_QLEN 50 |
/* Why 50? Well... there is a limit imposed by the slab cache 131000 |
* bytes. So the multipart netlink-message has to be < 131000 bytes. |
* Assuming a standard ethernet-mtu of 1500, we could define this up |
* to 80... but even 50 seems to be big enough. */ |
/* private data structure for each rule with a ULOG target */ |
struct ipt_ulog_info { |
unsigned int nl_group; |
size_t copy_range; |
size_t qthreshold; |
char prefix[ULOG_PREFIX_LEN]; |
}; |
/* Format of the ULOG packets passed through netlink */ |
typedef struct ulog_packet_msg { |
unsigned long mark; |
long timestamp_sec; |
long timestamp_usec; |
unsigned int hook; |
char indev_name[IFNAMSIZ]; |
char outdev_name[IFNAMSIZ]; |
size_t data_len; |
char prefix[ULOG_PREFIX_LEN]; |
unsigned char mac_len; |
unsigned char mac[ULOG_MAC_LEN]; |
unsigned char payload[0]; |
} ulog_packet_msg_t; |
#endif /*_IPT_ULOG_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_tuple.h |
---|
0,0 → 1,139 |
#ifndef _IP_CONNTRACK_TUPLE_H |
#define _IP_CONNTRACK_TUPLE_H |
/* A `tuple' is a structure containing the information to uniquely |
identify a connection. ie. if two packets have the same tuple, they |
are in the same connection; if not, they are not. |
We divide the structure along "manipulatable" and |
"non-manipulatable" lines, for the benefit of the NAT code. |
*/ |
/* The protocol-specific manipulable parts of the tuple: always in |
network order! */ |
union ip_conntrack_manip_proto |
{ |
/* Add other protocols here. */ |
u_int16_t all; |
struct { |
u_int16_t port; |
} tcp; |
struct { |
u_int16_t port; |
} udp; |
struct { |
u_int16_t id; |
} icmp; |
}; |
/* The manipulable part of the tuple. */ |
struct ip_conntrack_manip |
{ |
u_int32_t ip; |
union ip_conntrack_manip_proto u; |
}; |
/* This contains the information to distinguish a connection. */ |
struct ip_conntrack_tuple |
{ |
struct ip_conntrack_manip src; |
/* These are the parts of the tuple which are fixed. */ |
struct { |
u_int32_t ip; |
union { |
/* Add other protocols here. */ |
u_int16_t all; |
struct { |
u_int16_t port; |
} tcp; |
struct { |
u_int16_t port; |
} udp; |
struct { |
u_int8_t type, code; |
} icmp; |
} u; |
/* The protocol. */ |
u_int16_t protonum; |
} dst; |
}; |
/* This is optimized opposed to a memset of the whole structure. Everything we |
* really care about is the source/destination unions */ |
#define IP_CT_TUPLE_U_BLANK(tuple) \ |
do { \ |
(tuple)->src.u.all = 0; \ |
(tuple)->dst.u.all = 0; \ |
} while (0) |
enum ip_conntrack_dir |
{ |
IP_CT_DIR_ORIGINAL, |
IP_CT_DIR_REPLY, |
IP_CT_DIR_MAX |
}; |
#ifdef __KERNEL__ |
#define DUMP_TUPLE(tp) \ |
DEBUGP("tuple %p: %u %u.%u.%u.%u:%hu -> %u.%u.%u.%u:%hu\n", \ |
(tp), (tp)->dst.protonum, \ |
NIPQUAD((tp)->src.ip), ntohs((tp)->src.u.all), \ |
NIPQUAD((tp)->dst.ip), ntohs((tp)->dst.u.all)) |
#define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL) |
/* If we're the first tuple, it's the original dir. */ |
#define DIRECTION(h) ((enum ip_conntrack_dir)(&(h)->ctrack->tuplehash[1] == (h))) |
/* Connections have two entries in the hash table: one for each way */ |
struct ip_conntrack_tuple_hash |
{ |
struct list_head list; |
struct ip_conntrack_tuple tuple; |
/* this == &ctrack->tuplehash[DIRECTION(this)]. */ |
struct ip_conntrack *ctrack; |
}; |
#endif /* __KERNEL__ */ |
static inline int ip_ct_tuple_src_equal(const struct ip_conntrack_tuple *t1, |
const struct ip_conntrack_tuple *t2) |
{ |
return t1->src.ip == t2->src.ip |
&& t1->src.u.all == t2->src.u.all; |
} |
static inline int ip_ct_tuple_dst_equal(const struct ip_conntrack_tuple *t1, |
const struct ip_conntrack_tuple *t2) |
{ |
return t1->dst.ip == t2->dst.ip |
&& t1->dst.u.all == t2->dst.u.all |
&& t1->dst.protonum == t2->dst.protonum; |
} |
static inline int ip_ct_tuple_equal(const struct ip_conntrack_tuple *t1, |
const struct ip_conntrack_tuple *t2) |
{ |
return ip_ct_tuple_src_equal(t1, t2) && ip_ct_tuple_dst_equal(t1, t2); |
} |
static inline int ip_ct_tuple_mask_cmp(const struct ip_conntrack_tuple *t, |
const struct ip_conntrack_tuple *tuple, |
const struct ip_conntrack_tuple *mask) |
{ |
return !(((t->src.ip ^ tuple->src.ip) & mask->src.ip) |
|| ((t->dst.ip ^ tuple->dst.ip) & mask->dst.ip) |
|| ((t->src.u.all ^ tuple->src.u.all) & mask->src.u.all) |
|| ((t->dst.u.all ^ tuple->dst.u.all) & mask->dst.u.all) |
|| ((t->dst.protonum ^ tuple->dst.protonum) |
& mask->dst.protonum)); |
} |
#endif /* _IP_CONNTRACK_TUPLE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_ftp.h |
---|
0,0 → 1,48 |
#ifndef _IP_CONNTRACK_FTP_H |
#define _IP_CONNTRACK_FTP_H |
/* FTP tracking. */ |
#ifdef __KERNEL__ |
#include <linux/netfilter_ipv4/lockhelp.h> |
/* Protects ftp part of conntracks */ |
DECLARE_LOCK_EXTERN(ip_ftp_lock); |
#define FTP_PORT 21 |
#endif /* __KERNEL__ */ |
enum ip_ct_ftp_type |
{ |
/* PORT command from client */ |
IP_CT_FTP_PORT, |
/* PASV response from server */ |
IP_CT_FTP_PASV, |
/* EPRT command from client */ |
IP_CT_FTP_EPRT, |
/* EPSV response from server */ |
IP_CT_FTP_EPSV, |
}; |
/* This structure is per expected connection */ |
struct ip_ct_ftp_expect |
{ |
/* We record seq number and length of ftp ip/port text here: all in |
* host order. */ |
/* sequence number of IP address in packet is in ip_conntrack_expect */ |
u_int32_t len; /* length of IP address */ |
enum ip_ct_ftp_type ftptype; /* PORT or PASV ? */ |
u_int16_t port; /* TCP port that was to be used */ |
}; |
/* This structure exists only once per master */ |
struct ip_ct_ftp_master { |
/* Next valid seq position for cmd matching after newline */ |
u_int32_t seq_aft_nl[IP_CT_DIR_MAX]; |
/* 0 means seq_match_aft_nl not set */ |
int seq_aft_nl_set[IP_CT_DIR_MAX]; |
}; |
#endif /* _IP_CONNTRACK_FTP_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/listhelp.h |
---|
0,0 → 1,131 |
#ifndef _LISTHELP_H |
#define _LISTHELP_H |
#include <linux/config.h> |
#include <linux/list.h> |
#include <linux/netfilter_ipv4/lockhelp.h> |
/* Header to do more comprehensive job than linux/list.h; assume list |
is first entry in structure. */ |
/* Return pointer to first true entry, if any, or NULL. A macro |
required to allow inlining of cmpfn. */ |
#define LIST_FIND(head, cmpfn, type, args...) \ |
({ \ |
const struct list_head *__i = (head); \ |
\ |
ASSERT_READ_LOCK(head); \ |
do { \ |
__i = __i->next; \ |
if (__i == (head)) { \ |
__i = NULL; \ |
break; \ |
} \ |
} while (!cmpfn((const type)__i , ## args)); \ |
(type)__i; \ |
}) |
#define LIST_FIND_W(head, cmpfn, type, args...) \ |
({ \ |
const struct list_head *__i = (head); \ |
\ |
ASSERT_WRITE_LOCK(head); \ |
do { \ |
__i = __i->next; \ |
if (__i == (head)) { \ |
__i = NULL; \ |
break; \ |
} \ |
} while (!cmpfn((type)__i , ## args)); \ |
(type)__i; \ |
}) |
/* Just like LIST_FIND but we search backwards */ |
#define LIST_FIND_B(head, cmpfn, type, args...) \ |
({ \ |
const struct list_head *__i = (head); \ |
\ |
ASSERT_READ_LOCK(head); \ |
do { \ |
__i = __i->prev; \ |
if (__i == (head)) { \ |
__i = NULL; \ |
break; \ |
} \ |
} while (!cmpfn((const type)__i , ## args)); \ |
(type)__i; \ |
}) |
static inline int |
__list_cmp_same(const void *p1, const void *p2) { return p1 == p2; } |
/* Is this entry in the list? */ |
static inline int |
list_inlist(struct list_head *head, const void *entry) |
{ |
return LIST_FIND(head, __list_cmp_same, void *, entry) != NULL; |
} |
/* Delete from list. */ |
#ifdef CONFIG_NETFILTER_DEBUG |
#define LIST_DELETE(head, oldentry) \ |
do { \ |
ASSERT_WRITE_LOCK(head); \ |
if (!list_inlist(head, oldentry)) \ |
printk("LIST_DELETE: %s:%u `%s'(%p) not in %s.\n", \ |
__FILE__, __LINE__, #oldentry, oldentry, #head); \ |
else list_del((struct list_head *)oldentry); \ |
} while(0) |
#else |
#define LIST_DELETE(head, oldentry) list_del((struct list_head *)oldentry) |
#endif |
/* Append. */ |
static inline void |
list_append(struct list_head *head, void *new) |
{ |
ASSERT_WRITE_LOCK(head); |
list_add((new), (head)->prev); |
} |
/* Prepend. */ |
static inline void |
list_prepend(struct list_head *head, void *new) |
{ |
ASSERT_WRITE_LOCK(head); |
list_add(new, head); |
} |
/* Insert according to ordering function; insert before first true. */ |
#define LIST_INSERT(head, new, cmpfn) \ |
do { \ |
struct list_head *__i; \ |
ASSERT_WRITE_LOCK(head); \ |
for (__i = (head)->next; \ |
!cmpfn((new), (typeof (new))__i) && __i != (head); \ |
__i = __i->next); \ |
list_add((struct list_head *)(new), __i->prev); \ |
} while(0) |
/* If the field after the list_head is a nul-terminated string, you |
can use these functions. */ |
static inline int __list_cmp_name(const void *i, const char *name) |
{ |
return strcmp(name, i+sizeof(struct list_head)) == 0; |
} |
/* Returns false if same name already in list, otherwise does insert. */ |
static inline int |
list_named_insert(struct list_head *head, void *new) |
{ |
if (LIST_FIND(head, __list_cmp_name, void *, |
new + sizeof(struct list_head))) |
return 0; |
list_prepend(head, new); |
return 1; |
} |
/* Find this named element in the list. */ |
#define list_named_find(head, name) \ |
LIST_FIND(head, __list_cmp_name, void *, name) |
#endif /*_LISTHELP_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_tcpmss.h |
---|
0,0 → 1,9 |
#ifndef _IPT_TCPMSS_MATCH_H |
#define _IPT_TCPMSS_MATCH_H |
struct ipt_tcpmss_match_info { |
u_int16_t mss_min, mss_max; |
u_int8_t invert; |
}; |
#endif /*_IPT_TCPMSS_MATCH_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_TCPMSS.h |
---|
0,0 → 1,10 |
#ifndef _IPT_TCPMSS_H |
#define _IPT_TCPMSS_H |
struct ipt_tcpmss_info { |
u_int16_t mss; |
}; |
#define IPT_TCPMSS_CLAMP_PMTU 0xffff |
#endif /*_IPT_TCPMSS_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_CLASSIFY.h |
---|
0,0 → 1,8 |
#ifndef _IPT_CLASSIFY_H |
#define _IPT_CLASSIFY_H |
struct ipt_classify_target_info { |
u_int32_t priority; |
}; |
#endif /*_IPT_CLASSIFY_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_protocol.h |
---|
0,0 → 1,66 |
/* Header for use in defining a given protocol for connection tracking. */ |
#ifndef _IP_CONNTRACK_PROTOCOL_H |
#define _IP_CONNTRACK_PROTOCOL_H |
#include <linux/netfilter_ipv4/ip_conntrack.h> |
struct ip_conntrack_protocol |
{ |
/* Next pointer. */ |
struct list_head list; |
/* Protocol number. */ |
u_int8_t proto; |
/* Protocol name */ |
const char *name; |
/* Try to fill in the third arg: dataoff is offset past IP |
hdr. Return true if possible. */ |
int (*pkt_to_tuple)(const struct sk_buff *skb, |
unsigned int dataoff, |
struct ip_conntrack_tuple *tuple); |
/* Invert the per-proto part of the tuple: ie. turn xmit into reply. |
* Some packets can't be inverted: return 0 in that case. |
*/ |
int (*invert_tuple)(struct ip_conntrack_tuple *inverse, |
const struct ip_conntrack_tuple *orig); |
/* Print out the per-protocol part of the tuple. */ |
unsigned int (*print_tuple)(char *buffer, |
const struct ip_conntrack_tuple *); |
/* Print out the private part of the conntrack. */ |
unsigned int (*print_conntrack)(char *buffer, |
const struct ip_conntrack *); |
/* Returns verdict for packet, or -1 for invalid. */ |
int (*packet)(struct ip_conntrack *conntrack, |
const struct sk_buff *skb, |
enum ip_conntrack_info ctinfo); |
/* Called when a new connection for this protocol found; |
* returns TRUE if it's OK. If so, packet() called next. */ |
int (*new)(struct ip_conntrack *conntrack, const struct sk_buff *skb); |
/* Called when a conntrack entry is destroyed */ |
void (*destroy)(struct ip_conntrack *conntrack); |
/* Has to decide if a expectation matches one packet or not */ |
int (*exp_matches_pkt)(struct ip_conntrack_expect *exp, |
const struct sk_buff *skb); |
/* Module (if any) which this is connected to. */ |
struct module *me; |
}; |
/* Protocol registration. */ |
extern int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto); |
extern void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto); |
/* Existing built-in protocols */ |
extern struct ip_conntrack_protocol ip_conntrack_protocol_tcp; |
extern struct ip_conntrack_protocol ip_conntrack_protocol_udp; |
extern struct ip_conntrack_protocol ip_conntrack_protocol_icmp; |
extern int ip_conntrack_protocol_tcp_init(void); |
#endif /*_IP_CONNTRACK_PROTOCOL_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_LOG.h |
---|
0,0 → 1,15 |
#ifndef _IPT_LOG_H |
#define _IPT_LOG_H |
#define IPT_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ |
#define IPT_LOG_TCPOPT 0x02 /* Log TCP options */ |
#define IPT_LOG_IPOPT 0x04 /* Log IP options */ |
#define IPT_LOG_MASK 0x07 |
struct ipt_log_info { |
unsigned char level; |
unsigned char logflags; |
char prefix[30]; |
}; |
#endif /*_IPT_LOG_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_length.h |
---|
0,0 → 1,9 |
#ifndef _IPT_LENGTH_H |
#define _IPT_LENGTH_H |
struct ipt_length_info { |
u_int16_t min, max; |
u_int8_t invert; |
}; |
#endif /*_IPT_LENGTH_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_conntrack.h |
---|
0,0 → 1,38 |
/* Header file for kernel module to match connection tracking information. |
* GPL (C) 2001 Marc Boucher (marc@mbsi.ca). |
*/ |
#ifndef _IPT_CONNTRACK_H |
#define _IPT_CONNTRACK_H |
#define IPT_CONNTRACK_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) |
#define IPT_CONNTRACK_STATE_INVALID (1 << 0) |
#define IPT_CONNTRACK_STATE_SNAT (1 << (IP_CT_NUMBER + 1)) |
#define IPT_CONNTRACK_STATE_DNAT (1 << (IP_CT_NUMBER + 2)) |
/* flags, invflags: */ |
#define IPT_CONNTRACK_STATE 0x01 |
#define IPT_CONNTRACK_PROTO 0x02 |
#define IPT_CONNTRACK_ORIGSRC 0x04 |
#define IPT_CONNTRACK_ORIGDST 0x08 |
#define IPT_CONNTRACK_REPLSRC 0x10 |
#define IPT_CONNTRACK_REPLDST 0x20 |
#define IPT_CONNTRACK_STATUS 0x40 |
#define IPT_CONNTRACK_EXPIRES 0x80 |
struct ipt_conntrack_info |
{ |
unsigned int statemask, statusmask; |
struct ip_conntrack_tuple tuple[IP_CT_DIR_MAX]; |
struct in_addr sipmsk[IP_CT_DIR_MAX], dipmsk[IP_CT_DIR_MAX]; |
unsigned long expires_min, expires_max; |
/* Flags word */ |
u_int8_t flags; |
/* Inverse flags */ |
u_int8_t invflags; |
}; |
#endif /*_IPT_CONNTRACK_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_physdev.h |
---|
0,0 → 1,24 |
#ifndef _IPT_PHYSDEV_H |
#define _IPT_PHYSDEV_H |
#ifdef __KERNEL__ |
#include <linux/if.h> |
#endif |
#define IPT_PHYSDEV_OP_IN 0x01 |
#define IPT_PHYSDEV_OP_OUT 0x02 |
#define IPT_PHYSDEV_OP_BRIDGED 0x04 |
#define IPT_PHYSDEV_OP_ISIN 0x08 |
#define IPT_PHYSDEV_OP_ISOUT 0x10 |
#define IPT_PHYSDEV_OP_MASK (0x20 - 1) |
struct ipt_physdev_info { |
char physindev[IFNAMSIZ]; |
char in_mask[IFNAMSIZ]; |
char physoutdev[IFNAMSIZ]; |
char out_mask[IFNAMSIZ]; |
u_int8_t invert; |
u_int8_t bitmask; |
}; |
#endif /*_IPT_PHYSDEV_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_nat_rule.h |
---|
0,0 → 1,23 |
#ifndef _IP_NAT_RULE_H |
#define _IP_NAT_RULE_H |
#include <linux/netfilter_ipv4/ip_conntrack.h> |
#include <linux/netfilter_ipv4/ip_tables.h> |
#include <linux/netfilter_ipv4/ip_nat.h> |
#ifdef __KERNEL__ |
extern int ip_nat_rule_init(void) __init; |
extern void ip_nat_rule_cleanup(void); |
extern int ip_nat_rule_find(struct sk_buff **pskb, |
unsigned int hooknum, |
const struct net_device *in, |
const struct net_device *out, |
struct ip_conntrack *ct, |
struct ip_nat_info *info); |
extern unsigned int |
alloc_null_binding(struct ip_conntrack *conntrack, |
struct ip_nat_info *info, |
unsigned int hooknum); |
#endif |
#endif /* _IP_NAT_RULE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_tables.h |
---|
0,0 → 1,450 |
/* |
* 25-Jul-1998 Major changes to allow for ip chain table |
* |
* 3-Jan-2000 Named tables to allow packet selection for different uses. |
*/ |
/* |
* Format of an IP firewall descriptor |
* |
* src, dst, src_mask, dst_mask are always stored in network byte order. |
* flags are stored in host byte order (of course). |
* Port numbers are stored in HOST byte order. |
*/ |
#ifndef _IPTABLES_H |
#define _IPTABLES_H |
#ifdef __KERNEL__ |
#include <linux/if.h> |
#include <linux/types.h> |
#include <linux/in.h> |
#include <linux/ip.h> |
#include <linux/skbuff.h> |
#endif |
#include <linux/netfilter_ipv4.h> |
#define IPT_FUNCTION_MAXNAMELEN 30 |
#define IPT_TABLE_MAXNAMELEN 32 |
/* Yes, Virginia, you have to zero the padding. */ |
struct ipt_ip { |
/* Source and destination IP addr */ |
struct in_addr src, dst; |
/* Mask for src and dest IP addr */ |
struct in_addr smsk, dmsk; |
char iniface[IFNAMSIZ], outiface[IFNAMSIZ]; |
unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ]; |
/* Protocol, 0 = ANY */ |
u_int16_t proto; |
/* Flags word */ |
u_int8_t flags; |
/* Inverse flags */ |
u_int8_t invflags; |
}; |
struct ipt_entry_match |
{ |
union { |
struct { |
u_int16_t match_size; |
/* Used by userspace */ |
char name[IPT_FUNCTION_MAXNAMELEN]; |
} user; |
struct { |
u_int16_t match_size; |
/* Used inside the kernel */ |
struct ipt_match *match; |
} kernel; |
/* Total length */ |
u_int16_t match_size; |
} u; |
unsigned char data[0]; |
}; |
struct ipt_entry_target |
{ |
union { |
struct { |
u_int16_t target_size; |
/* Used by userspace */ |
char name[IPT_FUNCTION_MAXNAMELEN]; |
} user; |
struct { |
u_int16_t target_size; |
/* Used inside the kernel */ |
struct ipt_target *target; |
} kernel; |
/* Total length */ |
u_int16_t target_size; |
} u; |
unsigned char data[0]; |
}; |
struct ipt_standard_target |
{ |
struct ipt_entry_target target; |
int verdict; |
}; |
struct ipt_counters |
{ |
u_int64_t pcnt, bcnt; /* Packet and byte counters */ |
}; |
/* Values for "flag" field in struct ipt_ip (general ip structure). */ |
#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ |
#define IPT_F_MASK 0x01 /* All possible flag bits mask. */ |
/* Values for "inv" field in struct ipt_ip. */ |
#define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */ |
#define IPT_INV_VIA_OUT 0x02 /* Invert the sense of OUT IFACE */ |
#define IPT_INV_TOS 0x04 /* Invert the sense of TOS. */ |
#define IPT_INV_SRCIP 0x08 /* Invert the sense of SRC IP. */ |
#define IPT_INV_DSTIP 0x10 /* Invert the sense of DST OP. */ |
#define IPT_INV_FRAG 0x20 /* Invert the sense of FRAG. */ |
#define IPT_INV_PROTO 0x40 /* Invert the sense of PROTO. */ |
#define IPT_INV_MASK 0x7F /* All possible flag bits mask. */ |
/* This structure defines each of the firewall rules. Consists of 3 |
parts which are 1) general IP header stuff 2) match specific |
stuff 3) the target to perform if the rule matches */ |
struct ipt_entry |
{ |
struct ipt_ip ip; |
/* Mark with fields that we care about. */ |
unsigned int nfcache; |
/* Size of ipt_entry + matches */ |
u_int16_t target_offset; |
/* Size of ipt_entry + matches + target */ |
u_int16_t next_offset; |
/* Back pointer */ |
unsigned int comefrom; |
/* Packet and byte counters. */ |
struct ipt_counters counters; |
/* The matches (if any), then the target. */ |
unsigned char elems[0]; |
}; |
/* |
* New IP firewall options for [gs]etsockopt at the RAW IP level. |
* Unlike BSD Linux inherits IP options so you don't have to use a raw |
* socket for this. Instead we check rights in the calls. */ |
#define IPT_BASE_CTL 64 /* base for firewall socket options */ |
#define IPT_SO_SET_REPLACE (IPT_BASE_CTL) |
#define IPT_SO_SET_ADD_COUNTERS (IPT_BASE_CTL + 1) |
#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS |
#define IPT_SO_GET_INFO (IPT_BASE_CTL) |
#define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) |
#define IPT_SO_GET_MAX IPT_SO_GET_ENTRIES |
/* CONTINUE verdict for targets */ |
#define IPT_CONTINUE 0xFFFFFFFF |
/* For standard target */ |
#define IPT_RETURN (-NF_MAX_VERDICT - 1) |
/* TCP matching stuff */ |
struct ipt_tcp |
{ |
u_int16_t spts[2]; /* Source port range. */ |
u_int16_t dpts[2]; /* Destination port range. */ |
u_int8_t option; /* TCP Option iff non-zero*/ |
u_int8_t flg_mask; /* TCP flags mask byte */ |
u_int8_t flg_cmp; /* TCP flags compare byte */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "inv" field in struct ipt_tcp. */ |
#define IPT_TCP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ |
#define IPT_TCP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ |
#define IPT_TCP_INV_FLAGS 0x04 /* Invert the sense of TCP flags. */ |
#define IPT_TCP_INV_OPTION 0x08 /* Invert the sense of option test. */ |
#define IPT_TCP_INV_MASK 0x0F /* All possible flags. */ |
/* UDP matching stuff */ |
struct ipt_udp |
{ |
u_int16_t spts[2]; /* Source port range. */ |
u_int16_t dpts[2]; /* Destination port range. */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "invflags" field in struct ipt_udp. */ |
#define IPT_UDP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ |
#define IPT_UDP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ |
#define IPT_UDP_INV_MASK 0x03 /* All possible flags. */ |
/* ICMP matching stuff */ |
struct ipt_icmp |
{ |
u_int8_t type; /* type to match */ |
u_int8_t code[2]; /* range of code */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "inv" field for struct ipt_icmp. */ |
#define IPT_ICMP_INV 0x01 /* Invert the sense of type/code test */ |
/* The argument to IPT_SO_GET_INFO */ |
struct ipt_getinfo |
{ |
/* Which table: caller fills this in. */ |
char name[IPT_TABLE_MAXNAMELEN]; |
/* Kernel fills these in. */ |
/* Which hook entry points are valid: bitmask */ |
unsigned int valid_hooks; |
/* Hook entry points: one per netfilter hook. */ |
unsigned int hook_entry[NF_IP_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_IP_NUMHOOKS]; |
/* Number of entries */ |
unsigned int num_entries; |
/* Size of entries. */ |
unsigned int size; |
}; |
/* The argument to IPT_SO_SET_REPLACE. */ |
struct ipt_replace |
{ |
/* Which table. */ |
char name[IPT_TABLE_MAXNAMELEN]; |
/* Which hook entry points are valid: bitmask. You can't |
change this. */ |
unsigned int valid_hooks; |
/* Number of entries */ |
unsigned int num_entries; |
/* Total size of new entries */ |
unsigned int size; |
/* Hook entry points. */ |
unsigned int hook_entry[NF_IP_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_IP_NUMHOOKS]; |
/* Information about old entries: */ |
/* Number of counters (must be equal to current number of entries). */ |
unsigned int num_counters; |
/* The old entries' counters. */ |
struct ipt_counters *counters; |
/* The entries (hang off end: not really an array). */ |
struct ipt_entry entries[0]; |
}; |
/* The argument to IPT_SO_ADD_COUNTERS. */ |
struct ipt_counters_info |
{ |
/* Which table. */ |
char name[IPT_TABLE_MAXNAMELEN]; |
unsigned int num_counters; |
/* The counters (actually `number' of these). */ |
struct ipt_counters counters[0]; |
}; |
/* The argument to IPT_SO_GET_ENTRIES. */ |
struct ipt_get_entries |
{ |
/* Which table: user fills this in. */ |
char name[IPT_TABLE_MAXNAMELEN]; |
/* User fills this in: total entry size. */ |
unsigned int size; |
/* The entries. */ |
struct ipt_entry entrytable[0]; |
}; |
/* Standard return verdict, or do jump. */ |
#define IPT_STANDARD_TARGET "" |
/* Error verdict. */ |
#define IPT_ERROR_TARGET "ERROR" |
/* Helper functions */ |
static __inline__ struct ipt_entry_target * |
ipt_get_target(struct ipt_entry *e) |
{ |
return (void *)e + e->target_offset; |
} |
/* fn returns 0 to continue iteration */ |
#define IPT_MATCH_ITERATE(e, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ipt_entry_match *__match; \ |
\ |
for (__i = sizeof(struct ipt_entry); \ |
__i < (e)->target_offset; \ |
__i += __match->u.match_size) { \ |
__match = (void *)(e) + __i; \ |
\ |
__ret = fn(__match , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
__ret; \ |
}) |
/* fn returns 0 to continue iteration */ |
#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ipt_entry *__entry; \ |
\ |
for (__i = 0; __i < (size); __i += __entry->next_offset) { \ |
__entry = (void *)(entries) + __i; \ |
\ |
__ret = fn(__entry , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
__ret; \ |
}) |
/* |
* Main firewall chains definitions and global var's definitions. |
*/ |
#ifdef __KERNEL__ |
#include <linux/init.h> |
extern void ipt_init(void) __init; |
struct ipt_match |
{ |
struct list_head list; |
const char name[IPT_FUNCTION_MAXNAMELEN]; |
/* Return true or false: return FALSE and set *hotdrop = 1 to |
force immediate packet drop. */ |
/* Arguments changed since 2.4, as this must now handle |
non-linear skbs, using skb_copy_bits and |
skb_ip_make_writable. */ |
int (*match)(const struct sk_buff *skb, |
const struct net_device *in, |
const struct net_device *out, |
const void *matchinfo, |
int offset, |
int *hotdrop); |
/* Called when user tries to insert an entry of this type. */ |
/* Should return true or false. */ |
int (*checkentry)(const char *tablename, |
const struct ipt_ip *ip, |
void *matchinfo, |
unsigned int matchinfosize, |
unsigned int hook_mask); |
/* Called when entry of this type deleted. */ |
void (*destroy)(void *matchinfo, unsigned int matchinfosize); |
/* Set this to THIS_MODULE. */ |
struct module *me; |
}; |
/* Registration hooks for targets. */ |
struct ipt_target |
{ |
struct list_head list; |
const char name[IPT_FUNCTION_MAXNAMELEN]; |
/* Called when user tries to insert an entry of this type: |
hook_mask is a bitmask of hooks from which it can be |
called. */ |
/* Should return true or false. */ |
int (*checkentry)(const char *tablename, |
const struct ipt_entry *e, |
void *targinfo, |
unsigned int targinfosize, |
unsigned int hook_mask); |
/* Called when entry of this type deleted. */ |
void (*destroy)(void *targinfo, unsigned int targinfosize); |
/* Returns verdict. Argument order changed since 2.4, as this |
must now handle non-linear skbs, using skb_copy_bits and |
skb_ip_make_writable. */ |
unsigned int (*target)(struct sk_buff **pskb, |
const struct net_device *in, |
const struct net_device *out, |
unsigned int hooknum, |
const void *targinfo, |
void *userdata); |
/* Set this to THIS_MODULE. */ |
struct module *me; |
}; |
extern int ipt_register_target(struct ipt_target *target); |
extern void ipt_unregister_target(struct ipt_target *target); |
extern int ipt_register_match(struct ipt_match *match); |
extern void ipt_unregister_match(struct ipt_match *match); |
/* Furniture shopping... */ |
struct ipt_table |
{ |
struct list_head list; |
/* A unique name... */ |
char name[IPT_TABLE_MAXNAMELEN]; |
/* Seed table: copied in register_table */ |
struct ipt_replace *table; |
/* What hooks you will enter on */ |
unsigned int valid_hooks; |
/* Lock for the curtain */ |
rwlock_t lock; |
/* Man behind the curtain... */ |
struct ipt_table_info *private; |
/* Set to THIS_MODULE. */ |
struct module *me; |
}; |
extern int ipt_register_table(struct ipt_table *table); |
extern void ipt_unregister_table(struct ipt_table *table); |
extern unsigned int ipt_do_table(struct sk_buff **pskb, |
unsigned int hook, |
const struct net_device *in, |
const struct net_device *out, |
struct ipt_table *table, |
void *userdata); |
#define IPT_ALIGN(s) (((s) + (__alignof__(struct ipt_entry)-1)) & ~(__alignof__(struct ipt_entry)-1)) |
#endif /*__KERNEL__*/ |
#endif /* _IPTABLES_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_DSCP.h |
---|
0,0 → 1,20 |
/* iptables module for setting the IPv4 DSCP field |
* |
* (C) 2002 Harald Welte <laforge@gnumonks.org> |
* based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com> |
* This software is distributed under GNU GPL v2, 1991 |
* |
* See RFC2474 for a description of the DSCP field within the IP Header. |
* |
* ipt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp |
*/ |
#ifndef _IPT_DSCP_TARGET_H |
#define _IPT_DSCP_TARGET_H |
#include <linux/netfilter_ipv4/ipt_dscp.h> |
/* target info */ |
struct ipt_DSCP_info { |
u_int8_t dscp; |
}; |
#endif /* _IPT_DSCP_TARGET_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_dscp.h |
---|
0,0 → 1,23 |
/* iptables module for matching the IPv4 DSCP field |
* |
* (C) 2002 Harald Welte <laforge@gnumonks.org> |
* This software is distributed under GNU GPL v2, 1991 |
* |
* See RFC2474 for a description of the DSCP field within the IP Header. |
* |
* ipt_dscp.h,v 1.3 2002/08/05 19:00:21 laforge Exp |
*/ |
#ifndef _IPT_DSCP_H |
#define _IPT_DSCP_H |
#define IPT_DSCP_MASK 0xfc /* 11111100 */ |
#define IPT_DSCP_SHIFT 2 |
#define IPT_DSCP_MAX 0x3f /* 00111111 */ |
/* match info */ |
struct ipt_dscp_info { |
u_int8_t dscp; |
u_int8_t invert; |
}; |
#endif /* _IPT_DSCP_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_MARK.h |
---|
0,0 → 1,8 |
#ifndef _IPT_MARK_H_target |
#define _IPT_MARK_H_target |
struct ipt_mark_target_info { |
unsigned long mark; |
}; |
#endif /*_IPT_MARK_H_target*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_mark.h |
---|
0,0 → 1,9 |
#ifndef _IPT_MARK_H |
#define _IPT_MARK_H |
struct ipt_mark_info { |
unsigned long mark, mask; |
u_int8_t invert; |
}; |
#endif /*_IPT_MARK_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_helper.h |
---|
0,0 → 1,45 |
/* IP connection tracking helpers. */ |
#ifndef _IP_CONNTRACK_HELPER_H |
#define _IP_CONNTRACK_HELPER_H |
#include <linux/netfilter_ipv4/ip_conntrack.h> |
struct module; |
/* Reuse expectation when max_expected reached */ |
#define IP_CT_HELPER_F_REUSE_EXPECT 0x01 |
struct ip_conntrack_helper |
{ |
struct list_head list; /* Internal use. */ |
const char *name; /* name of the module */ |
unsigned char flags; /* Flags (see above) */ |
struct module *me; /* pointer to self */ |
unsigned int max_expected; /* Maximum number of concurrent |
* expected connections */ |
unsigned int timeout; /* timeout for expecteds */ |
/* Mask of things we will help (compared against server response) */ |
struct ip_conntrack_tuple tuple; |
struct ip_conntrack_tuple mask; |
/* Function to call when data passes; return verdict, or -1 to |
invalidate. */ |
int (*help)(struct sk_buff *skb, |
struct ip_conntrack *ct, |
enum ip_conntrack_info conntrackinfo); |
}; |
extern int ip_conntrack_helper_register(struct ip_conntrack_helper *); |
extern void ip_conntrack_helper_unregister(struct ip_conntrack_helper *); |
extern struct ip_conntrack_helper *ip_ct_find_helper(const struct ip_conntrack_tuple *tuple); |
/* Add an expected connection: can have more than one per connection */ |
extern int ip_conntrack_expect_related(struct ip_conntrack *related_to, |
struct ip_conntrack_expect *exp); |
extern int ip_conntrack_change_expect(struct ip_conntrack_expect *expect, |
struct ip_conntrack_tuple *newtuple); |
extern void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp); |
#endif /*_IP_CONNTRACK_HELPER_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_nat.h |
---|
0,0 → 1,128 |
#ifndef _IP_NAT_H |
#define _IP_NAT_H |
#include <linux/netfilter_ipv4.h> |
#include <linux/netfilter_ipv4/ip_conntrack_tuple.h> |
#define IP_NAT_MAPPING_TYPE_MAX_NAMELEN 16 |
enum ip_nat_manip_type |
{ |
IP_NAT_MANIP_SRC, |
IP_NAT_MANIP_DST |
}; |
#ifndef CONFIG_IP_NF_NAT_LOCAL |
/* SRC manip occurs only on POST_ROUTING */ |
#define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING) |
#else |
/* SRC manip occurs POST_ROUTING or LOCAL_IN */ |
#define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN) |
#endif |
#define IP_NAT_RANGE_MAP_IPS 1 |
#define IP_NAT_RANGE_PROTO_SPECIFIED 2 |
/* Used internally by get_unique_tuple(). */ |
#define IP_NAT_RANGE_FULL 4 |
/* NAT sequence number modifications */ |
struct ip_nat_seq { |
/* position of the last TCP sequence number |
* modification (if any) */ |
u_int32_t correction_pos; |
/* sequence number offset before and after last modification */ |
int32_t offset_before, offset_after; |
}; |
/* Single range specification. */ |
struct ip_nat_range |
{ |
/* Set to OR of flags above. */ |
unsigned int flags; |
/* Inclusive: network order. */ |
u_int32_t min_ip, max_ip; |
/* Inclusive: network order */ |
union ip_conntrack_manip_proto min, max; |
}; |
/* A range consists of an array of 1 or more ip_nat_range */ |
struct ip_nat_multi_range |
{ |
unsigned int rangesize; |
/* hangs off end. */ |
struct ip_nat_range range[1]; |
}; |
/* Worst case: local-out manip + 1 post-routing, and reverse dirn. */ |
#define IP_NAT_MAX_MANIPS (2*3) |
struct ip_nat_info_manip |
{ |
/* The direction. */ |
u_int8_t direction; |
/* Which hook the manipulation happens on. */ |
u_int8_t hooknum; |
/* The manipulation type. */ |
u_int8_t maniptype; |
/* Manipulations to occur at each conntrack in this dirn. */ |
struct ip_conntrack_manip manip; |
}; |
#ifdef __KERNEL__ |
#include <linux/list.h> |
#include <linux/netfilter_ipv4/lockhelp.h> |
/* Protects NAT hash tables, and NAT-private part of conntracks. */ |
DECLARE_RWLOCK_EXTERN(ip_nat_lock); |
/* Hashes for by-source and IP/protocol. */ |
struct ip_nat_hash |
{ |
struct list_head list; |
/* conntrack we're embedded in: NULL if not in hash. */ |
struct ip_conntrack *conntrack; |
}; |
/* The structure embedded in the conntrack structure. */ |
struct ip_nat_info |
{ |
/* Set to zero when conntrack created: bitmask of maniptypes */ |
int initialized; |
unsigned int num_manips; |
/* Manipulations to be done on this conntrack. */ |
struct ip_nat_info_manip manips[IP_NAT_MAX_MANIPS]; |
/* The mapping type which created us (NULL for null mapping). */ |
const struct ip_nat_mapping_type *mtype; |
struct ip_nat_hash bysource, byipsproto; |
/* Helper (NULL if none). */ |
struct ip_nat_helper *helper; |
struct ip_nat_seq seq[IP_CT_DIR_MAX]; |
}; |
/* Set up the info structure to map into this range. */ |
extern unsigned int ip_nat_setup_info(struct ip_conntrack *conntrack, |
const struct ip_nat_multi_range *mr, |
unsigned int hooknum); |
/* Is this tuple already taken? (not by us)*/ |
extern int ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple, |
const struct ip_conntrack *ignored_conntrack); |
/* Calculate relative checksum. */ |
extern u_int16_t ip_nat_cheat_check(u_int32_t oldvalinv, |
u_int32_t newval, |
u_int16_t oldcheck); |
#endif /*__KERNEL__*/ |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_multiport.h |
---|
0,0 → 1,21 |
#ifndef _IPT_MULTIPORT_H |
#define _IPT_MULTIPORT_H |
#include <linux/netfilter_ipv4/ip_tables.h> |
enum ipt_multiport_flags |
{ |
IPT_MULTIPORT_SOURCE, |
IPT_MULTIPORT_DESTINATION, |
IPT_MULTIPORT_EITHER |
}; |
#define IPT_MULTI_PORTS 15 |
/* Must fit inside union ipt_matchinfo: 16 bytes */ |
struct ipt_multiport |
{ |
u_int8_t flags; /* Type of comparison */ |
u_int8_t count; /* Number of ports */ |
u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */ |
}; |
#endif /*_IPT_MULTIPORT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_amanda.h |
---|
0,0 → 1,21 |
#ifndef _IP_CONNTRACK_AMANDA_H |
#define _IP_CONNTRACK_AMANDA_H |
/* AMANDA tracking. */ |
#ifdef __KERNEL__ |
#include <linux/netfilter_ipv4/lockhelp.h> |
/* Protects amanda part of conntracks */ |
DECLARE_LOCK_EXTERN(ip_amanda_lock); |
#endif |
struct ip_ct_amanda_expect |
{ |
u_int16_t port; /* port number of this expectation */ |
u_int16_t offset; /* offset of the port specification in ctrl packet */ |
u_int16_t len; /* the length of the port number specification */ |
}; |
#endif /* _IP_CONNTRACK_AMANDA_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_queue.h |
---|
0,0 → 1,72 |
/* |
* This is a module which is used for queueing IPv4 packets and |
* communicating with userspace via netlink. |
* |
* (C) 2000 James Morris, this code is GPL. |
*/ |
#ifndef _IP_QUEUE_H |
#define _IP_QUEUE_H |
#ifdef __KERNEL__ |
#ifdef DEBUG_IPQ |
#define QDEBUG(x...) printk(KERN_DEBUG ## x) |
#else |
#define QDEBUG(x...) |
#endif /* DEBUG_IPQ */ |
#else |
#include <net/if.h> |
#endif /* ! __KERNEL__ */ |
/* Messages sent from kernel */ |
typedef struct ipq_packet_msg { |
unsigned long packet_id; /* ID of queued packet */ |
unsigned long mark; /* Netfilter mark value */ |
long timestamp_sec; /* Packet arrival time (seconds) */ |
long timestamp_usec; /* Packet arrvial time (+useconds) */ |
unsigned int hook; /* Netfilter hook we rode in on */ |
char indev_name[IFNAMSIZ]; /* Name of incoming interface */ |
char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */ |
unsigned short hw_protocol; /* Hardware protocol (network order) */ |
unsigned short hw_type; /* Hardware type */ |
unsigned char hw_addrlen; /* Hardware address length */ |
unsigned char hw_addr[8]; /* Hardware address */ |
size_t data_len; /* Length of packet data */ |
unsigned char payload[0]; /* Optional packet data */ |
} ipq_packet_msg_t; |
/* Messages sent from userspace */ |
typedef struct ipq_mode_msg { |
unsigned char value; /* Requested mode */ |
size_t range; /* Optional range of packet requested */ |
} ipq_mode_msg_t; |
typedef struct ipq_verdict_msg { |
unsigned int value; /* Verdict to hand to netfilter */ |
unsigned long id; /* Packet ID for this verdict */ |
size_t data_len; /* Length of replacement data */ |
unsigned char payload[0]; /* Optional replacement packet */ |
} ipq_verdict_msg_t; |
typedef struct ipq_peer_msg { |
union { |
ipq_verdict_msg_t verdict; |
ipq_mode_msg_t mode; |
} msg; |
} ipq_peer_msg_t; |
/* Packet delivery modes */ |
enum { |
IPQ_COPY_NONE, /* Initial mode, packets are dropped */ |
IPQ_COPY_META, /* Copy metadata */ |
IPQ_COPY_PACKET /* Copy metadata + packet (range) */ |
}; |
#define IPQ_COPY_MAX IPQ_COPY_PACKET |
/* Types of messages */ |
#define IPQM_BASE 0x10 /* standard netlink messages below this */ |
#define IPQM_MODE (IPQM_BASE + 1) /* Mode request from peer */ |
#define IPQM_VERDICT (IPQM_BASE + 2) /* Verdict from peer */ |
#define IPQM_PACKET (IPQM_BASE + 3) /* Packet from kernel */ |
#define IPQM_MAX (IPQM_BASE + 4) |
#endif /*_IP_QUEUE_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_mac.h |
---|
0,0 → 1,8 |
#ifndef _IPT_MAC_H |
#define _IPT_MAC_H |
struct ipt_mac_info { |
unsigned char srcaddr[ETH_ALEN]; |
int invert; |
}; |
#endif /*_IPT_MAC_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_ttl.h |
---|
0,0 → 1,21 |
/* IP tables module for matching the value of the TTL |
* (C) 2000 by Harald Welte <laforge@gnumonks.org> */ |
#ifndef _IPT_TTL_H |
#define _IPT_TTL_H |
enum { |
IPT_TTL_EQ = 0, /* equals */ |
IPT_TTL_NE, /* not equals */ |
IPT_TTL_LT, /* less than */ |
IPT_TTL_GT, /* greater than */ |
}; |
struct ipt_ttl_info { |
u_int8_t mode; |
u_int8_t ttl; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_tcp.h |
---|
0,0 → 1,28 |
#ifndef _IP_CONNTRACK_TCP_H |
#define _IP_CONNTRACK_TCP_H |
/* TCP tracking. */ |
enum tcp_conntrack { |
TCP_CONNTRACK_NONE, |
TCP_CONNTRACK_ESTABLISHED, |
TCP_CONNTRACK_SYN_SENT, |
TCP_CONNTRACK_SYN_RECV, |
TCP_CONNTRACK_FIN_WAIT, |
TCP_CONNTRACK_TIME_WAIT, |
TCP_CONNTRACK_CLOSE, |
TCP_CONNTRACK_CLOSE_WAIT, |
TCP_CONNTRACK_LAST_ACK, |
TCP_CONNTRACK_LISTEN, |
TCP_CONNTRACK_MAX |
}; |
struct ip_ct_tcp |
{ |
enum tcp_conntrack state; |
/* Poor man's window tracking: sequence number of valid ACK |
handshake completion packet */ |
u_int32_t handshake_ack; |
}; |
#endif /* _IP_CONNTRACK_TCP_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_TOS.h |
---|
0,0 → 1,12 |
#ifndef _IPT_TOS_H_target |
#define _IPT_TOS_H_target |
#ifndef IPTOS_NORMALSVC |
#define IPTOS_NORMALSVC 0 |
#endif |
struct ipt_tos_target_info { |
u_int8_t tos; |
}; |
#endif /*_IPT_TOS_H_target*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_ecn.h |
---|
0,0 → 1,33 |
/* iptables module for matching the ECN header in IPv4 and TCP header |
* |
* (C) 2002 Harald Welte <laforge@gnumonks.org> |
* |
* This software is distributed under GNU GPL v2, 1991 |
* |
* ipt_ecn.h,v 1.4 2002/08/05 19:39:00 laforge Exp |
*/ |
#ifndef _IPT_ECN_H |
#define _IPT_ECN_H |
#include <linux/netfilter_ipv4/ipt_dscp.h> |
#define IPT_ECN_IP_MASK (~IPT_DSCP_MASK) |
#define IPT_ECN_OP_MATCH_IP 0x01 |
#define IPT_ECN_OP_MATCH_ECE 0x10 |
#define IPT_ECN_OP_MATCH_CWR 0x20 |
#define IPT_ECN_OP_MATCH_MASK 0xce |
/* match info */ |
struct ipt_ecn_info { |
u_int8_t operation; |
u_int8_t invert; |
u_int8_t ip_ect; |
union { |
struct { |
u_int8_t ect; |
} tcp; |
} proto; |
}; |
#endif /* _IPT_ECN_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_nat_core.h |
---|
0,0 → 1,33 |
#ifndef _IP_NAT_CORE_H |
#define _IP_NAT_CORE_H |
#include <linux/list.h> |
#include <linux/netfilter_ipv4/ip_conntrack.h> |
/* This header used to share core functionality between the standalone |
NAT module, and the compatibility layer's use of NAT for masquerading. */ |
extern int ip_nat_init(void); |
extern void ip_nat_cleanup(void); |
extern unsigned int do_bindings(struct ip_conntrack *ct, |
enum ip_conntrack_info conntrackinfo, |
struct ip_nat_info *info, |
unsigned int hooknum, |
struct sk_buff **pskb); |
extern struct list_head protos; |
extern int icmp_reply_translation(struct sk_buff **pskb, |
struct ip_conntrack *conntrack, |
unsigned int hooknum, |
int dir); |
extern void replace_in_hashes(struct ip_conntrack *conntrack, |
struct ip_nat_info *info); |
extern void place_in_hashes(struct ip_conntrack *conntrack, |
struct ip_nat_info *info); |
/* Built-in protocols. */ |
extern struct ip_nat_protocol ip_nat_protocol_tcp; |
extern struct ip_nat_protocol ip_nat_protocol_udp; |
extern struct ip_nat_protocol ip_nat_protocol_icmp; |
#endif /* _IP_NAT_CORE_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ip_conntrack_icmp.h |
---|
0,0 → 1,11 |
#ifndef _IP_CONNTRACK_ICMP_H |
#define _IP_CONNTRACK_ICMP_H |
/* ICMP tracking. */ |
#include <asm/atomic.h> |
struct ip_ct_icmp |
{ |
/* Optimization: when number in == number out, forget immediately. */ |
atomic_t count; |
}; |
#endif /* _IP_CONNTRACK_ICMP_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv4/ipt_REJECT.h |
---|
0,0 → 1,20 |
#ifndef _IPT_REJECT_H |
#define _IPT_REJECT_H |
enum ipt_reject_with { |
IPT_ICMP_NET_UNREACHABLE, |
IPT_ICMP_HOST_UNREACHABLE, |
IPT_ICMP_PROT_UNREACHABLE, |
IPT_ICMP_PORT_UNREACHABLE, |
IPT_ICMP_ECHOREPLY, |
IPT_ICMP_NET_PROHIBITED, |
IPT_ICMP_HOST_PROHIBITED, |
IPT_TCP_RESET, |
IPT_ICMP_ADMIN_PROHIBITED |
}; |
struct ipt_reject_info { |
enum ipt_reject_with with; /* reject type */ |
}; |
#endif /*_IPT_REJECT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_esp.h |
---|
0,0 → 1,23 |
#ifndef _IP6T_ESP_H |
#define _IP6T_ESP_H |
struct ip6t_esp |
{ |
u_int32_t spis[2]; /* Security Parameter Index */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
/* Values for "invflags" field in struct ip6t_esp. */ |
#define IP6T_ESP_INV_SPI 0x01 /* Invert the sense of spi. */ |
#define IP6T_ESP_INV_MASK 0x01 /* All possible flags. */ |
#endif /*_IP6T_ESP_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_ah.h |
---|
0,0 → 1,30 |
#ifndef _IP6T_AH_H |
#define _IP6T_AH_H |
struct ip6t_ah |
{ |
u_int32_t spis[2]; /* Security Parameter Index */ |
u_int32_t hdrlen; /* Header Length */ |
u_int8_t hdrres; /* Test of the Reserved Filed */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
#define IP6T_AH_SPI 0x01 |
#define IP6T_AH_LEN 0x02 |
#define IP6T_AH_RES 0x04 |
/* Values for "invflags" field in struct ip6t_ah. */ |
#define IP6T_AH_INV_SPI 0x01 /* Invert the sense of spi. */ |
#define IP6T_AH_INV_LEN 0x02 /* Invert the sense of length. */ |
#define IP6T_AH_INV_MASK 0x03 /* All possible flags. */ |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
#endif /*_IP6T_AH_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_mark.h |
---|
0,0 → 1,9 |
#ifndef _IP6T_MARK_H |
#define _IP6T_MARK_H |
struct ip6t_mark_info { |
unsigned long mark, mask; |
u_int8_t invert; |
}; |
#endif /*_IPT_MARK_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_owner.h |
---|
0,0 → 1,18 |
#ifndef _IP6T_OWNER_H |
#define _IP6T_OWNER_H |
/* match and invert flags */ |
#define IP6T_OWNER_UID 0x01 |
#define IP6T_OWNER_GID 0x02 |
#define IP6T_OWNER_PID 0x04 |
#define IP6T_OWNER_SID 0x08 |
struct ip6t_owner_info { |
uid_t uid; |
gid_t gid; |
pid_t pid; |
pid_t sid; |
u_int8_t match, invert; /* flags */ |
}; |
#endif /*_IPT_OWNER_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_MARK.h |
---|
0,0 → 1,8 |
#ifndef _IP6T_MARK_H_target |
#define _IP6T_MARK_H_target |
struct ip6t_mark_target_info { |
unsigned long mark; |
}; |
#endif /*_IPT_MARK_H_target*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_ipv6header.h |
---|
0,0 → 1,27 |
/* ipv6header match - matches IPv6 packets based |
on whether they contain certain headers */ |
/* Original idea: Brad Chapman |
* Rewritten by: Andras Kis-Szabo <kisza@sch.bme.hu> */ |
#ifndef __IPV6HEADER_H |
#define __IPV6HEADER_H |
struct ip6t_ipv6header_info |
{ |
u_int8_t matchflags; |
u_int8_t invflags; |
u_int8_t modeflag; |
}; |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
#endif /* __IPV6HEADER_H */ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_multiport.h |
---|
0,0 → 1,21 |
#ifndef _IP6T_MULTIPORT_H |
#define _IP6T_MULTIPORT_H |
#include <linux/netfilter_ipv6/ip6_tables.h> |
enum ip6t_multiport_flags |
{ |
IP6T_MULTIPORT_SOURCE, |
IP6T_MULTIPORT_DESTINATION, |
IP6T_MULTIPORT_EITHER |
}; |
#define IP6T_MULTI_PORTS 15 |
/* Must fit inside union ip6t_matchinfo: 16 bytes */ |
struct ip6t_multiport |
{ |
u_int8_t flags; /* Type of comparison */ |
u_int8_t count; /* Number of ports */ |
u_int16_t ports[IP6T_MULTI_PORTS]; /* Ports */ |
}; |
#endif /*_IPT_MULTIPORT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_mac.h |
---|
0,0 → 1,8 |
#ifndef _IP6T_MAC_H |
#define _IP6T_MAC_H |
struct ip6t_mac_info { |
unsigned char srcaddr[ETH_ALEN]; |
int invert; |
}; |
#endif /*_IPT_MAC_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_hl.h |
---|
0,0 → 1,22 |
/* ip6tables module for matching the Hop Limit value |
* Maciej Soltysiak <solt@dns.toxicfilms.tv> |
* Based on HW's ttl module */ |
#ifndef _IP6T_HL_H |
#define _IP6T_HL_H |
enum { |
IP6T_HL_EQ = 0, /* equals */ |
IP6T_HL_NE, /* not equals */ |
IP6T_HL_LT, /* less than */ |
IP6T_HL_GT, /* greater than */ |
}; |
struct ip6t_hl_info { |
u_int8_t mode; |
u_int8_t hop_limit; |
}; |
#endif |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_REJECT.h |
---|
0,0 → 1,16 |
#ifndef _IP6T_REJECT_H |
#define _IP6T_REJECT_H |
enum ip6t_reject_with { |
IP6T_ICMP_NET_UNREACHABLE, |
IP6T_ICMP_HOST_UNREACHABLE, |
IP6T_ICMP_PROT_UNREACHABLE, |
IP6T_ICMP_PORT_UNREACHABLE, |
IP6T_ICMP_ECHOREPLY |
}; |
struct ip6t_reject_info { |
enum ip6t_reject_with with; /* reject type */ |
}; |
#endif /*_IPT_REJECT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_limit.h |
---|
0,0 → 1,21 |
#ifndef _IP6T_RATE_H |
#define _IP6T_RATE_H |
/* timings are in milliseconds. */ |
#define IP6T_LIMIT_SCALE 10000 |
/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 |
seconds, or one every 59 hours. */ |
struct ip6t_rateinfo { |
u_int32_t avg; /* Average secs between packets * scale */ |
u_int32_t burst; /* Period multiplier for upper limit. */ |
/* Used internally by the kernel */ |
unsigned long prev; |
u_int32_t credit; |
u_int32_t credit_cap, cost; |
/* Ugly, ugly fucker. */ |
struct ip6t_rateinfo *master; |
}; |
#endif /*_IPT_RATE_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_frag.h |
---|
0,0 → 1,33 |
#ifndef _IP6T_FRAG_H |
#define _IP6T_FRAG_H |
struct ip6t_frag |
{ |
u_int32_t ids[2]; /* Security Parameter Index */ |
u_int32_t hdrlen; /* Header Length */ |
u_int8_t flags; /* */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
#define IP6T_FRAG_IDS 0x01 |
#define IP6T_FRAG_LEN 0x02 |
#define IP6T_FRAG_RES 0x04 |
#define IP6T_FRAG_FST 0x08 |
#define IP6T_FRAG_MF 0x10 |
#define IP6T_FRAG_NMF 0x20 |
/* Values for "invflags" field in struct ip6t_frag. */ |
#define IP6T_FRAG_INV_IDS 0x01 /* Invert the sense of ids. */ |
#define IP6T_FRAG_INV_LEN 0x02 /* Invert the sense of length. */ |
#define IP6T_FRAG_INV_MASK 0x03 /* All possible flags. */ |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
#endif /*_IP6T_FRAG_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_LOG.h |
---|
0,0 → 1,15 |
#ifndef _IP6T_LOG_H |
#define _IP6T_LOG_H |
#define IP6T_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ |
#define IP6T_LOG_TCPOPT 0x02 /* Log TCP options */ |
#define IP6T_LOG_IPOPT 0x04 /* Log IP options */ |
#define IP6T_LOG_MASK 0x07 |
struct ip6t_log_info { |
unsigned char level; |
unsigned char logflags; |
char prefix[30]; |
}; |
#endif /*_IPT_LOG_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_length.h |
---|
0,0 → 1,10 |
#ifndef _IP6T_LENGTH_H |
#define _IP6T_LENGTH_H |
struct ip6t_length_info { |
u_int16_t min, max; |
u_int8_t invert; |
}; |
#endif /*_IP6T_LENGTH_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_rt.h |
---|
0,0 → 1,42 |
#ifndef _IP6T_RT_H |
#define _IP6T_RT_H |
/*#include <linux/in6.h>*/ |
#define IP6T_RT_HOPS 16 |
struct ip6t_rt |
{ |
u_int32_t rt_type; /* Routing Type */ |
u_int32_t segsleft[2]; /* Segments Left */ |
u_int32_t hdrlen; /* Header Length */ |
u_int8_t flags; /* */ |
u_int8_t invflags; /* Inverse flags */ |
struct in6_addr addrs[IP6T_RT_HOPS]; /* Hops */ |
u_int8_t addrnr; /* Nr of Addresses */ |
}; |
#define IP6T_RT_TYP 0x01 |
#define IP6T_RT_SGS 0x02 |
#define IP6T_RT_LEN 0x04 |
#define IP6T_RT_RES 0x08 |
#define IP6T_RT_FST_MASK 0x30 |
#define IP6T_RT_FST 0x10 |
#define IP6T_RT_FST_NSTRICT 0x20 |
/* Values for "invflags" field in struct ip6t_rt. */ |
#define IP6T_RT_INV_TYP 0x01 /* Invert the sense of type. */ |
#define IP6T_RT_INV_SGS 0x02 /* Invert the sense of Segments. */ |
#define IP6T_RT_INV_LEN 0x04 /* Invert the sense of length. */ |
#define IP6T_RT_INV_MASK 0x07 /* All possible flags. */ |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
#endif /*_IP6T_RT_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6t_opts.h |
---|
0,0 → 1,32 |
#ifndef _IP6T_OPTS_H |
#define _IP6T_OPTS_H |
#define IP6T_OPTS_OPTSNR 16 |
struct ip6t_opts |
{ |
u_int32_t hdrlen; /* Header Length */ |
u_int8_t flags; /* */ |
u_int8_t invflags; /* Inverse flags */ |
u_int16_t opts[IP6T_OPTS_OPTSNR]; /* opts */ |
u_int8_t optsnr; /* Nr of OPts */ |
}; |
#define IP6T_OPTS_LEN 0x01 |
#define IP6T_OPTS_OPTS 0x02 |
#define IP6T_OPTS_NSTRICT 0x04 |
/* Values for "invflags" field in struct ip6t_rt. */ |
#define IP6T_OPTS_INV_LEN 0x01 /* Invert the sense of length. */ |
#define IP6T_OPTS_INV_MASK 0x01 /* All possible flags. */ |
#define MASK_HOPOPTS 128 |
#define MASK_DSTOPTS 64 |
#define MASK_ROUTING 32 |
#define MASK_FRAGMENT 16 |
#define MASK_AH 8 |
#define MASK_ESP 4 |
#define MASK_NONE 2 |
#define MASK_PROTO 1 |
#endif /*_IP6T_OPTS_H*/ |
/shark/trunk/drivers/linuxc26/include/linux/netfilter_ipv6/ip6_tables.h |
---|
0,0 → 1,458 |
/* |
* 25-Jul-1998 Major changes to allow for ip chain table |
* |
* 3-Jan-2000 Named tables to allow packet selection for different uses. |
*/ |
/* |
* Format of an IP6 firewall descriptor |
* |
* src, dst, src_mask, dst_mask are always stored in network byte order. |
* flags are stored in host byte order (of course). |
* Port numbers are stored in HOST byte order. |
*/ |
#ifndef _IP6_TABLES_H |
#define _IP6_TABLES_H |
#ifdef __KERNEL__ |
#include <linux/if.h> |
#include <linux/types.h> |
#include <linux/in6.h> |
#include <linux/ipv6.h> |
#include <linux/skbuff.h> |
#endif |
#include <linux/netfilter_ipv6.h> |
#define IP6T_FUNCTION_MAXNAMELEN 30 |
#define IP6T_TABLE_MAXNAMELEN 32 |
/* Yes, Virginia, you have to zero the padding. */ |
struct ip6t_ip6 { |
/* Source and destination IP6 addr */ |
struct in6_addr src, dst; |
/* Mask for src and dest IP6 addr */ |
struct in6_addr smsk, dmsk; |
char iniface[IFNAMSIZ], outiface[IFNAMSIZ]; |
unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ]; |
/* ARGH, HopByHop uses 0, so can't do 0 = ANY, |
instead IP6T_F_NOPROTO must be set */ |
u_int16_t proto; |
/* TOS to match iff flags & IP6T_F_TOS */ |
u_int8_t tos; |
/* Flags word */ |
u_int8_t flags; |
/* Inverse flags */ |
u_int8_t invflags; |
}; |
/* FIXME: If alignment in kernel different from userspace? --RR */ |
struct ip6t_entry_match |
{ |
union { |
struct { |
u_int16_t match_size; |
/* Used by userspace */ |
char name[IP6T_FUNCTION_MAXNAMELEN]; |
} user; |
struct { |
u_int16_t match_size; |
/* Used inside the kernel */ |
struct ip6t_match *match; |
} kernel; |
/* Total length */ |
u_int16_t match_size; |
} u; |
unsigned char data[0]; |
}; |
struct ip6t_entry_target |
{ |
union { |
struct { |
u_int16_t target_size; |
/* Used by userspace */ |
char name[IP6T_FUNCTION_MAXNAMELEN]; |
} user; |
struct { |
u_int16_t target_size; |
/* Used inside the kernel */ |
struct ip6t_target *target; |
} kernel; |
/* Total length */ |
u_int16_t target_size; |
} u; |
unsigned char data[0]; |
}; |
struct ip6t_standard_target |
{ |
struct ip6t_entry_target target; |
int verdict; |
}; |
struct ip6t_counters |
{ |
u_int64_t pcnt, bcnt; /* Packet and byte counters */ |
}; |
/* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */ |
#define IP6T_F_PROTO 0x01 /* Set if rule cares about upper |
protocols */ |
#define IP6T_F_TOS 0x02 /* Match the TOS. */ |
#define IP6T_F_MASK 0x03 /* All possible flag bits mask. */ |
/* Values for "inv" field in struct ip6t_ip6. */ |
#define IP6T_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */ |
#define IP6T_INV_VIA_OUT 0x02 /* Invert the sense of OUT IFACE */ |
#define IP6T_INV_TOS 0x04 /* Invert the sense of TOS. */ |
#define IP6T_INV_SRCIP 0x08 /* Invert the sense of SRC IP. */ |
#define IP6T_INV_DSTIP 0x10 /* Invert the sense of DST OP. */ |
#define IP6T_INV_FRAG 0x20 /* Invert the sense of FRAG. */ |
#define IP6T_INV_PROTO 0x40 /* Invert the sense of PROTO. */ |
#define IP6T_INV_MASK 0x7F /* All possible flag bits mask. */ |
/* This structure defines each of the firewall rules. Consists of 3 |
parts which are 1) general IP header stuff 2) match specific |
stuff 3) the target to perform if the rule matches */ |
struct ip6t_entry |
{ |
struct ip6t_ip6 ipv6; |
/* Mark with fields that we care about. */ |
unsigned int nfcache; |
/* Size of ipt_entry + matches */ |
u_int16_t target_offset; |
/* Size of ipt_entry + matches + target */ |
u_int16_t next_offset; |
/* Back pointer */ |
unsigned int comefrom; |
/* Packet and byte counters. */ |
struct ip6t_counters counters; |
/* The matches (if any), then the target. */ |
unsigned char elems[0]; |
}; |
/* |
* New IP firewall options for [gs]etsockopt at the RAW IP level. |
* Unlike BSD Linux inherits IP options so you don't have to use |
* a raw socket for this. Instead we check rights in the calls. */ |
#define IP6T_BASE_CTL 64 /* base for firewall socket options */ |
#define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL) |
#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1) |
#define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS |
#define IP6T_SO_GET_INFO (IP6T_BASE_CTL) |
#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1) |
#define IP6T_SO_GET_MAX IP6T_SO_GET_ENTRIES |
/* CONTINUE verdict for targets */ |
#define IP6T_CONTINUE 0xFFFFFFFF |
/* For standard target */ |
#define IP6T_RETURN (-NF_MAX_VERDICT - 1) |
/* TCP matching stuff */ |
struct ip6t_tcp |
{ |
u_int16_t spts[2]; /* Source port range. */ |
u_int16_t dpts[2]; /* Destination port range. */ |
u_int8_t option; /* TCP Option iff non-zero*/ |
u_int8_t flg_mask; /* TCP flags mask byte */ |
u_int8_t flg_cmp; /* TCP flags compare byte */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "inv" field in struct ipt_tcp. */ |
#define IP6T_TCP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ |
#define IP6T_TCP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ |
#define IP6T_TCP_INV_FLAGS 0x04 /* Invert the sense of TCP flags. */ |
#define IP6T_TCP_INV_OPTION 0x08 /* Invert the sense of option test. */ |
#define IP6T_TCP_INV_MASK 0x0F /* All possible flags. */ |
/* UDP matching stuff */ |
struct ip6t_udp |
{ |
u_int16_t spts[2]; /* Source port range. */ |
u_int16_t dpts[2]; /* Destination port range. */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "invflags" field in struct ipt_udp. */ |
#define IP6T_UDP_INV_SRCPT 0x01 /* Invert the sense of source ports. */ |
#define IP6T_UDP_INV_DSTPT 0x02 /* Invert the sense of dest ports. */ |
#define IP6T_UDP_INV_MASK 0x03 /* All possible flags. */ |
/* ICMP matching stuff */ |
struct ip6t_icmp |
{ |
u_int8_t type; /* type to match */ |
u_int8_t code[2]; /* range of code */ |
u_int8_t invflags; /* Inverse flags */ |
}; |
/* Values for "inv" field for struct ipt_icmp. */ |
#define IP6T_ICMP_INV 0x01 /* Invert the sense of type/code test */ |
/* The argument to IP6T_SO_GET_INFO */ |
struct ip6t_getinfo |
{ |
/* Which table: caller fills this in. */ |
char name[IP6T_TABLE_MAXNAMELEN]; |
/* Kernel fills these in. */ |
/* Which hook entry points are valid: bitmask */ |
unsigned int valid_hooks; |
/* Hook entry points: one per netfilter hook. */ |
unsigned int hook_entry[NF_IP6_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_IP6_NUMHOOKS]; |
/* Number of entries */ |
unsigned int num_entries; |
/* Size of entries. */ |
unsigned int size; |
}; |
/* The argument to IP6T_SO_SET_REPLACE. */ |
struct ip6t_replace |
{ |
/* Which table. */ |
char name[IP6T_TABLE_MAXNAMELEN]; |
/* Which hook entry points are valid: bitmask. You can't |
change this. */ |
unsigned int valid_hooks; |
/* Number of entries */ |
unsigned int num_entries; |
/* Total size of new entries */ |
unsigned int size; |
/* Hook entry points. */ |
unsigned int hook_entry[NF_IP6_NUMHOOKS]; |
/* Underflow points. */ |
unsigned int underflow[NF_IP6_NUMHOOKS]; |
/* Information about old entries: */ |
/* Number of counters (must be equal to current number of entries). */ |
unsigned int num_counters; |
/* The old entries' counters. */ |
struct ip6t_counters *counters; |
/* The entries (hang off end: not really an array). */ |
struct ip6t_entry entries[0]; |
}; |
/* The argument to IP6T_SO_ADD_COUNTERS. */ |
struct ip6t_counters_info |
{ |
/* Which table. */ |
char name[IP6T_TABLE_MAXNAMELEN]; |
unsigned int num_counters; |
/* The counters (actually `number' of these). */ |
struct ip6t_counters counters[0]; |
}; |
/* The argument to IP6T_SO_GET_ENTRIES. */ |
struct ip6t_get_entries |
{ |
/* Which table: user fills this in. */ |
char name[IP6T_TABLE_MAXNAMELEN]; |
/* User fills this in: total entry size. */ |
unsigned int size; |
/* The entries. */ |
struct ip6t_entry entrytable[0]; |
}; |
/* Standard return verdict, or do jump. */ |
#define IP6T_STANDARD_TARGET "" |
/* Error verdict. */ |
#define IP6T_ERROR_TARGET "ERROR" |
/* Helper functions */ |
static __inline__ struct ip6t_entry_target * |
ip6t_get_target(struct ip6t_entry *e) |
{ |
return (void *)e + e->target_offset; |
} |
/* fn returns 0 to continue iteration */ |
#define IP6T_MATCH_ITERATE(e, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ip6t_entry_match *__m; \ |
\ |
for (__i = sizeof(struct ip6t_entry); \ |
__i < (e)->target_offset; \ |
__i += __m->u.match_size) { \ |
__m = (void *)(e) + __i; \ |
\ |
__ret = fn(__m , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
__ret; \ |
}) |
/* fn returns 0 to continue iteration */ |
#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ |
({ \ |
unsigned int __i; \ |
int __ret = 0; \ |
struct ip6t_entry *__e; \ |
\ |
for (__i = 0; __i < (size); __i += __e->next_offset) { \ |
__e = (void *)(entries) + __i; \ |
\ |
__ret = fn(__e , ## args); \ |
if (__ret != 0) \ |
break; \ |
} \ |
__ret; \ |
}) |
/* |
* Main firewall chains definitions and global var's definitions. |
*/ |
#ifdef __KERNEL__ |
#include <linux/init.h> |
extern void ip6t_init(void) __init; |
struct ip6t_match |
{ |
struct list_head list; |
const char name[IP6T_FUNCTION_MAXNAMELEN]; |
/* Return true or false: return FALSE and set *hotdrop = 1 to |
force immediate packet drop. */ |
int (*match)(const struct sk_buff *skb, |
const struct net_device *in, |
const struct net_device *out, |
const void *matchinfo, |
int offset, |
const void *hdr, |
u_int16_t datalen, |
int *hotdrop); |
/* Called when user tries to insert an entry of this type. */ |
/* Should return true or false. */ |
int (*checkentry)(const char *tablename, |
const struct ip6t_ip6 *ip, |
void *matchinfo, |
unsigned int matchinfosize, |
unsigned int hook_mask); |
/* Called when entry of this type deleted. */ |
void (*destroy)(void *matchinfo, unsigned int matchinfosize); |
/* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
struct module *me; |
}; |
/* Registration hooks for targets. */ |
struct ip6t_target |
{ |
struct list_head list; |
const char name[IP6T_FUNCTION_MAXNAMELEN]; |
/* Returns verdict. */ |
unsigned int (*target)(struct sk_buff **pskb, |
unsigned int hooknum, |
const struct net_device *in, |
const struct net_device *out, |
const void *targinfo, |
void *userdata); |
/* Called when user tries to insert an entry of this type: |
hook_mask is a bitmask of hooks from which it can be |
called. */ |
/* Should return true or false. */ |
int (*checkentry)(const char *tablename, |
const struct ip6t_entry *e, |
void *targinfo, |
unsigned int targinfosize, |
unsigned int hook_mask); |
/* Called when entry of this type deleted. */ |
void (*destroy)(void *targinfo, unsigned int targinfosize); |
/* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
struct module *me; |
}; |
extern int ip6t_register_target(struct ip6t_target *target); |
extern void ip6t_unregister_target(struct ip6t_target *target); |
extern int ip6t_register_match(struct ip6t_match *match); |
extern void ip6t_unregister_match(struct ip6t_match *match); |
/* Furniture shopping... */ |
struct ip6t_table |
{ |
struct list_head list; |
/* A unique name... */ |
char name[IP6T_TABLE_MAXNAMELEN]; |
/* Seed table: copied in register_table */ |
struct ip6t_replace *table; |
/* What hooks you will enter on */ |
unsigned int valid_hooks; |
/* Lock for the curtain */ |
rwlock_t lock; |
/* Man behind the curtain... */ |
struct ip6t_table_info *private; |
/* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
struct module *me; |
}; |
extern int ip6t_register_table(struct ip6t_table *table); |
extern void ip6t_unregister_table(struct ip6t_table *table); |
extern unsigned int ip6t_do_table(struct sk_buff **pskb, |
unsigned int hook, |
const struct net_device *in, |
const struct net_device *out, |
struct ip6t_table *table, |
void *userdata); |
/* Check for an extension */ |
extern int ip6t_ext_hdr(u8 nexthdr); |
#define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1)) |
#endif /*__KERNEL__*/ |
#endif /* _IP6_TABLES_H */ |