static int ipmi_print_isol_info(struct ipmi_intf * intf) { struct isol_config_parameters params = {0}; if (ipmi_get_isol_info(intf, ¶ms)) return -1; if (csv_output) { printf("%s,", (params.enabled & 0x1)?"true": "false"); printf("%s,", val2str((params.privilege_level & 0xf), ipmi_privlvl_vals)); printf("%s,", val2str((params.bit_rate & 0xf), ipmi_bit_rate_vals)); } else { printf("Enabled : %s\n", (params.enabled & 0x1)?"true": "false"); printf("Privilege Level : %s\n", val2str((params.privilege_level & 0xf), ipmi_privlvl_vals)); printf("Bit Rate (kbps) : %s\n", val2str((params.bit_rate & 0xf), ipmi_bit_rate_vals)); } return 0; }
uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel) { struct ipmi_rs * rsp; struct ipmi_rq req; struct get_channel_info_rsp info; memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = IPMI_GET_CHANNEL_INFO; req.msg.data = &channel; req.msg.data_len = 1; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Get Channel Info command failed"); return -1; } if (rsp->ccode > 0) { if (rsp->ccode == 0xcc) return IPMI_CHANNEL_MEDIUM_RESERVED; lprintf(LOG_INFO, "Get Channel Info command failed: %s", val2str(rsp->ccode, completion_code_vals)); return IPMI_CHANNEL_MEDIUM_RESERVED; } memcpy(&info, rsp->data, sizeof(struct get_channel_info_rsp)); lprintf(LOG_DEBUG, "Channel type: %s", val2str(info.channel_medium, ipmi_channel_medium_vals)); return info.channel_medium; }
/** * Get the suffix used in file names */ const char* muxer_container_suffix(muxer_container_type_t mc, int video) { const char *str; if(video) str = val2str(mc, container_video_file_suffix); else str = val2str(mc, container_audio_file_suffix); if(!str) str = val2str(MC_UNKNOWN, container_video_file_suffix); return str; }
/* * Print set clause of update SQL statement */ static int print_set(MYSQL* _c, char* _b, int _l, db_key_t* _k, db_val_t* _v, int _n) { int i; int len = 0, ret; int l; if (!_c || !_b || !_l || !_k || !_v || !_n) { LOG(L_ERR, "print_set: Invalid parameter value\n"); return -1; } for(i = 0; i < _n; i++) { ret = snprintf(_b + len, _l - len, "%s=", _k[i]); if (ret < 0 || ret >= (_l - len)) goto error; len += ret; l = _l - len; val2str(_c, &(_v[i]), _b + len, &l); len += l; if (i != (_n - 1)) { if ((_l - len) >= 1) { *(_b + len++) = ','; } } } return len; error: LOG(L_ERR, "print_set: Error in snprintf\n"); return -1; }
char *sdp_uuid2msg(struct affix_tupla *message, uuid_t *uuid) { if (!uuid) return "uuid is NULL"; switch (uuid->type) { case SDP_DTD_UUID16: return val2str(message, uuid->value.uuid16Bit); case SDP_DTD_UUID32: return val2str(message, uuid->value.uuid32Bit); case SDP_DTD_UUID128: return "Error: This is uuid128"; default: return "Enum type of uuid_t not set."; } }
/* ** Make final adjustments in a tree. Fix open calls in tree 't', ** making them refer to their respective rules or raising appropriate ** errors (if not inside a grammar). Correct associativity of associative ** constructions (making them right associative). Assume that tree's ** ktable is at the top of the stack (for error messages). */ static void finalfix (lua_State *L, int postable, TTree *g, TTree *t) { tailcall: switch (t->tag) { case TGrammar: /* subgrammars were already fixed */ return; case TOpenCall: { if (g != NULL) /* inside a grammar? */ fixonecall(L, postable, g, t); else { /* open call outside grammar */ lua_rawgeti(L, -1, t->key); luaL_error(L, "rule '%s' used outside a grammar", val2str(L, -1)); } break; } case TSeq: case TChoice: correctassociativity(t); break; } switch (numsiblings[t->tag]) { case 1: /* finalfix(L, postable, g, sib1(t)); */ t = sib1(t); goto tailcall; case 2: finalfix(L, postable, g, sib1(t)); t = sib2(t); goto tailcall; /* finalfix(L, postable, g, sib2(t)); */ default: assert(numsiblings[t->tag] == 0); break; } }
/* * ipmi_isol_deactivate */ static int ipmi_isol_deactivate(struct ipmi_intf * intf) { struct ipmi_rs * rsp; struct ipmi_rq req; uint8_t data[6]; memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_ISOL; req.msg.cmd = ACTIVATE_ISOL; req.msg.data = data; req.msg.data_len = 5; memset(data, 0, 6); data[0] = 0x00; /* Deactivate */ data[1] = 0x00; data[2] = 0x00; data[3] = 0x00; data[5] = 0x00; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Error deactivating ISOL"); return -1; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Error deactivating ISOL: %s", val2str(rsp->ccode, completion_code_vals)); return -1; } /* response contain 4 additional bytes : 80 00 32 ff Don't know what to use them for yet... */ return 0; }
uint16_t ipmi_get_oem_id(struct ipmi_intf *intf) { /* Execute a Get Board ID command to determine the board */ struct ipmi_rs *rsp; struct ipmi_rq req; uint16_t oem_id; memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = 0x21; req.msg.data_len = 0; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Get Board ID command failed"); return 0; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Get Board ID command failed: %#x %s", rsp->ccode, val2str(rsp->ccode, completion_code_vals)); return 0; } oem_id = rsp->data[0] | (rsp->data[1] << 8); lprintf(LOG_DEBUG,"Board ID: %x", oem_id); return oem_id; }
/* KfwumGetStatus - Get (and prints) FWUM banks information * * *intf : IPMI interface * * returns 0 on success, otherwise (-1) */ int KfwumGetStatus(struct ipmi_intf * intf) { int rc = 0; struct ipmi_rs *rsp; struct ipmi_rq req; struct KfwumGetStatusResp *pGetStatus; unsigned char numBank; unsigned char counter; unsigned long firmLength; if (verbose) { printf(" Getting Status!\n"); } /* Retreive the number of bank */ rc = KfwumGetInfo(intf, 0, &numBank); for(counter = 0; (counter < numBank) && (rc == 0); counter ++) { /* Retreive the status of each bank */ memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_FIRMWARE; req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_STATUS; req.msg.data = &counter; req.msg.data_len = 1; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Error in FWUM Firmware Get Status Command."); rc = (-1); break; } else if (rsp->ccode) { lprintf(LOG_ERR, "FWUM Firmware Get Status returned %x", rsp->ccode); rc = (-1); break; } pGetStatus = (struct KfwumGetStatusResp *) rsp->data; printf("\nBank State %d : %s\n", counter, val2str(pGetStatus->bankState, bankStateValS)); if (!pGetStatus->bankState) { continue; } firmLength = pGetStatus->firmLengthMSB; firmLength = firmLength << 8; firmLength |= pGetStatus->firmLengthMid; firmLength = firmLength << 8; firmLength |= pGetStatus->firmLengthLSB; printf("Firmware Length : %ld bytes\n", firmLength); printf("Firmware Revision : %u.%u%u SDR %u\n", pGetStatus->firmRev1, pGetStatus->firmRev2 >> 4, pGetStatus->firmRev2 & 0x0f, pGetStatus->firmRev3); } printf("\n"); return rc; }
static int ipmi_tsol_send_keystroke(struct ipmi_intf * intf, char *buff, int length) { struct ipmi_rs * rsp; struct ipmi_rq req; unsigned char data[16]; static unsigned char keyseq = 0; memset(&req, 0, sizeof(struct ipmi_rq)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = IPMI_TSOL_CMD_SENDKEY; req.msg.data_len = length + 2; req.msg.data = data; memset(data, 0, sizeof(data)); data[0] = length + 1; memcpy(data + 1, buff, length); data[length + 1] = keyseq++; rsp = intf->sendrecv(intf, &req); if (verbose) { if (rsp == NULL) { lprintf(LOG_ERR, "Unable to send keystroke"); return -1; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Unable to send keystroke: %s", val2str(rsp->ccode, completion_code_vals)); return -1; } } return length; }
/* convert raw flags field to user-friendly string */ char *fmap_flags_to_string(uint16_t flags) { char *str = NULL; unsigned int i, total_size; str = malloc(1); str[0] = '\0'; total_size = 1; for (i = 0; i < sizeof(flags) * CHAR_BIT; i++) { if (!flags) break; if (flags & (1 << i)) { const char *tmp = val2str(1 << i, flag_lut); total_size += strlen(tmp); str = realloc(str, total_size); strcat(str, tmp); flags &= ~(1 << i); if (flags) { total_size++; str = realloc(str, total_size); strcat(str, ","); } } } return str; }
/* ** traverse grammar at index 'arg', pushing all its keys and patterns ** into the stack. Create a new table (before all pairs key-pattern) to ** collect all keys and their associated positions in the final tree ** (the "position table"). ** Return the number of rules and (in 'totalsize') the total size ** for the new tree. */ static int collectrules (lua_State *L, int arg, int *totalsize) { int n = 1; /* to count number of rules */ int postab = lua_gettop(L) + 1; /* index of position table */ int size; /* accumulator for total size */ lua_newtable(L); /* create position table */ getfirstrule(L, arg, postab); size = 2 + getsize(L, postab + 2); /* TGrammar + TRule + rule */ lua_pushnil(L); /* prepare to traverse grammar table */ while (lua_next(L, arg) != 0) { if (lua_tonumber(L, -2) == 1 || lua_equal(L, -2, postab + 1)) { /* initial rule? */ lua_pop(L, 1); /* remove value (keep key for lua_next) */ continue; } if (!testpattern(L, -1)) /* value is not a pattern? */ luaL_error(L, "rule '%s' is not a pattern", val2str(L, -2)); luaL_checkstack(L, LUA_MINSTACK, "grammar has too many rules"); lua_pushvalue(L, -2); /* push key (to insert into position table) */ lua_pushinteger(L, size); lua_settable(L, postab); size += 1 + getsize(L, -1); /* update size */ lua_pushvalue(L, -2); /* push key (for next lua_next) */ n++; } *totalsize = size + 1; /* TTrue to finish list of rules */ return n; }
int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf, unsigned char channel, unsigned char size) { struct ipmi_rs *rsp; struct ipmi_rq req; uint8_t msg_data[2]; memset(msg_data, 0, sizeof(msg_data)); /* channel =~ 0x0e => Currently running interface */ msg_data[0] = channel; msg_data[1] = size; memset(&req, 0, sizeof(req)); req.msg.netfn = 0x3E; /* Set Channel Buffer Length - OEM */ req.msg.cmd = 0x82; req.msg.data = msg_data; req.msg.data_len = 2; req.msg.lun = 0x00; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { printf("Cannot send large buffer command\n"); return(-1); } else if (rsp->ccode > 0) { printf("Invalid length for the selected interface (%s) %d\n", val2str(rsp->ccode, completion_code_vals), rsp->ccode); return(-1); } return 0; }
/* check if VITA 46.11 is supported */ uint8_t vita_discover(struct ipmi_intf *intf) { struct ipmi_rq req; struct ipmi_rs *rsp; unsigned char msg_data; int vita_avail = 0; memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; req.msg.cmd = VITA_GET_VSO_CAPABILITIES_CMD; req.msg.data = &msg_data; req.msg.data_len = 1; msg_data = GROUP_EXT_VITA; lprintf(LOG_INFO, "Running Get VSO Capabilities my_addr %#x, " "transit %#x, target %#x", intf->my_addr, intf->transit_addr, intf->target_addr); rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "No valid response received"); } else if (rsp->ccode == 0xC1) { lprintf(LOG_INFO, "Invalid completion code received: %s", val2str(rsp->ccode, completion_code_vals)); } else if (rsp->ccode == 0xCC) { lprintf(LOG_INFO, "Invalid data field received: %s", val2str(rsp->ccode, completion_code_vals)); } else if (rsp->ccode != 0) { lprintf(LOG_INFO, "Invalid completion code received: %s", val2str(rsp->ccode, completion_code_vals)); } else if (rsp->data_len < 5) { lprintf(LOG_INFO, "Invalid response length %d", rsp->data_len); } else if (rsp->data[0] != GROUP_EXT_VITA) { lprintf(LOG_INFO, "Invalid group extension %#x", rsp->data[0]); } else if ((rsp->data[3] & 0x03) != 0) { lprintf(LOG_INFO, "Unknown VSO Standard %d", (rsp->data[3] & 0x03)); } else if ((rsp->data[4] & 0x0F) != 1) { lprintf(LOG_INFO, "Unknown VSO Specification Revision %d.%d", (rsp->data[4] & 0x0F), (rsp->data[4] >> 4)); } else {
void lanplus_dump_open_session_response(const struct ipmi_rs * rsp) { if (verbose < 2) return; printf("%sOPEN SESSION RESPONSE\n", DUMP_PREFIX_INCOMING); printf("%s Message tag : 0x%02x\n", DUMP_PREFIX_INCOMING, rsp->payload.open_session_response.message_tag); printf("%s RMCP+ status : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.open_session_response.rakp_return_code, ipmi_rakp_return_codes)); printf("%s Maximum privilege level : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.open_session_response.max_priv_level, ipmi_priv_levels)); printf("%s Console Session ID : 0x%08lx\n", DUMP_PREFIX_INCOMING, (long)rsp->payload.open_session_response.console_id); /* only tag, status, privlvl, and console id are returned if error */ if (rsp->payload.open_session_response.rakp_return_code != IPMI_RAKP_STATUS_NO_ERRORS) return; printf("%s BMC Session ID : 0x%08lx\n", DUMP_PREFIX_INCOMING, (long)rsp->payload.open_session_response.bmc_id); printf("%s Negotiated authenticatin algorithm : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.open_session_response.auth_alg, ipmi_auth_algorithms)); printf("%s Negotiated integrity algorithm : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.open_session_response.integrity_alg, ipmi_integrity_algorithms)); printf("%s Negotiated encryption algorithm : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.open_session_response.crypt_alg, ipmi_encryption_algorithms)); printf("\n"); }
static int verifyerror (lua_State *L, int *passed, int npassed) { int i; for (i = npassed - 2; i >= 0; i--) { /* search for a repetition */ if (passed[i] == passed[npassed - 1]) { lua_rawgeti(L, -1, passed[i]); /* get rule's key */ return luaL_error(L, "rule '%s' may be left recursive", val2str(L, -1)); } } return luaL_error(L, "too many left calls in grammar"); }
/** * Convert a container type to a string */ const char* muxer_container_type2txt(muxer_container_type_t mc) { const char *str; str = val2str(mc, container_name); if(!str) return "unknown"; return str; }
// TODO: might actually put const char* into caid_t const char * descrambler_caid2name(uint16_t caid) { const char *s = val2str(caid, caidnametab); static char buf[20]; if(s != NULL) return s; snprintf(buf, sizeof(buf), "0x%x", caid); return buf; }
/* ipmi_kontron_next_boot_set - Select the next boot order on CP6012 * * @intf: ipmi interface * @id: fru id * * returns -1 on error * returns 1 if successful */ static int ipmi_kontron_nextboot_set(struct ipmi_intf * intf, int argc, char **argv) { struct ipmi_rs *rsp; struct ipmi_rq req; uint8_t msg_data[8]; int i; memset(msg_data, 0, sizeof(msg_data)); msg_data[0] = 0xb4; msg_data[1] = 0x90; msg_data[2] = 0x91; msg_data[3] = 0x8b; msg_data[4] = 0x9d; msg_data[5] = 0xFF; msg_data[6] = 0xFF; /* any */ for (i = 0; bootdev[i] != 0; i++) { if (strcmp(argv[0], bootdev[i]) == 0) { msg_data[5] = i; break; } } /* Invalid device selected? */ if (msg_data[5] == 0xFF) { printf("Unknown boot device: %s\n", argv[0]); return -1; } memset(&req, 0, sizeof(req)); req.msg.netfn = 0x3E; req.msg.cmd = 0x02; req.msg.data = msg_data; req.msg.data_len = 7; /* Set Lun temporary, necessary for this oem command */ req.msg.lun = 0x03; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { printf("Device not present (No Response)\n"); return(-1); } if (rsp->ccode > 0) { printf("Device not present (%s)\n", val2str(rsp->ccode, completion_code_vals)); return(-1); } return 0; }
static int parse(int number, char *str) { static int count = 0; static char *length_p = NULL; char *filename, *p; struct documents *docs; if (strncmp(str, "GET", 3)) return 0; for (p = str + 3; *p == ' '; p++) ; filename = p; p = strchr(p, ' '); *p = '\0'; if (!strcmp(filename, "/")) filename = "/index.html"; for (docs = documents; docs->filename; docs++) if (!strcmp(filename, docs->filename)) break; if (!docs->counterp) docs->counterp = strchr(docs->document, '#'); memset(docs->counterp, ' ', 5); p = val2str(count); memcpy(docs->counterp, p, strlen(p)); count++; if (!length_p) length_p = strchr(header, '#'); memset(length_p, ' ', 5); p = val2str(strlen(docs->document)); memcpy(length_p, p, strlen(p)); send_string(number, header); send_string(number, docs->document); return 1; }
/* ** Fix a TOpenCall into a TCall node, using table 'postable' to ** translate a key to its rule address in the tree. Raises an ** error if key does not exist. */ static void fixonecall (lua_State *L, int postable, TTree *g, TTree *t) { int n; lua_rawgeti(L, -1, t->key); /* get rule's name */ lua_gettable(L, postable); /* query name in position table */ n = lua_tonumber(L, -1); /* get (absolute) position */ lua_pop(L, 1); /* remove position */ if (n == 0) { /* no position? */ lua_rawgeti(L, -1, t->key); /* get rule's name again */ luaL_error(L, "rule '%s' undefined in given grammar", val2str(L, -1)); } t->tag = TCall; t->u.ps = n - (t - g); /* position relative to node */ assert(sib2(t)->tag == TRule); sib2(t)->key = t->key; }
static void verifygrammar (lua_State *L, TTree *grammar) { int passed[MAXRULES]; TTree *rule; /* check left-recursive rules */ for (rule = sib1(grammar); rule->tag == TRule; rule = sib2(rule)) { if (rule->key == 0) continue; /* unused rule */ verifyrule(L, sib1(rule), passed, 0, 0); } assert(rule->tag == TTrue); /* check infinite loops inside rules */ for (rule = sib1(grammar); rule->tag == TRule; rule = sib2(rule)) { if (rule->key == 0) continue; /* unused rule */ if (checkloops(sib1(rule))) { lua_rawgeti(L, -1, rule->key); /* get rule's key */ luaL_error(L, "empty loop in rule '%s'", val2str(L, -1)); } } assert(rule->tag == TTrue); }
/* * Print set clause of update SQL statement */ static int print_set(char* _b, int _l, db_key_t* _k, db_val_t* _v, int _n) { int i; int res = 0; int l; for(i = 0; i < _n; i++) { res += snprintf(_b + res, _l - res, "%s=", _k[i]); l = _l - res; val2str(&(_v[i]), _b + res, &l); res += l; if (i != (_n - 1)) { if ((_l - res) >= 1) { *(_b + res++) = ','; } } } return res; }
void lanplus_dump_rakp2_message(const struct ipmi_rs * rsp, uint8_t auth_alg) { int i; if (verbose < 2) return; printf("%sRAKP 2 MESSAGE\n", DUMP_PREFIX_INCOMING); printf("%s Message tag : 0x%02x\n", DUMP_PREFIX_INCOMING, rsp->payload.rakp2_message.message_tag); printf("%s RMCP+ status : %s\n", DUMP_PREFIX_INCOMING, val2str(rsp->payload.rakp2_message.rakp_return_code, ipmi_rakp_return_codes)); printf("%s Console Session ID : 0x%08lx\n", DUMP_PREFIX_INCOMING, (long)rsp->payload.rakp2_message.console_id); printf("%s BMC GUID : 0x", DUMP_PREFIX_INCOMING); for (i = 0; i < 16; ++i) printf("%02x", rsp->payload.rakp2_message.bmc_guid[i]); printf("\n"); switch(auth_alg) { case IPMI_AUTH_RAKP_NONE: printf("%s Key exchange auth code : none\n", DUMP_PREFIX_INCOMING); break; case IPMI_AUTH_RAKP_HMAC_SHA1: case IPMI_AUTH_RAKP_HMAC_MD5: case IPMI_AUTH_RAKP_HMAC_SHA256: printf("%s Key exchange auth code : ok\n", DUMP_PREFIX_INCOMING); break; default: printf("%s Key exchange auth code : invalid", DUMP_PREFIX_INCOMING); } printf("\n"); }
/* * Print where clause of SQL statement */ static int print_where(MYSQL* _c, char* _b, int _l, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n) { int i; int len = 0, ret; int l; if (!_c || !_b || !_l || !_k || !_v || !_n) { LOG(L_ERR, "print_where: Invalid parameter value\n"); return -1; } for(i = 0; i < _n; i++) { if (_v[i].nul) { ret = snprintf(_b + len, _l - len, "%s is ", _k[i]); if (ret < 0 || ret >= (_l - len)) goto error; len += ret; } else if (_o) { ret = snprintf(_b + len, _l - len, "%s%s", _k[i], _o[i]); if (ret < 0 || ret >= (_l - len)) goto error; len += ret; } else { ret = snprintf(_b + len, _l - len, "%s=", _k[i]); if (ret < 0 || ret >= (_l - len)) goto error; len += ret; } l = _l - len; val2str(_c, &(_v[i]), _b + len, &l); len += l; if (i == (_n - 1)) ret = snprintf(_b + len, _l - len, " "); else ret = snprintf(_b + len, _l - len, " AND "); if (ret < 0 || ret >= (_l - len)) goto error; len += ret; } return len; error: LOG(L_ERR, "print_where: Error in snprintf\n"); return -1; }
/* * Print list of values separated by comma */ static int print_values(char* _b, int _l, db_val_t* _v, int _n) { int i, res = 0, l; for(i = 0; i < _n; i++) { l = _l - res; /* LOG(L_ERR, "%d sizes l = _l - res %d = %d - %d\n", i, l,_l,res); */ if (val2str(_v + i, _b + res, &l) < 0) { LOG(L_ERR, "print_values(): Error converting value to string\n"); return 0; } res += l; if (i != (_n - 1)) { *(_b + res) = ','; res++; } } return res; }
static int ipmi_tsol_command(struct ipmi_intf * intf, char *recvip, int port, unsigned char cmd) { struct ipmi_rs *rsp; struct ipmi_rq req; unsigned char data[6]; unsigned ip1, ip2, ip3, ip4; if (sscanf(recvip, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != 4) { lprintf(LOG_ERR, "Invalid IP address: %s", recvip); return -1; } memset(&req, 0, sizeof(struct ipmi_rq)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = cmd; req.msg.data_len = 6; req.msg.data = data; memset(data, 0, sizeof(data)); data[0] = ip1; data[1] = ip2; data[2] = ip3; data[3] = ip4; data[4] = (port & 0xff00) >> 8; data[5] = (port & 0xff); rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { lprintf(LOG_ERR, "Unable to perform TSOL command"); return -1; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Unable to perform TSOL command: %s", val2str(rsp->ccode, completion_code_vals)); return -1; } return 0; }
/* * Print where clause of SQL statement */ static int print_where(char* _b, int _l, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n) { int i; int res = 0; int l; for(i = 0; i < _n; i++) { if (_o) { res += snprintf(_b + res, _l - res, "%s%s", _k[i], _o[i]); } else { res += snprintf(_b + res, _l - res, "%s=", _k[i]); } l = _l - res; val2str(&(_v[i]), _b + res, &l); res += l; if (i != (_n - 1)) { res += snprintf(_b + res, _l - res, " AND "); } } return res; }
static int __ipmi_sensor_set_threshold(struct ipmi_intf *intf, uint8_t num, uint8_t mask, uint8_t setting, uint8_t target, uint8_t lun) { struct ipmi_rs *rsp; rsp = ipmi_sensor_set_sensor_thresholds(intf, num, mask, setting, target, lun); if (rsp == NULL) { lprintf(LOG_ERR, "Error setting threshold"); return -1; } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Error setting threshold: %s", val2str(rsp->ccode, completion_code_vals)); return -1; } return 0; }
/* * Print list of values separated by comma */ static int print_values(MYSQL* _c, char* _b, int _l, db_val_t* _v, int _n) { int i, res = 0, l; if (!_c || !_b || !_l || !_v || !_n) { LOG(L_ERR, "print_values: Invalid parameter value\n"); return -1; } for(i = 0; i < _n; i++) { l = _l - res; if (val2str(_c, _v + i, _b + res, &l) < 0) { LOG(L_ERR, "print_values: Error while converting value to string\n"); return -1; } res += l; if (i != (_n - 1)) { *(_b + res) = ','; res++; } } return res; }