Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

payload.h

Go to the documentation of this file.
00001 /*
00002  *  payload.h  -  generate / parse all payloads
00003  *  
00004  *  EAP-IKEv2
00005  *
00006  *  This library implements ideas of draft-tschofenig-eap-ikev2-10.txt
00007  *  Internet-Draft. Version of the document that this library corresponds
00008  *  to you can find at
00009  *  http://tools.ietf.org/wg/eap/draft-tschofenig-eap-ikev2-10.txt.
00010  *
00011  *  This file is part of libeap-ikev2.
00012  *
00013  *  libeap-ikev2 is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  libeap-ikev2 is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License
00024  *  along with libeap-ikev2; if not, write to the Free Software
00025  *
00026  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  *  Copyright (C) 2005-2006 Krzysztof Rzecki <krzysztof.rzecki@ccns.pl>      
00029  *  Copyright (C) 2005-2006 Rafal Mijal <rafal.mijal@ccns.pl>                
00030  *  Copyright (C) 2005-2006 Piotr Marnik <piotr.marnik@ccns.pl>              
00031  *  Copyright (C) 2005-2006 Pawel Matejski <pawel.matejski@ccns.pl>          
00032  *  Copyright (C) 2003      Udo Schilcher <udo.schilcher@edu.uni-klu.ac.at>
00033  *  Copyright (C) 2003      Thomas Hambrusch <thambrus@edu.uni-klu.ac.at>          
00034  *
00035  */
00036 
00037 #ifndef __payload_h
00038 #define __payload_h
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 #include"common.h"
00045 
00046 #include"session.h"
00047 
00048 
00063 struct IKEv2KeyExchangePayload
00064 {
00065   uint8_t NextPayload;
00066   uint8_t C:1;
00067   uint8_t Reserved1:7;
00068   uint16_t Length;
00069   uint16_t DHGroupNr;
00070   uint16_t Reserved2;
00071 }__attribute__((packed));
00072 
00085 struct IKEv2PayloadHeader
00086 {
00087   uint8_t NextPayload;
00088   uint8_t C:1;
00089   uint8_t Reserved:7;
00090   uint16_t PayloadLength;
00091 }__attribute__((packed));
00092 
00110 struct IKEv2Proposal
00111 {
00112   uint8_t IsLast;
00113   uint8_t Reserved;
00114   uint16_t ProposalLength;
00115   uint8_t ProposalNr;
00116   uint8_t ProtocolId;
00117   uint8_t SPISize;
00118   uint8_t TransformsCount;
00119 }__attribute__((packed));
00120 
00137 struct IKEv2Transform
00138 {
00139   uint8_t IsLast;
00140   uint8_t Reserved1;
00141   uint16_t TransformLength;
00142   uint8_t TransformType;
00143   uint8_t Reserved2;
00144   uint16_t TransformID;
00145 }__attribute__((packed));
00146 
00159 struct IKEv2Attribute
00160 {
00161   uint16_t TypeAF;
00162   union
00163   {
00164     uint16_t Length;
00165     uint16_t Value;
00166   };
00167 }__attribute__((packed));
00168 
00169 
00187 struct IKEv2IdentificationPayload
00188 {
00189   uint8_t NextPayload;
00190   uint8_t C:1;
00191   uint8_t Reserved1:7;
00192   uint16_t Length;
00193   uint32_t IDType:8;
00194   uint32_t Reserved2:24;
00195 }__attribute__((packed));
00196 
00197 
00202 struct IKEv2IdentificationPayloadBody
00203 {
00204   uint32_t IDType:8;
00205   uint32_t Reserved2:24;
00206 }__attribute__((packed));
00207 
00208 
00209 #define IKEv2_GET_IDTYPE(x) ((struct IKEv2IdentificationPayloadBody*)(x))->IDType
00210 #define IKEv2_GET_ID(x)  ((x)+sizeof (struct IKEv2IdentificationPayloadBody))
00211 
00229 struct IKEv2AuthenticationPayload
00230 {
00231   uint8_t NextPayload;
00232   uint8_t C:1;
00233   uint8_t Reserved1:7;
00234   uint16_t Length;
00235   uint32_t AuthMethod:8;
00236   uint32_t Reserved2:24;
00237 }__attribute__((packed));
00238 
00239 
00263 struct IKEv2NotifyPayload
00264 {
00265   uint8_t NextPayload;
00266   uint8_t C:1;
00267   uint8_t Reserved:7;
00268   uint16_t Length;
00269   uint8_t SProtocolID;
00270   uint8_t SPISize;
00271   uint16_t MsgType;
00272 }__attribute__((packed));
00273 
00292 struct IKEv2DeletePayload
00293 {
00294   uint8_t NextPayload;
00295   uint8_t C:1;
00296   uint8_t Reserved:7;
00297   uint16_t Length;
00298   uint8_t SProtocolID;
00299   uint8_t SPISize;
00300   uint16_t SPICount;
00301 }__attribute__((packed));
00302 
00321 struct IKEv2CertReqPayload
00322 {
00323   uint8_t NextPayload;
00324   uint8_t C:1;
00325   uint8_t Reserved:7;
00326   uint16_t Length;
00327   uint8_t Encoding;
00328 }__attribute__((packed));
00329 
00330 
00331 // function prototypes
00332 
00333 // create packages
00334 uint32_t CreateSAPayload( uint8_t **next, struct Proposal *suppProp, uint8_t *p );
00335 uint32_t CreateKEPayload( uint8_t **next, uint16_t DHGroup, struct IKEv2Session *session, uint8_t *p );
00336 uint32_t CreateNoncePayload( uint8_t **next, struct IKEv2Session *s, uint32_t len, uint8_t *p );
00337 uint32_t CreateEncryptedPayload( uint8_t **next, uint8_t inner_next, uint8_t *data, uint32_t dlen, uint8_t *sigdata,
00338     struct IKEv2Session *session, uint8_t *p );
00339 uint32_t CreateIDPayload( uint8_t **next, uint8_t initiator, uint8_t type, uint8_t *id, uint16_t idlen, uint8_t *p );
00340 uint32_t CreateAuthPayload( const struct ikev2_ctx *i2, uint8_t **next, struct IKEv2Session *session, uint8_t *id,
00341     uint16_t idlen, uint8_t *p );
00342 uint32_t CreateCertPayload( const struct ikev2_ctx *i2, uint8_t **next, uint8_t type, uint8_t *p );
00343 uint32_t CreateNotifyPayload( uint8_t **next, uint16_t type, uint8_t *ndata, uint16_t ndlen, uint8_t *p );
00344 uint32_t CreateDeletePayload( uint8_t **next, uint8_t SProtocolID,
00345     uint8_t *SPIs, uint16_t count, uint8_t *p );
00346 uint32_t CreateCertReqPayload(const struct ikev2_ctx *i2,uint8_t **next,uint8_t *p );
00347 
00348 // parse packages
00349 struct Proposal *ParseSAPayload( uint8_t *p );
00350 BIGNUM *ParseKEPayload( uint16_t *DHGroup, uint8_t *p );
00351 BIGNUM *ParseNoncePayload( uint8_t *p );
00352 uint32_t ParseEncryptedPayload( uint8_t **data, struct IKEv2Session *session, uint8_t *p );
00353 uint16_t ParseIDPayload( uint8_t **data, uint8_t *p );
00354 int ParseAuthPayload( uint8_t *AuthMethod, uint8_t **data, uint8_t *p );
00355 int ParseCertPayload(uint8_t **cdata, uint32_t *cdlen,uint8_t *ctype, uint8_t *p );
00356 int ParseNotifyPayload( uint8_t *p, uint16_t *data );
00357 #if 0
00358 void ParseDeletePayload( const struct ikev2_ctx *i2, uint8_t *p );
00359 #endif
00360 void ParseCertReqPayload(const struct ikev2_ctx *i2, uint8_t *p);
00361 
00362 #ifdef __cplusplus
00363 }
00364 #endif
00365 
00366 #endif

Project hosted by: SourceForge.net Logo