(pat) 5-25: Allow the config neighbor list to optionally include a port. (pat) Neighbor discovery should be moved into SR. Each BTS should register, then when they want to look up a LAC reported by the MS they could just ask SR.
| 75 | // (pat) Neighbor discovery should be moved into SR. Each BTS should register, |
| 76 | // then when they want to look up a LAC reported by the MS they could just ask SR. |
| 77 | void NeighborTable::fill() |
| 78 | { |
| 79 | mConfigured.clear(); |
| 80 | if (mDB == NULL) { return; } // we already threw an ALERT. |
| 81 | // Stuff the neighbor ip addresses into the table without any other info. |
| 82 | // Let existing information persist for current neighbors. |
| 83 | // NeighborTable::refresh() will get updated infomation when it's available. |
| 84 | vector<string> neighbors = gConfig.getVectorOfStrings("GSM.Neighbors"); |
| 85 | LOG(DEBUG) << "neighbor list length " << neighbors.size(); |
| 86 | unsigned short port = gConfig.getNum("Peering.Port"); |
| 87 | for (unsigned int i = 0; i < neighbors.size(); i++) { |
| 88 | struct sockaddr_in address; |
| 89 | // (pat) The measurement report allows only 32 ARFCN slots, the last of which we reserve for 3G to avoid confusion. |
| 90 | // However, we cannot check that here, because some of the neighbors may share ARFCNs, and we cannot tell |
| 91 | // that until they report in. |
| 92 | // Do not check this here: if (i == 31) ... |
| 93 | const char *host = neighbors[i].c_str(); |
| 94 | LOG(DEBUG) << "resolving host name for " << host; |
| 95 | bool validAddr; |
| 96 | if (includesPort(host)) { |
| 97 | LOG(DEBUG) << "resolving host name for " << host; |
| 98 | validAddr = resolveAddress(&address, host); |
| 99 | } else { |
| 100 | LOG(DEBUG) << "resolving host name for " << host <<" + port:" <<port; |
| 101 | validAddr = resolveAddress(&address, host, port); |
| 102 | } |
| 103 | if (!validAddr) { |
| 104 | LOG(CRIT) << "cannot resolve host name for " << host; |
| 105 | // these two seem to want to get set even if addNeighbor isn't called |
| 106 | mBCCSet = getBCCSet(); |
| 107 | mARFCNList = getARFCNs(); |
| 108 | continue; |
| 109 | } |
| 110 | addNeighbor(&address); |
| 111 | } |
| 112 | // get a list of ipaddresses in neighbor table that aren't configured |
| 113 | vector<string> toBeDeleted; |
| 114 | sqlite3_stmt *stmt; |
| 115 | const char *query = "SELECT IPADDRESS FROM NEIGHBOR_TABLE"; |
| 116 | if (sqlite3_prepare_statement(mDB,&stmt,query)) { |
| 117 | LOG(ALERT) << "read of neighbor table failed: " << query; |
| 118 | return; |
| 119 | } |
| 120 | int src = sqlite3_step(stmt); |
| 121 | while (src==SQLITE_ROW) { |
| 122 | const char* ipaddress = (const char*)sqlite3_column_text(stmt,0); |
| 123 | if (!ipaddress) { |
| 124 | LOG(ALERT) << "null address in neighbor table"; |
| 125 | src = sqlite3_step(stmt); |
| 126 | continue; |
| 127 | } |
| 128 | if (mConfigured.find(ipaddress) == mConfigured.end()) { |
| 129 | toBeDeleted.push_back(ipaddress); |
| 130 | } |
| 131 | src = sqlite3_step(stmt); |
| 132 | } |
| 133 | sqlite3_finalize(stmt); |
| 134 | // remove entries in neighbor table that aren't configured |