Beispiel #1
0
helpBrowser::helpBrowser() {

  browser_ = new QTextBrowser(this);
  connect(browser_, SIGNAL(forwardAvailable(bool )),
          this, SLOT(forwardAvailable(bool )));
  connect(browser_, SIGNAL(backwardAvailable(bool )),
          this, SLOT(backwardAvailable(bool )));
  setCentralWidget(browser_);

  printAction_ = new QAction(QIcon(":print.png"), tr("Print this help page"), this);
  connect(printAction_, SIGNAL(triggered()),
          this, SLOT(processPrint()));
  printAllAction_ =
    new QAction(QIcon(":print_all.png"), tr("Print all help pages"), this);
  connect(printAllAction_, SIGNAL(triggered()),
          this, SLOT(processPrintAll()));
  backAction_ = new QAction(QIcon(":leftArrow.png"), tr("Back"), this);
  backAction_->setEnabled(false);
  connect(backAction_, SIGNAL(triggered()),
          this, SLOT(processBack()));
  forwardAction_ = new QAction(QIcon(":rightArrow.png"), tr("Forward"), this);
  forwardAction_->setEnabled(false);
  connect(forwardAction_, SIGNAL(triggered()),
          this, SLOT(processForward()));

  toolBar_ = addToolBar(tr("Toolbar"));
  toolBar_->addAction(printAction_);
  toolBar_->addAction(printAllAction_);
  toolBar_->addAction(backAction_);
  toolBar_->addAction(forwardAction_);
  resize(800, 600);
}
Beispiel #2
0
void sr_handlepacket(struct sr_instance* sr,
        uint8_t * packet/* lent */,
        unsigned int len,
        char* interface/* lent */)
{
  /* REQUIRES */
  assert(sr);
  assert(packet);
  assert(interface);

  printf("*** -> Received packet of length %d \n",len);

	if (ethertype(packet) == ethertype_arp) {			/* ARP packet */
		struct sr_arp_hdr *arpHeader = (struct sr_arp_hdr *) (packet + sizeof(struct sr_ethernet_hdr));
		if (is_broadcast_mac(packet) || we_are_dest(sr, arpHeader->ar_tip)) {
			/* Process only broadcasted packets or packets meant for me */
			processArp(sr, packet, len, interface);
		}

	} else if (ethertype(packet) == ethertype_ip) { 	/* IP packet */
		struct sr_ip_hdr *ipHeader = (struct sr_ip_hdr *) (packet + sizeof(struct sr_ethernet_hdr));
		
		/* Ignore invalid packets */
		if (!is_sane_ip_packet(packet, len)) {
			return;
		}

		/* If NAT is enabled, do an address translation */
		if (sr->natEnable) {
			int failed = sr_nat_translate_packet(sr, packet, len, interface);
			if (failed) {
				/* packet could not be translated. Drop it */
				return;
			}
		}

		if (we_are_dest(sr, ipHeader->ip_dst)) {
			/* We are destination */
			processIP(sr, packet, len, interface);
		} else {
			/* We are not destination. Forward it. */
			processForward(sr, packet, len, interface);
		}
	}
}