diff options
Diffstat (limited to 'util/ipmilan.c')
-rw-r--r-- | util/ipmilan.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/util/ipmilan.c b/util/ipmilan.c index 64b6425..b852f3a 100644 --- a/util/ipmilan.c +++ b/util/ipmilan.c @@ -216,13 +216,13 @@ extern char * get_iana_str(int mfg); /*subs.c*/ extern FILE *fperr; /*defined in ipmicmd.c, usu stderr */ extern FILE *fpdbg; /*defined in ipmicmd.c, usu stdout */ extern int gshutdown; /* from ipmicmd.c */ -extern char gnodename[]; /* from ipmicmd.c */ -extern char *gnode; /* from ipmicmd.c */ -extern char *guser; /* from ipmicmd.c */ -extern char *gpswd; /* from ipmicmd.c */ extern int fauth_type_set; /* from ipmicmd.c */ -extern int gauth_type; /* from ipmicmd.c */ -extern int gpriv_level; /* from ipmicmd.c */ +extern LAN_OPT lanp; /* from ipmicmd.c */ +//extern char *gnode; /* from ipmicmd.c */ +//extern char *guser; /* from ipmicmd.c */ +//extern char *gpswd; /* from ipmicmd.c */ +//extern int gauth_type; /* from ipmicmd.c */ +//extern int gpriv_level; /* from ipmicmd.c */ extern ipmi_cmd_t ipmi_cmds[NCMDS]; static IPMI_HDR ipmi_hdr = { 0x06, 0, 0xFF, 0x07, 0x00, 0, 0, @@ -294,6 +294,7 @@ typedef struct { // static uchar fMsgAuth = 1; static uchar auth_type = AUTHTYPE_INIT; /*initial value, not set*/ static char nodename[SZGNODE+1] = ""; + static char gnodename[SZGNODE+1] = ""; /*nodename returned after connection*/ #if defined(AI_NUMERICSERV) static int my_ai_flags = AI_NUMERICSERV; /*0x0400 Dont use name resolution NEW*/ // static int my_ai_flags = AI_NUMERICHOST; /*0x0004 Dont use name resolution*/ @@ -579,11 +580,11 @@ int open_sockfd(char *node, SockType *sfd, SOCKADDR_T *daddr, * and) try the next address. */ for (res0 = res; res0 != NULL; res0 = res0->ai_next) { + /* valid protocols are IPPROTO_UDP, IPPROTO_IPV6 */ + if (res0->ai_protocol == IPPROTO_TCP) continue; /*IPMI != TCP*/ s = socket(res0->ai_family, res0->ai_socktype, res0->ai_protocol); if (s == SockInvalid) continue; else _sockfd = s; - /* valid protocols are IPPROTO_UDP, IPPROTO_IPV6 */ - if (res0->ai_protocol == IPPROTO_TCP) continue; /*IPMI != TCP*/ pconn->connect_state = CONN_STATE_SOCK; rv = connect(_sockfd, res0->ai_addr, res0->ai_addrlen); if (fdebuglan) printf("socket(%d,%d,%d), connect(%d) rv = %d\n", @@ -737,12 +738,12 @@ static void h2net(uint h, uchar *net, int n) return; } -static void net2h(uint *h, uchar *net, int n) +static void net2h(uint32 *h, uchar *net, int n) { - uint v; + uint32 v; v = (net[1] << 8) | net[0]; if (n == 2) { *h = v; return; } - v |= (net[3] << 24) | (net[2] << 16); + v |= (uint32)(net[3] << 24) | (net[2] << 16); *h = v; return; } @@ -1065,7 +1066,7 @@ static int _send_lan_cmd(SockType s, uchar *pcmd, int scmd, uchar *presp, memcpy(&pdata[5],&sess_id_tmp,4); if (fdebuglan > 2) dbglog("auth_type=%x/%x fdoauth=%d hlen=%d seq_num=%x\n", /*SOL*/ - phdr->auth_type,gauth_type,fdoauth,hlen,phdr->seq_num); + phdr->auth_type,lanp.auth_type,fdoauth,hlen,phdr->seq_num); if (fdoauth) { psessid = (uchar *)&sess_id_tmp; do_hash(phdr->password, psessid, &cbuf[hlen],msglen, @@ -1434,7 +1435,7 @@ static int ipmilan_open_session(SockType sfd, struct sockaddr *destaddr, else pconn->fMsgAuth = 0; /*no auth support*/ iauthcap = rbuf[2] & 0x3f; if (fauth_type_set) { - iauthtype = (uchar)gauth_type; // set by user + iauthtype = (uchar)lanp.auth_type; // set by user auth_type = iauthtype; } else { iauthtype = AUTHTYPE_INIT; /*initial value, not set*/ @@ -1769,8 +1770,8 @@ int ipmi_open_lan(char *node, char *user, char *pswd, int fdebugcmd) } { - auth_type = (uchar)gauth_type; - priv_level = (uchar)gpriv_level; + auth_type = (uchar)lanp.auth_type; + priv_level = (uchar)lanp.priv; username = user; authcode = pswd; authcode_len = (pswd) ? strlen_(authcode) : 0; @@ -1834,6 +1835,8 @@ int ipmi_close_lan(char *node) int rv = 0; /* could match node via pconn = find_conn(node); */ + if (fdebuglan) fprintf(fpdbg,"ipmi_close_lan(%s) entry, sockfd=%d\n", + node,pconn->sockfd); if (!nodeislocal(node)) { /* ipmilan, need to close & cleanup */ if (pconn->sockfd != 0) { /* socket is open */ if (gshutdown) pconn->session_id = 0; @@ -1856,6 +1859,8 @@ int ipmi_close_lan(char *node) signal(SIGALRM,SIG_DFL); #endif } /* endif */ + if (fdebuglan) fprintf(fpdbg,"ipmi_close_lan(%s) rv=%d sockfd=%d\n", + node,rv,pconn->sockfd); return (rv); } @@ -1899,7 +1904,7 @@ int ipmicmd_lan(char *node, if (pconn->sockfd == 0) { /* closed, do re-open */ if (fdebugcmd) fprintf(fpdbg,"sockfd==0, node %s needs re-open\n",node); - rv = ipmi_open_lan(gnode, guser, gpswd, fdebugcmd); + rv = ipmi_open_lan(lanp.node, lanp.user, lanp.pswd, fdebugcmd); if (rv != 0) goto EXIT; } if (fdebugcmd) { @@ -2057,7 +2062,7 @@ void lan_get_sol_data(uchar fEnc, uchar seed_cnt, uint32 *seed) sol_seed_cnt = seed_cnt; pconn->start_out_seq = ipmi_hdr.seq_num; sol_snd_seq = (uchar)pconn->start_out_seq; - sol15_cipherinit(sol_seed_cnt, gpswd, pconn->start_out_seq); + sol15_cipherinit(sol_seed_cnt, lanp.pswd, pconn->start_out_seq); *seed = g_Seed[sol_seed_cnt]; if (fdebuglan > 2) dbglog("lan_get_sol_data: %02x %02x %02x\n", /*SOL*/ @@ -2084,7 +2089,7 @@ void lan_set_sol_data(uchar fenc, uchar auth, uchar seed_cnt, if (seed_cnt != sol_seed_cnt && (seed_cnt < 16)) { /* if seed count changed, re-init the cipher. */ sol_seed_cnt = seed_cnt; - sol15_cipherinit(sol_seed_cnt, gpswd, pconn->start_out_seq); + sol15_cipherinit(sol_seed_cnt, lanp.pswd, pconn->start_out_seq); } } @@ -2150,7 +2155,7 @@ int lan_send_sol( uchar *buffer, int len, SOL_RSP_PKT *rsp) if (fdebuglan > 2) { /*SOL*/ dbg_dump("lan_send_sol input", buffer,len,1); dbglog("auth_type=%x/%x fdoauth=%d hlen=%d seq_num=%x enc=%d\n", - phdr->auth_type,gauth_type,fdoauth,hlen,phdr->seq_num, + phdr->auth_type,lanp.auth_type,fdoauth,hlen,phdr->seq_num, sol_Encryption); dbg_dump("send_sol buf", pdata,msglen,1); } |