@@ -92,11 +92,9 @@ enum _VertexAttribute {
9292 VERTEX_ATTR_ID = 2 ,
9393 VERTEX_ATTR_BANDWIDTHDOWN = 3 ,
9494 VERTEX_ATTR_BANDWIDTHUP = 4 ,
95- VERTEX_ATTR_IP = 5 ,
95+ VERTEX_ATTR_IP_ADDRESS = 5 ,
9696 VERTEX_ATTR_CITYCODE = 6 ,
9797 VERTEX_ATTR_COUNTRYCODE = 7 ,
98- VERTEX_ATTR_ASN = 8 ,
99- VERTEX_ATTR_PACKETLOSS = 9 ,
10098};
10199
102100typedef enum _EdgeAttribute EdgeAttribute ;
@@ -118,7 +116,7 @@ struct _AttachHelper {
118116 guint numIPsGeo ;
119117 guint numIPsAll ;
120118
121- gchar * ipHint ;
119+ gchar * ipAddressHint ;
122120 gchar * citycodeHint ;
123121 gchar * countrycodeHint ;
124122
@@ -186,16 +184,12 @@ static const gchar* _topology_vertexAttributeToString(VertexAttribute attr) {
186184 return "bandwidth_down" ;
187185 } else if (attr == VERTEX_ATTR_BANDWIDTHUP ) {
188186 return "bandwidth_up" ;
189- } else if (attr == VERTEX_ATTR_IP ) {
190- return "ip " ;
187+ } else if (attr == VERTEX_ATTR_IP_ADDRESS ) {
188+ return "ip_address " ;
191189 } else if (attr == VERTEX_ATTR_CITYCODE ) {
192190 return "city_code" ;
193191 } else if (attr == VERTEX_ATTR_COUNTRYCODE ) {
194192 return "country_code" ;
195- } else if (attr == VERTEX_ATTR_ASN ) {
196- return "asn" ;
197- } else if (attr == VERTEX_ATTR_PACKETLOSS ) {
198- return "packet_loss" ;
199193 } else {
200194 return "unknown" ;
201195 }
@@ -595,20 +589,16 @@ static gboolean _topology_checkGraphAttributes(Topology* top) {
595589
596590 if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_ID )) {
597591 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
598- } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_IP )) {
592+ } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_IP_ADDRESS )) {
599593 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
600594 } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_CITYCODE )) {
601595 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
602596 } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_COUNTRYCODE )) {
603597 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
604- } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_ASN )) {
605- isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_NUMERIC );
606598 } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_BANDWIDTHDOWN )) {
607599 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
608600 } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_BANDWIDTHUP )) {
609601 isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_STRING );
610- } else if (_topology_isValidVertexAttributeKey (name , VERTEX_ATTR_PACKETLOSS )) {
611- isSuccess = isSuccess && _topology_checkAttributeType (name , type , IGRAPH_ATTRIBUTE_NUMERIC );
612602 } else {
613603 error ("vertex attribute '%s' is unsupported" , name );
614604 isSuccess = FALSE;
@@ -849,10 +839,10 @@ static gboolean _topology_checkGraphVerticesHelperHook(Topology* top, igraph_int
849839 }
850840
851841 /* this attribute is NOT required, so it is OK if it doesn't exist */
852- const gchar * ipKey = _topology_vertexAttributeToString (VERTEX_ATTR_IP );
842+ const gchar * ipKey = _topology_vertexAttributeToString (VERTEX_ATTR_IP_ADDRESS );
853843 if (igraph_cattribute_has_attr (& top -> graph , IGRAPH_ATTRIBUTE_VERTEX , ipKey )) {
854844 const gchar * ipVal ;
855- if (_topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP , & ipVal )) {
845+ if (_topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP_ADDRESS , & ipVal )) {
856846 g_string_append_printf (message , " %s='%s'" , ipKey , ipVal );
857847 } else {
858848 debug ("optional attribute '%s' on vertex %li (%s='%s') is NULL, ignoring" , ipKey ,
@@ -884,38 +874,6 @@ static gboolean _topology_checkGraphVerticesHelperHook(Topology* top, igraph_int
884874 }
885875 }
886876
887- /* this attribute is NOT required, so it is OK if it doesn't exist */
888- const gchar * asnKey = _topology_vertexAttributeToString (VERTEX_ATTR_ASN );
889- if (igraph_cattribute_has_attr (& top -> graph , IGRAPH_ATTRIBUTE_VERTEX , asnKey )) {
890- gdouble asnValue ;
891- if (_topology_findVertexAttributeDouble (top , vertexIndex , VERTEX_ATTR_ASN , & asnValue )) {
892- if (asnValue > 0.0f ) {
893- g_string_append_printf (message , " %s='%f'" , asnKey , asnValue );
894- } else {
895- /* its an error if they gave a value that is incorrect */
896- warning ("optional attribute '%s' on vertex %li (%s='%s') is non-positive" ,
897- asnKey , (glong )vertexIndex , idKey , idStr );
898- isSuccess = FALSE;
899- }
900- }
901- }
902-
903- /* this attribute is NOT required, so it is OK if it doesn't exist */
904- const gchar * packetlossKey = _topology_vertexAttributeToString (VERTEX_ATTR_PACKETLOSS );
905- if (igraph_cattribute_has_attr (& top -> graph , IGRAPH_ATTRIBUTE_VERTEX , packetlossKey )) {
906- gdouble packetlossValue ;
907- if (_topology_findVertexAttributeDouble (top , vertexIndex , VERTEX_ATTR_PACKETLOSS , & packetlossValue )) {
908- if (packetlossValue >= 0.0f && packetlossValue <= 1.0f ) {
909- g_string_append_printf (message , " %s='%f'" , packetlossKey , packetlossValue );
910- } else {
911- /* its an error if they gave a value that is incorrect */
912- warning ("optional attribute '%s' on vertex %li (%s='%s') is out of range [0.0,1.0]" ,
913- packetlossKey , (glong )vertexIndex , idKey , idStr );
914- isSuccess = FALSE;
915- }
916- }
917- }
918-
919877 trace ("%s" , message -> str );
920878
921879 g_string_free (message , TRUE);
@@ -1391,12 +1349,6 @@ static gboolean _topology_computePathProperties(Topology* top, igraph_integer_t
13911349
13921350 _topology_lockGraph (top );
13931351
1394- /* get source properties */
1395- gdouble sourcePacketLoss ;
1396- if (_topology_findVertexAttributeDouble (top , srcVertexIndex , VERTEX_ATTR_PACKETLOSS , & sourcePacketLoss )) {
1397- totalReliability *= (1.0f - sourcePacketLoss );
1398- }
1399-
14001352 gboolean found = _topology_findVertexAttributeString (top , srcVertexIndex , VERTEX_ATTR_ID , & srcIDStr );
14011353 utility_assert (found );
14021354 g_string_printf (pathStringBuffer , "%s" , srcIDStr );
@@ -1406,14 +1358,6 @@ static gboolean _topology_computePathProperties(Topology* top, igraph_integer_t
14061358 found = _topology_findVertexAttributeString (top , targetVertexIndex , VERTEX_ATTR_ID , & dstIDStr );
14071359 utility_assert (found );
14081360
1409- /* only include dst loss if there is no path between src and dst vertices */
1410- if ((srcVertexIndex != targetVertexIndex ) || (srcVertexIndex == targetVertexIndex && nVertices > 2 )) {
1411- gdouble destPacketLoss ;
1412- if (_topology_findVertexAttributeDouble (top , targetVertexIndex , VERTEX_ATTR_PACKETLOSS , & destPacketLoss )) {
1413- totalReliability *= (1.0f - destPacketLoss );
1414- }
1415- }
1416-
14171361 /* the source is in the first position only if we have more than one vertex */
14181362 if (nVertices > 1 ) {
14191363 utility_assert (srcVertexIndex == igraph_vector_e (resultPathVertices , 0 ));
@@ -1866,15 +1810,6 @@ static gboolean _topology_lookupDirectPath(Topology* top, igraph_integer_t srcVe
18661810 found = _topology_findVertexAttributeString (top , dstVertexIndex , VERTEX_ATTR_ID , & dstIDStr );
18671811 utility_assert (found );
18681812
1869- gdouble sourcePacketLoss ;
1870- if (_topology_findVertexAttributeDouble (top , srcVertexIndex , VERTEX_ATTR_PACKETLOSS , & sourcePacketLoss )) {
1871- totalReliability *= (1.0f - sourcePacketLoss );
1872- }
1873- gdouble destPacketLoss ;
1874- if (_topology_findVertexAttributeDouble (top , dstVertexIndex , VERTEX_ATTR_PACKETLOSS , & destPacketLoss )) {
1875- totalReliability *= (1.0f - destPacketLoss );
1876- }
1877-
18781813 gint result = _topology_getEdgeHelper (top , srcVertexIndex , dstVertexIndex , NULL , & edgeLatency , & edgeReliability );
18791814
18801815 if (result != IGRAPH_SUCCESS ) {
@@ -2075,7 +2010,7 @@ static gboolean _topology_findAttachmentVertexHelperHook(Topology* top, igraph_i
20752010 const gchar * citycodeStr = NULL ;
20762011 const gchar * countrycodeStr = NULL ;
20772012
2078- gboolean ipFound = _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP , & ipStr );
2013+ gboolean ipFound = _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP_ADDRESS , & ipStr );
20792014 gboolean citycodeFound = _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_CITYCODE , & citycodeStr );
20802015 gboolean countrycodeFound = _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_COUNTRYCODE , & countrycodeStr );
20812016
@@ -2168,19 +2103,19 @@ static igraph_integer_t* _topology_getLongestPrefixMatch(Topology* top, GQueue*
21682103}
21692104
21702105static igraph_integer_t _topology_findAttachmentVertex (Topology * top , Random * randomSourcePool , in_addr_t nodeIP ,
2171- gchar * ipHint , gchar * citycodeHint , gchar * countrycodeHint ) {
2106+ gchar * ipAddressHint , gchar * citycodeHint , gchar * countrycodeHint ) {
21722107 MAGIC_ASSERT (top );
21732108
21742109 igraph_integer_t vertexIndex = (igraph_integer_t ) - 1 ;
21752110 igraph_integer_t * vertexIndexPtr = GINT_TO_POINTER (-1 );
21762111
21772112 AttachHelper * ah = g_new0 (AttachHelper , 1 );
2178- ah -> ipHint = ipHint ;
2113+ ah -> ipAddressHint = ipAddressHint ;
21792114 ah -> citycodeHint = citycodeHint ;
21802115 ah -> countrycodeHint = countrycodeHint ;
21812116
2182- if (ipHint ) {
2183- in_addr_t ip = address_stringToIP (ipHint );
2117+ if (ipAddressHint ) {
2118+ in_addr_t ip = address_stringToIP (ipAddressHint );
21842119 if (ip != INADDR_NONE && ip != INADDR_ANY && ip != INADDR_LOOPBACK ) {
21852120 ah -> requestedIPIsUsable = TRUE;
21862121 ah -> requestedIP = ip ;
@@ -2213,7 +2148,7 @@ static igraph_integer_t _topology_findAttachmentVertex(Topology* top, Random* ra
22132148 useLongestPrefixMatching = (ah -> requestedIPIsUsable && ah -> numIPsCountry > 0 );
22142149 } else {
22152150 candidates = ah -> candidatesAll ;
2216- useLongestPrefixMatching = (ipHint && ah -> numIPsAll > 0 );
2151+ useLongestPrefixMatching = (ipAddressHint && ah -> numIPsAll > 0 );
22172152 }
22182153
22192154 guint numCandidates = g_queue_get_length (candidates );
@@ -2253,15 +2188,15 @@ static igraph_integer_t _topology_findAttachmentVertex(Topology* top, Random* ra
22532188 return vertexIndex ;
22542189}
22552190
2256- void topology_attach (Topology * top , Address * address , Random * randomSourcePool , gchar * ipHint ,
2257- gchar * citycodeHint , gchar * countrycodeHint , guint64 * bwDownOut ,
2258- guint64 * bwUpOut ) {
2191+ void topology_attach (Topology * top , Address * address , Random * randomSourcePool ,
2192+ gchar * ipAddressHint , gchar * citycodeHint , gchar * countrycodeHint ,
2193+ guint64 * bwDownOut , guint64 * bwUpOut ) {
22592194 MAGIC_ASSERT (top );
22602195 utility_assert (address );
22612196
22622197 in_addr_t nodeIP = address_toNetworkIP (address );
22632198 igraph_integer_t vertexIndex = _topology_findAttachmentVertex (top , randomSourcePool , nodeIP ,
2264- ipHint , citycodeHint , countrycodeHint );
2199+ ipAddressHint , citycodeHint , countrycodeHint );
22652200
22662201 /* attach it, i.e. store the mapping so we can route later */
22672202 g_rw_lock_writer_lock (& (top -> virtualIPLock ));
@@ -2296,7 +2231,7 @@ void topology_attach(Topology* top, Address* address, Random* randomSourcePool,
22962231
22972232 /* these may fail and not set the string value if the vertex does not have the attribute.
22982233 * that's ok though, glib will print null in its place in the format string below. */
2299- _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP , & ipStr );
2234+ _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_IP_ADDRESS , & ipStr );
23002235 _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_CITYCODE , & citycodeStr );
23012236 _topology_findVertexAttributeString (top , vertexIndex , VERTEX_ATTR_COUNTRYCODE , & countrycodeStr );
23022237
@@ -2306,7 +2241,7 @@ void topology_attach(Topology* top, Address* address, Random* randomSourcePool,
23062241 "with attributes (ip=%s, citycode=%s, countrycode=%s) "
23072242 "using hints (ip=%s, citycode=%s, countrycode=%s)" ,
23082243 address_toHostIPString (address ), (glong )vertexIndex , idStr , ipStr , citycodeStr ,
2309- countrycodeStr , ipHint , citycodeHint , countrycodeHint );
2244+ countrycodeStr , ipAddressHint , citycodeHint , countrycodeHint );
23102245}
23112246
23122247void topology_detach (Topology * top , Address * address ) {
0 commit comments