Lines Matching refs:isns
35 #include "isns.h"
49 uint32_t isns_id = 0; /* isns ID counter */
63 * data the source (from iSNS address field)
102 get_isns_target_info(isns_t * isns, uint8_t * TargetName)
122 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name);
137 DEB(10,("iSNS Attribute Query failed, rc = %d", retval));
143 DEB(10,("iSNS Attribute Query returned nothing"));
148 DEB(10,("iSNS Query returned bad type (tag = %d, length = %d)",
164 DEB(10,("iSNS Query returned no or invalid name (tag = %d, "
173 DEB(10,("iSNS Query returned no or invalid node type (tag = %d, "
180 DEB(10,("iSNS Query returned bad type (type=%x, should be 1)", u32));
188 DEB(10,("iSNS Query returned invalid alias (tag=%d, length=%d)",
205 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name);
218 DEB(10,("iSNS Attribute Query failed, rc = %d", retval));
224 DEB(10,("iSNS Attribute Query returned nothing"));
229 DEB(10,("iSNS Query2 returned bad name (tag = %d, length = %d)",
246 DEB(10,("iSNS Query2 returned no or invalid name (tag=%d, "
255 DEB(10,("iSNS Query returned no or invalid address (tag=%d, "
265 DEB(10,("iSNS Query returned no or invalid port (tag=%d, "
272 DEB(10,("iSNS Query returned invalid port (flags=%x, "
282 DEB(10,("iSNS Query returned no or invalid group tag (tag=%d, "
299 isns->entry.sid.id)) == NULL) {
317 * Support routine to deregister the initiator from the iSNS server
325 deregister_isns_server(isns_t * isns)
333 * Create transaction for deregistering with iSNS server
342 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name);
344 isns_add_string(t, isnst_EID, (char *)isns->reg_entity_id);
345 isns_add_tlv(t, isnst_PortalIPAddr, (uint32_t)sizeof(isns->reg_ip_addr),
346 isns->reg_ip_addr);
347 isns_add_tlv(t, isnst_PortalPort, (uint32_t)sizeof(isns->reg_ip_port),
348 &isns->reg_ip_port);
349 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name);
368 register_isns_server(isns_t * isns)
382 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name); /*tag=32 */
384 isns_add_string(t, isnst_EID, (char *)isns->reg_entity_id);
387 isns_add_tlv(t, isnst_PortalIPAddr, (uint32_t)sizeof(isns->reg_ip_addr),
388 isns->reg_ip_addr);
389 isns_add_tlv(t, isnst_PortalPort, (uint32_t)sizeof(isns->reg_ip_port),
390 &isns->reg_ip_port);
391 isns_add_string(t, isnst_iSCSIName, (char *)isns->reg_iscsi_name); /*tag=32 */
417 get_registration_info(isns_t * isns)
422 strlcpy((char *)isns->reg_iscsi_name, (char *)node_name.InitiatorName,
423 sizeof(isns->reg_iscsi_name));
424 strlcpy((char *)isns->reg_entity_id, (char *)node_name.InitiatorAlias,
425 sizeof(isns->reg_entity_id));
429 if (getsockname(isns->sock, (struct sockaddr *)(void *)&sa, &n)) {
438 uint32_t *u32 = (uint32_t *)(void *)isns->reg_ip_addr;
443 isns->reg_ip_port = htons(si->sin_port);
452 memcpy(isns->reg_ip_addr, &si->sin6_addr,
453 sizeof(isns->reg_ip_addr));
454 isns->reg_ip_port = htons(si->sin6_port);
470 * Parameters: The descriptor for the iSNS server to query
476 iscsi_isns_serverconn(isns_t * isns)
485 * Initialize the iSNS library if it needs it
490 /*Couldn't initialize the iSNS library */
498 * Find the server address from the iSNS server list entry,
499 * and try to connect to the iSNS server
502 snprintf(port, sizeof(port), "%d", (isns->port) ? isns->port : ISCSI_DEFAULT_ISNS_PORT);
508 retval = getaddrinfo((char *)isns->address, port, &hints, &ai);
547 isns->sock = sock;
549 if ((retval = get_registration_info(isns)) != 0) {
553 deregister_isns_server(isns);
555 return register_isns_server(isns);
561 * Support routine to query the specified iSNS server for all targets
564 iSNS server to query
571 update_isns_server_info(isns_t * isns)
584 DEB(9, ("update_isns_server_info for iSNS %s", isns->address));
586 if (isns->sock < 0) {
587 if ((status = iscsi_isns_serverconn(isns)) != 0) {
588 /*We couldn't connect to the iSNS server */
631 DEB(10,("iSNS GetNextDev returned no or invalid name (tag=%d, "
640 DEB(10,("iSNS GetDevNext did not return node type"));
646 DEB(10,("iSNS GetDevNext did not return node type (past delim)"));
651 DEB(10,("iSNS Query returned no or invalid node type (tag=%d, "
660 get_isns_target_info(isns, TargetName);
673 * Create an isns structure and initialize it.
676 * name The iSNS server name
678 * Returns: Pointer to isns structure, NULL if allocation failed.
684 isns_t *isns;
686 DEB(9, ("Create iSNS %s", req->address));
688 if ((isns = calloc(1, sizeof(*isns))) == NULL)
694 isns->entry.sid.id = isns_id;
695 strlcpy((char *)isns->entry.sid.name, (char *)req->name, sizeof(isns->entry.sid.name));
696 strlcpy((char *)isns->address, (char *)req->address, sizeof(isns->address));
697 isns->port = req->port;
698 isns->sock = -1;
700 return isns;
706 * Adds an iSNS server to the server list.
707 * This command will add the address of an iSNS server to the list
708 * of iSNS servers that the discovery daemon queries to discover targets.
709 * The daemon will then register itself with the iSNS server,
710 * and query the iSNS server for the list of targets.
712 * The response contains the ID of the iSNS server.
719 * server_id = Unique ID for the iSNS server
728 isns_t *isns;
745 * First, allocate the isns server structure to put on the list
748 isns = create_isns(req);
749 if (isns == NULL) {
755 TAILQ_INSERT_TAIL(&list[ISNS_LIST].list, &isns->entry, link);
757 res->server_id = isns->entry.sid.id;
760 isns->entry.sid.id, isns->address));
763 * Now try to connect to the iSNS server...
766 update_isns_server_info(isns);
772 * Returns the address of the iSNS server with the specified ID
777 * The response parameter contains the iSNS server address as a
787 isns_t *isns;
790 isns = find_isns(preq);
791 if (isns == NULL) {
804 strlcpy((char *)res->address, (char *)isns->address,
806 res->port = isns->port;
807 res->server_id = isns->entry.sid;
822 * Query the specified iSNS servers for the list of targets.
834 isns_t *isns;
838 isns = find_isns_id(id);
839 if (isns == NULL)
848 rc = update_isns_server_info(isns);
870 * Removed an iSNS server.
883 isns_t *isns;
886 isns = find_isns(preq);
887 if (isns == NULL)
890 /*Deregister with the iSNS server. */
892 if (isns->sock >= 0) {
893 deregister_isns_server(isns);
894 close(isns->sock);
897 TAILQ_REMOVE(&list[ISNS_LIST].list, &isns->entry, link);
900 id = isns->entry.sid.id;
901 free(isns);
914 Deregister all isns servers on daemon termination