From: Guo, M. <mi...@in...> - 2004-02-25 07:01:09
|
Add mc translation function to the nametable.c file --------------------------- Index: name_table.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/develop/unstable_tipc/net/tipc/name_table.c,v retrieving revision 1.3 retrieving revision 1.5 diff -u -r1.3 -r1.5 --- name_table.c 24 Feb 2004 02:00:08 -0000 1.3 +++ name_table.c 25 Feb 2004 06:49:24 -0000 1.5 @@ -38,13 +38,22 @@ * * = ------------------------------------------------------------------------ * - * $Id: name_table.c,v 1.3 2004/02/24 02:00:08 xling Exp $ + * $Id: name_table.c,v 1.5 2004/02/25 06:49:24 mguo Exp $ * * Revision history: * ---------------- * $Log: name_table.c,v $ - * Revision 1.3 2004/02/24 02:00:08 xling - * sf0224 + * Revision 1.5 2004/02/25 06:49:24 mguo + * complier pass + * + * Revision 1.4 2004/02/25 06:00:47 xling + * fix mc + * + * Revision 1.2 2004/02/18 07:22:02 xling + * *** empty log message *** + * + * Revision 1.1.1.1 2004/02/17 08:48:08 xling + * import * * Revision 1.4 2004/02/09 03:49:44 jonmaloy * *** empty log message *** @@ -69,6 +78,9 @@ #include "node_subscr.h" #include "name_subscr.h" #include "port.h" +#include "cluster.h" +#include "bcast.h" +#include <linux/list.h> =20 static void nametbl_dump(void); static void nametbl_print(struct print_buf *buf, const char *str); @@ -674,6 +686,146 @@ not_found: read_unlock_bh(&nametbl_lock);=20 return 0; +} + +/* + *nametbl_mc_translate +*/ +int nametbl_mc_translate(struct list_head* mc_head ,uint type, + uint lower,uint upper) +{ + struct name_seq* seq;=20 + int i =3D 0;=20 + struct publication* publ; + struct sub_seq *sseq; =20 + int low_seq, high_seq; + uint destport; + tipc_net_addr_t destnode; + + read_lock_bh(&nametbl_lock);=20 + seq =3D nametbl_find_seq(type);=20 + if (!seq) goto not_found; =20 + + sseq =3D nameseq_available(seq,lower,upper); =20 + if (!sseq) goto not_found; =20 + =20 + low_seq =3D nameseq_find_insert_pos(seq,lower); =20 + if (low_seq < 0) + low_seq =3D low_seq < 0 ? ~low_seq : low_seq; + + high_seq =3D nameseq_find_insert_pos(seq,upper);=20 + if (high_seq < 0) + high_seq =3D high_seq < 0 ? ((~high_seq) -1): high_seq; + =20 + if (high_seq < low_seq) + goto not_found;=20 + =20 + spin_lock_bh(&seq->lock); + + i =3D low_seq; + =20 + for (i =3D low_seq ; i <=3D high_seq; i++) + { + + publ =3D seq->sseqs[i].cluster_list; + if(!publ) { + spin_unlock_bh(&seq->lock); + goto not_found; + =09 + } + =09 + do { + destnode =3D publ->node;=20 + destport =3D publ->ref; + if ( false =3D=3D mc_indenity_create(mc_head,destport,destnode)) + goto found; =09 + publ=3D publ->cluster_list.next; + }while(publ !=3D seq->sseqs[i].cluster_list); + =09 + if (destport) + { + if ( false =3D=3D mc_indenity_create(mc_head,destport,destnode)) + goto found; =09 + } =09 + }=09 + if (list_empty(mc_head)) + { + spin_unlock_bh(&seq->lock); + goto not_found; + } + found: + spin_unlock_bh(&seq->lock); + read_unlock_bh(&nametbl_lock);=20 + return true; + not_found: + read_unlock_bh(&nametbl_lock);=20 + return false; +} + + +/* + *nametbl_mc_translate +*/ +int nametbl_self_translate(struct list_head* mc_head ,uint type, + uint lower,uint upper) +{ + struct name_seq* seq;=20 + int i =3D 0;=20 + struct publication* publ; + struct sub_seq *sseq; =20 + int low_seq, high_seq; + uint destport; + tipc_net_addr_t destnode; + + read_lock_bh(&nametbl_lock);=20 + seq =3D nametbl_find_seq(type);=20 + if (!seq) goto not_found; =20 + + sseq =3D nameseq_available(seq,lower,upper); =20 + if (!sseq) goto not_found; =20 + =20 + low_seq =3D nameseq_find_insert_pos(seq,lower); =20 + if (low_seq < 0) + low_seq =3D low_seq < 0 ? ~low_seq : low_seq; + + high_seq =3D nameseq_find_insert_pos(seq,upper);=20 + if (high_seq < 0) + high_seq =3D high_seq < 0 ? ((~high_seq) -1): high_seq; + =20 + if (high_seq < low_seq) + goto not_found;=20 + =20 + spin_lock_bh(&seq->lock); + + i =3D low_seq; + =20 + for (i =3D low_seq ; i <=3D high_seq; i++) + { + publ =3D seq->sseqs[i].node_list; + if(!publ) { + spin_unlock_bh(&seq->lock); + goto not_found; =09 + } + destnode =3D publ->node;=20 + destport =3D publ->ref; + if (destport && (destnode =3D=3D tipc_own_addr)) + { + if ( false =3D=3D mc_indenity_create(mc_head,destport,destnode)) { + spin_unlock_bh(&seq->lock); + goto not_found; =09 + } + } =09 + }=09 + if (list_empty(mc_head)) + spin_unlock_bh(&seq->lock); + goto not_found; + spin_unlock_bh(&seq->lock); + read_unlock_bh(&nametbl_lock);=20 + return true; + not_found: + read_unlock_bh(&nametbl_lock);=20 + return false; + } =20 struct publication * |