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 <ndebug.h>
0037 #include <atmi.h>
0038 #include <ndrstandard.h>
0039 #include <ubf.h>
0040 #include <test.fd.h>
0041 #include <string.h>
0042 #include <unistd.h>
0043
0044
0045
0046
0047
0048
0049
0050
0051 exprivate long M_seq = 0;
0052
0053
0054
0055
0056
0057
0058 void SEQVALID (TPSVCINFO *p_svc)
0059 {
0060 int ret = EXSUCCEED;
0061 long l;
0062 UBFH *p_ub = (UBFH *)p_svc->data;
0063
0064
0065 if (EXSUCCEED!=Bget(p_ub, T_LONG_FLD, 0, (char *)&l, NULL))
0066 {
0067 NDRX_LOG(log_always, "TESTERROR: T_LONG_FLD is missing!");
0068 EXFAIL_OUT(ret);
0069 }
0070
0071
0072 if (M_seq+1!=l)
0073 {
0074 NDRX_LOG(log_always, "TESTERROR: Invalid service call sequence: got %ld expected %ld",
0075 l, M_seq+1);
0076 userlog("TESTERROR: Invalid service call sequence: got %ld expected %ld",
0077 l, M_seq+1);
0078 EXFAIL_OUT(ret);
0079 }
0080 M_seq = l;
0081
0082 out:
0083 tpreturn( (EXSUCCEED==ret?TPSUCCESS:TPFAIL),
0084 0L,
0085 (char *)p_ub,
0086 0L,
0087 0L);
0088 }
0089
0090
0091
0092
0093 void FAILSVC (TPSVCINFO *p_svc)
0094 {
0095 UBFH *p_ub = (UBFH *)p_svc->data;
0096
0097 NDRX_LOG(log_debug, "%s got call", __func__);
0098
0099
0100 if (EXSUCCEED!=Bchg(p_ub, T_STRING_FLD, 0, "RSP", 0))
0101 {
0102 NDRX_LOG(log_error, "TESTERROR: failed to update buffer: %s",
0103 Bstrerror(Berror));
0104 }
0105
0106
0107 out:
0108 tpreturn( TPFAIL,
0109 0L,
0110 (char *)p_ub,
0111 0L,
0112 0L);
0113 }
0114
0115
0116
0117
0118 void OKSVC (TPSVCINFO *p_svc)
0119 {
0120 UBFH *p_ub = (UBFH *)p_svc->data;
0121
0122 out:
0123 tpreturn( TPSUCCESS,
0124 0L,
0125 (char *)p_ub,
0126 0L,
0127 0L);
0128 }
0129
0130
0131
0132
0133 void TOUT_SLEEP (TPSVCINFO *p_svc)
0134 {
0135 UBFH *p_ub = (UBFH *)p_svc->data;
0136
0137 sleep(35);
0138
0139 out:
0140 tpreturn( TPSUCCESS,
0141 0L,
0142 (char *)p_ub,
0143 0L,
0144 0L);
0145 }
0146
0147
0148
0149
0150 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0151 {
0152 int ret = EXSUCCEED;
0153 NDRX_LOG(log_debug, "tpsvrinit called");
0154
0155 if (EXSUCCEED!=tpadvertise("FAILSVC", FAILSVC))
0156 {
0157 NDRX_LOG(log_error, "Failed to initialise FAILSVC!");
0158 EXFAIL_OUT(ret);
0159 }
0160
0161 if (EXSUCCEED!=tpadvertise("OKSVC", OKSVC))
0162 {
0163 NDRX_LOG(log_error, "Failed to initialise OKSVC!");
0164 EXFAIL_OUT(ret);
0165 }
0166
0167 if (EXSUCCEED!=tpadvertise("SEQVALID", SEQVALID))
0168 {
0169 NDRX_LOG(log_error, "Failed to initialise SEQVALID!");
0170 EXFAIL_OUT(ret);
0171 }
0172
0173
0174 if (EXSUCCEED!=tpadvertise("T_OK", TOUT_SLEEP))
0175 {
0176 NDRX_LOG(log_error, "Failed to initialise T_OK!");
0177 EXFAIL_OUT(ret);
0178 }
0179
0180 if (EXSUCCEED!=tpadvertise("T_NOK", TOUT_SLEEP))
0181 {
0182 NDRX_LOG(log_error, "Failed to initialise T_NOK!");
0183 EXFAIL_OUT(ret);
0184 }
0185
0186 if (EXSUCCEED!=tpadvertise("NS_OK", TOUT_SLEEP))
0187 {
0188 NDRX_LOG(log_error, "Failed to initialise NS_OK!");
0189 EXFAIL_OUT(ret);
0190 }
0191
0192 if (EXSUCCEED!=tpadvertise("ND_OK", TOUT_SLEEP))
0193 {
0194 NDRX_LOG(log_error, "Failed to initialise ND_OK!");
0195 EXFAIL_OUT(ret);
0196 }
0197
0198 if (EXSUCCEED!=tpadvertise("ND_NOK", TOUT_SLEEP))
0199 {
0200 NDRX_LOG(log_error, "Failed to initialise ND_NOK!");
0201 EXFAIL_OUT(ret);
0202 }
0203
0204
0205 if (EXSUCCEED!=tpopen())
0206 {
0207 NDRX_LOG(log_error, "tpopen() failed: %s", tpstrerror(tperrno));
0208 EXFAIL_OUT(ret);
0209 }
0210
0211 out:
0212 return ret;
0213 }
0214
0215
0216
0217
0218 void NDRX_INTEGRA(tpsvrdone)(void)
0219 {
0220 NDRX_LOG(log_debug, "tpsvrdone called");
0221 tpclose();
0222 }
0223
0224