Ejemplo n.º 1
0
char *lookup_ether_type(unsigned int id)
{
	struct ether_type *entry = lookup_hash(id, &eth_ether_types);
	while (entry && id != entry->id)
		entry = entry->next;
	return (entry && id == entry->id ? entry->type : "Unknown");
}
Ejemplo n.º 2
0
char *lookup_vendor(unsigned int id)
{
	struct vendor_id *entry = lookup_hash(id, &eth_oui);
	while (entry && id != entry->id)
		entry = entry->next;
	return (entry && id == entry->id ? entry->vendor : "Unknown");
}
Ejemplo n.º 3
0
char *lookup_port_tcp(unsigned int id)
{
	struct port_tcp *entry = lookup_hash(id, &eth_ports_tcp);
	while (entry && id != entry->id)
		entry = entry->next;
	return (entry && id == entry->id ? entry->port : "Unknown");
}
Ejemplo n.º 4
0
static inline struct commit_name *find_commit_name(const unsigned char *peeled)
{
	struct commit_name *n = lookup_hash(hash_sha1(peeled), &names);
	while (n && !!hashcmp(peeled, n->peeled))
		n = n->next;
	return n;
}
Ejemplo n.º 5
0
/*
 * The main loop of the dissector. This is designed generic, so it doesn't
 * know the underlying linktype.
 */
static void dissector_main(uint8_t *packet, size_t len,
			   struct protocol *start, struct protocol *end)
{
	size_t off = 0;
	unsigned int key;
	struct hash_table *table;
	struct protocol *proto = start;

	while (proto != NULL) {
		len -= off;
		packet += off;
		if (unlikely(!proto->process))
			break;
		off = proto->offset;
		if (!off)
			off = len;
		proto->process(packet, off);
		if (unlikely(!proto->proto_next))
			break;
		proto->proto_next(packet, len, &table, &key, &off);
		if (unlikely(!table))
			break;
		proto = lookup_hash(key, table);
		while (proto && key != proto->key)
			proto = proto->next;
	}
	len -= off;
	packet += off;
	if (end != NULL)
		if (likely(end->process))
			end->process(packet, len);
	tprintf_flush();
}
Ejemplo n.º 6
0
int get_user_by_sockaddr(struct sockaddr_storage *sa, size_t sa_len,
			 struct curve25519_proto **proto)
{
	int ret = -1;
	struct sockaddr_map_entry *entry;
	unsigned int hash = hash_name((char *) sa, sa_len);

	errno = 0;

	rwlock_rd_lock(&sockaddr_map_lock);

	entry = lookup_hash(hash, &sockaddr_mapper);
	while (entry && entry->sa_len == sa_len &&
	       memcmp(sa, entry->sa, entry->sa_len))
		entry = entry->next;
	if (entry && entry->sa_len == sa_len &&
	    !memcmp(sa, entry->sa, entry->sa_len)) {
		(*proto) = entry->proto;
		ret = 0;
	} else {
		(*proto) = NULL;
		errno = ENOENT;
	}

	rwlock_unlock(&sockaddr_map_lock);

	return ret;
}
Ejemplo n.º 7
0
Table * lookup_set(Table * t, char *key, ValueType value) {
	int i, hashCode= lookup_hash(key);
	Entry * entry, *prev, *newEntry;
	if (t!=NULL) {
		for (entry = t->table[hashCode], prev=NULL;
		     entry !=NULL;
		     prev=entry, entry= entry->next) {
			//sets value if key was found
			if (strcmp(key, entry->key)==0) {
				entry->value= value; 
				return t;
			}
		}
	}
	/* At this point either table=NULL; entry *=NULL and either previous 
	points to NULL or prev points to last entry in hash index.
	In all cases we need to make new Entry* structure */
	newEntry= (Entry*)malloc(sizeof(Entry));
	newEntry->key= strdup(key);
	newEntry->value= value;
	newEntry->next=NULL;
	// t==NULL case //	
	if (t==NULL) {
		t= lookup_mkTable(); 
		t->table[hashCode] = newEntry; 
	}
	// case where entry in the hashcode index was NULL //
	else if (prev ==NULL) t->table[hashCode] = newEntry;
	//normal case: add newEntry to end of entry linked list //
	else prev->next= newEntry;
	return t;
}
Ejemplo n.º 8
0
struct dentry * sysfs_get_dentry(struct dentry * parent, const char * name)
{
	struct qstr qstr;

	qstr.name = name;
	qstr.len = strlen(name);
	qstr.hash = full_name_hash(name,qstr.len);
	return lookup_hash(&qstr,parent);
}
Ejemplo n.º 9
0
const char *lookup_vendor(unsigned int id)
{
	struct vendor_id *v;

	v = lookup_hash(id, &oui);
	while (v && id != v->id)
		v = v->next;

	return (v && id == v->id ? v->vendor : NULL);
}
Ejemplo n.º 10
0
struct dentry *vfsub_lookup_hash(struct nameidata *nd)
{
	struct path path = {
		.mnt = nd->path.mnt
	};

	IMustLock(nd->path.dentry->d_inode);

	path.dentry = lookup_hash(nd);
	if (IS_ERR(path.dentry))
		goto out;
	if (path.dentry->d_inode)
		vfsub_update_h_iattr(&path, /*did*/NULL); /*ignore*/

 out:
	AuTraceErrPtr(path.dentry);
	return path.dentry;
}

/* ---------------------------------------------------------------------- */

struct dentry *vfsub_lock_rename(struct dentry *d1, struct au_hinode *hdir1,
				 struct dentry *d2, struct au_hinode *hdir2)
{
	struct dentry *d;

	lockdep_off();
	d = lock_rename(d1, d2);
	lockdep_on();
	au_hn_suspend(hdir1);
	if (hdir1 != hdir2)
		au_hn_suspend(hdir2);

	return d;
}

void vfsub_unlock_rename(struct dentry *d1, struct au_hinode *hdir1,
			 struct dentry *d2, struct au_hinode *hdir2)
{
	au_hn_resume(hdir1);
	if (hdir1 != hdir2)
		au_hn_resume(hdir2);
	lockdep_off();
	unlock_rename(d1, d2);
	lockdep_on();
}
Ejemplo n.º 11
0
static struct sock_map_entry *socket_to_sock_map_entry(int fd)
{
	struct sock_map_entry *entry, *ret = NULL;

	errno = 0;

	rwlock_rd_lock(&sock_map_lock);

	entry = lookup_hash(fd, &sock_mapper);
	while (entry && fd != entry->fd)
		entry = entry->next;
	if (entry && fd == entry->fd)
		ret = entry;
	else
		errno = ENOENT;

	rwlock_unlock(&sock_map_lock);

	return ret;
}
Ejemplo n.º 12
0
Exec_stat MCVariableValue::lookup_element(MCExecPoint& ep, const MCString& key, MCVariableValue*& r_value)
{
	if (is_array())
		;
	else
		assign_new_array(TABLE_SIZE);
	
	// MW-2012-09-04: [[ Bug 10284 ]] Use common 'lookup_hash' method.
	MCHashentry *t_value;
	Exec_stat t_stat;
	t_stat = lookup_hash(ep, key, True, t_value);
	if (t_stat == ES_ERROR)
		return t_stat;
	
	r_value = &(t_value -> value);

	set_dbg_mutated(true);
	
	return ES_NORMAL;
}
Ejemplo n.º 13
0
unsigned int socket_to_cpu(int fd)
{
	int cpu = 0;
	struct map_entry *entry;

	errno = 0;

	rwlock_rd_lock(&map_lock);

	entry = lookup_hash(fd, &mapper);
	while (entry && fd != entry->fd)
		entry = entry->next;
	if (entry && fd == entry->fd)
		cpu = entry->cpu;
	else
		errno = ENOENT;

	rwlock_unlock(&map_lock);

	return cpu;
}
Ejemplo n.º 14
0
static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry)
{
	struct dentry *proc_dentry;
	struct inode *inode;
	int err, deleted;

	deleted = file_removed(dentry, NULL);
	if(deleted < 0)
		return(ERR_PTR(deleted));
	else if(deleted)
		return(ERR_PTR(-ENOENT));

	proc_dentry = lookup_hash(&dentry->d_name, ino->u.hppfs_i.proc_dentry);
	if(IS_ERR(proc_dentry))
		return(proc_dentry);

	inode = get_inode(ino->i_sb, proc_dentry, &err);
	if(err != 0) 
		return(ERR_PTR(err));

	d_add(dentry, inode);
	dentry->d_op = &hppfs_dentry_ops;
	return(NULL);
}
Ejemplo n.º 15
0
static struct sockaddr_map_entry *
sockaddr_to_sockaddr_map_entry(struct sockaddr_storage *sa, size_t sa_len)
{
	struct sockaddr_map_entry *entry, *ret = NULL;
	unsigned int hash = hash_name((char *) sa, sa_len);

	errno = 0;

	rwlock_rd_lock(&sockaddr_map_lock);

	entry = lookup_hash(hash, &sockaddr_mapper);
	while (entry && entry->sa_len == sa_len &&
	       memcmp(sa, entry->sa, entry->sa_len))
		entry = entry->next;
	if (entry && entry->sa_len == sa_len &&
	    !memcmp(sa, entry->sa, entry->sa_len))
		ret = entry;
	else
		errno = ENOENT;

	rwlock_unlock(&sockaddr_map_lock);

	return ret;
}
Ejemplo n.º 16
0
int get_user_by_socket(int fd, struct curve25519_proto **proto)
{
	int ret = -1;
	struct sock_map_entry *entry;

	errno = 0;

	rwlock_rd_lock(&sock_map_lock);

	entry = lookup_hash(fd, &sock_mapper);
	while (entry && fd != entry->fd)
		entry = entry->next;
	if (entry && fd == entry->fd) {
		(*proto) = entry->proto;
		ret = 0;
	} else {
		(*proto) = NULL;
		errno = ENOENT;
	}

	rwlock_unlock(&sock_map_lock);

	return ret;
}
Ejemplo n.º 17
0
struct dentry *vfsub_lookup_hash(struct nameidata *nd)
{
	struct path path = {
		.mnt = nd->path.mnt
	};

	IMustLock(nd->path.dentry->d_inode);

	path.dentry = lookup_hash(nd);
	if (IS_ERR(path.dentry))
		goto out;
	if (path.dentry->d_inode)
		vfsub_update_h_iattr(&path, /*did*/NULL); /*ignore*/

out:
	AuTraceErrPtr(path.dentry);
	return path.dentry;
}

/*
 * this is "VFS:__lookup_one_len()" which was removed and merged into
 * VFS:lookup_one_len() by the commit.
 *	6a96ba5 2011-03-14 kill __lookup_one_len()
 * this function should always be equivalent to the corresponding part in
 * VFS:lookup_one_len().
 */
int vfsub_name_hash(const char *name, struct qstr *this, int len)
{
	unsigned int c;

	this->name = name;
	this->len = len;
	this->hash = full_name_hash(name, len);
	if (!len)
		return -EACCES;

	while (len--) {
		c = *(const unsigned char *)name++;
		if (c == '/' || c == '\0')
			return -EACCES;
	}
	return 0;
}

/* ---------------------------------------------------------------------- */

struct dentry *vfsub_lock_rename(struct dentry *d1, struct au_hinode *hdir1,
				 struct dentry *d2, struct au_hinode *hdir2)
{
	struct dentry *d;

	lockdep_off();
	d = lock_rename(d1, d2);
	lockdep_on();
	au_hn_suspend(hdir1);
	if (hdir1 != hdir2)
		au_hn_suspend(hdir2);

	return d;
}

void vfsub_unlock_rename(struct dentry *d1, struct au_hinode *hdir1,
			 struct dentry *d2, struct au_hinode *hdir2)
{
	au_hn_resume(hdir1);
	if (hdir1 != hdir2)
		au_hn_resume(hdir2);
	lockdep_off();
	unlock_rename(d1, d2);
	lockdep_on();
}