loading of subjectPublicKeyInfo wrapped keys using KEY_ANY (openssl format)
[strongswan.git] / src / charon / network / packet.c
index 6c16a9d..fb5f992 100644 (file)
@@ -1,10 +1,3 @@
-/**
- * @file packet.c
- * 
- * @brief Implementation of packet_t.
- * 
- */
-
 /*
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
+ *
+ * $Id$
  */
 
-
 #include "packet.h"
 
-
 typedef struct private_packet_t private_packet_t;
 
 /**
@@ -58,10 +51,7 @@ struct private_packet_t {
  */
 static void set_source(private_packet_t *this, host_t *source)
 {
-       if (this->source)
-       {
-               this->source->destroy(this->source);    
-       }
+       DESTROY_IF(this->source);
        this->source = source;
 }
 
@@ -70,10 +60,7 @@ static void set_source(private_packet_t *this, host_t *source)
  */
 static void set_destination(private_packet_t *this, host_t *destination)
 {
-       if (this->destination)
-       {
-               this->destination->destroy(this->destination);  
-       }
+       DESTROY_IF(this->destination);
        this->destination = destination;
 }
 
@@ -130,7 +117,7 @@ static void destroy(private_packet_t *this)
 /**
  * Implements packet_t.clone.
  */
-static packet_t *clone(private_packet_t *this)
+static packet_t *clone_(private_packet_t *this)
 {
        private_packet_t *other = (private_packet_t*)packet_create();
        
@@ -163,12 +150,12 @@ packet_t *packet_create(void)
        this->public.get_source = (host_t*(*) (packet_t *)) get_source;
        this->public.set_destination = (void(*) (packet_t *,host_t*)) set_destination;
        this->public.get_destination = (host_t*(*) (packet_t *)) get_destination;
-       this->public.clone = (packet_t*(*) (packet_t *))clone;
+       this->public.clone = (packet_t*(*) (packet_t *))clone_;
        this->public.destroy = (void(*) (packet_t *)) destroy;
        
        this->destination = NULL;
        this->source = NULL;
-       this->data = CHUNK_INITIALIZER;
+       this->data = chunk_empty;
        
        return &(this->public);
 }