0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <string.h>
0037 #include <errno.h>
0038 #include <regex.h>
0039 #include <utlist.h>
0040 #include <unistd.h>
0041 #include <signal.h>
0042 #include <fcntl.h>
0043
0044 #include <ndebug.h>
0045 #include <atmi.h>
0046 #include <atmi_int.h>
0047 #include <typed_buf.h>
0048 #include <ndrstandard.h>
0049 #include <ubf.h>
0050 #include <Exfields.h>
0051 #include <Excompat.h>
0052 #include <ubfutil.h>
0053 #include <sys_unix.h>
0054 #include <gencall.h>
0055 #include "tpadmsv.h"
0056 #include "expr.h"
0057
0058
0059
0060
0061
0062
0063
0064
0065 typedef struct
0066 {
0067 long nodeid;
0068 long srvid;
0069 long remnodeid;
0070 char mode;
0071 long fd;
0072
0073 long time;
0074
0075
0076 long conseq;
0077 long lastsync;
0078 long timediff;
0079 long timediffms;
0080 long roundtrip;
0081
0082
0083 } ndrx_adm_brcon_t;
0084
0085
0086
0087
0088 expublic ndrx_adm_elmap_t ndrx_G_brcon_map[] =
0089 {
0090
0091 {TA_EX_NODEID, TPADM_EL(ndrx_adm_brcon_t, nodeid)}
0092 ,{TA_SRVID, TPADM_EL(ndrx_adm_brcon_t, srvid)}
0093 ,{TA_EX_REMNODEID, TPADM_EL(ndrx_adm_brcon_t, remnodeid)}
0094 ,{TA_EX_FD, TPADM_EL(ndrx_adm_brcon_t, fd)}
0095 ,{TA_EX_CONMODE, TPADM_EL(ndrx_adm_brcon_t, mode)}
0096 ,{TA_EX_TIME, TPADM_EL(ndrx_adm_brcon_t, time)}
0097 ,{TA_EX_LASTSYNC, TPADM_EL(ndrx_adm_brcon_t, lastsync)}
0098 ,{TA_EX_TIMEDIFF, TPADM_EL(ndrx_adm_brcon_t, timediff)}
0099 ,{TA_EX_TIMEDIFFF, TPADM_EL(ndrx_adm_brcon_t, timediffms)}
0100 ,{TA_EX_ROUNDTRIP, TPADM_EL(ndrx_adm_brcon_t, roundtrip)}
0101 ,{BBADFLDID}
0102 };
0103
0104
0105
0106
0107 exprivate ndrx_adm_cursors_t *M_cursnew;
0108 exprivate int M_idx;
0109 exprivate string_list_t *M_qlist;
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 exprivate int ndrx_adm_brconinfo_proc_list(command_reply_t *reply, size_t reply_len)
0120 {
0121 command_reply_brconinfo_t * info = (command_reply_brconinfo_t*)reply;
0122 int ret = EXSUCCEED;
0123 ndrx_adm_brcon_t brcon;
0124
0125 if (NDRXD_CALL_TYPE_BRCONINFO!=reply->msg_type)
0126 {
0127
0128 goto out;
0129 }
0130
0131
0132 memset(&brcon, 0, sizeof(brcon));
0133
0134 brcon.nodeid = info->locnodeid;
0135 brcon.srvid = info->srvid;
0136 brcon.fd = info->fd;
0137 brcon.mode = info->mode;
0138 brcon.remnodeid = info->remnodeid;
0139 brcon.lastsync = info->lastsync;
0140 brcon.timediff = info->timediffs;
0141 brcon.timediffms = info->timediffms;
0142 brcon.roundtrip = info->roundtrip;
0143
0144 brcon.time = info->time;
0145
0146 if (EXSUCCEED!=ndrx_growlist_add(&M_cursnew->list, (void *)&brcon, M_idx))
0147 {
0148 NDRX_LOG(log_error, "Growlist failed - out of memory?");
0149 EXFAIL_OUT(ret);
0150 }
0151
0152 M_idx++;
0153
0154 out:
0155 return ret;
0156 }
0157
0158
0159
0160
0161
0162
0163
0164 exprivate int ndrx_adm_blist_proc_list(command_reply_t *reply, size_t reply_len)
0165 {
0166 command_reply_blist_t * blist_info = (command_reply_blist_t*)reply;
0167 int ret = EXSUCCEED;
0168
0169 if (NDRXD_CALL_TYPE_BLIST!=reply->msg_type)
0170 {
0171
0172 goto out;
0173 }
0174
0175 NDRX_LOG(log_debug, "Got admin Q for bridge: [%s]", blist_info->qstr);
0176
0177 if (EXSUCCEED!=ndrx_string_list_add(&M_qlist, blist_info->qstr))
0178 {
0179 NDRX_LOG(log_error, "Failed to populate string list");
0180 EXFAIL_OUT(ret);
0181 }
0182
0183 out:
0184 return ret;
0185 }
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199 expublic int ndrx_adm_brcon_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags)
0200 {
0201 int ret = EXSUCCEED;
0202 string_list_t *qstr;
0203
0204
0205 M_idx = 0;
0206 M_qlist = NULL;
0207
0208 ndrx_growlist_init(&cursnew->list, 100, sizeof(ndrx_adm_brcon_t));
0209
0210 M_cursnew = cursnew;
0211 cursnew->map = ndrx_G_brcon_map;
0212
0213 if (EXSUCCEED!=ndrx_adm_list_call(ndrx_adm_blist_proc_list,
0214 NDRXD_COM_BLIST_RQ, NDRXD_COM_BLIST_RP, ndrx_get_G_atmi_conf()->ndrxd_q_str))
0215 {
0216 NDRX_LOG(log_error, "Failed to call blist");
0217 EXFAIL_OUT(ret);
0218 }
0219
0220 LL_FOREACH(M_qlist, qstr)
0221 {
0222
0223 if (EXSUCCEED!=ndrx_adm_list_call(ndrx_adm_brconinfo_proc_list,
0224 NDRXD_COM_BRCONINFO_RQ, NDRXD_COM_BRCONINFO_RP, qstr->qname))
0225 {
0226 NDRX_LOG(log_error, "Failed to call brclockinfo");
0227 EXFAIL_OUT(ret);
0228 }
0229 }
0230
0231 out:
0232
0233 if (EXSUCCEED!=ret)
0234 {
0235 ndrx_growlist_free(&M_cursnew->list);
0236 }
0237
0238
0239 ndrx_string_list_free(M_qlist);
0240
0241 return ret;
0242 }
0243
0244