diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-04-03 08:10:39 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-04-03 08:10:39 +0200 |
commit | e3a9bfc89256e939ab1c1f56f6961b6ee15aa84a (patch) | |
tree | 5bf7d587f0a399f0ab6aed2fd7abf61d73c0363e /util/iseltime.c | |
parent | e6806f1d217e07f52759e4fa1c792d1fe02f0d50 (diff) |
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'util/iseltime.c')
-rw-r--r-- | util/iseltime.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/util/iseltime.c b/util/iseltime.c index ba0013d..3aa9f27 100644 --- a/util/iseltime.c +++ b/util/iseltime.c @@ -6,6 +6,7 @@ * 05/11/09 Andy Cress v1.0 - created * 07/23/10 Andy Cress v1.1 - always show System time also * 08/20/10 Andy Cress v1.2 - show/set RTC time also if Linux + * 03/16/17 Andy Cress 3.03 - show/set UTC offset also */ /*M* Copyright (c) 2013, Andy Cress @@ -72,16 +73,45 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define GET_SELTIME 0x48 #define SET_SELTIME 0x49 +#define GET_SELUTC 0x5C +#define SET_SELUTC 0x5D /* * Global variables */ -static char * progver = "3.02"; +static char * progver = "3.03"; static char * progname = "iseltime"; static char fdebug = 0; static char fset = 0; static uchar ipmi_maj = 0; static uchar ipmi_min = 0; +static int get_sel_utc(uchar *rdata, int rlen) +{ + uchar idata[4]; + uchar ccode; + int ret; + ret = ipmi_cmdraw(GET_SELUTC, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, + idata, 0, rdata, &rlen, &ccode, fdebug); + if (ret == 0 && ccode != 0) ret = ccode; + return(ret); +} /*end get_sel_utc()*/ + +static int set_sel_utc(short offset) +{ + uchar idata[4]; + uchar rdata[16]; + int rlen = 8; + int ret; + uchar ccode; + + idata[0] = (uchar)(offset & 0x00ff); + idata[1] = (uchar)((offset >> 8) & 0x00ff); + ret = ipmi_cmdraw(SET_SELUTC, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, + idata, 2, rdata, &rlen, &ccode, fdebug); + if (ret == 0 && ccode != 0) ret = ccode; + return(ret); +} /*end set_sel_utc()*/ + static int get_sel_time(uchar *rdata, int rlen) { uchar idata[4]; @@ -142,15 +172,15 @@ time_t utc2local(time_t t) void show_time(time_t etime, int doutc) { char buf[TIMESTR_SZ]; - int bufsz = TIMESTR_SZ; + int bufsz = TIMESTR_SZ; time_t t; - strcpy(buf,"00/00/00 00:00:00"); + strcpy(buf,"00/00/00 00:00:00"); if (doutc) t = utc2local(etime); else t = etime; - strftime(buf,bufsz, "%x %H:%M:%S", gmtime(&t)); /*or "%x %T"*/ + strftime(buf,bufsz, "%x %H:%M:%S", gmtime(&t)); /*or "%x %T"*/ printf("%s\n",buf); - return; + return; } #ifdef METACOMMAND @@ -168,6 +198,7 @@ main(int argc, char **argv) uchar devrec[20]; uchar timebuf[4]; time_t ltime1, ltime2, ltime3; + short offset; int c; #if defined (EFI) @@ -214,11 +245,19 @@ main(int argc, char **argv) #endif } + offset = 0; + rv = get_sel_utc((uchar *)&offset,2); + if (fdebug) printf("get_sel_utc: ret=%x offset=%d\n",rv,offset); + if (rv == 0) { + /* TODO: get system UTC offset */ + rv = set_sel_utc(offset); + printf("set_sel_utc(%d): ret=%x\n",offset,rv); + } rv = get_sel_time(&timebuf[0],4); if (rv != 0) { - printf("get_sel_time error: ret = %x\n",rv); - ipmi_close_(); - exit(1); + printf("get_sel_time error: ret = %x\n",rv); + ipmi_close_(); + exit(1); } time(<ime2); printf("Current System time: "); show_time(ltime2,1); |