change n2n_edge_callbacks payload_size parameter to pointer.

This commit is contained in:
switch_st 2020-07-03 11:50:47 +08:00
parent e236c1f1ec
commit e7ac9cf129
2 changed files with 8 additions and 4 deletions

View File

@ -234,11 +234,11 @@ typedef struct n2n_edge_callbacks {
/* A packet has been received from a peer. N2N_DROP can be returned to
* drop the packet. The packet payload can be modified. */
n2n_verdict (*packet_from_peer)(n2n_edge_t *eee, const n2n_sock_t *peer, uint8_t *payload, uint16_t payload_size);
n2n_verdict (*packet_from_peer)(n2n_edge_t *eee, const n2n_sock_t *peer, uint8_t *payload, uint16_t *payload_size);
/* A packet has been received from the TAP interface. N2N_DROP can be
* returned to drop the packet. The packet payload can be modified. */
n2n_verdict (*packet_from_tap)(n2n_edge_t *eee, uint8_t *payload, uint16_t payload_size);
n2n_verdict (*packet_from_tap)(n2n_edge_t *eee, uint8_t *payload, uint16_t *payload_size);
/* Called whenever the IP address of the TAP interface changes. */
void (*ip_address_changed)(n2n_edge_t *eee, uint32_t old_ip, uint32_t new_ip);

View File

@ -1115,11 +1115,13 @@ static int handle_PACKET(n2n_edge_t * eee,
}
if(eee->cb.packet_from_peer) {
if(eee->cb.packet_from_peer(eee, orig_sender, eth_payload, eth_size) == N2N_DROP) {
uint16_t tmp_eth_size = eth_size;
if(eee->cb.packet_from_peer(eee, orig_sender, eth_payload, &tmp_eth_size) == N2N_DROP) {
traceEvent(TRACE_DEBUG, "DROP packet %u", (unsigned int)eth_size);
return(0);
}
eth_size = tmp_eth_size;
}
/* Write ethernet packet to tap device. */
@ -1580,11 +1582,13 @@ void edge_read_from_tap(n2n_edge_t * eee) {
else
{
if(eee->cb.packet_from_tap) {
if(eee->cb.packet_from_tap(eee, eth_pkt, len) == N2N_DROP) {
uint16_t tmp_len = len;
if(eee->cb.packet_from_tap(eee, eth_pkt, &tmp_len) == N2N_DROP) {
traceEvent(TRACE_DEBUG, "DROP packet %u", (unsigned int)len);
return;
}
len = tmp_len;
}
edge_send_packet2net(eee, eth_pkt, len);