Ignore:
Timestamp:
Feb 20, 2016, 10:43:32 PM (8 years ago)
Author:
coas-nagasima
Message:

インクルードのパス指定をContikiに合わせ変更。
整数型の型名をContikiに合わせ変更。

Location:
uKadecot/trunk/uip/net/ipv4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uKadecot/trunk/uip/net/ipv4/uip-fw.c

    r157 r158  
    5454 */
    5555
    56 #include "uip.h"
    57 #include "uip_arch.h"
    58 #include "uip-fw.h"
     56#include "net/ip/uip.h"
     57#include "net/ip/uip_arch.h"
     58#include "net/ipv4/uip-fw.h"
    5959
    6060#include <string.h> /* for memcpy() */
     
    7878struct tcpip_hdr {
    7979  /* IP header. */
    80   u8_t vhl,
     80  uint8_t vhl,
    8181    tos;
    82   u16_t len,
     82  uint16_t len,
    8383    ipid,
    8484    ipoffset;
    85   u8_t ttl,
     85  uint8_t ttl,
    8686    proto;
    87   u16_t ipchksum;
    88   u16_t srcipaddr[2],
     87  uint16_t ipchksum;
     88  uint16_t srcipaddr[2],
    8989    destipaddr[2];
    9090 
    9191  /* TCP header. */
    92   u16_t srcport,
     92  uint16_t srcport,
    9393    destport;
    94   u8_t seqno[4],
     94  uint8_t seqno[4],
    9595    ackno[4],
    9696    tcpoffset,
    9797    flags,
    9898    wnd[2];
    99   u16_t tcpchksum;
    100   u8_t urgp[2];
    101   u8_t optdata[4];
     99  uint16_t tcpchksum;
     100  uint8_t urgp[2];
     101  uint8_t optdata[4];
    102102};
    103103
    104104struct icmpip_hdr {
    105105  /* IP header. */
    106   u8_t vhl,
     106  uint8_t vhl,
    107107    tos,
    108108    len[2],
     
    111111    ttl,
    112112    proto;
    113   u16_t ipchksum;
    114   u16_t srcipaddr[2],
     113  uint16_t ipchksum;
     114  uint16_t srcipaddr[2],
    115115    destipaddr[2];
    116116  /* ICMP (echo) header. */
    117   u8_t type, icode;
    118   u16_t icmpchksum;
    119   u16_t id, seqno;
    120   u8_t payload[1];
     117  uint8_t type, icode;
     118  uint16_t icmpchksum;
     119  uint16_t id, seqno;
     120  uint8_t payload[1];
    121121};
    122122
     
    142142 */
    143143struct fwcache_entry {
    144   u16_t timer;
    145  
    146   u16_t srcipaddr[2];
    147   u16_t destipaddr[2];
    148   u16_t ipid;
    149   u8_t proto;
    150   u8_t unused;
     144  uint16_t timer;
     145 
     146  uint16_t srcipaddr[2];
     147  uint16_t destipaddr[2];
     148  uint16_t ipid;
     149  uint8_t proto;
     150  uint8_t unused;
    151151
    152152#if notdef
    153   u16_t payload[2];
     153  uint16_t payload[2];
    154154#endif
    155155
    156156#if UIP_REASSEMBLY > 0
    157   u16_t len, offset;
     157  uint16_t len, offset;
    158158#endif
    159159};
     
    217217/*------------------------------------------------------------------------------*/
    218218static unsigned char
    219 ipaddr_maskcmp(u16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)
     219ipaddr_maskcmp(uint16_t *ipaddr, uint16_t *netipaddr, uint16_t *netmask)
    220220{
    221221  return (ipaddr[0] & netmask [0]) == (netipaddr[0] & netmask[0]) &&
     
    234234time_exceeded(void)
    235235{
    236   u16_t tmp16;
     236  uint16_t tmp16;
    237237
    238238  /* We don't send out ICMP errors for ICMP messages. */
     
    250250  /* Calculate the ICMP checksum. */
    251251  ICMPBUF->icmpchksum = 0;
    252   ICMPBUF->icmpchksum = ~uip_chksum((u16_t *)&(ICMPBUF->type), 36);
     252  ICMPBUF->icmpchksum = ~uip_chksum((uint16_t *)&(ICMPBUF->type), 36);
    253253
    254254  /* Set the IP destination address to be the source address of the
     
    367367 */
    368368/*------------------------------------------------------------------------------*/
    369 u8_t
     369uint8_t
    370370uip_fw_output(void)
    371371{
     
    415415 */
    416416/*------------------------------------------------------------------------------*/
    417 u8_t
     417uint8_t
    418418uip_fw_forward(void)
    419419{
  • uKadecot/trunk/uip/net/ipv4/uip-fw.h

    r157 r158  
    4747#define __UIP_FW_H__
    4848
    49 #include "uip.h"
     49#include "net/ip/uip.h"
    5050
    5151/**
     
    5555  struct uip_fw_netif *next;  /**< Pointer to the next interface when
    5656                                 linked in a list. */
    57   u16_t ipaddr[2];            /**< The IP address of this interface. */
    58   u16_t netmask[2];           /**< The netmask of the interface. */
    59   u8_t (* output)(void);
     57  uint16_t ipaddr[2];            /**< The IP address of this interface. */
     58  uint16_t netmask[2];           /**< The netmask of the interface. */
     59  uint8_t (* output)(void);
    6060                              /**< A pointer to the function that
    6161                                 sends a packet. */
     
    9494 */
    9595#define uip_fw_setipaddr(netif, addr) \
    96         do { (netif)->ipaddr[0] = ((u16_t *)(addr))[0]; \
    97              (netif)->ipaddr[1] = ((u16_t *)(addr))[1]; } while(0)
     96        do { (netif)->ipaddr[0] = ((uint16_t *)(addr))[0]; \
     97             (netif)->ipaddr[1] = ((uint16_t *)(addr))[1]; } while(0)
    9898/**
    9999 * Set the netmask of a network interface.
     
    106106 */
    107107#define uip_fw_setnetmask(netif, addr) \
    108         do { (netif)->netmask[0] = ((u16_t *)(addr))[0]; \
    109              (netif)->netmask[1] = ((u16_t *)(addr))[1]; } while(0)
     108        do { (netif)->netmask[0] = ((uint16_t *)(addr))[0]; \
     109             (netif)->netmask[1] = ((uint16_t *)(addr))[1]; } while(0)
    110110
    111111void uip_fw_init(void);
    112 u8_t uip_fw_forward(void);
    113 u8_t uip_fw_output(void);
     112uint8_t uip_fw_forward(void);
     113uint8_t uip_fw_output(void);
    114114void uip_fw_register(struct uip_fw_netif *netif);
    115115void uip_fw_default(struct uip_fw_netif *netif);
  • uKadecot/trunk/uip/net/ipv4/uip-neighbor.c

    r157 r158  
    4040 */
    4141
    42 #include "uip-neighbor.h"
     42#include "net/ipv4/uip-neighbor.h"
    4343
    4444#include <string.h>
     
    5555  uip_ipaddr_t ipaddr;
    5656  struct uip_neighbor_addr addr;
    57   u8_t time;
     57  uint8_t time;
    5858};
    5959static struct neighbor_entry entries[ENTRIES];
     
    8686{
    8787  int i, oldest;
    88   u8_t oldest_time;
     88  uint8_t oldest_time;
    8989
    9090  printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
  • uKadecot/trunk/uip/net/ipv4/uip-neighbor.h

    r157 r158  
    4343#define __UIP_NEIGHBOR_H__
    4444
    45 #include "uip.h"
     45#include "net/ip/uip.h"
    4646
    4747struct uip_neighbor_addr {
  • uKadecot/trunk/uip/net/ipv4/uip.c

    r157 r158  
    8080*/
    8181
    82 #include "uip.h"
    83 #include "uipopt.h"
    84 #include "uip_arch.h"
     82#include "net/ip/uip.h"
     83#include "net/ip/uipopt.h"
     84#include "net/ip/uip_arch.h"
    8585
    8686#if UIP_CONF_IPV6
    87 #include "uip-neighbor.h"
     87#include "net/ipv4/uip-neighbor.h"
    8888#endif /* UIP_CONF_IPV6 */
    8989
     
    137137
    138138#ifndef UIP_CONF_EXTERNAL_BUFFER
    139 u8_t uip_buf[UIP_BUFSIZE + 2];   /* The packet buffer that contains
     139uint8_t uip_buf[UIP_BUFSIZE + 2];   /* The packet buffer that contains
    140140                                    incoming packets. */
    141141#endif /* UIP_CONF_EXTERNAL_BUFFER */
     
    150150                                       urgent data (out-of-band data), if
    151151                                       present. */
    152 u16_t uip_urglen, uip_surglen;
     152uint16_t uip_urglen, uip_surglen;
    153153#endif /* UIP_URGDATA > 0 */
    154154
    155 u16_t uip_len, uip_slen;
     155uint16_t uip_len, uip_slen;
    156156                             /* The uip_len is either 8 or 16 bits,
    157157                                depending on the maximum packet
    158158                                size. */
    159159
    160 u8_t uip_flags;     /* The uip_flags variable is used for
     160uint8_t uip_flags;     /* The uip_flags variable is used for
    161161                                communication between the TCP/IP stack
    162162                                and the application program. */
     
    167167                             /* The uip_conns array holds all TCP
    168168                                connections. */
    169 u16_t uip_listenports[UIP_LISTENPORTS];
     169uint16_t uip_listenports[UIP_LISTENPORTS];
    170170                             /* The uip_listenports list all currently
    171171                                listning ports. */
     
    175175#endif /* UIP_UDP */
    176176
    177 static u16_t ipid;           /* Ths ipid variable is an increasing
     177static uint16_t ipid;           /* Ths ipid variable is an increasing
    178178                                number that is used for the IP ID
    179179                                field. */
    180180
    181 void uip_setipid(u16_t id) { ipid = id; }
    182 
    183 static u8_t iss[4];          /* The iss variable is used for the TCP
     181void uip_setipid(uint16_t id) { ipid = id; }
     182
     183static uint8_t iss[4];          /* The iss variable is used for the TCP
    184184                                initial sequence number. */
    185185
    186186#if UIP_ACTIVE_OPEN
    187 static u16_t lastport;       /* Keeps track of the last port used for
     187static uint16_t lastport;       /* Keeps track of the last port used for
    188188                                a new connection. */
    189189#endif /* UIP_ACTIVE_OPEN */
    190190
    191191/* Temporary variables. */
    192 u8_t uip_acc32[4];
    193 static u8_t c, opt;
    194 static u16_t tmp16;
     192uint8_t uip_acc32[4];
     193static uint8_t c, opt;
     194static uint16_t tmp16;
    195195
    196196/* Structures and definitions. */
     
    247247#if ! UIP_ARCH_ADD32
    248248void
    249 uip_add32(u8_t *op32, u16_t op16)
     249uip_add32(uint8_t *op32, uint16_t op16)
    250250{
    251251  uip_acc32[3] = op32[3] + (op16 & 0xff);
     
    277277#if ! UIP_ARCH_CHKSUM
    278278/*---------------------------------------------------------------------------*/
    279 static u16_t
    280 chksum(u16_t sum, const u8_t *data, u16_t len)
     279static uint16_t
     280chksum(uint16_t sum, const uint8_t *data, uint16_t len)
    281281{
    282   u16_t t;
    283   const u8_t *dataptr;
    284   const u8_t *last_byte;
     282  uint16_t t;
     283  const uint8_t *dataptr;
     284  const uint8_t *last_byte;
    285285
    286286  dataptr = data;
     
    308308}
    309309/*---------------------------------------------------------------------------*/
    310 u16_t
    311 uip_chksum(u16_t *data, u16_t len)
     310uint16_t
     311uip_chksum(uint16_t *data, uint16_t len)
    312312{
    313   return htons(chksum(0, (u8_t *)data, len));
     313  return htons(chksum(0, (uint8_t *)data, len));
    314314}
    315315/*---------------------------------------------------------------------------*/
    316316#ifndef UIP_ARCH_IPCHKSUM
    317 u16_t
     317uint16_t
    318318uip_ipchksum(void)
    319319{
    320   u16_t sum;
     320  uint16_t sum;
    321321
    322322  sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN);
     
    326326#endif
    327327/*---------------------------------------------------------------------------*/
    328 static u16_t
    329 upper_layer_chksum(u8_t proto)
     328static uint16_t
     329upper_layer_chksum(uint8_t proto)
    330330{
    331   u16_t upper_layer_len;
    332   u16_t sum;
     331  uint16_t upper_layer_len;
     332  uint16_t sum;
    333333
    334334#if UIP_CONF_IPV6
    335   upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]);
     335  upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]);
    336336#else /* UIP_CONF_IPV6 */
    337   upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;
     337  upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;
    338338#endif /* UIP_CONF_IPV6 */
    339339
     
    343343  sum = upper_layer_len + proto;
    344344  /* Sum IP source and destination addresses. */
    345   sum = chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t));
     345  sum = chksum(sum, (uint8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t));
    346346
    347347  /* Sum TCP header and data. */
     
    353353/*---------------------------------------------------------------------------*/
    354354#if UIP_CONF_IPV6
    355 u16_t
     355uint16_t
    356356uip_icmp6chksum(void)
    357357{
     
    361361#endif /* UIP_CONF_IPV6 */
    362362/*---------------------------------------------------------------------------*/
    363 u16_t
     363uint16_t
    364364uip_tcpchksum(void)
    365365{
     
    368368/*---------------------------------------------------------------------------*/
    369369#if UIP_UDP_CHECKSUMS
    370 u16_t
     370uint16_t
    371371uip_udpchksum(void)
    372372{
     
    375375#endif /* UIP_UDP_CHECKSUMS */
    376376#endif /* UIP_ARCH_CHKSUM */
    377 u8_t
     377uint8_t
    378378uip_ismulticast(uip_ipaddr_t ipaddr)
    379379{
     
    381381  return 0;
    382382#else
    383   static const u16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };
    384   static const u16_t multicast_mask[2] = { 0x00f0, 0x0000 };
     383  static const uint16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };
     384  static const uint16_t multicast_mask[2] = { 0x00f0, 0x0000 };
    385385  return uip_ipaddr_maskcmp(ipaddr, multicast_ipaddr, multicast_mask);
    386386#endif
     
    416416#if UIP_ACTIVE_OPEN
    417417struct uip_conn *
    418 uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
     418uip_connect(uip_ipaddr_t *ripaddr, uint16_t rport)
    419419{
    420420  register struct uip_conn *conn, *cconn;
     
    482482#if UIP_UDP
    483483struct uip_udp_conn *
    484 uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport)
     484uip_udp_new(uip_ipaddr_t *ripaddr, uint16_t rport)
    485485{
    486486  register struct uip_udp_conn *conn;
     
    527527/*---------------------------------------------------------------------------*/
    528528void
    529 uip_unlisten(u16_t port)
     529uip_unlisten(uint16_t port)
    530530{
    531531  for(c = 0; c < UIP_LISTENPORTS; ++c) {
     
    538538/*---------------------------------------------------------------------------*/
    539539void
    540 uip_listen(u16_t port)
     540uip_listen(uint16_t port)
    541541{
    542542  for(c = 0; c < UIP_LISTENPORTS; ++c) {
     
    552552#if UIP_REASSEMBLY && !UIP_CONF_IPV6
    553553#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN)
    554 static u8_t uip_reassbuf[UIP_REASS_BUFSIZE];
    555 static u8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
    556 static const u8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,
     554static uint8_t uip_reassbuf[UIP_REASS_BUFSIZE];
     555static uint8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
     556static const uint8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,
    557557                                    0x0f, 0x07, 0x03, 0x01};
    558 static u16_t uip_reasslen;
    559 static u8_t uip_reassflags;
     558static uint16_t uip_reasslen;
     559static uint8_t uip_reassflags;
    560560#define UIP_REASS_FLAG_LASTFRAG 0x01
    561 static u8_t uip_reasstmr;
     561static uint8_t uip_reasstmr;
    562562
    563563#define IP_MF   0x20
    564564
    565 static u8_t
     565static uint8_t
    566566uip_reass(void)
    567567{
    568   u16_t offset, len;
    569   u16_t i;
     568  uint16_t offset, len;
     569  uint16_t i;
    570570
    571571  /* If ip_reasstmr is zero, no packet is present in the buffer, so we
     
    653653         right amount of bits. */
    654654      if(uip_reassbitmap[uip_reasslen / (8 * 8)] !=
    655          (u8_t)~bitmap_bits[uip_reasslen / 8 & 7]) {
     655         (uint8_t)~bitmap_bits[uip_reasslen / 8 & 7]) {
    656656        goto nullreturn;
    657657      }
     
    681681/*---------------------------------------------------------------------------*/
    682682static void
    683 uip_add_rcv_nxt(u16_t n)
     683uip_add_rcv_nxt(uint16_t n)
    684684{
    685685  uip_add32(uip_conn->rcv_nxt, n);
     
    691691/*---------------------------------------------------------------------------*/
    692692void
    693 uip_process(u8_t flag)
     693uip_process(uint8_t flag)
    694694{
    695695  register struct uip_conn *uip_connr = uip_conn;
     
    13491349                uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) {
    13501350        /* An MSS option with the right option length. */
    1351         tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
    1352           (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
     1351        tmp16 = ((uint16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
     1352          (uint16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
    13531353        uip_connr->initialmss = uip_connr->mss =
    13541354          tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
     
    16311631       "persistent timer" and uses the retransmission mechanim.
    16321632    */
    1633     tmp16 = ((u16_t)BUF->wnd[0] << 8) + (u16_t)BUF->wnd[1];
     1633    tmp16 = ((uint16_t)BUF->wnd[0] << 8) + (uint16_t)BUF->wnd[1];
    16341634    if(tmp16 > uip_connr->initialmss ||
    16351635       tmp16 == 0) {
     
    18911891}
    18921892/*---------------------------------------------------------------------------*/
    1893 u16_t
    1894 htons(u16_t val)
     1893uint16_t
     1894htons(uint16_t val)
    18951895{
    18961896  return HTONS(val);
  • uKadecot/trunk/uip/net/ipv4/uip_arp.c

    r157 r158  
    6060
    6161
    62 #include "uip_arp.h"
     62#include "net/ipv4/uip_arp.h"
    6363
    6464#include <string.h>
     
    7272struct arp_hdr {
    7373  struct uip_eth_hdr ethhdr;
    74   u16_t hwtype;
    75   u16_t protocol;
    76   u8_t hwlen;
    77   u8_t protolen;
    78   u16_t opcode;
     74  uint16_t hwtype;
     75  uint16_t protocol;
     76  uint8_t hwlen;
     77  uint8_t protolen;
     78  uint16_t opcode;
    7979  struct uip_eth_addr shwaddr;
    80   u16_t sipaddr[2];
     80  uint16_t sipaddr[2];
    8181  struct uip_eth_addr dhwaddr;
    82   u16_t dipaddr[2];
     82  uint16_t dipaddr[2];
    8383};
    8484
     
    8686  struct uip_eth_hdr ethhdr;
    8787  /* IP header. */
    88   u8_t vhl,
     88  uint8_t vhl,
    8989    tos,
    9090    len[2],
     
    9393    ttl,
    9494    proto;
    95   u16_t ipchksum;
    96   u16_t srcipaddr[2],
     95  uint16_t ipchksum;
     96  uint16_t srcipaddr[2],
    9797    destipaddr[2];
    9898};
     
    110110
    111111struct arp_entry {
    112   u16_t ipaddr[2];
     112  uint16_t ipaddr[2];
    113113  struct uip_eth_addr ethaddr;
    114   u8_t time;
     114  uint8_t time;
    115115};
    116116
    117117static const struct uip_eth_addr broadcast_ethaddr =
    118118  {{0xff,0xff,0xff,0xff,0xff,0xff}};
    119 static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
    120 static const u16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };
    121 static const u16_t multicast_mask[2] = { 0x00f0, 0x0000 };
     119static const uint16_t broadcast_ipaddr[2] = {0xffff,0xffff};
     120static const uint16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };
     121static const uint16_t multicast_mask[2] = { 0x00f0, 0x0000 };
    122122
    123123static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
    124 static u16_t ipaddr[2];
    125 static u8_t i, c;
    126 
    127 static u8_t arptime;
    128 static u8_t tmpage;
     124static uint16_t ipaddr[2];
     125static uint8_t i, c;
     126
     127static uint8_t arptime;
     128static uint8_t tmpage;
    129129
    130130#define BUF   ((struct arp_hdr *)&uip_buf[0])
     
    170170/*-----------------------------------------------------------------------------------*/
    171171static void
    172 uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
     172uip_arp_update(uint16_t *ipaddr, struct uip_eth_addr *ethaddr)
    173173{
    174174  register struct arp_entry *tabptr = NULL;
  • uKadecot/trunk/uip/net/ipv4/uip_arp.h

    r157 r158  
    5353#define __UIP_ARP_H__
    5454
    55 #include "uip.h"
     55#include "net/ip/uip.h"
    5656
    5757#ifdef __RX
     
    6969  struct uip_eth_addr dest;
    7070  struct uip_eth_addr src;
    71   u16_t type;
     71  uint16_t type;
    7272};
    7373
Note: See TracChangeset for help on using the changeset viewer.