direct-io.hg

changeset 470:b52f15bd4369

bitkeeper revision 1.245 (3ec92fdez1HafjDKzTvVNtSF_Pa4_g)

net_headers.h:
new file
kernel.c:
remove in-file net header declarations, put them in net_headers.h
author akw27@boulderdash.cl.cam.ac.uk
date Mon May 19 19:26:22 2003 +0000 (2003-05-19)
parents bfdd6b7987be
children 858e1659fdcb
files .rootkeys xen/common/kernel.c xen/include/xeno/net_headers.h
line diff
     1.1 --- a/.rootkeys	Mon May 19 13:53:25 2003 +0000
     1.2 +++ b/.rootkeys	Mon May 19 19:26:22 2003 +0000
     1.3 @@ -430,6 +430,7 @@ 3ddb79c1fsWuKI2sGlW5bqoG2lPVNA xen/inclu
     1.4  3ddb79c1gs2VbLbQlw0dcDUXYIepDA xen/include/xeno/mm.h
     1.5  3ddb79c13p9iHn1XAp0IS1qvj4yDsg xen/include/xeno/module.h
     1.6  3ddb79c1ieLZfGSFwfvvSQ2NK1BMSg xen/include/xeno/multiboot.h
     1.7 +3ec92e46saEJq7v1vgEJD3HZSufSBg xen/include/xeno/net_headers.h
     1.8  3ddb79c0CLfAlJLg1ohdPD-Jjn-jxg xen/include/xeno/netdevice.h
     1.9  3e4540ccaugeWGdOuphJKj6WFw1jkw xen/include/xeno/notifier.h
    1.10  3ddb79c2Fg44_PBPVxHSC0gTOMq4Ow xen/include/xeno/pci.h
     2.1 --- a/xen/common/kernel.c	Mon May 19 13:53:25 2003 +0000
     2.2 +++ b/xen/common/kernel.c	Mon May 19 19:26:22 2003 +0000
     2.3 @@ -18,6 +18,7 @@
     2.4  #include <linux/if_ether.h>
     2.5  #include <asm/domain_page.h>
     2.6  #include <xeno/console.h>
     2.7 +#include <xeno/net_headers.h>
     2.8  
     2.9  static int xpos, ypos;
    2.10  static volatile unsigned char *video;
    2.11 @@ -467,42 +468,6 @@ unsigned short compute_cksum(unsigned sh
    2.12  
    2.13  extern int netif_rx(struct sk_buff *); 
    2.14  
    2.15 -typedef struct my_udphdr {
    2.16 -    __u16 source;
    2.17 -    __u16 dest;
    2.18 -    __u16 len;
    2.19 -    __u16 check;
    2.20 -} my_udphdr_t; 
    2.21 -
    2.22 -
    2.23 -typedef struct my_iphdr {
    2.24 -#if defined(__LITTLE_ENDIAN_BITFIELD)
    2.25 -    __u8    ihl:4,
    2.26 -	version:4;
    2.27 -#elif defined (__BIG_ENDIAN_BITFIELD)
    2.28 -    __u8    version:4,
    2.29 -	ihl:4;
    2.30 -#else
    2.31 -#error  "Please fix <asm/byteorder.h>"
    2.32 -#endif
    2.33 -    __u8    tos;
    2.34 -    __u16   tot_len;
    2.35 -    __u16   id;
    2.36 -    __u16   frag_off;
    2.37 -    __u8    ttl;
    2.38 -    __u8    protocol;
    2.39 -    __u16   check;
    2.40 -    __u32   saddr;
    2.41 -    __u32   daddr;
    2.42 -} my_iphdr_t; 
    2.43 -
    2.44 -
    2.45 -typedef struct my_ethhdr {
    2.46 -    unsigned char   h_dest[6];   	
    2.47 -    unsigned char   h_source[6]; 	
    2.48 -    unsigned short  h_proto;        
    2.49 -} my_ethhdr_t; 
    2.50 -
    2.51  /*
    2.52   * Function written by ek247. Exports console output from all domains upwards 
    2.53   * to domain0, by stuffing it into a fake network packet.
    2.54 @@ -510,13 +475,13 @@ typedef struct my_ethhdr {
    2.55  int console_export(char *str, int len)
    2.56  {
    2.57      struct sk_buff *skb;
    2.58 -    struct my_iphdr *iph = NULL;  
    2.59 -    struct my_udphdr *udph = NULL; 
    2.60 -    struct my_ethhdr *ethh = NULL; 
    2.61 -    int hdr_size = sizeof(struct my_iphdr) + sizeof(struct my_udphdr); 
    2.62 +    struct iphdr *iph = NULL;  
    2.63 +    struct udphdr *udph = NULL; 
    2.64 +    struct ethhdr *ethh = NULL; 
    2.65 +    int hdr_size = sizeof(struct iphdr) + sizeof(struct udphdr); 
    2.66      u8 *skb_data;
    2.67  
    2.68 -    skb = dev_alloc_skb(sizeof(struct my_ethhdr) + 
    2.69 +    skb = dev_alloc_skb(sizeof(struct ethhdr) + 
    2.70                                     hdr_size + len + 20);
    2.71      if ( skb == NULL ) return 0;
    2.72  
    2.73 @@ -525,12 +490,12 @@ int console_export(char *str, int len)
    2.74      skb_reserve(skb, 2);
    2.75  
    2.76      /* Get a pointer to each header. */
    2.77 -    ethh = (struct my_ethhdr *) 
    2.78 +    ethh = (struct ethhdr *) 
    2.79          (skb_data + (skb->data - skb->head));
    2.80 -    iph  = (struct my_iphdr *)(ethh + 1);
    2.81 -    udph = (struct my_udphdr *)(iph + 1); 
    2.82 +    iph  = (struct iphdr *)(ethh + 1);
    2.83 +    udph = (struct udphdr *)(iph + 1); 
    2.84  
    2.85 -    skb_reserve(skb, sizeof(struct my_ethhdr)); 
    2.86 +    skb_reserve(skb, sizeof(struct ethhdr)); 
    2.87      skb_put(skb, hdr_size + len); 
    2.88  
    2.89      /* Build IP header. */
    2.90 @@ -544,12 +509,12 @@ int console_export(char *str, int len)
    2.91      iph->saddr   = htonl(0xa9fefeff);  /* 169.254.254.255 */
    2.92      iph->tot_len = htons(hdr_size + len); 
    2.93      iph->check	 = 0;
    2.94 -    iph->check   = compute_cksum((__u16 *)iph, sizeof(struct my_iphdr)/2); 
    2.95 +    iph->check   = compute_cksum((__u16 *)iph, sizeof(struct iphdr)/2); 
    2.96  
    2.97      /* Build UDP header. */
    2.98      udph->source = htons(current->domain);
    2.99      udph->dest   = htons(666);
   2.100 -    udph->len    = htons(sizeof(struct my_udphdr) + len);
   2.101 +    udph->len    = htons(sizeof(struct udphdr) + len);
   2.102      udph->check  = 0;
   2.103  
   2.104      /* Build the UDP payload. */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/include/xeno/net_headers.h	Mon May 19 19:26:22 2003 +0000
     3.3 @@ -0,0 +1,128 @@
     3.4 +/*
     3.5 + * net_headers.h
     3.6 + *
     3.7 + * This is a compilation of various network headers, to facilitate
     3.8 + * access in Xen, which is generally quite simple and doesn't need
     3.9 + * all the bloat of extra defines and so on.
    3.10 + *
    3.11 + * Pretty much everything here is pulled from ip.h, tcp.h, and if_eth.h
    3.12 + *
    3.13 + * Reduced, congealed, and otherwise munged by akw. 
    3.14 + * 
    3.15 + * Original authors:
    3.16 + * 
    3.17 + *    Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> (ip.h, tcp.h, udp.h)
    3.18 + *
    3.19 + *    (if_arp.h):
    3.20 + *    Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
    3.21 + *    Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
    3.22 + *    Ross Biro, <bir7@leland.Stanford.Edu>
    3.23 + *    Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
    3.24 + *    Florian La Roche,
    3.25 + *    Jonathan Layes <layes@loran.com>
    3.26 + *    Arnaldo Carvalho de Melo <acme@conectiva.com.br> ARPHRD_HWX25
    3.27 + *
    3.28 + * Original legalese:
    3.29 + *
    3.30 + *    This program is free software; you can redistribute it and/or
    3.31 + *    modify it under the terms of the GNU General Public License
    3.32 + *    as published by the Free Software Foundation; either version
    3.33 + *    2 of the License, or (at your option) any later version.
    3.34 + */
    3.35 +
    3.36 +#ifndef __NET_HEADERS_H__
    3.37 +#define __NET_HEADERS_H__
    3.38 +
    3.39 +#include <xeno/types.h>
    3.40 +#include <asm/byteorder.h>
    3.41 +#include <xeno/if_ether.h> 
    3.42 +
    3.43 +/* from ip.h */
    3.44 +
    3.45 +struct iphdr {
    3.46 +#if defined(__LITTLE_ENDIAN_BITFIELD)
    3.47 +    __u8    ihl:4,
    3.48 +        version:4;
    3.49 +#elif defined (__BIG_ENDIAN_BITFIELD)
    3.50 +    __u8    version:4,
    3.51 +        ihl:4;
    3.52 +#else
    3.53 +#error  "Please fix <asm/byteorder.h>"
    3.54 +#endif
    3.55 +    __u8    tos;
    3.56 +    __u16   tot_len;
    3.57 +    __u16   id;
    3.58 +    __u16   frag_off;
    3.59 +    __u8    ttl;
    3.60 +    __u8    protocol;
    3.61 +    __u16   check;
    3.62 +    __u32   saddr;
    3.63 +    __u32   daddr;
    3.64 +    /*The options start here. */
    3.65 +};
    3.66 +
    3.67 +/* from tcp.h */
    3.68 +
    3.69 +struct tcphdr {
    3.70 +    __u16   source;
    3.71 +    __u16   dest;
    3.72 +    __u32   seq;
    3.73 +    __u32   ack_seq;
    3.74 +#if defined(__LITTLE_ENDIAN_BITFIELD)
    3.75 +    __u16   res1:4,
    3.76 +        doff:4,
    3.77 +        fin:1,
    3.78 +        syn:1,
    3.79 +        rst:1,
    3.80 +        psh:1,
    3.81 +        ack:1,
    3.82 +        urg:1,
    3.83 +        ece:1,
    3.84 +        cwr:1;
    3.85 +#elif defined(__BIG_ENDIAN_BITFIELD)
    3.86 +    __u16   doff:4,
    3.87 +        res1:4,
    3.88 +        cwr:1,
    3.89 +        ece:1,
    3.90 +        urg:1,
    3.91 +        ack:1,
    3.92 +        psh:1,
    3.93 +        rst:1,
    3.94 +        syn:1,
    3.95 +        fin:1;
    3.96 +#else
    3.97 +#error  "Adjust your <asm/byteorder.h> defines"
    3.98 +#endif
    3.99 +    __u16   window;
   3.100 +    __u16   check;
   3.101 +    __u16   urg_ptr;
   3.102 +};
   3.103 +
   3.104 +/* From udp.h */
   3.105 +
   3.106 +struct udphdr {
   3.107 +    __u16   source;
   3.108 +    __u16   dest;
   3.109 +    __u16   len;
   3.110 +    __u16   check;
   3.111 +};
   3.112 +
   3.113 +/* from if_arp.h */
   3.114 +
   3.115 +struct arphdr
   3.116 +{
   3.117 +    __u16   ar_hrd;                      /* format of hardware address    */
   3.118 +    __u16   ar_pro;                      /* format of protocol address    */
   3.119 +    __u8    ar_hln;                      /* length of hardware address    */
   3.120 +    __u8    ar_pln;                      /* length of protocol address    */
   3.121 +    __u16   ar_op;                       /* ARP opcode (command)          */
   3.122 +
   3.123 +    /* This next bit is variable sized, and as coded only allows ETH-IPv4 */
   3.124 +    __u8    ar_sha[ETH_ALEN];            /* sender hardware address       */
   3.125 +    __u32   ar_sip;                      /* sender IP address             */
   3.126 +    __u8    ar_tha[ETH_ALEN];            /* target hardware address       */
   3.127 +    __u32   ar_tip;                      /* target IP address             */
   3.128 +};
   3.129 +
   3.130 +
   3.131 +#endif /* __NET_HEADERS_H__ */