Browse Source

Merge pull request #297 from switch-iot/hin2n_arp

Change n2n_edge_callbacks payload_size parameter to pointer.
pull/300/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
da870876c8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      include/n2n.h
  2. 8
      src/edge_utils.c

4
include/n2n.h

@ -234,11 +234,11 @@ typedef struct n2n_edge_callbacks {
/* A packet has been received from a peer. N2N_DROP can be returned to /* A packet has been received from a peer. N2N_DROP can be returned to
* drop the packet. The packet payload can be modified. */ * 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 /* A packet has been received from the TAP interface. N2N_DROP can be
* returned to drop the packet. The packet payload can be modified. */ * 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. */ /* 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); void (*ip_address_changed)(n2n_edge_t *eee, uint32_t old_ip, uint32_t new_ip);

8
src/edge_utils.c

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

Loading…
Cancel
Save