mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
gnrc_ipv6: use fragmentation if available
This commit is contained in:
parent
c2c3216c16
commit
51ef1c997d
@ -447,6 +447,28 @@ static bool _safe_fill_ipv6_hdr(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* functions for sending */
|
/* functions for sending */
|
||||||
|
static bool _fragment_pkt_if_needed(gnrc_pktsnip_t *pkt,
|
||||||
|
gnrc_netif_t *netif,
|
||||||
|
bool from_me)
|
||||||
|
{
|
||||||
|
#ifdef MODULE_GNRC_IPV6_EXT_FRAG
|
||||||
|
/* TODO: get path MTU when PMTU discovery is implemented */
|
||||||
|
unsigned path_mtu = netif->ipv6.mtu;
|
||||||
|
|
||||||
|
if (from_me && (gnrc_pkt_len(pkt->next) > path_mtu)) {
|
||||||
|
gnrc_netif_hdr_t *hdr = pkt->data;
|
||||||
|
hdr->if_pid = netif->pid;
|
||||||
|
gnrc_ipv6_ext_frag_send_pkt(pkt, path_mtu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#else /* MODULE_GNRC_IPV6_EXT_FRAG */
|
||||||
|
(void)pkt;
|
||||||
|
(void)netif;
|
||||||
|
(void)from_me;
|
||||||
|
#endif /* MODULE_GNRC_IPV6_EXT_FRAG */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MODULE_GNRC_IPV6_EXT_FRAG
|
#ifdef MODULE_GNRC_IPV6_EXT_FRAG
|
||||||
static void _send_by_netif_hdr(gnrc_pktsnip_t *pkt)
|
static void _send_by_netif_hdr(gnrc_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
@ -479,6 +501,11 @@ static void _send_unicast(gnrc_pktsnip_t *pkt, bool prep_hdr,
|
|||||||
netif_hdr_flags)) == NULL) {
|
netif_hdr_flags)) == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* prep_hdr => The packet is from me */
|
||||||
|
if (_fragment_pkt_if_needed(pkt, netif, prep_hdr)) {
|
||||||
|
DEBUG("ipv6: packet is fragmented\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
DEBUG("ipv6: send unicast over interface %" PRIkernel_pid "\n",
|
DEBUG("ipv6: send unicast over interface %" PRIkernel_pid "\n",
|
||||||
netif->pid);
|
netif->pid);
|
||||||
/* and send to interface */
|
/* and send to interface */
|
||||||
@ -490,6 +517,7 @@ static void _send_unicast(gnrc_pktsnip_t *pkt, bool prep_hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void _send_multicast_over_iface(gnrc_pktsnip_t *pkt,
|
static inline void _send_multicast_over_iface(gnrc_pktsnip_t *pkt,
|
||||||
|
bool prep_hdr,
|
||||||
gnrc_netif_t *netif,
|
gnrc_netif_t *netif,
|
||||||
uint8_t netif_hdr_flags)
|
uint8_t netif_hdr_flags)
|
||||||
{
|
{
|
||||||
@ -498,6 +526,11 @@ static inline void _send_multicast_over_iface(gnrc_pktsnip_t *pkt,
|
|||||||
GNRC_NETIF_HDR_FLAGS_MULTICAST)) == NULL) {
|
GNRC_NETIF_HDR_FLAGS_MULTICAST)) == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* prep_hdr => The packet is from me */
|
||||||
|
if (_fragment_pkt_if_needed(pkt, netif, prep_hdr)) {
|
||||||
|
DEBUG("ipv6: packet is fragmented\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
DEBUG("ipv6: send multicast over interface %" PRIkernel_pid "\n", netif->pid);
|
DEBUG("ipv6: send multicast over interface %" PRIkernel_pid "\n", netif->pid);
|
||||||
#ifdef MODULE_NETSTATS_IPV6
|
#ifdef MODULE_NETSTATS_IPV6
|
||||||
netif->ipv6.stats.tx_mcast_count++;
|
netif->ipv6.stats.tx_mcast_count++;
|
||||||
@ -550,12 +583,12 @@ static void _send_multicast(gnrc_pktsnip_t *pkt, bool prep_hdr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_send_multicast_over_iface(pkt, netif, netif_hdr_flags);
|
_send_multicast_over_iface(pkt, prep_hdr, netif, netif_hdr_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (_safe_fill_ipv6_hdr(netif, pkt, prep_hdr)) {
|
if (_safe_fill_ipv6_hdr(netif, pkt, prep_hdr)) {
|
||||||
_send_multicast_over_iface(pkt, netif, netif_hdr_flags);
|
_send_multicast_over_iface(pkt, prep_hdr, netif, netif_hdr_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* GNRC_NETIF_NUMOF */
|
#else /* GNRC_NETIF_NUMOF */
|
||||||
@ -569,7 +602,7 @@ static void _send_multicast(gnrc_pktsnip_t *pkt, bool prep_hdr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_safe_fill_ipv6_hdr(netif, pkt, prep_hdr)) {
|
if (_safe_fill_ipv6_hdr(netif, pkt, prep_hdr)) {
|
||||||
_send_multicast_over_iface(pkt, netif, netif_hdr_flags);
|
_send_multicast_over_iface(pkt, prep_hdr, netif, netif_hdr_flags);
|
||||||
}
|
}
|
||||||
#endif /* GNRC_NETIF_NUMOF */
|
#endif /* GNRC_NETIF_NUMOF */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user