00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "aodv.h"
00033 #include <string.h>
00034
00035 char
00036 aodv_cmp_addr( const aodv_addr_t* a, const aodv_addr_t* b )
00037 {
00038 unsigned int i;
00039
00040 if ( NULL == a )
00041 {
00042 if ( NULL == b )
00043 {
00044 return 0;
00045 }
00046 return -1;
00047 }
00048 if ( NULL == b )
00049 {
00050 return 1;
00051 }
00052
00053 for ( i = 0 ; i < a->length ; ++i )
00054 {
00055 if ( i >= b->length )
00056 {
00057 return 1;
00058 }
00059 if ( a->data[i] < b->data[i] )
00060 {
00061 return -1;
00062 }
00063 if ( a->data[i] > b->data[i] )
00064 {
00065 return 1;
00066 }
00067 }
00068
00069 if ( a->length < b->length )
00070 {
00071 return -1;
00072 }
00073 return 0;
00074 }
00075
00076 void
00077 set_aodv_addr( aodv_addr_t* dest, const aodv_addr_t* src )
00078 {
00079 if ( NULL == dest ) return;
00080 if ( NULL == src ) return;
00081 if ( NULL != dest->data )
00082 {
00083 free(dest->data);
00084 dest->length = 0;
00085 }
00086
00087 dest->data = calloc( src->length, sizeof(unsigned char) );
00088 if ( NULL == dest->data ) return;
00089 dest->length = src->length;
00090 memcpy( dest->data, src->data, dest->length );
00091 }