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 <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <errno.h>
0038 #include <memory.h>
0039 #include <sys/types.h>
0040 #include <sys/stat.h>
0041 #include <ndrstandard.h>
0042 #include <ndebug.h>
0043
0044 #include <ndrx.h>
0045 #include <ndrxdcmn.h>
0046 #include <atmi_int.h>
0047 #include <gencall.h>
0048
0049 #include <nstopwatch.h>
0050 #include <nclopt.h>
0051 #include <sys_unix.h>
0052 #include <utlist.h>
0053 #include <lcfint.h>
0054 #include <ndrx_ddr.h>
0055 #include <atmi_shm.h>
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 exprivate void print_hdr(void)
0070 {
0071
0072 fprintf(stderr, " SLOT SERVICE NAME PRIO ROUTE T TRANTIME FLAGS\n");
0073 fprintf(stderr, "------ ------------------------------ ---- --------------- - -------- ---------\n");
0074 }
0075
0076
0077
0078
0079
0080
0081
0082
0083 expublic int cmd_prtsvc(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0084 {
0085 int ret=EXSUCCEED;
0086 short print_all = EXFALSE;
0087 short print_isused = EXFALSE;
0088 short print_wasused = EXFALSE;
0089 int i;
0090 ndrx_services_t *el;
0091 ndrx_services_t *ptr;
0092 char flagsstr[128];
0093 int total = 0;
0094 int page;
0095 ncloptmap_t clopt[] =
0096 {
0097 {'a', BFLD_SHORT, (void *)&print_all, 0,
0098 NCLOPT_OPT | NCLOPT_TRUEBOOL,
0099 "Print all entries"},
0100 {'i', BFLD_SHORT, (void *)&print_isused, 0,
0101 NCLOPT_OPT | NCLOPT_TRUEBOOL,
0102 "Print entries in use"},
0103 {'w', BFLD_SHORT, (void *)&print_wasused, 0,
0104 NCLOPT_OPT | NCLOPT_TRUEBOOL,
0105 "Print entries which was used"},
0106 {0}
0107 };
0108
0109
0110 if (nstd_parse_clopt(clopt, EXTRUE, argc, argv, EXFALSE))
0111 {
0112 fprintf(stderr, XADMIN_INVALID_OPTIONS_MSG);
0113 EXFAIL_OUT(ret);
0114 }
0115
0116 if (!print_isused && !print_wasused && !print_all)
0117 {
0118 print_isused = EXTRUE;
0119 }
0120
0121 if (EXFAIL==tpinit(NULL))
0122 {
0123 fprintf(stderr, "* Failed to become client\n");
0124 EXFAIL_OUT(ret);
0125 }
0126
0127
0128 print_hdr();
0129
0130 page = ndrx_G_shmcfg->ddr_page;
0131 ptr = (ndrx_services_t *) (ndrx_G_routsvc.mem + page*G_atmi_env.rtsvcmax * sizeof(ndrx_services_t));
0132 for (i=0; i<G_atmi_env.rtsvcmax; i++)
0133 {
0134 el = NDRX_DDRV_SVC_INDEX(ptr, i);
0135
0136 if (print_all ||
0137 (print_isused && (el->flags & NDRX_LH_FLAG_ISUSED)) ||
0138
0139 (print_wasused && (el->flags & NDRX_LH_FLAG_WASUSED) &&
0140 !(el->flags & NDRX_LH_FLAG_ISUSED))
0141
0142 )
0143 {
0144 flagsstr[0]=EXEOS;
0145
0146 if (el->flags & NDRX_LH_FLAG_ISUSED)
0147 {
0148 if (EXEOS!=flagsstr[0])
0149 {
0150 NDRX_STRCAT_S(flagsstr, sizeof(flagsstr), ",");
0151 }
0152 NDRX_STRCAT_S(flagsstr, sizeof(flagsstr), "iuse");
0153 }
0154 else if (el->flags & NDRX_LH_FLAG_WASUSED)
0155 {
0156 if (EXEOS!=flagsstr[0])
0157 {
0158 NDRX_STRCAT_S(flagsstr, sizeof(flagsstr), ",");
0159 }
0160 NDRX_STRCAT_S(flagsstr, sizeof(flagsstr), "wuse");
0161 }
0162
0163 fprintf(stdout, "%6d %-30.30s %4d %-15.15s %c %8lu %s\n",
0164 i, el->svcnm, el->prio, el->criterion, el->autotran?'Y':'N',
0165 el->trantime, flagsstr);
0166 total++;
0167 }
0168 }
0169
0170 fprintf(stderr, "\nTOTAL: %d\n", total);
0171
0172 out:
0173
0174 return ret;
0175 }
0176