transform_null.c (n2n-2.8) | : | transform_null.c (n2n-3.0) | ||
---|---|---|---|---|
/** | /** | |||
* (C) 2007-20 - ntop.org and contributors | * (C) 2007-21 - ntop.org and contributors | |||
* | * | |||
* This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 3 of the License, or | * the Free Software Foundation; either version 3 of the License, or | |||
* (at your option) any later version. | * (at your option) any later version. | |||
* | * | |||
* This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | * GNU General Public License for more details. | |||
* | * | |||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | |||
* along with this program; if not see see <http://www.gnu.org/licenses/> | * along with this program; if not see see <http://www.gnu.org/licenses/> | |||
* | * | |||
*/ | */ | |||
#include "n2n.h" | #include "n2n.h" | |||
#include "n2n_transforms.h" | ||||
static int transop_deinit_null( n2n_trans_op_t * arg ) | static int transop_deinit_null (n2n_trans_op_t *arg ) { | |||
{ | ||||
/* nothing to deallocate, nothing to release. */ | // nothing to deallocate, nothing to release | |||
return 0; | return 0; | |||
} | } | |||
static int transop_encode_null( n2n_trans_op_t * arg, | static int transop_encode_null (n2n_trans_op_t *arg, | |||
uint8_t * outbuf, | uint8_t *outbuf, | |||
size_t out_len, | size_t out_len, | |||
const uint8_t * inbuf, | const uint8_t *inbuf, | |||
size_t in_len, | size_t in_len, | |||
const uint8_t * peer_mac) | const uint8_t *peer_mac) { | |||
{ | ||||
int retval = -1; | int retval = -1; | |||
traceEvent( TRACE_DEBUG, "encode_null %lu", in_len ); | traceEvent(TRACE_DEBUG, "encode_null %lu", in_len); | |||
if ( out_len >= in_len ) | if(out_len >= in_len) { | |||
{ | memcpy(outbuf, inbuf, in_len); | |||
memcpy( outbuf, inbuf, in_len ); | ||||
retval = in_len; | retval = in_len; | |||
} | } else { | |||
else | traceEvent(TRACE_DEBUG, "encode_null %lu too big for packet buffer", in_ | |||
{ | len); | |||
traceEvent( TRACE_DEBUG, "encode_null %lu too big for packet buffer", in | ||||
_len ); | ||||
} | } | |||
return retval; | return retval; | |||
} | } | |||
static int transop_decode_null( n2n_trans_op_t * arg, | static int transop_decode_null (n2n_trans_op_t *arg, | |||
uint8_t * outbuf, | uint8_t *outbuf, | |||
size_t out_len, | size_t out_len, | |||
const uint8_t * inbuf, | const uint8_t *inbuf, | |||
size_t in_len, | size_t in_len, | |||
const uint8_t * peer_mac) | const uint8_t *peer_mac) { | |||
{ | ||||
int retval = -1; | int retval = -1; | |||
traceEvent( TRACE_DEBUG, "decode_null %lu", in_len ); | traceEvent(TRACE_DEBUG, "decode_null %lu", in_len); | |||
if ( out_len >= in_len ) | if(out_len >= in_len) { | |||
{ | memcpy(outbuf, inbuf, in_len); | |||
memcpy( outbuf, inbuf, in_len ); | ||||
retval = in_len; | retval = in_len; | |||
} | } else { | |||
else | traceEvent(TRACE_DEBUG, "decode_null %lu too big for packet buffer", in_ | |||
{ | len); | |||
traceEvent( TRACE_DEBUG, "decode_null %lu too big for packet buffer", in | ||||
_len ); | ||||
} | } | |||
return retval; | return retval; | |||
} | } | |||
static void transop_tick_null(n2n_trans_op_t * arg, time_t now) {} | static void transop_tick_null (n2n_trans_op_t *arg, time_t now) { | |||
// no tick action | ||||
} | ||||
int n2n_transop_null_init(const n2n_edge_conf_t *conf, n2n_trans_op_t *ttt) { | int n2n_transop_null_init (const n2n_edge_conf_t *conf, n2n_trans_op_t *ttt) { | |||
memset(ttt, 0, sizeof(n2n_trans_op_t) ); | ||||
ttt->transform_id = N2N_TRANSFORM_ID_NULL; | memset(ttt, 0, sizeof(n2n_trans_op_t)); | |||
ttt->transform_id = N2N_TRANSFORM_ID_NULL; | ||||
ttt->no_encryption = 1; | ttt->no_encryption = 1; | |||
ttt->deinit = transop_deinit_null; | ttt->deinit = transop_deinit_null; | |||
ttt->tick = transop_tick_null; | ttt->tick = transop_tick_null; | |||
ttt->fwd = transop_encode_null; | ttt->fwd = transop_encode_null; | |||
ttt->rev = transop_decode_null; | ttt->rev = transop_decode_null; | |||
return(0); | return 0; | |||
} | } | |||
End of changes. 18 change blocks. | ||||
42 lines changed or deleted | 40 lines changed or added |