Changeset 8569 for source/ariba/communication/networkinfo
- Timestamp:
- Sep 21, 2010, 3:57:26 PM (14 years ago)
- Location:
- source/ariba/communication/networkinfo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/networkinfo/NetworkChangeDetection.cpp
r6930 r8569 196 196 } 197 197 198 // somehow all notifications with pid=0 are 199 // invalid and occur much too often 200 if(header->nlmsg_pid == 0) continue; 201 198 202 // 199 203 // here we evaluate the routing netlink message. for, the following 200 204 // messages are of interest: 201 // RTM_NEWLINK, RTM_DELLINK -> interface up/down202 205 // RTM_NEWADDR, RTM_DELADDR -> new address on iface, address deleted from iface 203 // not interesting are:204 // RTM_GETLINK, RTM_GETADDR205 // RTM_NEWROUTE, RTM_DELROUTE, RTM_GETROUTE206 206 // 207 207 … … 209 209 210 210 switch( header->nlmsg_type ){ 211 212 //213 // handle network interface up/down notifications214 // --> link layer notifications215 //216 217 case RTM_NEWLINK:218 case RTM_DELLINK:219 220 changeInfo = obj->extractInterfaceEvent( header );221 break;222 211 223 212 // … … 257 246 } 258 247 259 NetworkChangeInterface::NetworkChangeInfo NetworkChangeDetection::extractInterfaceEvent(struct nlmsghdr* header){260 NetworkChangeInterface::NetworkChangeInfo changeInfo;261 262 //263 // handle network interface up/down notifications264 // the differentiation between up/down is _not_265 // made using new/del-link in the message!266 //267 268 if( header->nlmsg_type == RTM_NEWLINK ){269 logging_debug("network change message RTM_NEWLINK");270 }else if( header->nlmsg_type == RTM_DELLINK ){271 logging_debug("network change message RTM_DELLINK");272 }273 274 if( header->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg)) ){275 logging_error( "netlink packet soo small for ifinfomsg" );276 return changeInfo;277 }278 279 //280 // get the interface index and through this281 // further information about the interface282 //283 284 struct ifinfomsg* detailIface = (struct ifinfomsg*)NLMSG_DATA(header);285 changeInfo.interface = networkInformation.getInterface( detailIface->ifi_index );286 287 //288 // check whether device is now up or down289 //290 291 if( changeInfo.interface.isUp && changeInfo.interface.isRunning )292 changeInfo.type = NetworkChangeInterface::EventTypeInterfaceUp;293 else294 changeInfo.type = NetworkChangeInterface::EventTypeInterfaceDown;295 296 297 return changeInfo;298 }299 300 248 NetworkChangeInterface::NetworkChangeInfo NetworkChangeDetection::extractAddressEvent(struct nlmsghdr* header){ 301 249 NetworkChangeInterface::NetworkChangeInfo changeInfo; … … 308 256 if( header->nlmsg_type == RTM_NEWADDR ){ 309 257 logging_debug("network change message RTM_NEWADDR"); 310 changeInfo.type = NetworkChangeInterface::EventType AddressNew;258 changeInfo.type = NetworkChangeInterface::EventTypeInterfaceUp; 311 259 }else if( header->nlmsg_type == RTM_DELADDR ){ 312 260 logging_debug("network change message RTM_DELADDR"); 313 changeInfo.type = NetworkChangeInterface::EventType AddressDelete;261 changeInfo.type = NetworkChangeInterface::EventTypeInterfaceDown; 314 262 } 315 263 -
source/ariba/communication/networkinfo/NetworkChangeDetection.h
r6919 r8569 100 100 NetworkInformation networkInformation; 101 101 102 NetworkChangeInterface::NetworkChangeInfo extractInterfaceEvent( struct nlmsghdr* header );103 102 NetworkChangeInterface::NetworkChangeInfo extractAddressEvent( struct nlmsghdr* header ); 104 103 }; -
source/ariba/communication/networkinfo/NetworkChangeInterface.h
r3690 r8569 55 55 56 56 typedef enum _EventType { 57 EventTypeInvalid, // INVALID57 EventTypeInvalid, // INVALID 58 58 EventTypeInterfaceUp, // network interface came up 59 59 EventTypeInterfaceDown, // network interface went down 60 EventTypeAddressNew, // new network address configured61 EventTypeAddressDelete, // network address deleted62 60 } EventType; 63 61 64 62 static string eventString(EventType ev){ 65 63 switch( ev ){ 66 case EventTypeInvalid: return "invalid type";67 case EventTypeInterfaceUp: return "interface up";64 case EventTypeInvalid: return "invalid type"; 65 case EventTypeInterfaceUp: return "interface up"; 68 66 case EventTypeInterfaceDown: return "interface down"; 69 case EventTypeAddressNew: return "new address"; 70 case EventTypeAddressDelete: return "deleted address"; 71 default: return "unknown event"; 67 default: return "unknown event"; 72 68 } 73 69 }
Note:
See TracChangeset
for help on using the changeset viewer.