From: Robert W. <wrw...@us...> - 2006-12-11 18:50:13
|
Update of /cvsroot/linuxisns/iscsiClient/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17609/src Modified Files: config.c initiator.c target.c Log Message: add dynamic dd and dds support Index: config.c =================================================================== RCS file: /cvsroot/linuxisns/iscsiClient/src/config.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** config.c 11 Dec 2006 18:12:27 -0000 1.1 --- config.c 11 Dec 2006 18:50:04 -0000 1.2 *************** *** 145,148 **** --- 145,158 ---- break; + case '7': + fscanf (ifp, "%s", line); + strcpy (thisInit->DDAlias, line); + break; + + case '8': + fscanf (ifp, "%s", line); + strcpy (thisInit->DDSAlias, line); + break; + default: break; Index: initiator.c =================================================================== RCS file: /cvsroot/linuxisns/iscsiClient/src/initiator.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** initiator.c 11 Dec 2006 18:12:27 -0000 1.6 --- initiator.c 11 Dec 2006 18:50:04 -0000 1.7 *************** *** 287,294 **** char *ptr; char ipstring[100]; - FILE* OutputFile; - OutputFile = fopen ("Targets.txt", "w"); - pdu = (struct isns_hdr *)buffer; ptr = buffer + sizeof (ISNS_HDR) + 4 /* Error Code Length */; --- 287,291 ---- *************** *** 303,334 **** { case ISNS_ISCSI_NODE_ID: - fprintf (OutputFile, "iSCSI Target: %s", &p_attr->val); printf ("iSCSI Target: %s", &p_attr->val); break; case ISNS_ISCSI_ALIAS: - fprintf (OutputFile, ", \"%s\"",&p_attr->val); printf (", \"%s\"",&p_attr->val); break; case ISNS_PORTAL_IP: ipaddrchar(&p_attr->val, ipstring); - fprintf (OutputFile, ", %s",ipstring); printf (", %s",ipstring); break; case ISNS_PORTAL_PORT: ! p_attr->val.etype = ntohl (p_attr->val.etype); ! fprintf (OutputFile, ", %d\n", p_attr->val.etype & 0xFFFF); ! printf (", %d\n", p_attr->val.etype & 0xFFFF); break; ! case ISNS_ENTITY_ID: ! printf ("Entity ID : %s\n", &p_attr->val); ! strcpy (current->EntityID, (char*) (&(p_attr->val))); ! break; default: ! break; } ptr = (char *) ptr + p_attr->len + 8/* Size of tag and length fields*/; } - - fclose (OutputFile); } --- 300,330 ---- { case ISNS_ISCSI_NODE_ID: printf ("iSCSI Target: %s", &p_attr->val); break; + case ISNS_ISCSI_ALIAS: printf (", \"%s\"",&p_attr->val); break; + case ISNS_PORTAL_IP: ipaddrchar(&p_attr->val, ipstring); printf (", %s",ipstring); break; + case ISNS_PORTAL_PORT: ! p_attr->val.etype = ntohl (p_attr->val.etype); ! printf (", %d\n", p_attr->val.etype & 0xFFFF); break; ! ! case ISNS_ENTITY_ID: ! printf ("Entity ID : %s\n", &p_attr->val); ! strcpy (current->EntityID, (char*) (&(p_attr->val))); ! break; ! default: ! break; } ptr = (char *) ptr + p_attr->len + 8/* Size of tag and length fields*/; } } Index: target.c =================================================================== RCS file: /cvsroot/linuxisns/iscsiClient/src/target.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** target.c 11 Dec 2006 18:01:08 -0000 1.5 --- target.c 11 Dec 2006 18:50:04 -0000 1.6 *************** *** 189,193 **** /* Add the Entity ID */ - printf("EntityID is %s\n",input->EntityID); ISNSAppendAttr (&cmd, ISNS_ENTITY_ID, PAD4(strlen(input->EntityID)),input->EntityID,0); --- 189,192 ---- *************** *** 230,234 **** ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* We are adding a portal to our target's entity */ ISNSAppendAttr (&cmd, ISNS_ENTITY_ID, PAD4 (strlen (current->EntityID)), current->EntityID, 0); --- 229,233 ---- ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* We are adding a portal to our target's entity */ ISNSAppendAttr (&cmd, ISNS_ENTITY_ID, PAD4 (strlen (current->EntityID)), current->EntityID, 0); *************** *** 279,284 **** ISNSAppendAttr (&cmd, ISNS_DD_ID, 0, NULL, 0); ! /* The DD Symbolic Name is the Target ID */ ! ISNSAppendAttr (&cmd, ISNS_DD_SYM_NAME, PAD4 (strlen ((char*)current->iscsiID)), (char*)current->iscsiID, 0); if(0 == ISNSSendCmd2 (&cmd, buffer, sizeof (buffer))) --- 278,283 ---- ISNSAppendAttr (&cmd, ISNS_DD_ID, 0, NULL, 0); ! /* The DD Symbolic Name */ ! ISNSAppendAttr (&cmd, ISNS_DD_SYM_NAME, PAD4 (strlen ((char*)current->DDAlias)), (char*)current->DDAlias, 0); if(0 == ISNSSendCmd2 (&cmd, buffer, sizeof (buffer))) *************** *** 297,322 **** char sym[256]={0}; uint32_t status=0; ! int* pmember = &(current->DDSmember); ! printf ("Registering a DDS\n"); ! ISNSCreateHdr (ISNS_REG_DDS_REQ, &cmd, sizeof (cmd), ISNS_FLAG_REPLACE_REG); ! /* The source type is iSCSI node and the name is the name of the target */ ! ISNSAppendAttr (&cmd, ISNS_ISCSI_NODE_ID, PAD4 (strlen (current->iscsiID)), current->iscsiID, 0); ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* We do not request a particular DDS ID */ ! ISNSAppendAttr (&cmd, ISNS_DDS_ID, 0, NULL, 0); ! /* The DDS Symbolic Name is the Target ID */ ! ISNSAppendAttr (&cmd, ISNS_DDS_SYM_NAME, PAD4 (strlen ((char*)current->iscsiID)), (char*)current->iscsiID, 0); ! /* Turn the status to ON by default */ status = 1; ! ISNSAppendAttr (&cmd, ISNS_DDS_STATUS, 4, NULL, status); if (0 == ISNSSendCmd2 (&cmd, buffer, sizeof (buffer))) --- 296,321 ---- char sym[256]={0}; uint32_t status=0; ! int* pmember = &(current->DDSmember); ! printf ("Registering a DDS\n"); ! ISNSCreateHdr (ISNS_REG_DDS_REQ, &cmd, sizeof (cmd), ISNS_FLAG_REPLACE_REG); ! /* The source type is iSCSI node and the name is the name of the target */ ! ISNSAppendAttr (&cmd, ISNS_ISCSI_NODE_ID, PAD4 (strlen (current->iscsiID)), current->iscsiID, 0); ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* We do not request a particular DDS ID */ ! ISNSAppendAttr (&cmd, ISNS_DDS_ID, 0, NULL, 0); ! /* The DDS Symbolic Name */ ! ISNSAppendAttr (&cmd, ISNS_DDS_SYM_NAME, PAD4 (strlen ((char*)current->DDSAlias)), (char*)current->DDSAlias, 0); ! /* Turn the status to ON by default */ status = 1; ! ISNSAppendAttr (&cmd, ISNS_DDS_STATUS, 4, NULL, status); if (0 == ISNSSendCmd2 (&cmd, buffer, sizeof (buffer))) *************** *** 332,349 **** listelement* temp; char buffer[2048]; ! printf ("Adding DD to DDS\n"); ! ISNSCreateHdr (ISNS_REG_DDS_REQ, &cmd, sizeof (cmd),0); ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* The target's DDS ID is sent */ ! ISNSAppendAttr (&cmd, ISNS_DDS_ID, 4, NULL, current->DDSmember); ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* The target's DD is sent */ ! ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); ISNSSendCmd2 (&cmd, buffer, sizeof (buffer)); --- 331,349 ---- listelement* temp; char buffer[2048]; ! printf ("Adding DD to DDS\n"); ! ISNSCreateHdr (ISNS_REG_DDS_REQ, &cmd, sizeof (cmd),0); ! ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* The target's DDS ID is sent */ ! ISNSAppendAttr (&cmd, ISNS_DDS_ID, 4, NULL, current->DDSmember); ! /* Delimiter */ ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* The target's DD is sent */ ! ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); ISNSSendCmd2 (&cmd, buffer, sizeof (buffer)); *************** *** 358,363 **** printf ("Adding ISCSI to DD.\n"); ! /* Adding an iSCSI node to a DD is actually a DD Register Request without replacing the DD */ ! ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), 0); ISNSAppendAttr (&cmd, 0, 0, NULL, 0); --- 358,363 ---- printf ("Adding ISCSI to DD.\n"); ! /* Adding an iSCSI node to a DD is actually a DD Register Request without replacing the DD */ ! ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), 0); ISNSAppendAttr (&cmd, 0, 0, NULL, 0); *************** *** 369,373 **** printf ("DD ID> %d\n", current->DDmember); ! /* Insert as a key */ ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); --- 369,373 ---- printf ("DD ID> %d\n", current->DDmember); ! /* Insert as a key */ ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); *************** *** 375,382 **** ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* Add the target ID */ ! ISNSAppendAttr (&cmd, ISNS_DD_ISCSI_MEMBER, PAD4 (strlen (current->iscsiID)), current->iscsiID, 0); ! /* Send the command, do not parse the reply */ ISNSSendCmd2 (&cmd, buffer, sizeof (buffer)); } --- 375,382 ---- ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* Add the target ID */ ! ISNSAppendAttr (&cmd, ISNS_DD_ISCSI_MEMBER, PAD4 (strlen (current->iscsiID)), current->iscsiID, 0); ! /* Send the command, do not parse the reply */ ISNSSendCmd2 (&cmd, buffer, sizeof (buffer)); } *************** *** 392,396 **** printf ("Adding ISCSI to DD.\n"); /*ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), ISNS_FLAG_UPDATE_REG);*/ ! ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), 0); ISNSAppendAttr (&cmd, 0, 0, NULL, 0); --- 392,396 ---- printf ("Adding ISCSI to DD.\n"); /*ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), ISNS_FLAG_UPDATE_REG);*/ ! ISNSCreateHdr (ISNS_REG_DD_REQ, &cmd, sizeof (cmd), 0); ISNSAppendAttr (&cmd, 0, 0, NULL, 0); *************** *** 402,406 **** printf ("DD ID> %d \n", current->DDmember); ! /* Insert as a key */ ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); --- 402,406 ---- printf ("DD ID> %d \n", current->DDmember); ! /* Insert as a key */ ISNSAppendAttr (&cmd, ISNS_DD_ID, 4, NULL, current->DDmember); *************** *** 408,412 **** ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* Add the initiator ID */ ISNSAppendAttr (&cmd, ISNS_DD_ISCSI_MEMBER, PAD4 (strlen (current->listPtr->InitiatorName)), current->listPtr->InitiatorName, 0); --- 408,412 ---- ISNSAppendAttr (&cmd, 0, 0, NULL, 0); ! /* Add the initiator ID */ ISNSAppendAttr (&cmd, ISNS_DD_ISCSI_MEMBER, PAD4 (strlen (current->listPtr->InitiatorName)), current->listPtr->InitiatorName, 0); *************** *** 423,427 **** char *ptr; ! printf ("Parsing the query\n"); pdu = (struct isns_hdr *)buffer; --- 423,427 ---- char *ptr; ! printf ("Parsing the query\n"); pdu = (struct isns_hdr *)buffer; *************** *** 437,482 **** case ISNS_DD_ID: p_attr->val.etype = htonl (p_attr->val.etype); ! /* Assign the DD ID */ ! current->DDmember = p_attr->val.etype; ! /* Just to show what was returned */ printf ("DD ID : %d\n", p_attr->val.etype); break; ! case ISNS_DD_SYM_NAME: ! memset (current->DDAlias, (int) NULL, 256); ! /* Just to show what was returned */ ! printf ("DD Alias = %s\n", &p_attr->val); ! /* Assign the DD Symbolic name */ ! /* This assignment could just as well have used the Target ID from the config file ! But I wanted to check what the server was returning */ ! strcpy (current->DDAlias, (char*) (&p_attr->val)); ! break; case ISNS_DD_ISCSI_MEMBER: ! /* Just to show what was returned */ ! printf ("DD iSCSI MEMBER : %s\n", &p_attr->val); ! /* Note this does not make any assignments */ break; case ISNS_DDS_ID: p_attr->val.etype = htonl (p_attr->val.etype); ! /* Assign the DDS ID */ ! current->DDSmember = p_attr->val.etype; ! /* Just to show what was returned */ ! printf ("DDS ID : %d\n", p_attr->val.etype); ! break; ! case ISNS_DDS_SYM_NAME: ! memset (current->DDSAlias, (int) NULL, 256); ! printf ("DDS Alias : %s\n", &p_attr->val); ! /* Assign the DDS Symbolic name */ ! /* This assignment could just as well have used the Target ID from the config file ! But I wanted to check what the server was returning */ ! strcpy (current->DDSAlias, (char*) (&p_attr->val)); ! break; ! case ISNS_ENTITY_ID: ! /* There should be no reason to do this but being thorough is good */ ! memset (current->EntityID, (int) NULL, 256); ! /* Just to show what was returned */ ! printf ("Entity ID : %s\n", &p_attr->val); ! /* Assign the entity ID to what is returned from the server */ ! strcpy (current->EntityID, (char*) (&(p_attr->val))); ! break; default: break; --- 437,487 ---- case ISNS_DD_ID: p_attr->val.etype = htonl (p_attr->val.etype); ! /* Assign the DD ID */ ! current->DDmember = p_attr->val.etype; ! /* Just to show what was returned */ printf ("DD ID : %d\n", p_attr->val.etype); break; ! ! case ISNS_DD_SYM_NAME: ! memset (current->DDAlias, (int) NULL, 256); ! /* Just to show what was returned */ ! printf ("DD Alias = %s\n", &p_attr->val); ! /* Assign the DD Symbolic name */ ! /* This assignment could just as well have used the Target ID from the config file ! But I wanted to check what the server was returning */ ! strcpy (current->DDAlias, (char*) (&p_attr->val)); ! break; ! case ISNS_DD_ISCSI_MEMBER: ! /* Just to show what was returned */ ! printf ("DD iSCSI MEMBER : %s\n", &p_attr->val); ! /* Note this does not make any assignments */ break; + case ISNS_DDS_ID: p_attr->val.etype = htonl (p_attr->val.etype); ! /* Assign the DDS ID */ ! current->DDSmember = p_attr->val.etype; ! /* Just to show what was returned */ ! printf ("DDS ID : %d\n", p_attr->val.etype); ! break; ! ! case ISNS_DDS_SYM_NAME: ! memset (current->DDSAlias, (int) NULL, 256); ! printf ("DDS Alias : %s\n", &p_attr->val); ! /* Assign the DDS Symbolic name */ ! /* This assignment could just as well have used the Target ID from the config file ! But I wanted to check what the server was returning */ ! strcpy (current->DDSAlias, (char*) (&p_attr->val)); ! break; ! ! case ISNS_ENTITY_ID: ! memset (current->EntityID, (int) NULL, 256); ! /* Just to show what was returned */ ! printf ("Entity ID : %s\n", &p_attr->val); ! /* Assign the entity ID to what is returned from the server */ ! strcpy (current->EntityID, (char*) (&(p_attr->val))); ! break; ! default: break; |