diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c index 1a95cc64286..1081aade330 100644 --- a/modules/usrloc/dlist.c +++ b/modules/usrloc/dlist.c @@ -85,10 +85,12 @@ static inline int find_dlist(str* _n, dlist_t** _d) * \param flags contact flags * \param part_idx part index * \param part_max maximal part + * \param GAU options * \return 0 on success, positive if buffer size was not sufficient, negative on failure */ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags, - unsigned int part_idx, unsigned int part_max) + unsigned int part_idx, unsigned int part_max, + int options) { struct socket_info *sock; unsigned int dbflags; @@ -108,9 +110,9 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags, int i; void *cp; int shortage, needed; - db_key_t keys1[3]; /* where */ - db_val_t vals1[3]; - db_op_t ops1[3]; + db_key_t keys1[4]; /* where */ + db_val_t vals1[4]; + db_op_t ops1[4]; db_key_t keys2[6]; /* select */ int n[2] = {2,6}; /* number of dynamic values used on key1/key2 */ @@ -160,6 +162,14 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags, vals1[n[0]].val.int_val = 1; n[0]++; } + if(options&GAU_OPT_SERVER_ID) { + keys1[n[0]] = &srv_id_col; + ops1[n[0]] = OP_EQ; + vals1[n[0]].type = DB1_INT; + vals1[n[0]].nul = 0; + vals1[n[0]].val.int_val = server_id; + n[0]++; + } /* TODO: use part_idx and part_max on keys1 */ @@ -323,10 +333,12 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags, * \param flags contact flags * \param part_idx part index * \param part_max maximal part + * \param GAU options * \return 0 on success, positive if buffer size was not sufficient, negative on failure */ static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags, - unsigned int part_idx, unsigned int part_max) + unsigned int part_idx, unsigned int part_max, + int options) { dlist_t *p; urecord_t *r; @@ -370,6 +382,9 @@ static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags, if ((c->cflags & flags) != flags) continue; + if(options&GAU_OPT_SERVER_ID && server_id!=c->server_id) + continue; + if(ul_keepalive_timeout>0 && c->last_keepalive>0) { if(c->sock!=NULL && c->sock->proto==PROTO_UDP) @@ -468,15 +483,17 @@ static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags, * \param flags contact flags * \param part_idx part index * \param part_max maximal part + * \param GAU options * \return 0 on success, positive if buffer size was not sufficient, negative on failure */ int get_all_ucontacts(void *buf, int len, unsigned int flags, - unsigned int part_idx, unsigned int part_max) + unsigned int part_idx, unsigned int part_max, + int options) { if (db_mode==DB_ONLY) - return get_all_db_ucontacts( buf, len, flags, part_idx, part_max); + return get_all_db_ucontacts( buf, len, flags, part_idx, part_max, options); else - return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max); + return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max, options); } diff --git a/modules/usrloc/dlist.h b/modules/usrloc/dlist.h index 9b8b84c91e6..a21099682f3 100644 --- a/modules/usrloc/dlist.h +++ b/modules/usrloc/dlist.h @@ -109,10 +109,11 @@ int synchronize_all_udomains(int istart, int istep); * \param flags contact flags * \param part_idx part index * \param part_max maximal part + * \param GAU options * \return 0 on success, positive if buffer size was not sufficient, negative on failure */ int get_all_ucontacts(void *buf, int len, unsigned int flags, - unsigned int part_idx, unsigned int part_max); + unsigned int part_idx, unsigned int part_max, int options); /*! diff --git a/modules/usrloc/usrloc.h b/modules/usrloc/usrloc.h index 5688e8cfded..4425a0610c2 100644 --- a/modules/usrloc/usrloc.h +++ b/modules/usrloc/usrloc.h @@ -40,6 +40,8 @@ #define DB_ONLY 3 #define DB_READONLY 4 +#define GAU_OPT_SERVER_ID (1<<0) /* filter query by server_id */ + /*forward declaration necessary for udomain*/ struct udomain; @@ -181,7 +183,7 @@ typedef void (*unlock_udomain_t)(struct udomain* _d, str *_aor); typedef int (*register_udomain_t)(const char* _n, struct udomain** _d); typedef int (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags, - unsigned int part_idx, unsigned int part_max); + unsigned int part_idx, unsigned int part_max, int options); typedef int (*get_udomain_t)(const char* _n, udomain_t** _d);