/* This function is invoked by a node with hop count = 1.
 * This function creates an Path Establishment Answer packet and, using other
 * functions it sends
 * the packet back.
 */
void
SunIPRoutingNode::answerPath(const Packet *p_old)
{
	if (STACK_TRACE)
		cout << "> answerPath()" << endl;
	// This node is a node with hop count = 1. Checks anyway for errors.
	// The packet p_old is removed by the method that invokes this one.
	if (this->getNumberOfHopToSink() == 1) {
		Packet *p_answer = Packet::alloc();
		this->initPktPathEstAnswer(p_answer, p_old);
		hdr_cmn *ch_answer = HDR_CMN(p_answer);
		hdr_uwip *iph = HDR_UWIP(p_answer);
		hdr_sun_path_est *hpest = HDR_SUN_PATH_EST(p_answer);
		if (printDebug_ > 10)
			cout << "@" << Scheduler::instance().clock()
				 << " -> N: " << this->printIP(ipAddr_)
				 << " - CP: " << ch_answer->uid()
				 << " - Answer Path sent. Hop Count: "
				 << (hpest->list_of_hops_length() + 1)
				 << " (destination: " << printIP(iph->daddr()) << ")." << endl;
		number_of_pathestablishment_++;
		if (trace_)
			this->tracePacket(p_answer, "SEND_PTH");
		sendDown(p_answer, this->getDelay(period_status_));
		return;
	} else {
		return;
	}
} /* SunIPRoutingNode::answerPath */
int dhcpInit()
{
   Serial.println("getting ip address with DHCP...");
   int result = Dhcp.beginWithDHCP(mac);
   
   if(result == 1)
   {
      byte buffer[4];   
   
      Dhcp.getLocalIp(buffer);
      Serial.print("IP address: ");
      printIP(&Serial, buffer );
      Serial.println("");
    
      Dhcp.getSubnetMask(buffer);
      Serial.print("subnet mask: ");
      printIP(&Serial, buffer );
      Serial.println("");
    
      Dhcp.getGatewayIp(buffer);
      Serial.print("gateway : ");
      printIP(&Serial, buffer );
      Serial.println("");
    
      Dhcp.getDnsServerIp(buffer);
      Serial.print("dns server ip: ");
      printIP(&Serial, buffer );
      Serial.println("");
    
      delay(2000);
   }
   else
   {
      Serial.println("DHCP failed");  
   }
  
   Serial.println("");
   return result;
}
/* This function is invoked by the node that requested a Search Path.
 * The function accepts in input a packet path establishment with a full queue
 * of paths. Compare it with the previous saved, if it exists, and decide which
 * is the better one.
 * It returns the current value of num_hop_to_sink.
 */
const int &
SunIPRoutingNode::evaluatePath(const Packet *p)
{
	if (STACK_TRACE)
		cout << "> evaluatePath()" << endl;
	hdr_cmn *ch = HDR_CMN(p);
	hdr_uwip *iph = HDR_UWIP(p);
	hdr_sun_path_est *hpest = HDR_SUN_PATH_EST(p);

	if (metrics_ == HOPCOUNT) {
		int tmp_metric_ = hpest->list_of_hops_length();
		if (tmp_metric_ > 0) { // There is at least one hop in the path.
			if (((this->getNumberOfHopToSink() == 0) ||
						(this->getNumberOfHopToSink() > tmp_metric_ + 1)) &&
					this->getNumberOfHopToSink() !=
							1) { // New best route. +1 because of the final hop.
				this->clearHops();
				this->setNumberOfHopToSink(0);
				//                cout << "----> " << printIP(ipAddr_) << endl;
				for (int i = 0; i < hpest->list_of_hops_length(); i++) {
					hop_table[i] = hpest->list_of_hops()[i];
					//                    cout << "hop_table[i].ip_ = " <<
					//                    printIP(hop_table[i]) << endl;
				}
				quality_link = tmp_metric_ + 1;
				sink_associated = hpest->sinkAssociated();
				hop_table_length = hpest->list_of_hops_length();
				this->setNumberOfHopToSink(hop_table_length +
						1); // The value to reach the node connected to the sink
							// + 1 (node-node with hc 1-sink)
				if (printDebug_ > 5)
					cout << "@" << Scheduler::instance().clock()
						 << " -> N: " << this->printIP(ipAddr_)
						 << " - CP: " << ch->uid()
						 << " - New best Route. The new Hop Count is: "
						 << this->getNumberOfHopToSink()
						 << " (final hop: " << printIP(iph->saddr()) << ")."
						 << endl;
				rmhopTableTmr_.resched(timer_route_validity_);
				ack_warnings_counter_ = 0;
				ack_error_state = false;
			}
			return this->getNumberOfHopToSink();
		} else {
			return this->getNumberOfHopToSink();
		}
	} else if (metrics_ == SNR) {
		double tmp_metric_ = hpest->quality();
		if (hpest->list_of_hops_length() >
				0) { // There is at least one hop in the path.
			if (this->isZero(quality_link) || (quality_link < tmp_metric_) ||
					(this->getNumberOfHopToSink() == 0)) {
				this->clearHops();
				this->setNumberOfHopToSink(0);
				for (int i = 0; i < hpest->list_of_hops_length(); i++) {
					hop_table[i] = hpest->list_of_hops()[i];
					//                    cout << "hop[" << i << "]: " <<
					//                    printIP(hop_table[i].ip_) << endl;
				}
				quality_link = tmp_metric_;
				sink_associated = hpest->sinkAssociated();
				hop_table_length = hpest->list_of_hops_length();
				this->setNumberOfHopToSink(hop_table_length +
						1); // The value to reach the node connected to the sink
							// + 1 (node-node with hc 1-sink)
				if (printDebug_ > 5)
					cout << "@" << Scheduler::instance().clock()
						 << " -> N: " << this->printIP(ipAddr_)
						 << " - CP: " << ch->uid()
						 << " - New best Route. The new Hop Count is: "
						 << this->getNumberOfHopToSink()
						 << ", with an SNR of: " << quality_link
						 << "dB (final hop: " << printIP(iph->saddr()) << ")."
						 << endl;
				rmhopTableTmr_.resched(timer_route_validity_);
				ack_warnings_counter_ = 0;
				ack_error_state = false;
			}
			return this->getNumberOfHopToSink();
		} else {
			return this->getNumberOfHopToSink();
		}
	} else if (metrics_ == LESSCONGESTED) {
		double tmp_metric_ = hpest->quality() / hpest->list_of_hops_length();
		if (hpest->list_of_hops_length() >
				0) { // There is at least one hop in the path.
			if (this->isZero(quality_link) || (quality_link > tmp_metric_) ||
					(this->getNumberOfHopToSink() == 0)) {
				this->clearHops();
				this->setNumberOfHopToSink(0);
				for (int i = 0; i < hpest->list_of_hops_length(); i++) {
					hop_table[i] = hpest->list_of_hops()[i];
					//                    cout << "hop[" << i << "]: " <<
					//                    printIP(hop_table[i].ip_) << endl;
				}
				quality_link = tmp_metric_;
				sink_associated = hpest->sinkAssociated();
				hop_table_length = hpest->list_of_hops_length();
				this->setNumberOfHopToSink(hop_table_length +
						1); // The value to reach the node connected to the sink
							// + 1 (node-node with hc 1-sink)
				if (printDebug_ > 5)
					cout << "@" << Scheduler::instance().clock()
						 << " -> N: " << this->printIP(ipAddr_)
						 << " - CP: " << ch->uid()
						 << " - New best Route. The new Hop Count is: "
						 << this->getNumberOfHopToSink()
						 << ", with a load of: " << quality_link
						 << " (final hop: " << printIP(iph->saddr()) << ")."
						 << endl;
				rmhopTableTmr_.resched(timer_route_validity_);
				ack_warnings_counter_ = 0;
				ack_error_state = false;
			}
			return this->getNumberOfHopToSink();
		} else {
			return this->getNumberOfHopToSink();
		}
	} else {
		exit(1);
	}
} /* SunIPRoutingNode::evaluatePath */
/* This function receives a Path Establishment Answer Packet and checks
 * if the IP of the current node is in the list.
 * If no it drops the packet, otherwise it sends to the previous node the
 * packet,
 * and adds the information about the route in its the routing table.
 * Returns 0 if it drops the packet, 1 if it sends back the packet.
 */
void
SunIPRoutingNode::sendRouteBack(Packet *p)
{
	if (STACK_TRACE)
		cout << "> sendRouteBack()" << endl;
	hdr_cmn *ch = HDR_CMN(p);
	hdr_uwip *iph = HDR_UWIP(p);
	hdr_sun_path_est *hpest = HDR_SUN_PATH_EST(p);

	if (hpest->ptype() ==
			PATH_ANSWER) { // This function processes only PATH_ANSWER packets
		if (hpest->list_of_hops_length() == 0) {
			drop(p, 1, DROP_PATH_ESTABLISHMENT_ANSWER_PACKET_GARBAGE);
			return;
		} else {
			short j_ = hpest->pointer();
			if (hpest->list_of_hops()[j_] ==
					ipAddr_) { // The current node is the right next hop.
				// Update the hop table of the current node only if the node
				// receives a new best path or it doesn't have any path.
				/* The number of hops from the node to the sink are:
				 * list_of_hops_length - 1 + pointer + 1 = list_of_hops_length -
				 * pointer
				 */
				if (metrics_ == HOPCOUNT) {
					if (((hpest->list_of_hops_length() - hpest->pointer()) <=
								this->getNumberOfHopToSink()) ||
							(this->getNumberOfHopToSink() ==
									0)) { // Attention: the pointer is a
										  // decreasing value.
						// Reset of the routing information.
						this->clearHops();
						this->setNumberOfHopToSink(0);
						// Update the routing table of the current node.
						for (int i = j_ + 1, w = 0;
								i < hpest->list_of_hops_length();
								i++, w++) {
							hop_table[w] = hpest->list_of_hops()[i];
						}
						hop_table_length = hpest->list_of_hops_length() -
								hpest->pointer() - 1;
						this->setNumberOfHopToSink(hop_table_length + 1);
						sink_associated = hpest->sinkAssociated();
						rmhopTableTmr_.resched(timer_route_validity_);
						ack_warnings_counter_ = 0;
						ack_error_state = false;
					}
				} else if (metrics_ == SNR) {
					double tmp_ = hpest->quality();
					if (this->isZero(quality_link) || (quality_link < tmp_) ||
							(this->getNumberOfHopToSink() == 0)) {
						// Reset of the routing information.
						this->clearHops();
						this->setNumberOfHopToSink(0);
						// Update the routing table of the current node.
						for (int i = j_ + 1, w = 0;
								i < hpest->list_of_hops_length();
								i++, w++) {
							hop_table[w] = hpest->list_of_hops()[i];
						}
						hop_table_length = hpest->list_of_hops_length() -
								hpest->pointer() - 1;
						this->setNumberOfHopToSink(hop_table_length + 1);
						quality_link = tmp_;
						sink_associated = hpest->sinkAssociated();
						rmhopTableTmr_.resched(timer_route_validity_);
						ack_warnings_counter_ = 0;
						ack_error_state = false;
					}
				} else if (metrics_ == LESSCONGESTED) {
					double tmp_ =
							hpest->quality() / hpest->list_of_hops_length();
					if ((!this->isZero(quality_link) &&
								(quality_link > tmp_)) ||
							(this->getNumberOfHopToSink() == 0)) {
						// Reset of the routing information.
						this->clearHops();
						this->setNumberOfHopToSink(0);
						// Update the routing table of the current node.
						for (int i = j_ + 1, w = 0;
								i < hpest->list_of_hops_length();
								i++, w++) {
							hop_table[w] = hpest->list_of_hops()[i];
						}
						hop_table_length = hpest->list_of_hops_length() -
								hpest->pointer() - 1;
						this->setNumberOfHopToSink(hop_table_length + 1);
						quality_link = tmp_;
						sink_associated = hpest->sinkAssociated();
						rmhopTableTmr_.resched(timer_route_validity_);
						ack_warnings_counter_ = 0;
						ack_error_state = false;
					}
				}
				// Update the information in the Path Establishment Answer
				// packet.
				hpest->pointer()--;
				if (hpest->pointer() < 0) { // The list is over, the next hop
											// will be the destination.
					ch->next_hop() = iph->daddr();
					ch->prev_hop_ = ipAddr_;
				} else { // Look in the hop list for the next hop.
					ch->next_hop() = hpest->list_of_hops()[hpest->pointer()];
					ch->prev_hop_ = ipAddr_;
				}
				if (printDebug_ > 10)
					cout << "@" << Scheduler::instance().clock()
						 << " -> N: " << this->printIP(ipAddr_)
						 << " - CP: " << ch->uid()
						 << " - Send Answer Path reply. Next hop: "
						 << printIP(ch->next_hop())
						 << " (destination: " << printIP(iph->saddr()) << ")."
						 << endl;
				number_of_pathestablishment_++;
				if (trace_)
					this->tracePacket(p, "FRWD_PTH");
				sendDown(p, this->getDelay(period_status_));
				return;
			} else {
				drop(p, 1, DROP_PATH_ESTABLISHMENT_ANSWER_PACKET_GARBAGE);
				return;
			}
		}
	} else {
		Packet::free(p);
		return;
	}
} /* SunIPRoutingNode::sendRouteBack */
int WiFiCmdRobot::WiFiCmdRobot_begin() {
  
    int conID = DWIFIcK::INVALID_CONNECTION_ID;
    int cNetworks = 0;
    int iNetwork = 0; 
    int ret=SUCCESS;
    
     Serial.println("Begin WiFiCmdRobot Init");
 
  
    // initialize the SD-Card    
    ret = initSDCard();
    if (ret != SUCCESS)
    {  
        Serial.print("Error Init SD-Card, error: ");
        Serial.println(ret);
    }                                                                    
    else
    {
        Serial.println("Init SD-Card OK");
        Serial.println("");
    }
    
    // get infos from SD-Card  
    ret=infoSDCard();
    if (ret != SUCCESS)
    {  
        Serial.print("Error Infos SD-Card, error: ");
        Serial.println(ret);
    }
    
    Serial.println("Begin WIFI Init"); 
    lcd.clear();
    lcd.print("Begin WIFI Init");
           
    // set my default wait time to nothing
    DNETcK::setDefaultBlockTime(DNETcK::msImmediate); 

    // start a scan
    DWIFIcK::beginScan();
    while (1)
    {
            // every pass through loop(), keep the stack alive
            DNETcK::periodicTasks(); 
            if(DWIFIcK::isScanDone(&cNetworks, &status))
            {
                Serial.println("Scan Done");
                break;
            }
            else if(DNETcK::isStatusAnError(status))
            {
                Serial.print("Scan Failed");
                return -1;
            }
            
    }        
    
    while (1)
    {            
            // every pass through loop(), keep the stack alive
            DNETcK::periodicTasks();            
            if(iNetwork < cNetworks)
            {
                DWIFIcK::SCANINFO scanInfo;
                int j = 0;

                if(DWIFIcK::getScanInfo(iNetwork, &scanInfo))
                {
                    Serial.print("Scan info for index: ");
                    Serial.println(iNetwork, DEC);

                    Serial.print("SSID: ");
                    Serial.println(scanInfo.szSsid);

                    Serial.print("Secuity type: ");
                    Serial.println(scanInfo.securityType, DEC);
                    switch(scanInfo.securityType)
                    {
                           case DWIFIcK::WF_SECURITY_OPEN:
                                Serial.println("SECURITY OPEN");
                                break;
                           case DWIFIcK::WF_SECURITY_WEP_40:
                                Serial.println("WF SECURITY WEP 40");
                                break;
                           case DWIFIcK::WF_SECURITY_WEP_104:
                                Serial.println("SECURITY WEP 104");
                                break;
                           case DWIFIcK::WF_SECURITY_WPA_WITH_KEY:
                                Serial.println("SECURITY WPA WITH KEY");
                                break;
                           case DWIFIcK::WF_SECURITY_WPA_WITH_PASS_PHRASE:
                                Serial.println("SECURITY WPA WITH PASS PHRASE");
                                break;
                           case DWIFIcK::WF_SECURITY_WPA2_WITH_KEY:
                                Serial.println("SECURITY WPA2 WITH KEY");
                                break;
                           case DWIFIcK::WF_SECURITY_WPA2_WITH_PASS_PHRASE:
                                Serial.println("SECURITY WPA2 WITH PASS PHRASE");
                                break;
                           case DWIFIcK::WF_SECURITY_WPA_AUTO_WITH_KEY:
                                Serial.println("SECURITY WPA AUTO WITH KEY");
                                break; 
                           case DWIFIcK::WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE:
                                Serial.println("SECURITY WPA AUTO WITH PASS PHRASE");
                                break;                                
                    }
                    
                    Serial.print("Channel: ");
                    Serial.println(scanInfo.channel, DEC);    

                    Serial.print("Signal Strength: ");
                    Serial.println(scanInfo.signalStrength, DEC);    

                    Serial.print("Count of supported bit rates: ");
                    Serial.println(scanInfo.cBasicRates, DEC);    

                    for( j= 0; j< scanInfo.cBasicRates; j++)
                    {
                        Serial.print("\tSupported Rate: ");
                        Serial.print(scanInfo.basicRates[j], DEC); 
                        Serial.println(" bps");
                    }

                    Serial.print("SSID MAC: ");
                    for(j=0; j<sizeof(scanInfo.ssidMAC); j++)
                    {
                        if(scanInfo.ssidMAC[j] < 16)
                        {
                            Serial.print(0, HEX);
                        }
                        Serial.print(scanInfo.ssidMAC[j], HEX);
                    }

                    Serial.print("\nBeacon Period: ");
                    Serial.println(scanInfo.beconPeriod, DEC);    

                    Serial.print("dtimPeriod: ");
                    Serial.println(scanInfo.dtimPeriod, DEC);    

                    Serial.print("atimWindow: ");
                    Serial.println(scanInfo.atimWindow, DEC); 
                    
                    Serial.println("");
                }
                else
                {
                    Serial.print("Unable to get scan info for iNetwork: ");
                    Serial.println(iNetwork, DEC);
                }

                iNetwork++;
            }
            else
            {
                break;
            }           
    }

    if((conID = WiFiConnectMacro()) != DWIFIcK::INVALID_CONNECTION_ID)
    {
          Serial.print("Connection Created, ConID = ");
          Serial.println(conID, DEC);
    }
    else
    {
          Serial.print("Unable to connection, status: ");
          Serial.println(status, DEC);
          return -2;
    }
 
    while (1)
    { 
           // every pass through loop(), keep the stack alive
           DNETcK::periodicTasks(); 
            
          // initialize the stack with a static IP
          DNETcK::begin(ipServer);
          if(DNETcK::isInitialized(&status))
          {
                Serial.println("IP Stack Initialized");
                break;
          }
          else if(DNETcK::isStatusAnError(status))
          {
                Serial.print("Error in initializing, status: ");
                Serial.println(status, DEC);
                return -3;
          }
    }
        
    Serial.println("");
    IPv4 ip;

    DNETcK::getMyIP(&ip);
    Serial.print("My ");
    printIP(ip);
    Serial.println("");

    DNETcK::getGateway(&ip);
    Serial.print("Gateway ");
    printIP(ip);
    Serial.println("");

    DNETcK::getSubnetMask(&ip);
    Serial.print("Subnet mask: ");
    printNumb(ip.rgbIP, 4, '.');
    Serial.println("");

    DNETcK::getDns1(&ip);
    Serial.print("Dns1 ");
    printIP(ip);
    Serial.println("");

    DNETcK::getDns2(&ip);
    Serial.print("Dns2 ");
    printIP(ip);
    Serial.println("");
       
    
    DWIFIcK::CONFIGINFO configInfo;
    if(DWIFIcK::getConfigInfo(&configInfo))
    {
        Serial.println("WiFi config information");

        Serial.print("Scan Type: ");
        switch(configInfo.scanType)
        {
                   case DWIFIcK::WF_ACTIVE_SCAN:
                        Serial.println("ACTIVE SCAN");
                        break;
                   case DWIFIcK::WF_PASSIVE_SCAN:
                        Serial.println("PASSIVE SCAN");
                        break;                
        }

        Serial.print("Beacon Timeout: ");
        Serial.println(configInfo.beaconTimeout, DEC);

        Serial.print("Connect Retry Count: ");
        Serial.println(configInfo.connectRetryCount, DEC);

        Serial.print("Scan Count: ");
        Serial.println(configInfo.scanCount, DEC);

        Serial.print("Minimum Signal Strength: ");
        Serial.println(configInfo.minSignalStrength, DEC);

        Serial.print("Minimum Channel Time: ");
        Serial.println(configInfo.minChannelTime, DEC);

        Serial.print("Maximum Channel Time: ");
        Serial.println(configInfo.maxChannelTime, DEC);

        Serial.print("Probe Delay: ");
        Serial.println(configInfo.probeDelay, DEC);

        Serial.print("Polling Interval: ");
        Serial.println(configInfo.pollingInterval, DEC);                                                 
    }
    else
    {
        Serial.println("Unable to get WiFi config data");
        return -4; 
    }                  
   
    tcpServer.startListening(portServer);

    lcd.setCursor(0,1); 
    lcd.print("End   WIFI Init");
    
    Serial.println("");
    Serial.println("End WiFiCmdRobot Init");
    Serial.println("*********************");
    Serial.println("");

    return SUCCESS;                        
}
	void DebugCLI::enterDebugger()
	{	
		setCurrentSource( (core->callStack) ? (core->callStack->filename()) : 0 );
		if (currentSource == NULL)
		{
			stepInto();
			return;
		}

		for (;;) {
			printIP();
			
			core->console << "(asdb) ";
			fflush(stdout);
			fgets(commandLine, kMaxCommandLine, stdin);

			commandLine[strlen(commandLine)-1] = 0;
			
			if (!commandLine[0]) {
				strcpy(commandLine, lastCommand);
			} else {
				strcpy(lastCommand, commandLine);
			}
				
			currentToken = commandLine;
		
			char *command = nextToken();
			int cmd = commandFor(command);

			switch (cmd) {
			case -1:
				// ambiguous, we already printed error message
				break;
			case CMD_INFO:
				info();
				break;
			case CMD_BREAK:
				breakpoint(nextToken());
				break;
			case CMD_DELETE:
				deleteBreakpoint(nextToken());
				break;
			case CMD_LIST:
				list(nextToken());
				break;
			case CMD_UNKNOWN:
				core->console << "Unknown command.\n";
				break;
			case CMD_QUIT:
				exit(0);
				break;
			case CMD_CONTINUE:
				return;
			case CMD_PRINT:
				print(nextToken());
				break;
			case CMD_NEXT:
				stepOver();
				return;
			case INFO_STACK_CMD:
				bt();
				break;
			case CMD_FINISH:
				stepOut();
				return;
			case CMD_STEP:
				stepInto();
				return;
			case CMD_SET:
				set();
				break;
			default:
				core->console << "Command not implemented.\n";
				break;
			}
		}
	}
Beispiel #7
0
/*
 *   Test a global thresholding object
 */
static inline int sfthd_test_global(
    SFXHASH *global_hash,
    THD_NODE   * sfthd_node,
    unsigned     gen_id,     /* from current event */
    unsigned     sig_id,     /* from current event */
    snort_ip_p   sip,        /* " */
    snort_ip_p   dip,        /* " */
    time_t       curtime )
{
    THD_IP_GNODE_KEY key;
    THD_IP_NODE      data, *sfthd_ip_node;
    int              status=0;
    snort_ip_p       ip;
    tSfPolicyId policy_id = getRuntimePolicy();

#ifdef THD_DEBUG
    printf("THD_DEBUG-GLOBAL:  gen_id=%u, sig_id=%u\n",gen_id,sig_id);
    printf("THD_DEBUG: Global THD_NODE IP=%s,",printIP((unsigned)sfthd_node->ip_address) );
    printf(" MASK=%s\n",printIP((unsigned)sfthd_node->ip_mask) );
    printf("THD_DEBUG:        PKT  SIP=%s\n",printIP((unsigned)sip) );
    printf("THD_DEBUG:        PKT  DIP=%s\n",printIP((unsigned)dip) );
    fflush(stdout);
#endif

    /* -1 means don't do any limit or thresholding */
    if ( sfthd_node->count == THD_NO_THRESHOLD)
    {
#ifdef THD_DEBUG
        printf("\n...No Threshold applied for this object\n");
        fflush(stdout);
#endif
        return 0;
    }

    /* Get The correct IP */
    if (sfthd_node->tracking == THD_TRK_SRC)
       ip = sip;
    else
       ip = dip;

    /* Check for and test Suppression of this event to this IP */
    if( sfthd_node->type == THD_TYPE_SUPPRESS )
    {
#ifdef THD_DEBUG
        printf("THD_DEBUG: G-SUPPRESS NODE Testing...\n");fflush(stdout);
#endif
        return sfthd_test_suppress(sfthd_node, ip);
    }

    /*
    *  Go on and do standard thresholding
    */

    /* Set up the key */
    key.ip     = IP_VAL(ip);
    key.gen_id = sfthd_node->gen_id;
    key.sig_id = sig_id;
    key.policyId = policy_id;

    /* Set up a new data element */
    data.count  = 1;
    data.prev  = 0;
    data.tstart = data.tlast = curtime; /* Event time */

    /* Check for any Permanent sig_id objects for this gen_id  or add this one ...  */
    status = sfxhash_add(global_hash, (void*)&key, &data);
    if (status == SFXHASH_INTABLE)
    {
        /* Already in the table */
        sfthd_ip_node = global_hash->cnode->data;

        /* Increment the event count */
        sfthd_ip_node->count++;
    }
    else if (status != SFXHASH_OK)
    {
        /* hash error */
        return 1; /*  check the next threshold object */
    }
    else
    {
        /* Was not in the table - it was added - work with our copy of the data */
        sfthd_ip_node = &data;
    }

    return sfthd_test_non_suppress(sfthd_node, sfthd_ip_node, curtime);
}
Beispiel #8
0
void print(void) {
	unsigned val, val2;
	int i;

	//	readReg(&nf2, UNET_ID, &val);
	//	printf("Board ID: Version %i, Device %i\n", GET_VERSION(val), GET_DEVICE(val));
	readReg(&nf2, MAC_GRP_0_CONTROL_REG, &val);
	printf("MAC 0 Control: 0x%08x ", val);
	if(val&(1<<MAC_GRP_TX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("TX disabled, ");
	}
	else {
	  printf("TX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("RX disabled, ");
	}
	else {
	  printf("RX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RESET_MAC_BIT_NUM)) {
	  printf("reset on\n");
	}
	else {
	  printf("reset off\n");
	}
	printf("mac config 0x%02x\n", val>>MAC_GRP_MAC_DISABLE_TX_BIT_NUM);

	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_STORED_REG, &val);
	printf("Num pkts enqueued to rx queue 0:      %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_DROPPED_FULL_REG, &val);
	printf("Num pkts dropped (rx queue 0 full): %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &val);
	printf("Num pkts dropped (bad fcs q 0):     %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of rx queue 0: %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of rx queue 0: %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_DEQUEUED_REG, &val);
	printf("Num pkts dequeued from rx queue 0: %u\n", val);
	readReg(&nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in rx queue 0: %u\n\n", val);

	readReg(&nf2, MAC_GRP_0_TX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in tx queue 0:             %u\n", val);
	readReg(&nf2, MAC_GRP_0_TX_QUEUE_NUM_PKTS_SENT_REG, &val);
	printf("Num pkts dequeued from tx queue 0:           %u\n", val);
	readReg(&nf2, MAC_GRP_0_TX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of tx queue 0: %u\n", val);
	readReg(&nf2, MAC_GRP_0_TX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of tx queue 0: %u\n", val);
	readReg(&nf2, MAC_GRP_0_TX_QUEUE_NUM_PKTS_ENQUEUED_REG, &val);
	printf("Num pkts enqueued to tx queue 0: %u\n\n", val);

	readReg(&nf2, MAC_GRP_1_CONTROL_REG, &val);
	printf("MAC 1 Control: 0x%08x ", val);
	if(val&(1<<MAC_GRP_TX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("TX disabled, ");
	}
	else {
	  printf("TX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("RX disabled, ");
	}
	else {
	  printf("RX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RESET_MAC_BIT_NUM)) {
	  printf("reset on\n");
	}
	else {
	  printf("reset off\n");
	}
	printf("mac config 0x%02x\n", val>>MAC_GRP_MAC_DISABLE_TX_BIT_NUM);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_STORED_REG, &val);
	printf("Num pkts enqueued to rx queue 1:      %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_DROPPED_FULL_REG, &val);
	printf("Num pkts dropped (rx queue 1 full): %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &val);
	printf("Num pkts dropped (bad fcs q 1):     %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of rx queue 1: %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of rx queue 1: %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_DEQUEUED_REG, &val);
	printf("Num pkts dequeued from rx queue 1: %u\n", val);
	readReg(&nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in rx queue 1: %u\n\n", val);

	readReg(&nf2, MAC_GRP_1_TX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in tx queue 1:             %u\n", val);
	readReg(&nf2, MAC_GRP_1_TX_QUEUE_NUM_PKTS_SENT_REG, &val);
	printf("Num pkts dequeued from tx queue 1:           %u\n", val);
	readReg(&nf2, MAC_GRP_1_TX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of tx queue 1: %u\n", val);
	readReg(&nf2, MAC_GRP_1_TX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of tx queue 1: %u\n", val);
        readReg(&nf2, MAC_GRP_1_TX_QUEUE_NUM_PKTS_ENQUEUED_REG, &val);
        printf("Num pkts enqueued to tx queue 1: %u\n\n", val);

	readReg(&nf2, MAC_GRP_2_CONTROL_REG, &val);
	printf("MAC 2 Control: 0x%08x ", val);
	if(val&(1<<MAC_GRP_TX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("TX disabled, ");
	}
	else {
	  printf("TX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("RX disabled, ");
	}
	else {
	  printf("RX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RESET_MAC_BIT_NUM)) {
	  printf("reset on\n");
	}
	else {
	  printf("reset off\n");
	}
	printf("mac config 0x%02x\n", val>>MAC_GRP_MAC_DISABLE_TX_BIT_NUM);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_STORED_REG, &val);
	printf("Num pkts enqueued to rx queue 2:      %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_DROPPED_FULL_REG, &val);
	printf("Num pkts dropped (rx queue 2 full): %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &val);
	printf("Num pkts dropped (bad fcs q 2):     %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of rx queue 2: %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of rx queue 2: %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_DEQUEUED_REG, &val);
	printf("Num pkts dequeued from rx queue 2: %u\n", val);
	readReg(&nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in rx queue 2: %u\n\n", val);

	readReg(&nf2, MAC_GRP_2_TX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in tx queue 2:             %u\n", val);
	readReg(&nf2, MAC_GRP_2_TX_QUEUE_NUM_PKTS_SENT_REG, &val);
	printf("Num pkts dequeued from tx queue 2:           %u\n", val);
	readReg(&nf2, MAC_GRP_2_TX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of tx queue 2: %u\n", val);
	readReg(&nf2, MAC_GRP_2_TX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of tx queue 2: %u\n", val);
        readReg(&nf2, MAC_GRP_2_TX_QUEUE_NUM_PKTS_ENQUEUED_REG, &val);
        printf("Num pkts enqueued to tx queue 2: %u\n\n", val);

	readReg(&nf2, MAC_GRP_3_CONTROL_REG, &val);
	printf("MAC 3 Control: 0x%08x ", val);
	if(val&(1<<MAC_GRP_TX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("TX disabled, ");
	}
	else {
	  printf("TX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RX_QUEUE_DISABLE_BIT_NUM)) {
	  printf("RX disabled, ");
	}
	else {
	  printf("RX enabled,  ");
	}
	if(val&(1<<MAC_GRP_RESET_MAC_BIT_NUM)) {
	  printf("reset on\n");
	}
	else {
	  printf("reset off\n");
	}
        printf("mac config 0x%02x\n", val>>MAC_GRP_MAC_DISABLE_TX_BIT_NUM);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_STORED_REG, &val);
	printf("Num pkts enqueued to rx queue 3:      %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_DROPPED_FULL_REG, &val);
	printf("Num pkts dropped (rx queue 3 full): %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &val);
	printf("Num pkts dropped (bad fcs q 3):     %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of rx queue 3: %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of rx queue 3: %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_DEQUEUED_REG, &val);
	printf("Num pkts dequeued from rx queue 3: %u\n", val);
	readReg(&nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in rx queue 3: %u\n\n", val);

	readReg(&nf2, MAC_GRP_3_TX_QUEUE_NUM_PKTS_IN_QUEUE_REG, &val);
	printf("Num pkts in tx queue 3:             %u\n", val);
	readReg(&nf2, MAC_GRP_3_TX_QUEUE_NUM_PKTS_SENT_REG, &val);
	printf("Num pkts dequeued from tx queue 3:           %u\n", val);
	readReg(&nf2, MAC_GRP_3_TX_QUEUE_NUM_WORDS_PUSHED_REG, &val);
	printf("Num words pushed out of tx queue 3: %u\n", val);
	readReg(&nf2, MAC_GRP_3_TX_QUEUE_NUM_BYTES_PUSHED_REG, &val);
	printf("Num bytes pushed out of tx queue 3: %u\n", val);
        readReg(&nf2, MAC_GRP_3_TX_QUEUE_NUM_PKTS_ENQUEUED_REG, &val);
        printf("Num pkts enqueued to tx queue 3: %u\n\n", val);
/*
	readReg(&nf2, CPU_REG_Q_0_WR_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_0_WR_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_0_WR_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_0_WR_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_0_WR_NUM_WORDS_LEFT_REG, &val);
	printf("CPU_REG_Q_0_WR_NUM_WORDS_LEFT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_WR_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_0_WR_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_RD_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_0_RD_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_0_RD_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_0_RD_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_0_RD_NUM_WORDS_AVAIL_REG, &val);
	printf("CPU_REG_Q_0_RD_NUM_WORDS_AVAIL_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_RD_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_0_RD_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_RX_NUM_PKTS_RCVD_REG, &val);
	printf("CPU_REG_Q_0_RX_NUM_PKTS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_TX_NUM_PKTS_SENT_REG, &val);
	printf("CPU_REG_Q_0_TX_NUM_PKTS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_RX_NUM_WORDS_RCVD_REG, &val);
	printf("CPU_REG_Q_0_RX_NUM_WORDS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_TX_NUM_WORDS_SENT_REG, &val);
	printf("CPU_REG_Q_0_TX_NUM_WORDS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_RX_NUM_BYTES_RCVD_REG, &val);
	printf("CPU_REG_Q_0_RX_NUM_BYTES_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_0_TX_NUM_BYTES_SENT_REG, &val);
	printf("CPU_REG_Q_0_TX_NUM_BYTES_SENT_REG: %u\n\n", val);

	readReg(&nf2, CPU_REG_Q_1_WR_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_1_WR_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_1_WR_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_1_WR_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_1_WR_NUM_WORDS_LEFT_REG, &val);
	printf("CPU_REG_Q_1_WR_NUM_WORDS_LEFT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_WR_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_1_WR_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_RD_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_1_RD_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_1_RD_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_1_RD_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_1_RD_NUM_WORDS_AVAIL_REG, &val);
	printf("CPU_REG_Q_1_RD_NUM_WORDS_AVAIL_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_RD_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_1_RD_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_RX_NUM_PKTS_RCVD_REG, &val);
	printf("CPU_REG_Q_1_RX_NUM_PKTS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_TX_NUM_PKTS_SENT_REG, &val);
	printf("CPU_REG_Q_1_TX_NUM_PKTS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_RX_NUM_WORDS_RCVD_REG, &val);
	printf("CPU_REG_Q_1_RX_NUM_WORDS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_TX_NUM_WORDS_SENT_REG, &val);
	printf("CPU_REG_Q_1_TX_NUM_WORDS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_RX_NUM_BYTES_RCVD_REG, &val);
	printf("CPU_REG_Q_1_RX_NUM_BYTES_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_1_TX_NUM_BYTES_SENT_REG, &val);
	printf("CPU_REG_Q_1_TX_NUM_BYTES_SENT_REG: %u\n\n", val);

	readReg(&nf2, CPU_REG_Q_2_WR_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_2_WR_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_2_WR_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_2_WR_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_2_WR_NUM_WORDS_LEFT_REG, &val);
	printf("CPU_REG_Q_2_WR_NUM_WORDS_LEFT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_WR_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_2_WR_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_RD_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_2_RD_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_2_RD_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_2_RD_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_2_RD_NUM_WORDS_AVAIL_REG, &val);
	printf("CPU_REG_Q_2_RD_NUM_WORDS_AVAIL_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_RD_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_2_RD_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_RX_NUM_PKTS_RCVD_REG, &val);
	printf("CPU_REG_Q_2_RX_NUM_PKTS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_TX_NUM_PKTS_SENT_REG, &val);
	printf("CPU_REG_Q_2_TX_NUM_PKTS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_RX_NUM_WORDS_RCVD_REG, &val);
	printf("CPU_REG_Q_2_RX_NUM_WORDS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_TX_NUM_WORDS_SENT_REG, &val);
	printf("CPU_REG_Q_2_TX_NUM_WORDS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_RX_NUM_BYTES_RCVD_REG, &val);
	printf("CPU_REG_Q_2_RX_NUM_BYTES_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_2_TX_NUM_BYTES_SENT_REG, &val);
	printf("CPU_REG_Q_2_TX_NUM_BYTES_SENT_REG: %u\n\n", val);

	readReg(&nf2, CPU_REG_Q_3_WR_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_3_WR_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_3_WR_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_3_WR_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_3_WR_NUM_WORDS_LEFT_REG, &val);
	printf("CPU_REG_Q_3_WR_NUM_WORDS_LEFT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_WR_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_3_WR_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_RD_DATA_WORD_REG, &val);
	printf("CPU_REG_Q_3_RD_DATA_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_3_RD_CTRL_WORD_REG, &val);
	printf("CPU_REG_Q_3_RD_CTRL_WORD_REG: 0x%08x\n", val);
	readReg(&nf2, CPU_REG_Q_3_RD_NUM_WORDS_AVAIL_REG, &val);
	printf("CPU_REG_Q_3_RD_NUM_WORDS_AVAIL_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_RD_NUM_PKTS_IN_Q_REG, &val);
	printf("CPU_REG_Q_3_RD_NUM_PKTS_IN_Q_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_RX_NUM_PKTS_RCVD_REG, &val);
	printf("CPU_REG_Q_3_RX_NUM_PKTS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_TX_NUM_PKTS_SENT_REG, &val);
	printf("CPU_REG_Q_3_TX_NUM_PKTS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_RX_NUM_WORDS_RCVD_REG, &val);
	printf("CPU_REG_Q_3_RX_NUM_WORDS_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_TX_NUM_WORDS_SENT_REG, &val);
	printf("CPU_REG_Q_3_TX_NUM_WORDS_SENT_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_RX_NUM_BYTES_RCVD_REG, &val);
	printf("CPU_REG_Q_3_RX_NUM_BYTES_RCVD_REG: %u\n", val);
	readReg(&nf2, CPU_REG_Q_3_TX_NUM_BYTES_SENT_REG, &val);
	printf("CPU_REG_Q_3_TX_NUM_BYTES_SENT_REG: %u\n\n", val);
*/
	for(i=0; i<ROUTER_OP_LUT_ARP_TABLE_DEPTH; i=i+1){
	  writeReg(&nf2, ROUTER_OP_LUT_ARP_TABLE_RD_ADDR_REG, i);
	  printf("   ARP table entry %02u: mac: ", i);
	  readReg(&nf2, ROUTER_OP_LUT_ARP_TABLE_ENTRY_MAC_HI_REG, &val);
	  readReg(&nf2, ROUTER_OP_LUT_ARP_TABLE_ENTRY_MAC_LO_REG, &val2);
	  printMAC(val, val2);
	  printf(" ip: ");
	  readReg(&nf2, ROUTER_OP_LUT_ARP_TABLE_ENTRY_NEXT_HOP_IP_REG, &val);
	  printIP(val);
	  printf("\n", val);
	}
	printf("\n");

	for(i=0; i<ROUTER_OP_LUT_ROUTE_TABLE_DEPTH; i=i+1){
	  writeReg(&nf2, ROUTER_OP_LUT_ROUTE_TABLE_RD_ADDR_REG, i);
	  readReg(&nf2, ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_IP_REG, &val);
	  printf("   IP table entry %02u: ip: ", i);
	  printIP(val);
	  readReg(&nf2, ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_MASK_REG, &val);
	  printf(" mask: 0x%08x", val);
	  readReg(&nf2, ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_NEXT_HOP_IP_REG, &val);
	  printf(" next hop: ");
	  printIP(val);
	  readReg(&nf2, ROUTER_OP_LUT_ROUTE_TABLE_ENTRY_OUTPUT_PORT_REG, &val);
	  printf(" output port: 0x%04x\n", val);
	}
	printf("\n");

	for(i=0; i<ROUTER_OP_LUT_DST_IP_FILTER_TABLE_DEPTH; i=i+1){
	  writeReg(&nf2, ROUTER_OP_LUT_DST_IP_FILTER_TABLE_RD_ADDR_REG, i);
	  readReg(&nf2, ROUTER_OP_LUT_DST_IP_FILTER_TABLE_ENTRY_IP_REG, &val);
	  printf("   Dst IP Filter table entry %02u: ", i);
	  printIP(val);
	  printf("\n");
	}
	printf("\n");

	readReg(&nf2, ROUTER_OP_LUT_ARP_NUM_MISSES_REG, &val);
	printf("ROUTER_OP_LUT_ARP_NUM_MISSES: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_LPM_NUM_MISSES_REG, &val);
	printf("ROUTER_OP_LUT_LPM_NUM_MISSES: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_CPU_PKTS_SENT_REG, &val);
	printf("ROUTER_OP_LUT_NUM_CPU_PKTS_SENT: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_BAD_OPTS_VER_REG, &val);
	printf("ROUTER_OP_LUT_NUM_BAD_OPTS_VER: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_BAD_CHKSUMS_REG, &val);
	printf("ROUTER_OP_LUT_NUM_BAD_CHKSUMS: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_BAD_TTLS_REG, &val);
	printf("ROUTER_OP_LUT_NUM_BAD_TTLS: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_NON_IP_RCVD_REG, &val);
	printf("ROUTER_OP_LUT_NUM_NON_IP_RCVD: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_PKTS_FORWARDED_REG, &val);
	printf("ROUTER_OP_LUT_NUM_PKTS_FORWARDED: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_WRONG_DEST_REG, &val);
	printf("ROUTER_OP_LUT_NUM_WRONG_DEST: %u\n", val);
	readReg(&nf2, ROUTER_OP_LUT_NUM_FILTERED_PKTS_REG, &val);
	printf("ROUTER_OP_LUT_NUM_FILTERED_PKTS: %u\n", val);
	printf("\n");

	readReg(&nf2, ROUTER_OP_LUT_MAC_0_HI_REG, &val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_0_LO_REG, &val2);
	printf("ROUTER_OP_LUT_MAC_0: ");
	printMAC(val, val2);
	printf("\n");
	readReg(&nf2, ROUTER_OP_LUT_MAC_1_HI_REG, &val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_1_LO_REG, &val2);
	printf("ROUTER_OP_LUT_MAC_1: ");
	printMAC(val, val2);
	printf("\n");
	readReg(&nf2, ROUTER_OP_LUT_MAC_2_HI_REG, &val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_2_LO_REG, &val2);
	printf("ROUTER_OP_LUT_MAC_2: ");
	printMAC(val, val2);
	printf("\n");
	readReg(&nf2, ROUTER_OP_LUT_MAC_3_HI_REG, &val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_3_LO_REG, &val2);
	printf("ROUTER_OP_LUT_MAC_3: ");
	printMAC(val, val2);
	printf("\n");

	/*
	readReg(&nf2, ROUTER_OP_LUT_MAC_0_HI_REG, &val);
	printf("ROUTER_OP_LUT_MAC_0_HI: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_0_LO_REG, &val);
	printf("ROUTER_OP_LUT_MAC_0_LO: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_1_HI_REG, &val);
	printf("ROUTER_OP_LUT_MAC_1_HI: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_1_LO_REG, &val);
	printf("ROUTER_OP_LUT_MAC_1_LO: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_2_HI_REG, &val);
	printf("ROUTER_OP_LUT_MAC_2_HI: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_2_LO_REG, &val);
	printf("ROUTER_OP_LUT_MAC_2_LO: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_3_HI_REG, &val);
	printf("ROUTER_OP_LUT_MAC_3_HI: 0x%08x\n", val);
	readReg(&nf2, ROUTER_OP_LUT_MAC_3_LO_REG, &val);
	printf("ROUTER_OP_LUT_MAC_3_LO: 0x%08x\n\n", val);
	*/

	readReg(&nf2, IN_ARB_NUM_PKTS_SENT_REG, &val);
	printf("IN_ARB_NUM_PKTS_SENT                  %u\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_WORD_0_LO_REG, &val);
	printf("IN_ARB_LAST_PKT_WORD_0_LO             0x%08x\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_WORD_0_HI_REG, &val);
	printf("IN_ARB_LAST_PKT_WORD_0_HI             0x%08x\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_CTRL_0_REG, &val);
	printf("IN_ARB_LAST_PKT_CTRL_0                0x%02x\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_WORD_1_LO_REG, &val);
	printf("IN_ARB_LAST_PKT_WORD_1_LO             0x%08x\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_WORD_1_HI_REG, &val);
	printf("IN_ARB_LAST_PKT_WORD_1_HI             0x%08x\n", val);
	readReg(&nf2, IN_ARB_LAST_PKT_CTRL_1_REG, &val);
	printf("IN_ARB_LAST_PKT_CTRL_1                0x%02x\n", val);
	readReg(&nf2, IN_ARB_STATE_REG, &val);
	printf("IN_ARB_STATE                          %u\n\n", val);

	readReg(&nf2, OQ_QUEUE_0_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_0_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_0_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_0_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_0_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_0_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_0_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_0_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_0_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_0_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_0_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_0_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_0_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_0_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_0_CTRL_REG, &val);
	printf("OQ_QUEUE_0_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_1_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_1_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_1_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_1_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_1_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_1_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_1_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_1_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_1_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_1_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_1_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_1_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_1_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_1_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_1_CTRL_REG, &val);
	printf("OQ_QUEUE_1_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_2_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_2_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_2_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_2_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_2_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_2_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_2_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_2_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_2_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_2_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_2_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_2_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_2_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_2_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_2_CTRL_REG, &val);
	printf("OQ_QUEUE_2_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_3_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_3_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_3_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_3_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_3_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_3_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_3_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_3_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_3_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_3_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_3_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_3_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_3_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_3_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_3_CTRL_REG, &val);
	printf("OQ_QUEUE_3_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_4_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_4_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_4_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_4_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_4_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_4_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_4_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_4_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_4_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_4_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_4_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_4_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_4_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_4_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_4_CTRL_REG, &val);
	printf("OQ_QUEUE_4_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_5_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_5_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_5_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_5_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_5_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_5_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_5_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_5_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_5_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_5_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_5_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_5_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_5_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_5_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_5_CTRL_REG, &val);
	printf("OQ_QUEUE_5_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_6_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_6_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_6_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_6_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_6_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_6_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_6_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_6_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_6_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_6_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_6_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_6_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_6_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_6_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_6_CTRL_REG, &val);
	printf("OQ_QUEUE_6_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_7_NUM_WORDS_LEFT_REG, &val);
	printf("OQ_QUEUE_7_NUM_WORDS_LEFT                   %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKT_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKT_BYTES_STORED             %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_OVERHEAD_BYTES_STORED_REG, &val);
	printf("OQ_QUEUE_7_NUM_OVERHEAD_BYTES_STORED        %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKTS_STORED_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKTS_STORED                  %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKTS_DROPPED_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKTS_DROPPED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKT_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKT_BYTES_REMOVED            %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_OVERHEAD_BYTES_REMOVED_REG, &val);
	printf("OQ_QUEUE_7_NUM_OVERHEAD_BYTES_REMOVED       %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKTS_REMOVED_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKTS_REMOVED                 %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_ADDR_LO_REG, &val);
	printf("OQ_QUEUE_7_ADDR_LO                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_7_ADDR_HI_REG, &val);
	printf("OQ_QUEUE_7_ADDR_HI                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_7_WR_ADDR_REG, &val);
	printf("OQ_QUEUE_7_WR_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_7_RD_ADDR_REG, &val);
	printf("OQ_QUEUE_7_RD_ADDR                       0x%08x\n", val);
	readReg(&nf2, OQ_QUEUE_7_NUM_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_7_NUM_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_MAX_PKTS_IN_Q_REG, &val);
	printf("OQ_QUEUE_7_MAX_PKTS_IN_Q                    %u\n", val);
	readReg(&nf2, OQ_QUEUE_7_CTRL_REG, &val);
	printf("OQ_QUEUE_7_CTRL                          0x%08x\n\n", val);

	readReg(&nf2, OQ_QUEUE_0_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_0_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_1_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_1_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_2_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_2_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_3_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_3_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_4_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_4_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_5_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_5_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_6_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_6_FULL_THRESH                      %u\n",val);
	readReg(&nf2, OQ_QUEUE_7_FULL_THRESH_REG, &val);
	printf("OQ_QUEUE_7_FULL_THRESH                      %u\n\n",val);
/*
	readReg(&nf2, DELAY_ENABLE_REG, &val);
	printf("DELAY_ENABLE_REG                          0x%08x\n",val);
	readReg(&nf2, DELAY_1ST_WORD_HI_REG, &val);
	printf("DELAY_1ST_WORD_HI_REG                     0x%08x\n",val);
	readReg(&nf2, DELAY_1ST_WORD_LO_REG, &val);
	printf("DELAY_1ST_WORD_LO_REG                     0x%08x\n",val);
	readReg(&nf2, DELAY_LENGTH_REG, &val);
	printf("DELAY_LENGTH_REG                          0x%08x\n\n",val);

	readReg(&nf2, RATE_LIMIT_ENABLE_REG, &val);
	printf("RATE_LIMIT_ENABLE_REG                     0x%08x\n",val);
	readReg(&nf2, RATE_LIMIT_SHIFT_REG, &val);
	printf("RATE_LIMIT_SHIFT_REG                      0x%08x\n\n",val);
*/

}
Beispiel #9
0
void QueueController::run() {
    int cnt = 0;
    std::vector<uint32_t> fallOuts = {};
    while (true) {
        try {
            if (receivingQueue->size_ack() > 0 || receivingQueue->size_default() > 0) {
                PIA packet = receivingQueue->retrievePacket();

                //Check for NTA
                if (packet.isNta()) {
                    ntaProcessor(packet);
                }
                //check for ACK
                else if (packet.isAck() && (packet.getDestinationAddress() == settings->getLocalIP())){
                    std::cout<< "ack incoming\n";
                    ackProcessor(packet);
                }//Check for ACK to be forwarded
                else if (packet.isAck() && (packet.getDestinationAddress() != settings->getLocalIP())){
                    sendQueue->forwardPacket(packet, true);
                    std::cout<<"Forwarding an ACK\n";
                }//Check for DATA
                else if (receivingQueue->size_default() > 0 || receivingQueue->size_ack() > 0) {
                    if (packet.getDestinationAddress() == settings->getLocalIP()) {
                        	defaultProcessor(packet);

                            std::cout << "The Other user says: " << packet.getPayload() << std::endl;
                            chatHistory->AddToHistory(QString::fromStdString(printIP(packet.getSourceAddress())), QString::fromStdString(packet.getPayload()), QString::fromStdString(printIP(packet.getSourceAddress())));

                            //2end an ACK
                        	sendAck(packet);
                            std::cout<<"Send an ACK\n";
                        }
                    //Check for DATA forwarding
                    else {
                    	if (!packet.isAck()){
                    		receivingQueue->removeDefaultPacket(packet);
                    	}
                        std::cout<<"forwarded a packet\n";
                        sendQueue->forwardPacket(packet, true);
                    }
                }
            }
        } catch (exception &e) {
            std::cout << e.what() << std::endl;
        }

        if (cnt > 25000) {
            fallOuts = routingTable->tagFallouts();
            for (size_t i = 0; i < fallOuts.size(); i++) {
                sendQueue->removeDestination(fallOuts[i]);
                std::cout << "Removing packets destined to: " << printIP(fallOuts[i]) << std::endl;
                fallOuts.erase(fallOuts.begin() + i);
            }
            sendQueue->printDefaultQueue();
            routingTable->printRoutingTable();
            cnt = 0;
        }
        cnt++;
        usleep(50);
    }

}
void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
{
  const struct ether_header *ethernet;
  const struct ip *ip;
  const struct tcphdr *tcp;
  const struct udphdr *udp;
  struct arphdr *arp;
  u_char* trame;
  int size_ethernet = sizeof(struct ether_header);
  int size_ip;
  int size_tcp;
  int size_trame;
  int *vFlag = (int *) args;

  ethernet = (struct ether_header*)(packet);
  ip = (struct ip*)(packet+size_ethernet);
  size_ip=IP_HL(ip)*4;
  tcp = (struct tcphdr*)(packet+size_ip+size_ethernet);
  size_tcp=sizeof(struct tcphdr);
  udp = (struct udphdr*)(packet + sizeof(struct ether_header) + ip->ip_len*4);
  arp = (struct arphdr*)(packet+14);

  printf("Caught packet with length of [%d]\n", header->len);
  printEther(ethernet,*vFlag);
    switch(ntohs(ethernet->ether_type)){
    case ETHERTYPE_IP:
    case ETHERTYPE_IPV6:
      printIP(ip, *vFlag);
      switch(ip->ip_p)
      {
        case IPPROTO_TCP:
          printTcp(tcp, *vFlag);
          break;
        case IPPROTO_UDP:
          printUdp(udp, *vFlag);
          if((ntohs(udp->source)==IPPORT_BOOTPS && ntohs(udp->dest)==IPPORT_BOOTPC) ||
                (ntohs(udp->dest)==IPPORT_BOOTPS && ntohs(udp->source)==IPPORT_BOOTPC)){
                printBootp((struct bootp*) (packet + sizeof(struct ether_header) + ip->ip_len*4+8),*vFlag);
          }
          else if(ntohs(udp->source)== 53 || ntohs(udp->dest)==53){
                 printDns((u_char *)packet + sizeof(struct ether_header) + size_ip+8,*vFlag,1);
                }
          break;
        case IPPROTO_ICMP:
          printf("ICMP");
          break;
        case IPPROTO_SCTP:
          printf("SCTP");
          break;
        default:
          printf("Unknown Protocol\n");
        break;
      }
      break;
      case ETHERTYPE_ARP:
        printArp(arp, *vFlag);
        break;
      default:
        printf("EtherType not handled\n");
  }

  trame = (u_char *)(packet + size_ethernet + size_ip + size_tcp);
  size_trame = ntohs(ip->ip_len) - (size_ip + size_tcp);
  if (size_trame > 0)
  {
    printf("DATA (%d bytes):\n", size_trame);
    printAscii(trame, size_trame);
  }
  printf("\n");
  printf("\n");
  printf("\n");
  return;
}
Beispiel #11
0
void PrintIFClass::print(Stream &output){
    printIP(output);
    printMask(output);
    printGW(output);
    printDNS(output);
}