예제 #1
0
파일: net_ip.c 프로젝트: Rappalot/FUZIX
void ip_rcv(void)
{
  uint16_t len = pkt_left;
  SNMP(ip_in_receives);
  if (!pkt_pull(&iph, sizeof(struct iphdr)))
    return;
  plen = ntohs(iph.tot_len);
  /* FIXME: for speed fold ihl/version and be smarter */
  if (iph.ihl < 5 || iph.version != 4 || len < plen) {
    SNMP(ip_in_hdr_errors);
    return;
  }
  plen -= sizeof(struct iphdr));
  if (pkt_len > plen)
    pkt_len = plen;

  /* FIXME: checksum */
  if (iph.ihl != 5)
    if (ip_options())
      return;
  /* No frags for now (memory limits on 8bit) */
  if (iph.frag_off)
    return;
  if (iph.daddr == 0xFFFFFFFF)
    pkt_type = PKT_BROADCAST;
  else if (MULTICAST(iph.daddr))
    pkt_type = PKT_MULTICAST;
  else if (iph.daddr == ip_addr || LOOPBACK(iph.daddr))
    pkt_type = PKT_HOST;
  else
    /* No forwarding so we don't have to worry about martians either */
    return;

  /* FIXME: raw sockets ?? */
  if (iph.protocol == IPPROTO_TCP)
    tcp_rcv();
  else if (iph.protocol == IPPROTO_UDP)
    udp_rcv();
  else if (iph.protocol == IPPROTO_ICMP)
    icmp_rcv();
  else
    icmp_send_unreach(ICMP_DEST_UNREACH, ICMP_PROT_UNREACH);
}
예제 #2
0
static void runIRC(FILE *uart) {
	char mynick[10] = "ISMO";
	char mychannel[20] = "SOP";
	int userchoice = 0;
	DDRB= 0x0f;
	PORTB=0x0f;
	PORTB = 13;
	lcdPrint("SNMP Chat");

	do {
	   fflush(uart);
		puts("\n\n\n\n\n");
		puts("\n*************");
		puts("\n* SNMP Chat *");
		puts("\n*************\n");
		printf("\n1. Nickname: %s\n", mynick);
		printf("\n2. Channel: %s\n", mychannel);
		puts("\n3. Start chatting\n");
		puts("\n4. Return to Main Menu\n");
		puts("\nEnter your choice: ");
	   
	   readLine(inbuf, sizeof(inbuf));
	
		if (inbuf[0]) {
	         puts("\n\n");
				userchoice = atoi(inbuf);
			
				switch (userchoice)
	    		{
	    		case 1: puts("\nEnter your nickname: ");
					readLine(mynick, sizeof(mynick));
	        		break;
	    		case 2: puts("\nEnter server address: ");
					readLine(mychannel, sizeof(mychannel));
	        		break;
				case 3: puts("\nStart Chatting!\n");
					SNMP(mynick, mychannel, myip, mysubnetmask);
	        		break;					
				case 4: puts("\nReturning to Main Menu\n");
						puts("\n\n\n\n\n");
	        		break;
	    		default: puts("\nInvalid option selected\n");
	    		}
		}
	}
	while (userchoice != 4);
}