From: Robert W. <wrw...@us...> - 2006-12-15 18:17:23
|
Update of /cvsroot/linuxisns/isnsNT/isnsserver/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11562/src Modified Files: iSNSList.c iSNSdb.c iSNSdereg.c iSNSesi.c iSNSparse.c iSNSquery.c iSNSreg.c Log Message: Adding support for Portal Groups Index: iSNSquery.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSquery.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** iSNSquery.c 15 Dec 2006 01:13:29 -0000 1.10 --- iSNSquery.c 15 Dec 2006 18:17:19 -0000 1.11 *************** *** 240,244 **** SOIP_Portal *p_portal; SOIP_Ifcp *p_port; ! SOIP_DB_Portal db_portal; ISNS_Key read_key; int rval; --- 240,244 ---- SOIP_Portal *p_portal; SOIP_Ifcp *p_port; ! SOIP_Portal_Key db_portal; ISNS_Key read_key; int rval; *************** *** 300,308 **** while (entityKeyFlag != -1) { /* Entity ID found in key */ key = (ISNS_Key *)(key_indx[entityKeyFlag]); /* Fetch entity from hash */ ! if (ISNS_NO_ERR != SNSdbFetchEntity ((char *)&key->val, &p_entity, &entry)) { return (ISNS_INVALID_QUERY_ERR); --- 300,313 ---- while (entityKeyFlag != -1) { + SOIP_Entity_Id db_entity_id; + /* Entity ID found in key */ key = (ISNS_Key *)(key_indx[entityKeyFlag]); + memset(db_entity_id.id,0,sizeof(SOIP_Entity_Id)); + memcpy(db_entity_id.id,&key->val,key->len); + /* Fetch entity from hash */ ! if (ISNS_NO_ERR != SNSdbFetchEntity (db_entity_id.id, &p_entity, &entry)) { return (ISNS_INVALID_QUERY_ERR); *************** *** 376,380 **** read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 381,385 ---- read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 986,990 **** SOIP_Entity *p_entity; SOIP_Ifcp *p_port; ! SOIP_DB_Portal db_portal; int entityKeyFlag; int portalIpKeyFlag; --- 991,995 ---- SOIP_Entity *p_entity; SOIP_Ifcp *p_port; ! SOIP_Portal_Key db_portal; int entityKeyFlag; int portalIpKeyFlag; *************** *** 1057,1061 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1062,1066 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1096,1100 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1101,1105 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1124,1128 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1129,1133 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1237,1241 **** key2.tag = PORTAL_ID_KEY; ! key2.len = sizeof (SOIP_DB_Portal); while (SNSdbGetNextOfKey (&key2) == SUCCESS) --- 1242,1246 ---- key2.tag = PORTAL_ID_KEY; ! key2.len = sizeof (SOIP_Portal_Key); while (SNSdbGetNextOfKey (&key2) == SUCCESS) *************** *** 1243,1247 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&key2.val,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1248,1252 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&key2.val,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1280,1284 **** SOIP_Entity *p_entity; SOIP_Portal *p_portal; ! SOIP_DB_Portal db_portal; int entityKeyFlag; int portKeyFlag; --- 1285,1289 ---- SOIP_Entity *p_entity; SOIP_Portal *p_portal; ! SOIP_Portal_Key db_portal; int entityKeyFlag; int portKeyFlag; *************** *** 1457,1461 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1462,1466 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1720,1724 **** else if (portalPortKeyIndex != -1 || portalIpKeyIndex != -1) { ! SOIP_DB_Portal db_portal; SOIP_Portal * p_portal; --- 1725,1729 ---- else if (portalPortKeyIndex != -1 || portalIpKeyIndex != -1) { ! SOIP_Portal_Key db_portal; SOIP_Portal * p_portal; *************** *** 1742,1746 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry); if (rval != SUCCESS) --- 1747,1751 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry); if (rval != SUCCESS) *************** *** 2199,2203 **** { SOIP_Portal * p_portal; ! SOIP_DB_Portal db_portal; memset(&db_portal, 0, sizeof(db_portal)); --- 2204,2208 ---- { SOIP_Portal * p_portal; ! SOIP_Portal_Key db_portal; memset(&db_portal, 0, sizeof(db_portal)); *************** *** 2228,2232 **** } memcpy (&qkey.val, ptr, sizeof(db_portal)); ! qkey.len = sizeof(SOIP_DB_Portal); } } --- 2233,2237 ---- } memcpy (&qkey.val, ptr, sizeof(db_portal)); ! qkey.len = sizeof(SOIP_Portal_Key); } } *************** *** 2241,2245 **** qkey.len += key->len; ! memcpy(&qkey.val, (char *)&db_portal, sizeof (SOIP_DB_Portal)); } --- 2246,2250 ---- qkey.len += key->len; ! memcpy(&qkey.val, (char *)&db_portal, sizeof (SOIP_Portal_Key)); } *************** *** 2813,2817 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry5); if (rval != SUCCESS ) --- 2818,2822 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry5); if (rval != SUCCESS ) *************** *** 2823,2827 **** { q_attr = (ISNS_Attr *) attr_indx[jj]; ! DEBUG_1 (isns_query_debug &1, process attribute for portal object (%s),isnsTagText(q_attr->tag)); switch ( q_attr->tag ) --- 2828,2832 ---- { q_attr = (ISNS_Attr *) attr_indx[jj]; ! DEBUG_1 (isns_query_debug &1, process attribute for portal objects (%s),isnsTagText(q_attr->tag)); switch ( q_attr->tag ) *************** *** 2872,2875 **** --- 2877,2914 ---- } + /* Process Portal Groups */ + for (jj = 0; (jj < SNS_MAX_ATTRS) && (attr_indx[jj]); jj++) + { + q_attr = (ISNS_Attr *) attr_indx[jj]; + DEBUG_1 (isns_query_debug &1, process attribute for portal group objects (%s),isnsTagText(q_attr->tag)); + + switch ( q_attr->tag ) + { + /* Located in the Portal object */ + case ISNS_PORTAL_GROUP_PORT: + DEBUG_1 (isns_query_debug &1,ISNS_PORTAL_GROUP_PORT:%i,p_portal->ip_port); + ISNSAppendAttr (p_msg, ISNS_PORTAL_GROUP_PORT, ISNS_PORTAL_GROUP_PORT_SIZE, + NULL, p_portal->ip_port); + break; + case ISNS_PORTAL_GROUP_IP: + DEBUG_0 (isns_query_debug &1,Add ISNS_PORTAL_GROUP_IP); + ISNSAppendAttr (p_msg, ISNS_PORTAL_GROUP_IP, ISNS_PORTAL_GROUP_IP_SIZE, + p_portal->ip_addr.v, 0); + break; + case ISNS_PORTAL_GROUP_ISCSI_NAME: + ISNSAppendAttr (p_msg, ISNS_PORTAL_GROUP_ISCSI_NAME, + PAD4 (strlen (p_node->id.v)), + p_node->id.v, 0); + break; + case ISNS_PORTAL_GROUP_TAG: + ISNSAppendAttr (p_msg, ISNS_PORTAL_GROUP_TAG, ISNS_PORTAL_GROUP_TAG_SIZE, + NULL, 1); // hard code group 1 for now + break; + default: + break; + } /* end for */ + } + + return ( SUCCESS ); } Index: iSNSList.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSList.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** iSNSList.c 14 Dec 2006 23:04:27 -0000 1.9 --- iSNSList.c 15 Dec 2006 18:17:18 -0000 1.10 *************** *** 183,187 **** ISNS_LIST_NODE *curr_node; int rval; ! ISNS_Key key; SOIP_DB_Entry entry; int next_index; --- 183,187 ---- ISNS_LIST_NODE *curr_node; int rval; ! ISNS_DBKey key; SOIP_DB_Entry entry; int next_index; *************** *** 226,230 **** /* read current node */ ! memset(&key,0,sizeof(ISNS_Key)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; --- 226,230 ---- /* read current node */ ! memset(&key,0,sizeof(ISNS_DBKey)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; *************** *** 374,378 **** AddNode(ISNS_LIST *plist, char *pdata, int data_size) { ! ISNS_Key key; SOIP_DB_Entry entry; --- 374,378 ---- AddNode(ISNS_LIST *plist, char *pdata, int data_size) { ! ISNS_DBKey key; SOIP_DB_Entry entry; *************** *** 387,391 **** DEBUG_1 (isns_list_debug &1, AddNode - list_id:%i,plist->list_id); ! memset(&key,0,sizeof(ISNS_Key)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; --- 387,391 ---- DEBUG_1 (isns_list_debug &1, AddNode - list_id:%i,plist->list_id); ! memset(&key,0,sizeof(ISNS_DBKey)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; *************** *** 509,513 **** { ISNS_LIST_NODE *node; ! ISNS_Key key; SOIP_DB_Entry entry; int rval; --- 509,513 ---- { ISNS_LIST_NODE *node; ! ISNS_DBKey key; SOIP_DB_Entry entry; int rval; *************** *** 527,531 **** } ! memset(&key,0,sizeof(ISNS_Key)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; --- 527,531 ---- } ! memset(&key,0,sizeof(ISNS_DBKey)); key.tag = LIST_KEY; key.val.list.list_id = plist->list_id; Index: iSNSesi.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSesi.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** iSNSesi.c 15 Dec 2006 01:13:29 -0000 1.7 --- iSNSesi.c 15 Dec 2006 18:17:19 -0000 1.8 *************** *** 75,82 **** int rval; SOIP_Portal *p_portal; ! SOIP_DB_Portal db_portal; ISNS_Msg_Descp *p_md; time_t mytime; ! ISNS_Key read_key = { 0 }; DEBUG_0 (isns_esi_debug &1, ISNS_SendESI); --- 75,82 ---- int rval; SOIP_Portal *p_portal; ! SOIP_Portal_Key db_portal; ISNS_Msg_Descp *p_md; time_t mytime; ! ISNS_DBKey read_key = { 0 }; DEBUG_0 (isns_esi_debug &1, ISNS_SendESI); *************** *** 190,198 **** ISNS_ProcessESI ( ISNS_Msg_Descp *p_md ) { ! ISNS_Attr *p_attr; SOIP_Entity *p_entity; SOIP_Portal *p_portal; time_t mytime; ! SOIP_DB_Portal db_portal; int i; int len; --- 190,198 ---- ISNS_ProcessESI ( ISNS_Msg_Descp *p_md ) { ! ISNS_Key *p_attr; SOIP_Entity *p_entity; SOIP_Portal *p_portal; time_t mytime; ! SOIP_Portal_Key db_portal; int i; int len; *************** *** 200,204 **** char *key_indx[SNS_MAX_ATTRS]; int rval; ! ISNS_Key update_key; DEBUG_0 (isns_esi_debug &1, ISNS_ProcessESI); --- 200,205 ---- char *key_indx[SNS_MAX_ATTRS]; int rval; ! SOIP_Entity_Id db_entity_id; ! ISNS_DBKey update_key; DEBUG_0 (isns_esi_debug &1, ISNS_ProcessESI); *************** *** 211,219 **** return ( ERROR ); } ! p_attr = (ISNS_Attr *)(key_indx[ i ]); ! ISNS_Key key; key.tag = ENTITY_ID_KEY; ! strcpy(key.val.entity_id.id,p_attr->val.entity_id.id); rval = ISNSdbRead(&key,&entry); if (rval != SUCCESS) --- 212,223 ---- return ( ERROR ); } ! p_attr = (ISNS_Key *)(key_indx[ i ]); ! memset(db_entity_id.id,0,sizeof(SOIP_Entity_Id)); ! strncpy(db_entity_id.id,p_attr->val.entity_id.id,sizeof(SOIP_Entity_Id)); ! ! ISNS_DBKey key; key.tag = ENTITY_ID_KEY; ! strcpy(key.val.entity_id.id,db_entity_id.id); rval = ISNSdbRead(&key,&entry); if (rval != SUCCESS) *************** *** 233,237 **** ISNSdbWrite(&key,entry); ! memset(&db_portal,0,sizeof(SOIP_DB_Portal)); /* Fetch the portal IP */ --- 237,241 ---- ISNSdbWrite(&key,entry); ! memset(&db_portal,0,sizeof(SOIP_Portal_Key)); /* Fetch the portal IP */ *************** *** 242,246 **** return ( ERROR ); } ! p_attr = (ISNS_Attr *)(key_indx[i]); memcpy(db_portal.ip_addr.v, p_attr->val.ip_addr.v, ISNS_IP_SIZE); --- 246,250 ---- return ( ERROR ); } ! p_attr = (ISNS_Key *)(key_indx[i]); memcpy(db_portal.ip_addr.v, p_attr->val.ip_addr.v, ISNS_IP_SIZE); *************** *** 251,259 **** return ( ERROR ); } ! p_attr = (ISNS_Attr *)(key_indx[i]); db_portal.ip_port=p_attr->val.ip_port; update_key.tag = PORTAL_ID_KEY; ! memcpy(&update_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&update_key,&entry); if (rval != SUCCESS) --- 255,263 ---- return ( ERROR ); } ! p_attr = (ISNS_Key *)(key_indx[i]); db_portal.ip_port=p_attr->val.ip_port; update_key.tag = PORTAL_ID_KEY; ! memcpy(&update_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&update_key,&entry); if (rval != SUCCESS) Index: iSNSparse.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSparse.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** iSNSparse.c 15 Dec 2006 01:13:29 -0000 1.14 --- iSNSparse.c 15 Dec 2006 18:17:19 -0000 1.15 *************** *** 145,151 **** case ISNS_DD_ISCSI_MEMBER: case ISNS_PORTAL_GROUP_ISCSI_NAME: - //if ( len != PAD2(strlen(ptr)) && len != 0) - // rval = FALSE; - if ( len == 0) DEBUG_3 (isns_parse_debug &1,%sTag:%i (%s),src,tag,isnsTagText(tag)); --- 145,148 ---- *************** *** 153,167 **** DEBUG_4 (isns_parse_debug &1,%sTag:%i (%s) %s,src,tag,isnsTagText(tag),(char *)ptr); break; ! case ISNS_MGMT_IP: case ISNS_PORTAL_IP: ! { ! char ipaddr[256]; if (len != ISNS_IP_SIZE && len != 0) rval = FALSE; ! ipaddrchar (ptr,ipaddr); ! DEBUG_4 (isns_parse_debug &1,%sTag:%i (%s) %s,src,tag,isnsTagText(tag),ipaddr); break; - } case ISNS_TIMESTAMP: if (len != ISNS_TIMESTAMP_SIZE && len != 0 ) --- 150,162 ---- DEBUG_4 (isns_parse_debug &1,%sTag:%i (%s) %s,src,tag,isnsTagText(tag),(char *)ptr); break; ! case ISNS_MGMT_IP: case ISNS_PORTAL_IP: ! case ISNS_PORTAL_GROUP_IP: if (len != ISNS_IP_SIZE && len != 0) rval = FALSE; ! DEBUG_4 (isns_parse_debug &1,%sTag:%i (%s) %s,src,tag,isnsTagText(tag), ! inet_ntoa(*(struct in_addr *)(ptr+12)) ); break; case ISNS_TIMESTAMP: if (len != ISNS_TIMESTAMP_SIZE && len != 0 ) *************** *** 229,243 **** case ISNS_FC_NODE_IP: - case ISNS_PORTAL_GROUP_IP: case ISNS_FC_NODE_IPA: - #if 0 - case ISNS_VENDOR_ID: - case ISNS_VENDOR_REV: - case ISNS_PRIMARY_VER: - case ISNS_PRIMARY_IP: - case ISNS_PRIMARY_TCP_PORT: - case ISNS_PRIMARY_UDP_PORT: - case ISNS_PRIMARY_MGMT_IP: - #endif case ISNS_COMPANY_OUI: case ISNS_SCN_CALLBACK: --- 224,228 ---- *************** *** 460,463 **** --- 445,449 ---- case ISNS_PORTAL_SECURITY_BITMAP: case ISNS_PORTAL_GROUP_PORT: + case ISNS_PORTAL_GROUP_TAG: if (pattr->len != 0) { *************** *** 507,511 **** case ISNS_ISCSI_ALIAS: case ISNS_SCN_PORT: - case ISNS_PORTAL_GROUP_TAG: case ISNS_PORTAL_GROUP_ISCSI_NAME: case ISNS_PORTAL_GROUP_IP: --- 493,496 ---- *************** *** 604,607 **** --- 589,594 ---- case ISNS_COMPANY_OUI: case ISNS_PORTAL_PORT: + case ISNS_PORTAL_GROUP_PORT: + case ISNS_PORTAL_GROUP_TAG: case ISNS_PORT_TYPE: case ISNS_DDS_STATUS: *************** *** 629,632 **** --- 616,620 ---- case ISNS_FC4_TYPE: case ISNS_PORTAL_IP: + case ISNS_PORTAL_GROUP_IP: case ISNS_PORT_ID: case ISNS_FC_NODE_IP: *************** *** 653,656 **** --- 641,645 ---- case ISNS_ISCSI_CERT: case ISNS_ISCSI_ALIAS: + case ISNS_PORTAL_GROUP_ISCSI_NAME: ptr = (uint8_t *) ptr + len; break; Index: iSNSdereg.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSdereg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** iSNSdereg.c 15 Dec 2006 01:13:29 -0000 1.14 --- iSNSdereg.c 15 Dec 2006 18:17:19 -0000 1.15 *************** *** 778,782 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry3); if (rval != SUCCESS) --- 778,782 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry3); if (rval != SUCCESS) *************** *** 827,831 **** { int foundFlag; ! SOIP_DB_Portal db_portal; int ii; int portalIpIndex; --- 827,831 ---- { int foundFlag; ! SOIP_Portal_Key db_portal; int ii; int portalIpIndex; *************** *** 1239,1243 **** read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,portal_key,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1239,1243 ---- read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,portal_key,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) Index: iSNSreg.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSreg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** iSNSreg.c 15 Dec 2006 01:13:29 -0000 1.14 --- iSNSreg.c 15 Dec 2006 18:17:19 -0000 1.15 *************** *** 93,96 **** --- 93,97 ---- int regPortalFlag; int regISCSIFlag; + int regPortalGroupFlag; int regFlag; char *attr_indx[SNS_MAX_ATTRS]; *************** *** 106,109 **** --- 107,111 ---- regPortalFlag = 0; regISCSIFlag = 0; + regPortalGroupFlag = 0; ISNSParseMsg( &p_md->msg, attr_indx, key_indx, &src_attr ); *************** *** 163,166 **** --- 165,172 ---- regISCSIFlag = TRUE; break; + + case ISNS_PORTAL_GROUP_ISCSI_NAME: + regPortalGroupFlag = TRUE; + break; default: break; *************** *** 168,171 **** --- 174,179 ---- } + regPortalGroupFlag = (regISCSIFlag && regPortalFlag) || regPortalGroupFlag; + DEBUG_1 (isns_reg_debug &1,regISCSIFlag:%i,regISCSIFlag); DEBUG_1 (isns_reg_debug &1,regPortalFlag:%i,regPortalFlag); *************** *** 204,207 **** --- 212,221 ---- } + if (regPortalGroupFlag && status == ISNS_NO_ERR) + { + regFlag=TRUE; + status = ISNSdbAddAttrPortalGroup (attr_indx, key_indx, p_md, rspMsg); + } + if (!regFlag) status=ISNS_INVALID_REG_ERR; *************** *** 224,228 **** SOIP_Portal *p_portal; SOIP_Entity *p_entity; ! SOIP_DB_Portal db_portal; int ii; int rval; --- 238,242 ---- SOIP_Portal *p_portal; SOIP_Entity *p_entity; ! SOIP_Portal_Key db_portal; int ii; int rval; *************** *** 364,368 **** DEBUG_1 (isns_reg_debug &1,(read portal:%s),db_portal.ip_addr.v); read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); --- 378,382 ---- DEBUG_1 (isns_reg_debug &1,(read portal:%s),db_portal.ip_addr.v); read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry2); *************** *** 629,633 **** ISNS_Key update_key; update_key.tag = PORTAL_ID_KEY; ! memcpy(&update_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbWrite(&update_key,entry2); --- 643,647 ---- ISNS_Key update_key; update_key.tag = PORTAL_ID_KEY; ! memcpy(&update_key.val,&db_portal,sizeof(SOIP_Portal_Key)); rval = ISNSdbWrite(&update_key,entry2); *************** *** 665,668 **** --- 679,942 ---- /********************************************************************* + _ISNSdbAddAttrPortalGroup + + Adds a portal group to the database. The keys are appended to the + rsp message. + *********************************************************************/ + int + ISNSdbAddAttrPortalGroup (char **attr_indx, char **key_indx, ISNS_Msg_Descp * p_md, + ISNS_Msg * p_rspmsg) + { + ISNS_Key *key = NULL; + ISNS_Attr *attr = NULL; + SOIP_Portal_Group *p_portal_group; + SOIP_Portal_Key db_portal_group; + int ii; + int rval; + int portalIpIndex; + int portalPortIndex; + int saveIndex; + int stopFlag = FALSE; + int newPortalRegFlag; + int updateFlag; + //char *p_iscsi_name; + ISNS_Key read_key; + + DEBUG_0 (isns_reg_debug & 1, (Registering Portal)); + + newPortalRegFlag = FALSE; + portalPortIndex = -1; + portalIpIndex = -1; + + for (ii = 0; ii < SNS_MAX_ATTRS && key_indx[ ii ] + && (portalIpIndex == -1 || portalPortIndex == -1); ii++) + { + key = (ISNS_Key *)( key_indx[ ii ] ); + switch ( key->tag ) + { + case ISNS_PORTAL_GROUP_IP: + /* Check to see if we already had an IP */ + if (portalIpIndex != -1) + { + DEBUG_0 (isns_reg_debug & 1, (PORTAL_IP tag found twice)); + return ( ISNS_INVALID_REG_ERR ); + } + portalIpIndex = ii; + break; + case ISNS_PORTAL_GROUP_PORT: + /* Check to see if we already had a PORT */ + if (portalPortIndex != -1) + { + DEBUG_0 (isns_reg_debug & 1, (PORTAL_PORT tag found twice)); + return ( ISNS_INVALID_REG_ERR ); + } + portalPortIndex = ii; + break; + default: + break; + } + } + + if (portalIpIndex == -1 && portalPortIndex == -1) + { + /* No keys */ + newPortalRegFlag = TRUE; + } + else if (portalIpIndex == -1 || portalPortIndex == -1) + { + /* One or the other key */ + DEBUG_0 (isns_reg_debug & 1, (Portal Reg: Missing keys)); + return ( ISNS_INVALID_REG_ERR ); + } + + saveIndex = 0; + /* Loop for every portal IP and portal PORT */ + while ( saveIndex < SNS_MAX_ATTRS ) + { + if ( newPortalRegFlag ) + { + /* Search for the tag portal IP and portal PORT. */ + /* These are going to be used as the key. */ + portalIpIndex = -1; + portalPortIndex = -1; + + for ( ii = saveIndex; ii < SNS_MAX_ATTRS && attr_indx[ii] + && (portalIpIndex == -1 || portalPortIndex == -1); ii++ ) + { + attr = (ISNS_Attr *) attr_indx[ ii ]; + switch ( attr->tag ) + { + case ISNS_PORTAL_IP: + /* Check to see if we already had an IP */ + if (portalIpIndex != -1) + { + DEBUG_0 (isns_reg_debug & 1, (PORTAL_IP tag found twice)); + return ( ISNS_INVALID_REG_ERR ); + } + portalIpIndex = ii; + break; + case ISNS_PORTAL_PORT: + /* Check to see if we already had a PORT */ + if (portalPortIndex != -1) + { + DEBUG_0 (isns_reg_debug & 1, (PORTAL_PORT tag found twice)); + return ( ISNS_INVALID_REG_ERR ); + } + portalPortIndex = ii; + break; + default: + break; + } + } + + /* Check to see if we have both indices */ + if ( portalIpIndex == -1 || portalPortIndex == -1 ) + { + DEBUG_0 (isns_reg_debug & 1, (PORTAL REG, MISSING KEYS)); + return ( ISNS_INVALID_REG_ERR ); + } + + DEBUG_1 (isns_reg_debug &1,(Portal ip_port:%i),attr->val.ip_port); + attr = (ISNS_Attr *) attr_indx[ portalPortIndex ]; + db_portal_group.ip_port = attr->val.ip_port; + + attr = (ISNS_Attr *) attr_indx[ portalIpIndex ]; + memcpy ( (char *) db_portal_group.ip_addr.v, &attr->val, + ISNS_PORTAL_IP_SIZE ); + + saveIndex = ii; + } + else + { + DEBUG_1 (isns_reg_debug &1,(Portal ip_port:%i),key->val.ip_port); + /* Use Keys to fetch the portal Object */ + key = (ISNS_Key *) key_indx[ portalPortIndex ]; + db_portal_group.ip_port = key->val.ip_port; + + DEBUG_1 (isns_reg_debug &1,(Portal ip_addr len:%i),key->len); + key = (ISNS_Key *) key_indx[ portalIpIndex ]; + memcpy ( (char *) db_portal_group.ip_addr.v, &key->val, + key->len ); + saveIndex = 0; + } + + DEBUG_1 (isns_reg_debug &1,(read portal:%s),db_portal_group.ip_addr.v); + read_key.tag = PORTAL_GROUP_ID_KEY; + memcpy(&read_key.val,&db_portal_group,sizeof(SOIP_Portal_Group_Key)); + rval = ISNSdbRead(&read_key,&entry2); + + p_portal_group = &entry2.data.portal_group; + + if ( (rval == SUCCESS) && (p_md->msg.hdr.flags & ISNS_FLAG_REPLACE_REG) ) + { + DEBUG_0 (isns_reg_debug & 1,Deregistering PortalGroup); + // SNSRemovePortalEntry ((char *)&db_portal_group, NULL, NULL); + rval = ERROR; + } + + /* Create new entry */ + if ( rval != SUCCESS ) + { + DEBUG_0 (isns_reg_debug &1,create new portal entry); + + if ( FALSE == newPortalRegFlag ) + { + DEBUG_0 (isns_reg_debug & 1, (Unable to retrieve portal entry)); + return ( ISNS_INVALID_REG_ERR ); + } + /* create a new node element */ + memset (&entry2, 0, sizeof (SOIP_DB_Entry)); + entry2.data_type = PORTAL_ID_KEY; + + attr = (ISNS_Attr *) attr_indx[portalIpIndex]; + memcpy (p_portal_group->ip_addr.v, attr->val.ip_addr.v, attr->len); + + attr = (ISNS_Attr *) attr_indx[portalPortIndex]; + p_portal_group->ip_port = attr->val.ip_port; + + //p_portal_group->portal_index = ISNSGetNewPortalIdx(); + + newPortalRegFlag = TRUE; + } + else + + stopFlag = FALSE; + updateFlag = FALSE; + memset(p_scn_all_msg_buffer, 0, sizeof(ISNS_Msg)); + for ( ii = saveIndex; (ii < SNS_MAX_ATTRS) && (attr_indx[ ii ]); ii++ ) + { + attr = (ISNS_Attr *) attr_indx[ ii ]; + switch ( attr->tag ) + { + case ISNS_PORTAL_IP: + case ISNS_PORTAL_PORT: + saveIndex = ii; + stopFlag = TRUE; + break; + case ISNS_PORTAL_GROUP: + //if (p_portal->group!=*(uint32_t *)&attr->val) + //{ + // p_portal->group=*(uint32_t *)&attr->val; + + // ISNSAppendKey( p_scn_all_msg_buffer, ISNS_PORTAL_GROUP, + // ISNS_PORTAL_GROUP_SIZE, NULL, p_portal->group ); + + //updateFlag = TRUE; + //} + break; + default: + break; + } + + if (stopFlag) + break; + } + + /* Store the portal */ + DEBUG_1 (isns_reg_debug &1,Store Portal Group:%s,db_portal_group.ip_addr.v); + ISNS_Key update_key; + update_key.tag = PORTAL_GROUP_ID_KEY; + memcpy(&update_key.val,&db_portal_group,sizeof(SOIP_Portal_Group_Key)); + rval = ISNSdbWrite(&update_key,entry2); + + if ( newPortalRegFlag ) + iSNS_stats.num_portal_groups++; + + /* insert the key(s) */ + if (p_rspmsg != NULL) + { + ISNSAppendKey (p_rspmsg, ISNS_PORTAL_GROUP_IP, ISNS_PORTAL_IP_SIZE, + p_portal_group->ip_addr.v, 0); + ISNSAppendKey (p_rspmsg, ISNS_PORTAL_GROUP_PORT, ISNS_PORTAL_PORT_SIZE, 0, + p_portal_group->ip_port); + ISNSAppendKey (p_rspmsg, ISNS_PORTAL_GROUP_ISCSI_NAME, ISNS_PORTAL_PORT_SIZE, 0, + p_portal_group->ip_port); + ISNSAppendKey (p_rspmsg, ISNS_PORTAL_GROUP_TAG, ISNS_PORTAL_GROUP_TAG_SIZE, 0, + p_portal_group->portal_tag); + } + + /* Loop on the following conditions. */ + attr = (ISNS_Attr *)(attr_indx[saveIndex]); + + if (!newPortalRegFlag) + break; + + if (!attr_indx[saveIndex]) + break; + + newPortalRegFlag = TRUE; + if ((attr->tag == ISNS_PORTAL_IP) || (attr->tag == ISNS_PORTAL_PORT)) + continue; + else + break; + + DEBUG_0 (isns_reg_debug &1,end of loop); + } + + DEBUG_0 (isns_reg_debug &1,return); + return (ISNS_NO_ERR); + } + + /********************************************************************* _SNSdbAddAttrDDS *************** *** 2126,2130 **** memset ( &db_node_name, 0, sizeof (db_node_name) ); ! strncpy ((char *) db_node_name.v, (char *) &key->val, sizeof(db_node_name.v) ); ISNS_Key read_key; --- 2400,2404 ---- memset ( &db_node_name, 0, sizeof (db_node_name) ); ! strncpy ((char *) db_node_name.v, (char *) &key->val, key->len ); ISNS_Key read_key; *************** *** 2490,2494 **** ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry3); if (rval != SUCCESS) --- 2764,2768 ---- ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_Portal_Key)); rval = ISNSdbRead(&read_key,&entry3); if (rval != SUCCESS) *************** *** 3598,3602 **** SOIP_DB_Entry lentry2; SOIP_Dd *p_dd = NULL; ! ISNS_Key dd_key = { 0 }; int rval; int found; --- 3872,3876 ---- SOIP_DB_Entry lentry2; SOIP_Dd *p_dd = NULL; ! ISNS_Key dd_key = { 0 }; int rval; int found; Index: iSNSdb.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSdb.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** iSNSdb.c 15 Dec 2006 01:13:29 -0000 1.20 --- iSNSdb.c 15 Dec 2006 18:17:18 -0000 1.21 *************** *** 105,109 **** *********************************************************************/ int ! ISNSdbRead (ISNS_Key *key, SOIP_DB_Entry *entry) { datum k; --- 105,109 ---- *********************************************************************/ int ! ISNSdbRead (ISNS_DBKey *key, SOIP_DB_Entry *entry) { datum k; *************** *** 204,219 **** case PORTAL_ID_KEY: { ! SOIP_DB_Portal db_portal; ! char ipaddr[256]; ! memcpy(&db_portal,&key->val,sizeof(SOIP_DB_Portal)); ! ipaddrchar(&db_portal.ip_addr,ipaddr); ! DEBUG_2 (isns_db_debug &1,read Portal ip_addr:%s port:%i,ipaddr,db_portal.ip_port); k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_DB_Portal); d = ndb_fetch_sns (PORTAL_ID_KEY, k, (char *)entry); if (d.dptr == NULL) { ! DEBUG_2 (isns_db_debug &1,read failure Portal ip_addr:%s port:%i,ipaddr,db_portal.ip_port); return (ISNS_NO_SUCH_ENTRY_ERR); } --- 204,219 ---- case PORTAL_ID_KEY: { ! SOIP_Portal_Key db_portal; ! memcpy(&db_portal,&key->val,sizeof(SOIP_Portal_Key)); ! DEBUG_2 (isns_db_debug &1,read Portal ip_addr:%s port:%i, ! inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_Portal_Key); d = ndb_fetch_sns (PORTAL_ID_KEY, k, (char *)entry); if (d.dptr == NULL) { ! DEBUG_2 (isns_db_debug &1,read failure Portal ip_addr:%s port:%i, ! inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); return (ISNS_NO_SUCH_ENTRY_ERR); } *************** *** 222,225 **** --- 222,245 ---- break; } + case PORTAL_GROUP_ID_KEY: + { + SOIP_Portal_Group_Key db_portal; + memcpy(&db_portal,&key->val,sizeof(SOIP_Portal_Group_Key)); + DEBUG_2 (isns_db_debug &1,read Portal Group ip_addr:%s port:%i, + inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); + + k.dptr = (char *)&key->val; + k.dsize = sizeof(SOIP_Portal_Group_Key); + d = ndb_fetch_sns (PORTAL_GROUP_ID_KEY, k, (char *)entry); + if (d.dptr == NULL) + { + DEBUG_2 (isns_db_debug &1,read Portal Group ip_addr:%s port:%i, + inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); + return (ISNS_NO_SUCH_ENTRY_ERR); + } + if (entry->data_type != PORTAL_GROUP_ID_KEY) + return (ISNS_UNKNOWN_ERR); + break; + } case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: *************** *** 255,259 **** case PORTAL_ENTITY_LIST: DEBUG_1 (isns_db_debug & 1, (read list:%i),key->val.list.key.portal.ip_port); ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_DB_Portal); break; case ISCSI_DD_LIST: --- 275,279 ---- case PORTAL_ENTITY_LIST: DEBUG_1 (isns_db_debug & 1, (read list:%i),key->val.list.key.portal.ip_port); ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_Portal_Key); break; case ISCSI_DD_LIST: *************** *** 299,303 **** *********************************************************************/ int ! ISNSdbWrite (ISNS_Key *key, SOIP_DB_Entry entry) { datum k; --- 319,323 ---- *********************************************************************/ int ! ISNSdbWrite (ISNS_DBKey *key, SOIP_DB_Entry entry) { datum k; *************** *** 361,369 **** case PORTAL_ID_KEY: k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_DB_Portal); rc = ndb_store_sns (key->tag, k, d, GDBM_REPLACE); if (rc == ERROR) DEBUG_0 (isns_db_debug &1,PORTAL Name Write failed); break; case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: --- 381,396 ---- case PORTAL_ID_KEY: k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_Portal_Key); rc = ndb_store_sns (key->tag, k, d, GDBM_REPLACE); if (rc == ERROR) DEBUG_0 (isns_db_debug &1,PORTAL Name Write failed); break; + case PORTAL_GROUP_ID_KEY: + k.dptr = (char *)&key->val; + k.dsize = sizeof(SOIP_Portal_Group_Key); + rc = ndb_store_sns (key->tag, k, d, GDBM_REPLACE); + if (rc == ERROR) + DEBUG_0 (isns_db_debug &1,PORTAL Group Write failed); + break; case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: *************** *** 395,399 **** case PORTAL_ENTITY_LIST: DEBUG_1 (isns_db_debug & 1, (write list:%i),key->val.list.key.portal.ip_port); ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_DB_Portal); break; case ISCSI_DD_LIST: --- 422,426 ---- case PORTAL_ENTITY_LIST: DEBUG_1 (isns_db_debug & 1, (write list:%i),key->val.list.key.portal.ip_port); ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_Portal_Key); break; case ISCSI_DD_LIST: *************** *** 432,436 **** *********************************************************************/ int ! ISNSdbDelete (ISNS_Key *key) { datum k; --- 459,463 ---- *********************************************************************/ int ! ISNSdbDelete (ISNS_DBKey *key) { datum k; *************** *** 489,497 **** case PORTAL_ID_KEY: k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_DB_Portal); rc = ndb_delete (key->tag, k); if (rc == ERROR) DEBUG_0 (isns_db_debug &1,PORTAL Name Delete failed); break; case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: --- 516,531 ---- case PORTAL_ID_KEY: k.dptr = (char *)&key->val; ! k.dsize = sizeof(SOIP_Portal_Key); rc = ndb_delete (key->tag, k); if (rc == ERROR) DEBUG_0 (isns_db_debug &1,PORTAL Name Delete failed); break; + case PORTAL_GROUP_ID_KEY: + k.dptr = (char *)&key->val; + k.dsize = sizeof(SOIP_Portal_Group_Key); + rc = ndb_delete (key->tag, k); + if (rc == ERROR) + DEBUG_0 (isns_db_debug &1,PORTAL Group Delete failed); + break; case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: *************** *** 520,524 **** break; case PORTAL_ENTITY_LIST: ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_DB_Portal); break; case ISCSI_DD_LIST: --- 554,558 ---- break; case PORTAL_ENTITY_LIST: ! k.dsize = LIST_KEY_SIZE + sizeof(SOIP_Portal_Key); break; case ISCSI_DD_LIST: *************** *** 608,612 **** dbfp[PORT_NAME_KEY] = gdbm_open("isns7.db",1024,GDBM_WRCREAT,0666, ISNSExceptionHdlr); ! dbfp[ESI_KEY] = gdbm_open("isns8.db",1024,GDBM_WRCREAT,0666, ISNSExceptionHdlr); dbfp[ENTITY_IDX_KEY] = gdbm_open("isns9.db",1024,GDBM_WRCREAT,0666, --- 642,646 ---- dbfp[PORT_NAME_KEY] = gdbm_open("isns7.db",1024,GDBM_WRCREAT,0666, ISNSExceptionHdlr); ! dbfp[PORTAL_GROUP_ID_KEY] = gdbm_open("isns8.db",1024,GDBM_WRCREAT,0666, ISNSExceptionHdlr); dbfp[ENTITY_IDX_KEY] = gdbm_open("isns9.db",1024,GDBM_WRCREAT,0666, *************** *** 645,649 **** gdbm_close(dbfp[NODE_NAME_KEY]); gdbm_close(dbfp[PORT_NAME_KEY]); ! gdbm_close(dbfp[ESI_KEY]); gdbm_close(dbfp[ENTITY_IDX_KEY]); gdbm_close(dbfp[ISCSI_IDX_KEY]); --- 679,683 ---- gdbm_close(dbfp[NODE_NAME_KEY]); gdbm_close(dbfp[PORT_NAME_KEY]); ! gdbm_close(dbfp[PORTAL_GROUP_ID_KEY]); gdbm_close(dbfp[ENTITY_IDX_KEY]); gdbm_close(dbfp[ISCSI_IDX_KEY]); *************** *** 671,675 **** SOIP_DB_Entry * p_entry) { ! ISNS_Key key; int rval; --- 705,709 ---- SOIP_DB_Entry * p_entry) { ! ISNS_DBKey key; int rval; *************** *** 695,699 **** { SOIP_DD_Key dd_key; ! ISNS_Key key; int rval; --- 729,733 ---- { SOIP_DD_Key dd_key; ! ISNS_DBKey key; int rval; *************** *** 714,721 **** *********************************************************************/ int ! SNSdbGetNextOfKey (ISNS_Key * key) { datum k, d, next; ! ISNS_Key null_key = { 0 }; SOIP_DB_Entry *p_entry; --- 748,755 ---- *********************************************************************/ int ! SNSdbGetNextOfKey (ISNS_DBKey * key) { datum k, d, next; ! ISNS_DBKey null_key = { 0 }; SOIP_DB_Entry *p_entry; |