static ClRcT _clPluginHelperGetIpNodeAddress(const ClCharT *xportType, ClCharT *hostAddress, ClCharT *networkMask, ClCharT *broadcast, ClUint32T *ipAddressMask, ClCharT *xportSubnetPrefix) { ClCharT envSubNetType[CL_MAX_FIELD_LENGTH] = { 0 }; ClCharT xportSubnet[CL_MAX_FIELD_LENGTH] = { 0 }; ClCharT *subnetMask = NULL; ClCharT *subnetPrefix = NULL; ClUint32T CIDR, ipMask, ip, mask; if (!xportType) { return CL_ERR_INVALID_PARAMETER; } else { snprintf(envSubNetType, CL_MAX_FIELD_LENGTH, "ASP_%s_SUBNET", xportType); subnetMask = getenv(envSubNetType); if (subnetMask == NULL) { subnetMask = ASP_PLUGIN_SUBNET_DEFAULT; } subnetPrefix = strrchr(subnetMask, '/'); if(!subnetPrefix) { subnetPrefix = ASP_PLUGIN_SUBNET_PREFIX_DEFAULT; } else { ++subnetPrefix; } if(! (CIDR = atoi(subnetPrefix) ) ) { clLogInfo("IOC", CL_LOG_PLUGIN_HELPER_AREA, "%s", subnetMask); return CL_ERR_INVALID_PARAMETER; } xportSubnetPrefix[0] = 0; strncat(xportSubnetPrefix, subnetPrefix, CL_MAX_FIELD_LENGTH-1); snprintf(xportSubnet, sizeof(xportSubnet), "%s", subnetMask); mask = _clPluginHelperBitFillRShift(CIDR); _clPluginHelperConvertInternetToHostAddress(&ip, xportSubnet); /* network address */ ipMask = (ip & mask); _clPluginHelperConvertHostToInternetAddress(ipMask + gIocLocalBladeAddress, hostAddress); _clPluginHelperConvertHostToInternetAddress(mask, networkMask); _clPluginHelperConvertHostToInternetAddress(ip | ~mask, broadcast); *ipAddressMask = ipMask; } return CL_OK; }
static ClRcT _clPluginHelperGetIpNodeAddress(const ClCharT *xportType, const ClCharT *devIf, ClCharT *hostAddress, ClCharT *networkMask, ClCharT *broadcast, ClUint32T *ipAddressMask, ClCharT *xportSubnetPrefix) { ClCharT envSubNetType[CL_MAX_FIELD_LENGTH] = { 0 }; ClCharT xportSubnet[CL_MAX_FIELD_LENGTH] = { 0 }; ClCharT *subnetMask = NULL; ClCharT *subnetPrefix = NULL; ClUint32T CIDR, ipMask, ip, mask; ClRcT rc; if (!xportType) { return CL_ERR_INVALID_PARAMETER; } else { snprintf(envSubNetType, CL_MAX_FIELD_LENGTH, "ASP_%s_SUBNET", xportType); subnetMask = getenv(envSubNetType); if (subnetMask == NULL) { subnetMask = ASP_PLUGIN_SUBNET_DEFAULT; } subnetPrefix = strrchr(subnetMask, '/'); if(!subnetPrefix) { subnetPrefix = ASP_PLUGIN_SUBNET_PREFIX_DEFAULT; } else { ++subnetPrefix; } if(! (CIDR = atoi(subnetPrefix) ) ) { clLogInfo("IOC", CL_LOG_PLUGIN_HELPER_AREA, "%s", subnetMask); return CL_ERR_INVALID_PARAMETER; } xportSubnetPrefix[0] = 0; strncat(xportSubnetPrefix, subnetPrefix, CL_MAX_FIELD_LENGTH-1); snprintf(xportSubnet, sizeof(xportSubnet), "%s", subnetMask); mask = _clPluginHelperBitFillRShift(CIDR); _clPluginHelperConvertInternetToHostAddress(&ip, xportSubnet); /* network address */ ipMask = (ip & mask); /* Try to get address from devif */ rc = CL_OK+1; /* start with any error condition, so the if below this one will be taken */ if (clParseEnvBoolean("ASP_UDP_USE_EXISTING_IP")) { rc = _clPluginHelperDevToIpAddress(devIf, hostAddress); if (rc == CL_OK) clLogInfo("IOC",CL_LOG_PLUGIN_HELPER_AREA,"Use existing IP address [%s] as this nodes transport address.", hostAddress); else clLogError("IOC",CL_LOG_PLUGIN_HELPER_AREA,"Configured to use an existing IP address for message transport. But address lookup failed on device [%s] error [0x%x]", devIf, rc); } if (rc != CL_OK) { /* Automatic assignment of IP address */ _clPluginHelperConvertHostToInternetAddress(ipMask + gIocLocalBladeAddress, hostAddress); } _clPluginHelperConvertHostToInternetAddress(mask, networkMask); _clPluginHelperConvertHostToInternetAddress(ip | ~mask, broadcast); *ipAddressMask = ipMask; } return CL_OK; }