Skip to content

Commit dd0b660

Browse files
committed
Bgp: rename identifiers to the INET naming convention
Cosmetic, behavior-preserving cleanup; all 8 bgpv4 fingerprints unchanged. - Acronyms in method names take only a leading capital (Tcp/Bgp/Ip/Fsm/Id): openTCPConnectionToPeer -> openTcpConnectionToPeer, processMessageFromTCP -> processMessageFromTcp, getBGPRoutingTable -> getBgpRoutingTable, deleteBGPRoutingEntry -> deleteBgpRoutingEntry, getIPRoutingTable -> getIpRoutingTable, getFSM -> getFsm, getSessionID -> getSessionId. - BgpHeader.msg fields BGPIdentifier -> bgpIdentifier and NLRI -> nlri (and the accessors/locals they drive: getBgpIdentifier, getNlri, ...). - The get-prefixed forwarders in BgpRouter that are not getters become plain forwarders: getScheduleAt/getCancelEvent/getCancelAndDelete -> scheduleAt/cancelEvent/cancelAndDelete. "AS" (autonomous system) is deliberately left uppercase (getMyAS, getASCount, isInASList, the myAS field, ...) -- folding it to "As" reads worse than the acronym. The shared getIPAddress() network-layer API is out of scope (not BGP-owned; called from ~40 files across other protocols).
1 parent 71c2819 commit dd0b660

8 files changed

Lines changed: 81 additions & 81 deletions

File tree

src/inet/routing/bgpv4/Bgp.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void Bgp::handleMessageWhenUp(cMessage *msg)
7979
else if (msg->isSelfMessage()) // BGP level
8080
handleTimer(msg);
8181
else if (!strcmp(msg->getArrivalGate()->getName(), "socketIn")) // TCP level
82-
bgpRouter->processMessageFromTCP(msg);
82+
bgpRouter->processMessageFromTcp(msg);
8383
else
8484
delete msg;
8585
}
@@ -163,22 +163,22 @@ void Bgp::handleTimer(cMessage *timer)
163163
switch (timer->getKind()) {
164164
case START_EVENT_KIND:
165165
EV_INFO << "Processing Start Event" << std::endl;
166-
pSession->getFSM()->ManualStart();
166+
pSession->getFsm()->ManualStart();
167167
break;
168168

169169
case CONNECT_RETRY_KIND:
170170
EV_INFO << "Expiring Connect Retry Timer" << std::endl;
171-
pSession->getFSM()->ConnectRetryTimer_Expires();
171+
pSession->getFsm()->ConnectRetryTimer_Expires();
172172
break;
173173

174174
case HOLD_TIME_KIND:
175175
EV_INFO << "Expiring Hold Timer" << std::endl;
176-
pSession->getFSM()->HoldTimer_Expires();
176+
pSession->getFsm()->HoldTimer_Expires();
177177
break;
178178

179179
case KEEP_ALIVE_KIND:
180180
EV_INFO << "Expiring Keep Alive timer" << std::endl;
181-
pSession->getFSM()->KeepaliveTimer_Expires();
181+
pSession->getFsm()->KeepaliveTimer_Expires();
182182
break;
183183

184184
default:

src/inet/routing/bgpv4/BgpFsm.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void Idle::ManualStart()
3636
// - listens for a connection that may be initiated by the remote BGP peer,
3737
session.listenConnectionFromPeer();
3838
// - initiates a TCP connection to the other BGP peer and,
39-
session.openTCPConnectionToPeer();
39+
session.openTcpConnectionToPeer();
4040
// - changes its state to Connect.
4141
setState<Connect>();
4242
}
@@ -53,7 +53,7 @@ void Connect::ConnectRetryTimer_Expires()
5353
session.stopConnectRetryTimer();
5454
// - initiates a TCP connection to the other BGP peer,
5555
// session._info.socket->renewSocket();
56-
session.openTCPConnectionToPeer();
56+
session.openTcpConnectionToPeer();
5757
// - continues to listen for a connection that may be initiated by the remote BGP peer, and
5858
// - stays in the Connect state.
5959
setState<Connect>();
@@ -136,7 +136,7 @@ void Active::ConnectRetryTimer_Expires()
136136
session.stopConnectRetryTimer();
137137
// - initiates a TCP connection to the other BGP peer,T);
138138
// session._info.socket->renewSocket();
139-
session.openTCPConnectionToPeer();
139+
session.openTcpConnectionToPeer();
140140
// - continues to listen for a TCP connection that may be initiated by a remote BGP peer, and
141141
// - changes its state to Connect.
142142
setState<Connect>();
@@ -412,7 +412,7 @@ void Established::entry()
412412
// if it's an IGP Session, send update message with only the BGP routes learned by EGP
413413

414414
if (session.getType() == EGP) {
415-
auto IPRoutingTable = session.getIPRoutingTable();
415+
auto IPRoutingTable = session.getIpRoutingTable();
416416
for (int i = 0; i < IPRoutingTable->getNumRoutes(); i++) {
417417
const Ipv4Route *rtEntry = IPRoutingTable->getRoute(i);
418418
if (session.isRouteExcluded(*rtEntry))
@@ -424,7 +424,7 @@ void Established::entry()
424424
}
425425
}
426426

427-
for (auto& elem : session.getBGPRoutingTable())
427+
for (auto& elem : session.getBgpRoutingTable())
428428
session.updateSendProcess(elem);
429429

430430
// when all EGP Sessions are in established state, start IGP Session(s)

src/inet/routing/bgpv4/BgpRouter.cc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void BgpRouter::setRedistributeOspf(std::string str)
287287
}
288288
}
289289

290-
void BgpRouter::processMessageFromTCP(cMessage *msg)
290+
void BgpRouter::processMessageFromTcp(cMessage *msg)
291291
{
292292
TcpSocket *socket = check_and_cast_nullable<TcpSocket *>(_socketMap.findSocketFor(msg));
293293
if (!socket) {
@@ -340,7 +340,7 @@ void BgpRouter::processMessageFromTCP(cMessage *msg)
340340
void BgpRouter::listenConnectionFromPeer(SessionId sessionID)
341341
{
342342
// Ensure the single shared listening socket is up. One wildcard listener per router
343-
// accepts all incoming BGP connections on TCP_PORT; processMessageFromTCP() demuxes
343+
// accepts all incoming BGP connections on TCP_PORT; processMessageFromTcp() demuxes
344344
// accepted connections to the right session by peer address. This replaces the former
345345
// per-session listeners, which collided on the shared wildcard port when several
346346
// sessions reconnected at once (see plan §4 Phase 0 result).
@@ -364,7 +364,7 @@ void BgpRouter::listenConnectionFromPeer(SessionId sessionID)
364364
}
365365
}
366366

367-
void BgpRouter::openTCPConnectionToPeer(SessionId sessionID)
367+
void BgpRouter::openTcpConnectionToPeer(SessionId sessionID)
368368
{
369369
EV_DEBUG << "Opening a TCP connection to "
370370
<< _BGPSessions[sessionID]->getPeerAddr()
@@ -423,10 +423,10 @@ void BgpRouter::socketEstablished(TcpSocket *socket)
423423
if (_BGPSessions[_currSessionId]->getType() == IGP &&
424424
this->findNextSession(EGP) != static_cast<SessionId>(-1))
425425
{
426-
_BGPSessions[_currSessionId]->getFSM()->TcpConnectionFails();
426+
_BGPSessions[_currSessionId]->getFsm()->TcpConnectionFails();
427427
}
428428
else {
429-
_BGPSessions[_currSessionId]->getFSM()->TcpConnectionConfirmed();
429+
_BGPSessions[_currSessionId]->getFsm()->TcpConnectionConfirmed();
430430
}
431431
// Note: the shared listening socket is intentionally left listening (it is not a
432432
// per-session resource and must stay up to accept connections for other sessions).
@@ -437,7 +437,7 @@ void BgpRouter::socketFailure(TcpSocket *socket, int code)
437437
int connId = socket->getSocketId();
438438
_currSessionId = findIdFromSocketConnId(_BGPSessions, connId);
439439
if (_currSessionId != static_cast<SessionId>(-1)) {
440-
_BGPSessions[_currSessionId]->getFSM()->TcpConnectionFails();
440+
_BGPSessions[_currSessionId]->getFsm()->TcpConnectionFails();
441441
}
442442
}
443443

@@ -447,7 +447,7 @@ void BgpRouter::socketPeerClosed(TcpSocket *socket)
447447
int connId = socket->getSocketId();
448448
_currSessionId = findIdFromSocketConnId(_BGPSessions, connId);
449449
if (_currSessionId != static_cast<SessionId>(-1))
450-
_BGPSessions[_currSessionId]->getFSM()->TcpConnectionFails();
450+
_BGPSessions[_currSessionId]->getFsm()->TcpConnectionFails();
451451
}
452452

453453
void BgpRouter::socketDataArrived(TcpSocket *socket)
@@ -495,7 +495,7 @@ void BgpRouter::processMessage(const BgpOpenMessage& msg)
495495
<< session->getPeerAddr().str(false)
496496
<< " with contents: \n";
497497
printOpenMessage(msg);
498-
session->getFSM()->OpenMsgEvent();
498+
session->getFsm()->OpenMsgEvent();
499499
}
500500

501501
void BgpRouter::processMessage(const BgpKeepAliveMessage& msg)
@@ -505,7 +505,7 @@ void BgpRouter::processMessage(const BgpKeepAliveMessage& msg)
505505
<< session->getPeerAddr().str(false)
506506
<< " with contents: \n";
507507
printKeepAliveMessage(msg);
508-
session->getFSM()->KeepAliveMsgEvent();
508+
session->getFsm()->KeepAliveMsgEvent();
509509
}
510510

511511
void BgpRouter::processMessage(const BgpUpdateMessage& msg)
@@ -515,14 +515,14 @@ void BgpRouter::processMessage(const BgpUpdateMessage& msg)
515515
<< session->getPeerAddr().str(false)
516516
<< " with contents: \n";
517517
printUpdateMessage(msg);
518-
session->getFSM()->UpdateMsgEvent();
518+
session->getFsm()->UpdateMsgEvent();
519519

520520
BgpRoutingTableEntry *entry = new BgpRoutingTableEntry();
521521
entry->setLocalPreference(bgpModule->par("localPreference").intValue());
522-
entry->setDestination(msg.getNLRI(0).prefix);
522+
entry->setDestination(msg.getNlri(0).prefix);
523523

524524
Ipv4Address netMask(Ipv4Address::ALLONES_ADDRESS);
525-
netMask = Ipv4Address::makeNetmask(msg.getNLRI(0).length);
525+
netMask = Ipv4Address::makeNetmask(msg.getNlri(0).length);
526526
entry->setNetmask(netMask);
527527

528528
for (size_t i = 0; i < msg.getPathAttributesArraySize(); i++) {
@@ -688,22 +688,22 @@ BgpProcessResult BgpRouter::decisionProcess(const BgpUpdateMessage& msg, BgpRout
688688
bool BgpRouter::tieBreakingProcess(BgpRoutingTableEntry *oldEntry, BgpRoutingTableEntry *entry)
689689
{
690690
if (entry->getLocalPreference() > oldEntry->getLocalPreference()) {
691-
deleteBGPRoutingEntry(oldEntry);
691+
deleteBgpRoutingEntry(oldEntry);
692692
return false;
693693
}
694694

695695
/* Remove from consideration all routes that are not tied for
696696
having the smallest number of AS numbers present in their
697697
AS_PATH attributes.*/
698698
if (entry->getASCount() < oldEntry->getASCount()) {
699-
deleteBGPRoutingEntry(oldEntry);
699+
deleteBgpRoutingEntry(oldEntry);
700700
return false;
701701
}
702702

703703
/* Remove from consideration all routes that are not tied for
704704
having the lowest Origin number in their Origin attribute.*/
705705
if (entry->getPathType() < oldEntry->getPathType()) {
706-
deleteBGPRoutingEntry(oldEntry);
706+
deleteBgpRoutingEntry(oldEntry);
707707
return false;
708708
}
709709

@@ -745,7 +745,7 @@ void BgpRouter::updateSendProcess(BgpProcessResult type, SessionId sessionIndex,
745745
type == ROUTE_DESTINATION_CHANGED ||
746746
type == NEW_SESSION_ESTABLISHED)
747747
{
748-
BgpUpdateNlri NLRI;
748+
BgpUpdateNlri nlri;
749749
std::vector<BgpUpdatePathAttributes *> content;
750750

751751
unsigned int nbAS = entry->getASCount();
@@ -798,10 +798,10 @@ void BgpRouter::updateSendProcess(BgpProcessResult type, SessionId sessionIndex,
798798
originAttr->setValue((BgpSessionType)entry->getPathType());
799799

800800
Ipv4Address netMask = entry->getNetmask();
801-
NLRI.prefix = entry->getDestination().doAnd(netMask);
802-
NLRI.length = (unsigned char)netMask.getNetmaskLength();
801+
nlri.prefix = entry->getDestination().doAnd(netMask);
802+
nlri.length = (unsigned char)netMask.getNetmaskLength();
803803

804-
(elem).second->sendUpdateMessage(content, NLRI);
804+
(elem).second->sendUpdateMessage(content, nlri);
805805
}
806806
}
807807
}
@@ -811,7 +811,7 @@ void BgpRouter::updateSendProcess(BgpProcessResult type, SessionId sessionIndex,
811811
* Side effects when returns true:
812812
* bgpRoutingTable changed, iterators on bgpRoutingTable will be invalid.
813813
*/
814-
bool BgpRouter::deleteBGPRoutingEntry(BgpRoutingTableEntry *entry)
814+
bool BgpRouter::deleteBgpRoutingEntry(BgpRoutingTableEntry *entry)
815815
{
816816
for (auto it = bgpRoutingTable.begin();
817817
it != bgpRoutingTable.end(); it++)
@@ -927,7 +927,7 @@ void BgpRouter::printOpenMessage(const BgpOpenMessage& openMsg)
927927
{
928928
EV_INFO << " My AS: " << openMsg.getMyAS() << "\n";
929929
EV_INFO << " Hold time: " << openMsg.getHoldTime() << "s \n";
930-
EV_INFO << " BGP Id: " << openMsg.getBGPIdentifier() << "\n";
930+
EV_INFO << " BGP Id: " << openMsg.getBgpIdentifier() << "\n";
931931
if (openMsg.getOptionalParameterArraySize() == 0)
932932
EV_INFO << " Optional parameters: empty \n";
933933
for (size_t i = 0; i < openMsg.getOptionalParameterArraySize(); i++) {
@@ -1000,11 +1000,11 @@ void BgpRouter::printUpdateMessage(const BgpUpdateMessage& updateMsg)
10001000
}
10011001
}
10021002

1003-
if (updateMsg.getNLRIArraySize() > 0) {
1004-
auto NLRI_Base = updateMsg.getNLRI(0);
1003+
if (updateMsg.getNlriArraySize() > 0) {
1004+
auto nlriBase = updateMsg.getNlri(0);
10051005
EV_INFO << " Network Layer Reachability Information (NLRI): \n";
1006-
EV_INFO << " NLRI length: " << (int)NLRI_Base.length << "\n";
1007-
EV_INFO << " NLRI prefix: " << NLRI_Base.prefix << "\n";
1006+
EV_INFO << " NLRI length: " << (int)nlriBase.length << "\n";
1007+
EV_INFO << " NLRI prefix: " << nlriBase.prefix << "\n";
10081008
}
10091009
}
10101010

src/inet/routing/bgpv4/BgpRouter.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
4444
SocketMap _socketMap;
4545
// A single shared listening socket per router accepts all incoming BGP connections
4646
// on TCP_PORT (wildcard bind) and demuxes them to sessions by peer address in
47-
// processMessageFromTCP(). RFC 4271: a BGP speaker listens for connections on port 179.
47+
// processMessageFromTcp(). RFC 4271: a BGP speaker listens for connections on port 179.
4848
TcpSocket *listeningSocket = nullptr;
4949
SessionId _currSessionId = 0;
5050
std::map<SessionId, BgpSession *> _BGPSessions;
@@ -95,7 +95,7 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
9595
void setNextHopSelf(Ipv4Address peer, bool nextHopSelf);
9696
void setLocalPreference(Ipv4Address peer, int localPref);
9797
bool isExternalAddress(const Ipv4Route& rtEntry);
98-
void processMessageFromTCP(cMessage *msg);
98+
void processMessageFromTcp(cMessage *msg);
9999

100100
void printOpenMessage(const BgpOpenMessage& msg);
101101
void printUpdateMessage(const BgpUpdateMessage& msg);
@@ -118,11 +118,11 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
118118

119119
friend class BgpSession;
120120
// functions used by the BgpSession class
121-
void getScheduleAt(simtime_t t, cMessage *msg) { bgpModule->scheduleAt(t, msg); }
122-
void getCancelAndDelete(cMessage *msg) { bgpModule->cancelAndDelete(msg); }
123-
cMessage *getCancelEvent(cMessage *msg) { return bgpModule->cancelEvent(msg); }
124-
IIpv4RoutingTable *getIPRoutingTable() { return rt; }
125-
std::vector<BgpRoutingTableEntry *> getBGPRoutingTable() { return bgpRoutingTable; }
121+
void scheduleAt(simtime_t t, cMessage *msg) { bgpModule->scheduleAt(t, msg); }
122+
void cancelAndDelete(cMessage *msg) { bgpModule->cancelAndDelete(msg); }
123+
cMessage *cancelEvent(cMessage *msg) { return bgpModule->cancelEvent(msg); }
124+
IIpv4RoutingTable *getIpRoutingTable() { return rt; }
125+
std::vector<BgpRoutingTableEntry *> getBgpRoutingTable() { return bgpRoutingTable; }
126126

127127
/**
128128
* \brief active listenSocket for a given session (used by fsm)
@@ -131,7 +131,7 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
131131
/**
132132
* \brief active TcpConnection for a given session (used by fsm)
133133
*/
134-
void openTCPConnectionToPeer(SessionId sessionID);
134+
void openTcpConnectionToPeer(SessionId sessionID);
135135
/**
136136
* \brief RFC 4271, 9.2 : Update-Send Process / Sent or not new UPDATE messages to its peers
137137
*/
@@ -148,7 +148,7 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
148148
void processMessage(const BgpKeepAliveMessage& msg);
149149
void processMessage(const BgpUpdateMessage& msg);
150150

151-
bool deleteBGPRoutingEntry(BgpRoutingTableEntry *entry);
151+
bool deleteBgpRoutingEntry(BgpRoutingTableEntry *entry);
152152

153153
/**
154154
* \brief RFC 4271: 9.1. : Decision Process used when an UPDATE message is received

0 commit comments

Comments
 (0)