Print this page
4823 don't open-code NSEC2MSEC and MSEC2NSEC


 136 } ipmpstat_probe_state_t;
 137 
 138 /*
 139  * Options that modify the output mode; more than one may be lit.
 140  */
 141 typedef enum {
 142         IPMPSTAT_OPT_NUMERIC    = 0x1,
 143         IPMPSTAT_OPT_PARSABLE   = 0x2
 144 } ipmpstat_opt_t;
 145 
 146 /*
 147  * Indices for the FLAGS field of the `-i' output format.
 148  */
 149 enum {
 150         IPMPSTAT_IFLAG_INDEX,   IPMPSTAT_SFLAG_INDEX,   IPMPSTAT_M4FLAG_INDEX,
 151         IPMPSTAT_BFLAG_INDEX,   IPMPSTAT_M6FLAG_INDEX,  IPMPSTAT_DFLAG_INDEX,
 152         IPMPSTAT_HFLAG_INDEX,   IPMPSTAT_NUM_FLAGS
 153 };
 154 
 155 #define IPMPSTAT_NCOL   80
 156 #define NS2FLOATMS(ns)  ((float)(ns) / (NANOSEC / MILLISEC))
 157 #define MS2FLOATSEC(ms) ((float)(ms) / 1000)
 158 
 159 static const char       *progname;
 160 static hrtime_t         probe_output_start;
 161 static ipmpstat_opt_t   opt;
 162 static ofmt_handle_t    ofmt;
 163 static ipmpstat_enum_t  addr_state[], group_state[], if_state[], if_link[];
 164 static ipmpstat_enum_t  if_probe[], targ_mode[];
 165 static ofmt_field_t     addr_fields[], group_fields[], if_fields[];
 166 static ofmt_field_t     probe_fields[], targ_fields[];
 167 static ipmpstat_cbfunc_t walk_addr_cbfunc, walk_if_cbfunc;
 168 static ipmpstat_cbfunc_t info_output_cbfunc, targinfo_output_cbfunc;
 169 static ipmpstat_walker_t walk_addr, walk_if, walk_group;
 170 
 171 static int probe_event(sysevent_t *, void *);
 172 static void probe_output(ipmp_handle_t, ofmt_handle_t);
 173 static void ofmt_output(ofmt_handle_t, ipmp_handle_t, void *);
 174 static void enum2str(const ipmpstat_enum_t *, int, char *, uint_t);
 175 static void sockaddr2str(const struct sockaddr_storage *, char *, uint_t);
 176 static void sighandler(int);




 136 } ipmpstat_probe_state_t;
 137 
 138 /*
 139  * Options that modify the output mode; more than one may be lit.
 140  */
 141 typedef enum {
 142         IPMPSTAT_OPT_NUMERIC    = 0x1,
 143         IPMPSTAT_OPT_PARSABLE   = 0x2
 144 } ipmpstat_opt_t;
 145 
 146 /*
 147  * Indices for the FLAGS field of the `-i' output format.
 148  */
 149 enum {
 150         IPMPSTAT_IFLAG_INDEX,   IPMPSTAT_SFLAG_INDEX,   IPMPSTAT_M4FLAG_INDEX,
 151         IPMPSTAT_BFLAG_INDEX,   IPMPSTAT_M6FLAG_INDEX,  IPMPSTAT_DFLAG_INDEX,
 152         IPMPSTAT_HFLAG_INDEX,   IPMPSTAT_NUM_FLAGS
 153 };
 154 
 155 #define IPMPSTAT_NCOL   80
 156 #define NS2FLOATMS(ns)  (NSEC2MSEC((float)(ns)))
 157 #define MS2FLOATSEC(ms) ((float)(ms) / 1000)
 158 
 159 static const char       *progname;
 160 static hrtime_t         probe_output_start;
 161 static ipmpstat_opt_t   opt;
 162 static ofmt_handle_t    ofmt;
 163 static ipmpstat_enum_t  addr_state[], group_state[], if_state[], if_link[];
 164 static ipmpstat_enum_t  if_probe[], targ_mode[];
 165 static ofmt_field_t     addr_fields[], group_fields[], if_fields[];
 166 static ofmt_field_t     probe_fields[], targ_fields[];
 167 static ipmpstat_cbfunc_t walk_addr_cbfunc, walk_if_cbfunc;
 168 static ipmpstat_cbfunc_t info_output_cbfunc, targinfo_output_cbfunc;
 169 static ipmpstat_walker_t walk_addr, walk_if, walk_group;
 170 
 171 static int probe_event(sysevent_t *, void *);
 172 static void probe_output(ipmp_handle_t, ofmt_handle_t);
 173 static void ofmt_output(ofmt_handle_t, ipmp_handle_t, void *);
 174 static void enum2str(const ipmpstat_enum_t *, int, char *, uint_t);
 175 static void sockaddr2str(const struct sockaddr_storage *, char *, uint_t);
 176 static void sighandler(int);