Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

uIP device driver functions
[The uIP TCP/IP stack]


Detailed Description

These functions are used by a network device driver for interacting with uIP.

´ÙÀ½ ÇÔ¼öµéÀº uIP¿Í Åë½ÅÇϱâ À§ÇÏ¿© ³×Æ®¿öÅ© µð¹ÙÀ̽º µå¶óÀ̹ö¿¡ ÀÇÇØ »ç¿ëµÈ´Ù.


Defines

#define uip_input()
 Process an incoming packet.
¼ö½ÅµÈ ÆÐŶ ó¸®

#define uip_periodic(conn)
 Periodic processing for a connection identified by its number.
¹øÈ£¸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®.

#define uip_periodic_conn(conn)
 Periodic processing for a connection identified by a pointer to its structure.
±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®.

#define uip_udp_periodic(conn)
 Periodic processing for a UDP connection identified by its number.
¹øÈ£¸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â UDP Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®.

#define uip_udp_periodic_conn(conn)
 Periodic processing for a UDP connection identified by a pointer to its structure.
±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â UDP Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®.


Variables

u8_t uip_buf [UIP_BUFSIZE+2]
 The uIP packet buffer.
uIP ÆÐŶ ¹öÆÛ.


Define Documentation

#define uip_input  ) 
 

Process an incoming packet.
¼ö½ÅµÈ ÆÐŶ ó¸®.

This function should be called when the device driver has received a packet from the network. The packet from the device driver must be present in the uip_buf buffer, and the length of the packet should be placed in the uip_len variable.

ÀÌ ÇÔ¼ö´Â µð¹ÙÀ̽º µå¶óÀ̹ö°¡ ³×Æ®¿öÅ©·ÎºÎÅÍ ÆÐŶÀ» ¼ö½ÅÇßÀ» °æ¿ì È£ÃâµÇ¾î¾ß ÇÑ´Ù. µð¹ÙÀ̽º µå¶óÀ̹ö·ÎºÎÅÍ ¿Â ÆÐŶÀº uip_buf ¹öÆÛ¿¡ ÀÖ¾î¾ß Çϸç, ÆÐŶÀÇ ±æÀÌ´Â uip_len º¯¼ö¿¡ ÀúÀåµÇ¾î¾ß ÇÑ´Ù.


When the function returns, there may be an outbound packet placed in the uip_buf packet buffer. If so, the uip_len variable is set to the length of the packet. If no packet is to be sent out, the uip_len variable is set to 0.

ÇÔ¼ö°¡ Á¾·áµÉ ¶§, uip_buf ÆÐŶ ¹öÆÛ¿¡ ¿ÜºÎ·Î ³ª°¥ ÆÐŶÀÌ ÀÖ´Â °æ¿ì°¡ ÀÖ´Ù. ±×·² °æ¿ì¿¡ uip_len º¯¼ö¿¡´Â ÇØ´ç ÆÐŶÀÇ ±æÀ̰¡ ÀúÀåµÈ´Ù. ¸¸¾à, ³»º¸³¾ ÆÐŶÀÌ ¾ø´Ù¸é, uip_len º¯¼ö´Â 0 °ªÀ» °¡Áø´Ù.


The usual way of calling the function is presented by the source code below.

ÇÔ¼ö¸¦ »ç¿ëÇÏ´Â ÀϹÝÀûÀÎ ¹æ¹ýÀº ¾Æ·¡ ¼Ò½º ÄÚµå¿Í °°´Ù.

  uip_len = devicedriver_poll();
  if(uip_len > 0) {
    uip_input();
    if(uip_len > 0) {
      devicedriver_send();
    }
  }

Note:
If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the uIP ARP code before calling this function:

¸¸¾à ARP°¡ ÇÊ¿äÇÑ uIP µð¹ÙÀ̽º µå¶óÀ̹ö¸¦ ÀÛ¼ºÇϰí ÀÖ´Ù¸é, ¿¹¸¦ µé¾î Ethernet»ó¿¡¼­ uIP¸¦ ½ÇÇà½ÃŲ´Ù¸é, ÀÌ ÇÔ¼ö¸¦ È£ÃâÇϱâ Àü¿¡ uIP ARP Äڵ带 ¸ÕÀú È£ÃâÇØ¾ß ÇÑ´Ù.


  #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
  uip_len = ethernet_devicedrver_poll();
  if(uip_len > 0) {
    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
      uip_arp_ipin();
      uip_input();
      if(uip_len > 0) {
        uip_arp_out();
        ethernet_devicedriver_send();
      }
    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
      uip_arp_arpin();
      if(uip_len > 0) {
        ethernet_devicedriver_send();
      }
    }

#define uip_periodic conn   ) 
 

Periodic processing for a connection identified by its number.

¹øÈ£¸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®

This function does the necessary periodic processing (timers, polling) for a uIP TCP conneciton, and should be called when the periodic uIP timer goes off. It should be called for every connection, regardless of whether they are open of closed.

ÀÌ ÇÔ¼ö´Â uIP TCP ¿¬°áÀ» À§ÇØ ÇÊ¿äÇÑ ÁÖ±âÀûÀÎ »çÇ×µé(ŸÀ̸Ó, Æú¸µ)À» ¼öÇàÇϸç, ÁÖ±âÀû uIP ŸÀ̸Ӱ¡ ²¨Á³À» °æ¿ì ¹Ýµå½Ã È£ÃâµÇ¾î¾ß ÇÑ´Ù. ÀÌ ÇÔ¼ö´Â Á¢¼ÓÀÌ ¿­·Á ÀÖ´ø, ´ÝÇô ÀÖ´ø »ó°ü¾øÀÌ ¸ðµç Á¢¼Ó¿¡ ´ëÇÏ¿© È£ÃâµÇ¾î¾ß ÇÑ´Ù.


When the function returns, it may have an outbound packet waiting for service in the uIP packet buffer, and if so the uip_len variable is set to a value larger than zero. The device driver should be called to send out the packet.

ÇÔ¼ö°¡ Á¾·áµÉ ¶§, uIP ÆÐŶ ¹öÆÛ¿¡ ¿ÜºÎ·Î ³ª°¥ ÆÐŶÀÌ ÀÖ´Â °æ¿ì°¡ ÀÖÀִµ¥, ±×·± °æ¿ì¿¡´Â uip_len º¯¼ö´Â 0º¸´Ù Å« °ªÀ» °¡Áø´Ù. ÀÌ ÆÐŶÀ» ¼Û½ÅÇϱâ À§Çؼ­´Â µð¹ÙÀ̽º µå¶óÀ̹ö°¡ ¹Ýµå½Ã È£ÃâµÇ¾î¾ß ÇÑ´Ù.


The ususal way of calling the function is through a for() loop like this:

ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÏ´Â ÀϹÝÀûÀÎ ¹æ¹ýÀº ¾Æ·¡¿Í °°ÀÌ for() ·çÇÁ¸¦ ÀÌ¿ëÇÏ´Â °ÍÀÌ´Ù.

  for(i = 0; i < UIP_CONNS; ++i) {
    uip_periodic(i);
    if(uip_len > 0) {
      devicedriver_send();
    }
  }

Note:
If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the uip_arp_out() function before calling the device driver:

¸¸¾à ARP°¡ ÇÊ¿äÇÑ uIP µð¹ÙÀ̽º µå¶óÀ̹ö¸¦ ÀÛ¼ºÇϰí ÀÖ´Ù¸é, ¿¹¸¦ µé¾î Ethernet»ó¿¡¼­ uIP¸¦ ½ÇÇà½ÃŲ´Ù¸é, ÀÌ ÇÔ¼ö¸¦ È£ÃâÇϱâ Àü¿¡ uip_arp_out() ÇÔ¼ö¸¦ ¸ÕÀú È£ÃâÇØ¾ß ÇÑ´Ù.

  for(i = 0; i < UIP_CONNS; ++i) {
    uip_periodic(i);
    if(uip_len > 0) {
      uip_arp_out();
      ethernet_devicedriver_send();
    }
  }
Parameters:
conn The number of the connection which is to be periodically polled.

ÁÖ±âÀûÀ¸·Î Æú¸µÇØ¾ß ÇÒ Á¢¼ÓÀÇ ¹øÈ£

#define uip_periodic_conn conn   ) 
 

Periodic processing for a connection identified by a pointer to its structure.

±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®


Same as uip_periodic() but takes a pointer to the actual uip_conn struct instead of an integer as its argument. This function can be used to force periodic processing of a specific connection.

uip_periodic() ÇÔ¼ö¿Í °°Áö¸¸ ÀÎÀÚ·Î Á¤¼ö°ª ´ë½Å ½ÇÁ¦ uip_conn ±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ¹Þ´Â´Ù. ÀÌ ÇÔ¼ö´Â ƯÁ¤ Á¢¼Ó¿¡ ´ëÇÑ °­Á¦ÀûÀÎ ÁÖ±âÀû 󸮸¦ Çϴµ¥ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

Parameters:
conn A pointer to the uip_conn struct for the connection to be processed.

ó¸®ÇØ¾ß ÇÒ Á¢¼Ó¿¡ ´ëÇÑ uip_conn ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ.

#define uip_udp_periodic conn   ) 
 

Periodic processing for a UDP connection identified by its number.

¹øÈ£¸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â UDP Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®


This function is essentially the same as uip_prerioic(), but for UDP connections. It is called in a similar fashion as the uip_periodic() function:

ÀÌ ÇÔ¼ö´Â ¿øÄ¢ÀûÀ¸·Î uip_periodic()ÇÔ¼ö¿Í µ¿ÀÏÇÏÁö¸¸, UPD Á¢¼ÓÀ» À§ÇÑ °ÍÀÌ´Ù. uip_periodic() ÇÔ¼ö¿Í À¯»çÇÑ ¹æ¹ýÀ¸·Î È£ÃâÇÑ´Ù.

  for(i = 0; i < UIP_UDP_CONNS; i++) {
    uip_udp_periodic(i);
    if(uip_len > 0) {
      devicedriver_send();
    }
  }   

Note:
As for the uip_periodic() function, special care has to be taken when using uIP together with ARP and Ethernet:

uip_periodic() ÇÔ¼ö¿Í °°ÀÌ, uIP¸¦ ARP¿Í Ethernet°ú °°ÀÌ »ç¿ëÇϱâ À§Çؼ­´Â Ưº°È÷ ÁÖÀÇÇØ¾ß ÇÑ´Ù.
  for(i = 0; i < UIP_UDP_CONNS; i++) {
    uip_udp_periodic(i);
    if(uip_len > 0) {
      uip_arp_out();
      ethernet_devicedriver_send();
    }
  }   
Parameters:
conn The number of the UDP connection to be processed.

ó¸®ÇØ¾ß ÇÒ UDP Á¢¼ÓÀÇ ¹øÈ£

#define uip_udp_periodic_conn conn   ) 
 

Periodic processing for a UDP connection identified by a pointer to its structure.

±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ÅëÇØ È®ÀÎÇÒ ¼ö ÀÖ´Â UDP Á¢¼Ó¿¡ ´ëÇÑ ÁÖ±âÀû ó¸®


Same as uip_udp_periodic() but takes a pointer to the actual uip_conn struct instead of an integer as its argument. This function can be used to force periodic processing of a specific connection.

uip_udp_periodic() ÇÔ¼ö¿Í µ¿ÀÏÇÏÁö¸¸, ÀÎÀÚ·Î Á¤¼ö°ª ´ë½Å ½ÇÁ¦ uip_conn ±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ¹Þ´Â´Ù. ÀÌ ÇÔ¼ö´Â ƯÁ¤ Á¢¼ÓÀ» °­Á¦ÀûÀ¸·Î ÁÖ±âÀûÀ¸·Î ó¸®ÇÒ ¶§ ¾µ ¼ö ÀÖ´Ù.


Parameters:
conn A pointer to the uip_udp_conn struct for the connection to be processed.

ó¸®ÇØ¾ß ÇÒ uip_udp_conn ±¸Á¶Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅÍ.


Variable Documentation

u8_t uip_buf[UIP_BUFSIZE+2]
 

The uIP packet buffer.

uIP ÆÐŶ ¹öÆÛ


The uip_buf array is used to hold incoming and outgoing packets. The device driver should place incoming data into this buffer. When sending data, the device driver should read the link level headers and the TCP/IP headers from this buffer. The size of the link level headers is configured by the UIP_LLH_LEN define.

uip_buf ¹è¿­Àº µé¾î¿À°í ³ª°¡´Â ÆÐŶµéÀ» ÀúÀåÇϱâ À§ÇØ »ç¿ëÇÑ´Ù. µð¹ÙÀ̽º µå¶óÀ̹ö´Â ¼ö½ÅµÈ µ¥ÀÌÅ͸¦ ¹Ýµå½Ã ÀÌ ¹öÆÛ¿¡ ÀúÀåÇØ¾ß ÇÑ´Ù. µ¥ÀÌÅ͸¦ º¸³¾ °æ¿ì, µð¹ÙÀ̽º µå¶óÀ̹ö´Â ÀÌ ¹öÆÛ¿¡¼­ ¸µÅ© ·¹º§ Çì´õµé°ú TCP/IP Çì´õµéÀ» Àоî¾ß ÇÑ´Ù. ¸µÅ© ·¹º§ Çì´õµéÀÇ Å©±â´Â UIP_LLH_LENÀ» Á¤ÀÇÇÔÀ¸·Î½á ¼³Á¤ÇÑ´Ù.


Note:
The application data need not be placed in this buffer, so the device driver must read it from the place pointed to by the uip_appdata pointer as illustrated by the following example:

¾îÇø®ÄÉÀÌ¼Ç µ¥ÀÌÅ͸¦ ÀÌ ¹öÆÛ¿¡ ÀúÀåÇÒ ÇÊ¿ä´Â ¾øÀ¸¹Ç·Î, µð¹ÙÀ̽º µå¶óÀ̹ö´Â ´ÙÀ½ ¿¹Á¦¿Í °°ÀÌ uip_appdataÆ÷ÀÎÅÍ¿¡ ÀÇÇØ °¡¸®ÄÑÁö´Â Àå¼Ò¿¡¼­ À̸¦ Àоî¾ß ÇÑ´Ù.
 void
 devicedriver_send(void)
 {
    hwsend(&uip_buf[0], UIP_LLH_LEN);
    hwsend(&uip_buf[UIP_LLH_LEN], 40);
    hwsend(uip_appdata, uip_len - 40 - UIP_LLH_LEN);
 }


Generated on Tue Oct 7 15:51:43 2003 for uIP 0.9 by doxygen 1.3.3