Ejemplo n.º 1
0
int process_eth(struct net_iface *iface, void *data)
{
	int result;
	struct pkt_buff pkt;
	struct ioq_header *ioq;
	unsigned int size;
	struct ether_header *eth;

	result = 0;

	ioq = data;
	size = ntohs(ioq->byte_length);

	pkt_fill(&pkt, data, size + sizeof(struct ioq_header));
	eth = pkt_pull(&pkt, ETHER_HDR_LEN);

			result = process_arp(iface, ioq, eth, &pkt);
//	switch (eth->ether_type)
//	{
//		case ETHERTYPE_ARP:
//			result = process_arp(iface, ioq, eth, &pkt);
//			break;
//		default:
//			result = 1;
//			break;
//	}
	return result;
}
Ejemplo n.º 2
0
static void process_pkt(void* data) {
  struct pkt_buff pkt;
  struct ioq_header *ioq = data;
  unsigned int size = ntohs(ioq->byte_length);
  unsigned short dest = ntohs(ioq->src_port) ^ 2;

  //print_pkt(data, size + sizeof(struct ioq_header));
  log("%hd -> %hd (%d)\n", ntohs(ioq->src_port), dest, size);

  //  log("ioq_hdr: dst=%hx words=%hu src=%hu bytes=%hu\n", ntohs(ioq->dst_port), ntohs(ioq->word_length), ntohs(ioq->src_port), size);
  pkt_fill(&pkt, data, size + sizeof(struct ioq_header));

  struct pkt_buff reply;
  struct ioq_header *dioq;

  pkt_push_all(&pkt);
  while (pkt_alloc(&reply, pkt.len) == 0) {
    log("Failed to alloc\n");
  }

  memcpy32(reply.data+ sizeof(struct ioq_header),
	   pkt.data  + sizeof(struct ioq_header), 
	   reply.len - sizeof(struct ioq_header));

  nf_pktin_free(data);
	
  dioq = pkt_pull_type(&reply, struct ioq_header);
  fill_ioq(dioq, dest, size);

  nf_pktout_send(reply.data, reply.data + reply.total_size);
}