NWCCODE ncp_ns_search_entry_set(NWCONN_HANDLE conn, unsigned int search_attributes, const char* pattern, unsigned int datastream, u_int32_t rim, int* more, size_t *itemcount, struct ncp_search_seq* seq, void* buffer, size_t* size) { size_t slen; NWCCODE result; ncp_init_request(conn); ncp_add_byte(conn, 0x14); ncp_add_byte(conn, seq->name_space); ncp_add_byte(conn, datastream); ncp_add_word_lh(conn, search_attributes); ncp_add_dword_lh(conn, rim); ncp_add_word_lh(conn, *itemcount); ncp_add_mem(conn, &seq->s, 9); slen = pattern ? strlen(pattern) : 0; ncp_add_byte(conn, slen); if (slen) ncp_add_mem(conn, pattern, slen); result = ncp_request(conn, 0x57); if (result) { ncp_unlock_conn(conn); return result; } if (conn->ncp_reply_size < 9 + 1 + 2) { ncp_unlock_conn(conn); return NWE_INVALID_NCP_PACKET_LENGTH; } memcpy(&seq->s, ncp_reply_data(conn, 0), 9); *more = ncp_reply_byte(conn, 9); *itemcount = ncp_reply_word_lh(conn, 10); slen = conn->ncp_reply_size - 9 - 1 - 2; if (slen > *size) { slen = *size; result = NWE_BUFFER_OVERFLOW; } else *size = slen; memcpy(buffer, ncp_reply_data(conn, 12), slen); ncp_unlock_conn(conn); return result; }
/* * target is a 8-byte buffer */ int ncp_get_encryption_key(NWCONN_HANDLE cH, char *target) { int error; DECLARE_RQ; ncp_init_request_s(conn, 23); error = ncp_request(cH, 23, conn); if (error) return error; if (conn->rpsize < 8) return EACCES; memcpy(target, ncp_reply_data(conn, 0), 8); return 0; }
int ncp_get_bindery_object_name(NWCONN_HANDLE connid, u_int32_t object_id, struct ncp_bindery_object *target) { int error; DECLARE_RQ; ncp_init_request_s(conn, 54); ncp_add_dword_hl(conn, object_id); if ((error = ncp_request(connid, 23, conn)) != 0) return error; target->object_id = ncp_reply_dword_hl(conn, 0); target->object_type = ncp_reply_word_hl(conn, 4); memcpy(target->object_name, ncp_reply_data(conn, 6), 48); return 0; }
int ncp_read_property_value(NWCONN_HANDLE connid, int object_type, const char *object_name, int segment, const char *prop_name, struct nw_property *target) { int error; struct ncp_buf conn; ncp_init_request_s(&conn, 61); ncp_add_word_hl(&conn, object_type); ncp_add_pstring(&conn, object_name); ncp_add_byte(&conn, segment); ncp_add_pstring(&conn, prop_name); if ((error = ncp_request(connid,23,&conn)) != 0) { return error; } memcpy(&(target->value), ncp_reply_data(&conn, 0), 128); target->more_flag = ncp_reply_byte(&conn, 128); target->property_flag = ncp_reply_byte(&conn, 129); return 0; }
int ncp_scan_bindery_object(NWCONN_HANDLE connid, u_int32_t last_id, u_int16_t object_type, const char *search_string, struct ncp_bindery_object *target) { int error; DECLARE_RQ; ncp_init_request_s(conn, 55); ncp_add_dword_hl(conn, last_id); ncp_add_word_hl(conn, object_type); ncp_add_pstring(conn, search_string); error = ncp_request(connid, 23, conn); if (error) return error; target->object_id = ncp_reply_dword_hl(conn, 0); target->object_type = ncp_reply_word_hl(conn, 4); memcpy(target->object_name, ncp_reply_data(conn, 6),NCP_BINDERY_NAME_LEN); target->object_flags = ncp_reply_byte(conn, 54); target->object_security = ncp_reply_byte(conn, 55); target->object_has_prop = ncp_reply_byte(conn, 56); return 0; }
int ncp_get_bindery_object_id(NWCONN_HANDLE connid, u_int16_t object_type, const char *object_name, struct ncp_bindery_object *target) { int error; DECLARE_RQ; ncp_init_request_s(conn, 53); ncp_add_word_hl(conn, object_type); ncp_add_pstring(conn, object_name); if ((error = ncp_request(connid, 23, conn)) != 0) { return error; } if (conn->rpsize < 54) { return EACCES; } target->object_id = ncp_reply_dword_hl(conn, 0); target->object_type = ncp_reply_word_hl(conn, 4); memcpy(target->object_name, ncp_reply_data(conn, 6), 48); return 0; }
u_int32_t ncp_reply_dword_lh(struct ncp_buf *conn, int offset) { return getdle(ncp_reply_data(conn, offset), 0); }
u_int16_t ncp_reply_word_lh(struct ncp_buf *conn, int offset) { return getwle(ncp_reply_data(conn, offset), 0); }