/home/tomh/openhip/hip-0.5/src/include/hip/hip_types.h

Go to the documentation of this file.
00001 /*
00002  * Host Identity Protocol
00003  * Copyright (C) 2002-05 the Boeing Company
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  *              Definitions for the HIP protocol.
00016  *
00017  *  Version:    @(#)hip.h       1.5     08/12/04
00018  *
00019  *  Authors:    Jeff Ahrenholz, <jeffrey.m.ahrenholz@boeing.com>
00020  *              Tom Henderson, <thomas.r.henderson@boeing.com>
00021  *
00022  *
00023  */
00024 
00025 #ifndef _HIP_TYPES_H_
00026 #define _HIP_TYPES_H_
00027 
00028 /* XXX clean up type portability */
00029 #if defined (__MACOSX__)
00030 #include <mac/mac_types.h>
00031 #elif defined (__WIN32__) 
00032 #include <win32/types.h>
00033 #else /* Linux */
00034 #include <asm/types.h>  
00035 #endif
00036 
00037 #ifdef __MACOSX__
00038 #include <sys/types.h>
00039 #include <sys/time.h>
00040 #endif
00041 #ifdef __WIN32__
00042 #include <winsock2.h>
00043 #else
00044 #include <sys/socket.h> /* sockaddr */
00045 #include <netinet/in.h>
00046 #endif
00047 #include <sys/types.h>
00048 #include <openssl/bn.h>
00049 #include <openssl/hmac.h>
00050 #include <openssl/rsa.h>
00051 #include <time.h>
00052 
00053 #include <hip/hip_proto.h>
00054 
00055 /* 
00056  * Implementation configuration options 
00057  */
00058 #define HIP_PUB_SUFFIX          "_host_identities.pub.xml"
00059 #ifndef __WIN32__
00060 #define HIP_CONF_FILENAME       "../etc/hip/hip.conf"
00061 #define HIP_MYID_FILENAME       "../etc/hip/my_host_identities.xml"
00062 #define HIP_KNOWNID_FILENAME    "../etc/hip/known_host_identities.xml"
00063 #define HIP_REG_FILENAME        "../etc/hip/registered_host_identities.xml"
00064 #define HIP_PUB_PREFIX          "../etc/hip/"
00065 /*
00066  * The below hard coded paths are checked if the above fails
00067  */
00068 #define HIP_DEFAULT_CONF_FILENAME       "/usr/local/etc/hip/hip.conf"
00069 #define HIP_DEFAULT_MYID_FILENAME       "/usr/local/etc/hip/my_host_identities.xml"
00070 #define HIP_DEFAULT_KNOWNID_FILENAME    "/usr/local/etc/hip/known_host_identities.xml"
00071 #define HIP_DEFAULT_REG_FILENAME        "/usr/local/etc/hip/registered_host_identities.xml"
00072 #define HIP_LOCK_FILENAME       "/var/run/hip.pid"
00073 #define HIP_LOG_FILENAME        "/var/log/hipd.log"
00074 #else
00075 #define HIP_CONF_FILENAME       "hip.conf"
00076 #define HIP_MYID_FILENAME       "my_host_identities.xml"
00077 #define HIP_KNOWNID_FILENAME    "known_host_identities.xml"
00078 #define HIP_REG_FILENAME        "registered_host_identities.xml"
00079 #define HIP_PUB_PREFIX          ""
00080 /*
00081  * The below hard coded paths are checked if the above fails
00082  */
00083 #define HIP_DEFAULT_CONF_FILENAME       HIP_CONF_FILENAME
00084 #define HIP_DEFAULT_MYID_FILENAME       HIP_MYID_FILENAME
00085 #define HIP_DEFAULT_KNOWNID_FILENAME    HIP_KNOWNID_FILENAME
00086 #define HIP_DEFAULT_REG_FILENAME        HIP_REG_FILENAME
00087 #define HIP_LOCK_FILENAME       "hip.pid"
00088 #define HIP_LOG_FILENAME        "hipd.log"
00089 #endif
00090 
00091 /*
00092  * Implementation limits
00093  */
00094 #define MAX_HITS 32
00095 #define MAX_CONNECTIONS 32 /* Should be == MAX_HITS */
00096 #define MAX_OPAQUE_SIZE 255 /* how many bytes we may echo in response */
00097 #define MAX_HI_NAMESIZE 255 /* number of bytes for HI Domain Identifier */
00098 #define MAX_HI_BITS 2048 /* number of bits of largest HI accepted - this
00099                           * may limit the time spent w/ DSA verification */
00100 #define MAX_LOCATORS 8  /* number of LOCATORs accepted in an UPDATE message */
00101 #define MAX_REGISTRATIONS 1024  /* used in rvs mode */
00102 
00103 /*
00104  * IPsec-related constants
00105  */
00106 #define DSA_PRIV 20 /* Size in bytes of DSA private key and Q value */
00107 #define HIP_KEY_SIZE 24 /* Must be large enough to hold largest possible key */
00108 #define HIP_DSA_SIG_SIZE 41 /* T(1) + R(20) + S(20)  from RFC 2536 */
00109 #define MAX_SIG_SIZE 512 /* RFC 3110 4096-bits max RSA length */
00110 #define NUMKEYS 8 /* HIP, HMAC, HIP, HMAC, ESP, AUTH, ESP, AUTH */
00111 #define KEYMAT_SIZE (4 * NUMKEYS * HIP_KEY_SIZE) /* 768 bytes, enough space for
00112                                                     32 ESP keys */
00113 /* 3DES keys = 192 bits, 24 bytes; SHA-1 keys = 160 bits, 20 bytes.
00114  * We need 4 3DES and 2 SHA for our 6 keys, 136 bytes, so 144 is enough.
00115  */
00116 
00117 /* 
00118  * Protocol constants 
00119  */ 
00120 #define HIP_RES_SHIM6_BITS 0x01
00121 
00122 
00123 #define H_PROTO_UDP 17
00124 #define HIP_ESP_UDP_PORT 54500
00125 
00126 /* PFKEY message sizes*/
00127 #define SADB_RESPONSE_BUFFER    20
00128 #define SADB_MSG_SIZE_ADD       300
00129 #define SADB_MSG_SIZE_DELETE    150
00130         
00131 /* 
00132  * Miscellaneous constants and enums 
00133  */
00134 #define TRUE 1
00135 #define FALSE 0
00136 /*
00137 #define UNKNOWN -1
00138 */
00139 #define SPI_RESERVED 255
00140 #define HIP_ALIGN 4
00141 #define R1_CACHE_SIZE 8
00142 #define ACCEPTABLE_R1_COUNT_RANGE 2
00143 #ifndef HIP_UPDATE_BIND_CHECKS
00144 #define HIP_UPDATE_BIND_CHECKS 5
00145 #endif
00146 
00147 /* 
00148  * Macros  
00149  */
00150 #define DBG(x) x /* Debugging */
00151 #define TDIFF(a, b) ((a).tv_sec - (b).tv_sec) /* Time diff in seconds */
00152 
00153 /* get pointer to IP from a sockaddr 
00154  *    useful for inet_ntop calls     */
00155 #define SA2IP(x) (((struct sockaddr*)x)->sa_family==AF_INET) ? \
00156         (void*)&((struct sockaddr_in*)x)->sin_addr : \
00157         (void*)&((struct sockaddr_in6*)x)->sin6_addr
00158 /* get socket address length in bytes */
00159 #define SALEN(x) (((struct sockaddr*)x)->sa_family==AF_INET) ? \
00160         sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)
00161 /* get IP address length in bytes */
00162 #define SAIPLEN(x) (((struct sockaddr*)x)->sa_family==AF_INET) ? 4 : 16
00163 /* cast to sockaddr */
00164 #define SA(x) ((struct sockaddr*)x)
00165 
00166 /* boolean to text yes/no */
00167 #define yesno(x) x ? "yes" : "no"
00168 
00169 /* Host Identity Tag is 128 bits long */
00170 #define HIT_SIZE 16
00171 /* The below prefix applies to the uppermost 28 bits only (RFC 4843) */
00172 #define HIT_PREFIX_SHA1_32BITS 0x20010010 
00173 /* convert lower 24-bits of HIT to LSI */
00174 #define HIT2LSI(a) ( 0x01000000L | \
00175                      ((a[HIT_SIZE-3]<<16)+(a[HIT_SIZE-2]<<8)+(a[HIT_SIZE-1])))
00176 
00177 /* compute the exponent of registration lifetime */
00178 #define YLIFE(x) ((float)x-(float)64)/(float)8
00179 
00180 /*
00181  * typedefs
00182  */
00183 typedef __u8 hip_hit [HIT_SIZE];     /* 16-byte (128 bit) Host Identity Tag */
00184 
00185 
00186 
00187 #define HIP_UDP_PORT 50500
00188 #define HIP_KEEPALIVE_TIMEOUT 20
00189 
00190 /* 
00191  * UDP header, used for UDP encapsulation
00192  */
00193 typedef struct _udphdr {
00194       __u16 src_port;
00195       __u16 dst_port;
00196       __u16 len;
00197       __u16 checksum;
00198 } udphdr;
00199 
00200 /*
00201  * HIP header
00202  * This HIP protocol header defines the structure of HIP packets.
00203  */
00204 typedef struct _hiphdr {
00205         __u8  nxt_hdr;         /* payload protocol            */
00206         __u8  hdr_len;          /* header length               */
00207         __u8  packet_type;      /* packet type                 */
00208 
00209 #if defined(__MACOSX__) && defined(__BIG_ENDIAN__)  
00210         __u8  version:4,res:4; /* Endian - not OSX specific */
00211 #else
00212         __u8  res:4,version:4; /* version, reserved        */
00213 #endif
00214         __u16 checksum;         /* checksum                    */
00215         __u16 control;          /* control                     */
00216         hip_hit hit_sndr;       /* Sender's Host Identity Tag  */
00217         hip_hit hit_rcvr;       /* Receiver's Host Identity Tag */
00218         /* HIP TLV parameters follow ...  */
00219 } hiphdr;
00220 
00221 /*
00222  * HIP Cookie
00223  */
00224 typedef struct _hipcookie {
00225         __u8  k;
00226         __u8  lifetime;
00227         __u16 opaque;   
00228         __u64 i __attribute__ ((packed));
00229 } hipcookie;
00230 
00231 struct key_entry {
00232         int type;
00233         int length;
00234         __u8 key[HIP_KEY_SIZE];
00235 };
00236 
00237 struct rekey_info {
00238         __u32 update_id;        /* to be ACKed                  */
00239         __u32 new_spi;          /* SPI that will be adopted     */
00240         __u16 keymat_index;     /* keymat index                 */
00241         __u8 acked;/* set to TRUE when update_id has been ACKed */
00242         __u8 dh_group_id;       /* new DH group given by peer   */
00243         DH *dh;                 /* new DH given by the peer     */
00244         struct timeval rk_time; /* creation time, so struct can be freed */
00245 };
00246 
00247 /*
00248  * HIP Packet Entry
00249  */
00250 struct hip_packet_entry {
00251         __u8 *packet;
00252         int len;
00253         struct timeval xmit_time;
00254         __u32 retransmits;
00255         struct sockaddr_storage dst; /* for address checks */
00256 };
00257 
00258 /*
00259  * HIP association entry
00260  *
00261  */
00262 typedef struct _hip_assoc {
00263         /* Identities */
00264         struct _hi_node *hi;
00265         struct _hi_node *peer_hi;
00266         /* Misc. state variables */
00267         int state;
00268         struct timeval state_time;
00269         struct timeval use_time;
00270         __u64 used_bytes_in;
00271         __u64 used_bytes_out;
00272         __u32 spi_in;
00273         __u32 spi_out;
00274         hipcookie cookie_r;
00275         __u64     cookie_j;
00276         struct hip_packet_entry rexmt_cache;
00277         struct opaque_entry *opaque;
00278         struct rekey_info *rekey; /* new parameters to use after REKEY  */
00279         struct rekey_info *peer_rekey; /* peer's REKEY data from UPDATE */
00280         /* Other crypto */
00281         __u16 hip_transform;
00282         __u16 esp_transform;
00283         __u16 available_transforms; /* bit mask used to flag available xfrms */
00284         __u8 dh_group_id;
00285         DH *dh;
00286         DH *peer_dh;    /* needed for rekeying */
00287         __u8 *dh_secret; /* without packing, these cause memset segfaults! */
00288         __u16 keymat_index;
00289         __u8 keymat[KEYMAT_SIZE] __attribute__ ((packed));
00290         struct key_entry keys[NUMKEYS] __attribute__ ((packed));
00291         __u8 preserve_outbound_policy;
00292         int use_udp; /* 0: no UDP / 1: HIP over UDP */
00293         int next_use_udp; /* used during UPDATE, when rekeying has not been completed */
00294         __u16 peer_dst_port; /* UDP port number used by the peer for HIP packets */
00295         struct timeval use_time_ka; /* last use timestamp, including keepalives */
00296         __u16 peer_esp_dst_port; /* UDP port number used by the peer for ESP packets */
00297 #ifdef __MACOSX__
00298         __u16 ipfw_rule;
00299 #endif
00300 } hip_assoc;
00301 #define HIPA_SRC(h) ((struct sockaddr*)&h->hi->addrs.addr)
00302 #define HIPA_DST(h) ((struct sockaddr*)&h->peer_hi->addrs.addr)
00303 
00304 /*
00305  * HIP registration entry
00306  *
00307 */
00308 typedef struct _hip_reg {
00309         hip_hit peer_hit;
00310 #ifdef __WIN32__
00311         HANDLE peer_addr_mutex;
00312 #else
00313         pthread_mutex_t peer_addr_mutex;
00314 #endif
00315         struct sockaddr_storage peer_addr;
00316         double lifetime;
00317         int update;
00318         hip_assoc *hip_a;
00319 } hip_reg;
00320 
00321 /*
00322  * Struct to use with the search_reg_table
00323 */
00324 typedef struct _returned {
00325         int position;
00326         int update;
00327 } returned;
00328 
00329 /*
00330  * Structs used in the relaying I1 process
00331 */
00332 typedef struct _from {
00333         int add_from;
00334         hip_hit hit_from;
00335         struct sockaddr_storage ip_rvs;
00336         struct sockaddr_storage ip_from;
00337 } from; 
00338 
00339 typedef struct _via {
00340         int add_via_rvs;
00341         struct sockaddr_storage ip_from;
00342 } via;
00343 
00344 /*
00345  * list of struct sockaddrs
00346  */
00347 typedef struct _sockaddr_list
00348 {
00349         struct _sockaddr_list *next;
00350         struct sockaddr_storage addr; /* 128 bytes, enough to store any size */
00351         int if_index;   /* link index */
00352         int lifetime;   /* address lifetime in seconds*/
00353         int status;     /* status from enum ADDRESS_STATES */
00354         int preferred;  /* set to TRUE if it's a new pending preferred addr */
00355         __u32 nonce;    /* random value for address verification */
00356         struct timeval creation_time;
00357 } sockaddr_list;
00358 
00359 /* 
00360  * R1 Cache
00361  */
00362 typedef struct _r1_cache_entry
00363 {
00364         /* the precomputed R1 packet */
00365         __u8 *packet;
00366         int len;
00367         /* stored cookie solutions */
00368         hipcookie *current_puzzle;  /* the cookie that is in packet */
00369         hipcookie *previous_puzzle; /* old cookie */
00370         /* the DH context used in the R1 */
00371         struct _dh_cache_entry *dh_entry;
00372         /* time of entry creation */
00373         struct timeval creation_time;
00374 } r1_cache_entry;
00375 
00376 /* For reference:  struct DSA definition from openssl/dsa.h */
00377 /*
00378  * struct dsa_st {
00379  * 
00380  *      * This first variable is used to pick up errors where
00381  *      * a DSA is passed instead of of a EVP_PKEY *
00382         int pad; 
00383         int version;
00384         int write_params;
00385         BIGNUM *p;
00386         BIGNUM *q;      * == 20 *
00387         BIGNUM *g;
00388 
00389         BIGNUM *pub_key;  * y public key *
00390         BIGNUM *priv_key; * x private key *
00391 
00392         ... (plus some other fields not used in HIP)
00393 */
00394 
00395 typedef struct _hi_node {
00396         struct _hi_node *next;
00397         hip_hit hit;
00398         struct sockaddr_storage lsi;
00399         struct sockaddr_storage rvs;
00400         /* 
00401          * IP address is needed to select a HIT corresponding to
00402          * an IP address.  This value needs update upon readdress.
00403          * Only the first entry of addrs is used for hip_assoc,
00404          * while the list addrs->next is populated when building the
00405          * HI tables.
00406          */
00407 #ifdef __WIN32__
00408         HANDLE addrs_mutex;
00409 #else
00410         pthread_mutex_t addrs_mutex; /* provide DHT thread synchronization */
00411 #endif
00412         struct _sockaddr_list addrs;
00413         /* Key data */
00414         int size;               /* Size in bytes of the Host Identity   */
00415         DSA *dsa;               /* HI in DSA format                     */
00416         RSA *rsa;               /* HI in RSA format                     */
00417         struct _r1_cache_entry r1_cache[R1_CACHE_SIZE]; /* the R1 cache */
00418         __u64 r1_gen_count;     /* R1 generation counter                */
00419         __u32 update_id;        /* this host's Update ID                */
00420         /* Options */
00421         char algorithm_id;
00422         char anonymous;
00423         char allow_incoming;
00424         char skip_addrcheck;
00425         char name[MAX_HI_NAMESIZE];
00426         int name_len;           /* use this instead of strlen()         */
00427 } hi_node;
00428 
00429 /* DH Cache
00430  */
00431 typedef struct _dh_cache_entry
00432 {
00433         struct _dh_cache_entry *next;   /* the cache is a linked-list   */
00434         __u8 group_id;                  /* can have various group_ids   */
00435         DH *dh;                         /* the Diffie-Hellman context   */
00436         __u8 is_current;                /* if this is the latest DH context 
00437                                            for this group_id, then TRUE */
00438         int ref_count;  /* number of hip_assoc that point to this entry */
00439         struct timeval creation_time;   /* determines age */
00440 } dh_cache_entry;
00441 
00442 /* Opaque Data
00443  */
00444 struct opaque_entry
00445 {
00446         __u16 opaque_len;
00447         __u8 opaque_data[MAX_OPAQUE_SIZE];
00448         __u8 opaque_nosig;
00449 };
00450 
00451 typedef struct _pseudo_header6
00452 {
00453         unsigned char src_addr[16];
00454         unsigned char dst_addr[16];
00455         __u32 packet_length;
00456         char zero[3];
00457         __u8 next_hdr;
00458 } pseudo_header6;
00459 
00460 typedef struct _pseudo_header
00461 {
00462         unsigned char src_addr[4];
00463         unsigned char dst_addr[4];
00464         __u8 zero;
00465         __u8 protocol;
00466         __u16 packet_length;
00467 } pseudo_header;
00468 
00469 /*
00470  * TLV parameters
00471  */
00472 
00473 typedef struct _tlv_head
00474 {
00475         __u16 type;
00476         __u16 length;
00477 } tlv_head;
00478 
00479 typedef struct _tlv_esp_info
00480 {
00481         __u16 type;
00482         __u16 length;
00483         __u16 reserved;
00484         __u16 keymat_index;
00485         __u32 old_spi;
00486         __u32 new_spi;
00487 } tlv_esp_info;
00488 
00489 typedef struct _tlv_r1_counter
00490 {
00491         __u16 type;
00492         __u16 length;
00493         __u32 reserved;
00494         __u64 r1_gen_counter;
00495 } tlv_r1_counter;
00496 
00497 typedef struct _tlv_puzzle
00498 {
00499         __u16 type;
00500         __u16 length;
00501         hipcookie cookie;
00502 } tlv_puzzle;
00503 
00504 typedef struct _tlv_solution
00505 {
00506         __u16 type;
00507         __u16 length;
00508         hipcookie cookie;
00509         __u64 j;
00510 } tlv_solution;
00511 
00512 typedef struct _tlv_diffie_hellman
00513 {
00514         __u16 type;
00515         __u16 length;
00516         __u8 group_id __attribute__ ((packed));
00517         __u16 pub_len __attribute__ ((packed));
00518         __u8 pub[1]; /* variable length */
00519 } tlv_diffie_hellman;
00520 
00521 /* used for second DH public value */
00522 typedef struct _tlv_diffie_hellman_pub_value
00523 {
00524         __u8 group_id;
00525         __u16 pub_len;
00526         __u8 pub[1]; /* variable length */
00527 } tlv_diffie_hellman_pub_value;
00528 
00529 typedef struct _tlv_hip_transform
00530 {
00531         __u16 type;
00532         __u16 length;
00533         __u16 transform_id;
00534 } tlv_hip_transform;
00535 
00536 typedef struct _tlv_esp_transform
00537 {
00538         __u16 type;
00539         __u16 length;
00540         __u16 reserved; /* LSB is E-bit */
00541         __u16 suite_id;
00542 } tlv_esp_transform;
00543 
00544 typedef struct _tlv_encrypted
00545 {
00546         __u16 type;
00547         __u16 length;
00548         __u8 reserved[4];
00549         __u8 iv[8];       /* 64-bits for 3-DES and Blowfish */
00550         /* adjust for 128-bits if using AES */
00551         __u8 enc_data[1]; /* variable length */
00552 } tlv_encrypted;
00553 
00554 typedef struct _tlv_host_id
00555 {
00556         __u16 type;
00557         __u16 length;
00558         __u16 hi_length;
00559         __u16 di_type_length;
00560         __u8 hi_hdr[4];
00561         /* for DSA:                             for RSA:
00562          * __u8 hi_t;                           __u8 e_len
00563          * __u8 hi_q[DSA_PRIV];                 __u8 e[1] or __u8 e[3];
00564          * P, G, Y are here, variable           __u8 n[]; variable
00565          * length based on t (64 + 3*t)
00566          *
00567          * also DI is variable
00568          *
00569          */
00570 } tlv_host_id;
00571 
00572 typedef struct _tlv_cert
00573 {
00574         __u16 type;
00575         __u16 length;
00576         __u8 cert_count;
00577         __u8 cert_id;
00578         __u8 cert_type;
00579         __u8 certificate[1];    /* variable length */
00580 } tlv_cert;
00581 
00582 typedef struct _tlv_reg_info
00583 {
00584         __u16 type;
00585         __u16 length;
00586         __u8 min_lifetime;      /* defined as in draft-koponen-hip-registration-01 (exponential lifetime) */
00587         __u8 max_lifetime;      /* defined as in draft-koponen-hip-registration-01 (exponential lifetime) */
00588         __u8 reg_type;          /* reg_type_rvs = 1 by default. no other registration types defined yet */ 
00589 } tlv_reg_info;
00590 
00591 typedef struct _tlv_reg_request
00592 {
00593         __u16 type;
00594         __u16 length;
00595         __u8 lifetime;
00596         __u8 reg_type;   
00597 } tlv_reg_request;
00598 
00599 typedef struct _tlv_reg_response
00600 {
00601         __u16 type;
00602         __u16 length;
00603         __u8 lifetime;
00604         __u8 reg_type;  
00605 } tlv_reg_response;
00606 
00607 typedef struct _tlv_reg_failed
00608 {
00609         __u16 type;
00610         __u16 length;
00611         __u8 fail_type;         /* if 1, error in registration type */
00612         __u8 reg_type;  
00613 } tlv_reg_failed;
00614 
00615 
00616 #ifndef __WIN32__
00617 typedef struct _tlv_reg_required
00618 {
00619         /* TBD */ /* parameter to use in a NOTIFY packet */
00620 } tlv_reg_required;
00621 #endif /* __WIN32__ */
00622 
00623 
00624 typedef struct _tlv_echo        /* response and request the same */
00625 {
00626         __u16 type;
00627         __u16 length;
00628         __u8 opaque_data[1];    /* variable length */
00629         
00630 } tlv_echo;
00631 
00632 typedef struct _tlv_hmac
00633 {
00634         __u16 type;
00635         __u16 length;
00636         __u8 hmac[20];
00637 } tlv_hmac;
00638 
00639 typedef struct _tlv_hip_sig
00640 {
00641         __u16 type;
00642         __u16 length;
00643         __u8 algorithm;
00644         __u8 signature[0]; /* variable length */
00645 } tlv_hip_sig;
00646 
00647 typedef struct _tlv_seq
00648 {
00649         __u16 type;
00650         __u16 length;
00651         __u32 update_id;
00652 } tlv_seq;
00653 
00654 typedef struct _tlv_ack
00655 {
00656         __u16 type;
00657         __u16 length;
00658         __u32 peer_update_id;
00659 } tlv_ack;
00660 
00661 typedef struct _tlv_notify
00662 {
00663         __u16 type;
00664         __u16 length;
00665         __u16 reserved;
00666         __u16 notify_type;
00667         __u8 notify_data[0]; /* variable length */
00668 } tlv_notify;
00669 
00670 typedef struct _locator
00671 {
00672         __u8 traffic_type;
00673         __u8 locator_type;
00674         __u8 locator_length;
00675         __u8 reserved;
00676         __u32 locator_lifetime;
00677         __u8 locator[20]; /* 32-bit SPI + 128-bit IPv6/IPv4-in-IPv6 address */
00678 } locator;
00679 #define LOCATOR_PREFERRED 0x01
00680 #define LOCATOR_TRAFFIC_TYPE_BOTH       0x00
00681 #define LOCATOR_TRAFFIC_TYPE_SIGNALING  0x01
00682 #define LOCATOR_TRAFFIC_TYPE_DATA       0x02
00683 #define LOCATOR_TYPE_IPV6       0x00
00684 #define LOCATOR_TYPE_SPI_IPV6   0x01
00685 
00686 typedef struct _tlv_locator
00687 {
00688         __u16 type;
00689         __u16 length;
00690         locator locator1[1]; /* one or more */
00691 } tlv_locator;
00692 
00693 typedef struct _tlv_from
00694 {
00695         __u16 type;
00696         __u16 length;
00697         unsigned char addr[16];
00698 } tlv_from;
00699 
00700 typedef struct _tlv_rvs_hmac
00701 {
00702         __u16 type;
00703         __u16 length;
00704         __u8 hmac[20];
00705 
00706 } tlv_rvs_hmac;
00707 
00708 typedef struct _tlv_via_rvs
00709 {
00710         __u16 type;
00711         __u16 length;
00712         __u8 address[16];
00713 } tlv_via_rvs;
00714 
00715 
00716 /*
00717  * Struct to use in the set_lifetime_thread
00718 */
00719 typedef struct _thread_arg{
00720         hiphdr hip_header;
00721         tlv_reg_response resp;
00722 } thread_arg;
00723 
00724 
00725 /*
00726  * Logging
00727  */
00728 typedef enum {
00729         D_DEFAULT,
00730         D_VERBOSE,
00731         D_QUIET,
00732 } DEBUG_MODES;
00733 
00734 typedef enum {
00735         NORM,
00736         NORMT,
00737         WARN,
00738         ERR,
00739         QOUT,
00740 } LOG_LEVELS;
00741 
00742 
00743 /*
00744  * Global options
00745  */
00746 struct hip_opt {
00747         int daemon;
00748         int debug;
00749         int debug_R1;
00750         int no_retransmit;
00751         int permissive;
00752         int opportunistic;
00753         int allow_any;
00754         int enable_udp;
00755         struct sockaddr *trigger;
00756         int use_i3;
00757         int rvs;
00758         int entries;
00759         int stun;
00760 };
00761 
00762 /*
00763  * Global configuration data
00764  */
00765 struct hip_conf {
00766         __u8 min_lifetime;              /* values offered by the rvs */
00767         __u8 max_lifetime;
00768         __u8 reg_type_rvs;
00769         __u8 lifetime;  /* for registration with rvs. exponential lifetime */
00770         __u8 reg_type;                  /*for registration with rvs.    */      
00771         __u32 cookie_difficulty;        /* 2 raised to this power       */
00772         __u32 cookie_lifetime;          /* valid 2^(life-32) seconds    */
00773         __u32 packet_timeout;           /* seconds                      */
00774         __u32 max_retries;              /* retransmissions              */
00775         __u32 sa_lifetime;              /* lifetime of SAs in seconds   */
00776         __u32 loc_lifetime;             /* lifetime of locators in seconds */
00777         char *preferred_hi;             /* which HI to use              */
00778         __u8  send_hi_name;             /* flag to include DI (FQDN) in HI */
00779         __u8  dh_group;                 /* which DH group to propose in R1 */
00780         __u32 dh_lifetime;              /* seconds until DH expires     */
00781         __u32 r1_lifetime;              /* seconds until an R1 is replaced */
00782         __u32 failure_timeout;          /* seconds to wait in state E_FAILED */
00783         __u32 msl;                      /* max segment lifetime */
00784         __u32 ual;                      /* seconds until unused SA expires */
00785         __u16 esp_transforms[SUITE_ID_MAX]; /* ESP transforms proposed in R1 */
00786         __u16 hip_transforms[SUITE_ID_MAX]; /* HIP transforms proposed in R1 */
00787         char *log_filename;             /* non-default pathname for log      */
00788         struct sockaddr_storage dht_server; /* address+port of DHT server    */
00789         struct sockaddr_storage dns_server; /* address of server w/HIP RRs   */
00790         __u8  disable_dns_lookups;      /* T/F disable DNS lookups           */
00791         __u8  disable_notify;           /* T/F disable sending NOTIFY packets */
00792 #ifdef __UMH__
00793         __u8  disable_dns_thread;       /* T/F disable DNS thread            */
00794         __u8  enable_bcast;             /* T/F unicast packets from bcast LSI */
00795 #endif
00796         struct sockaddr_storage preferred; /* preferred address */
00797         char *preferred_iface;          /* preferred interface name */
00798         __u8 save_known_identities;     /* save known_host_id's on exit */
00799 };
00800 
00801 
00802 #endif /* _HIP_TYPES_H_*/
00803 
00804 
00805 

Generated on Mon Oct 22 11:43:43 2007 for OpenHIP by  doxygen 1.5.1