lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

March 2026

  • 1 participants
  • 1933 discussions
[XS] Change in libosmo-netif[master]: ip_checksum: Add SPDX license identifier
by laforge 23 Mar '26

23 Mar '26
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42477?usp=email ) Change subject: ip_checksum: Add SPDX license identifier ...................................................................... ip_checksum: Add SPDX license identifier Let's make sure the newly-created/imported file has a machine-readable SPDX identifier. Change-Id: Ic40d01771e8d01461ed81d1a60d9e91a48fdc8d0 --- M src/ip_checksum.c 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/77/42477/1 diff --git a/src/ip_checksum.c b/src/ip_checksum.c index 1fa6f42..ec715e2 100644 --- a/src/ip_checksum.c +++ b/src/ip_checksum.c @@ -27,6 +27,8 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0+ */ /* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42477?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Ic40d01771e8d01461ed81d1a60d9e91a48fdc8d0 Gerrit-Change-Number: 42477 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in libosmo-netif[master]: icmpv6: Re-license code under GPL-v2-or-later
by laforge 23 Mar '26

23 Mar '26
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42476?usp=email ) Change subject: icmpv6: Re-license code under GPL-v2-or-later ...................................................................... icmpv6: Re-license code under GPL-v2-or-later The original statement in my code from osmo-ggsn commit d46bcd236e93432c894a939f4e5810dc5e9b4974 in 2017 was worded GPLv2-only, which was most likely an oversight. All subsequent modifications to this code were done by either me or Pau Espin, who was doing the work under contract with sysmocom, of which I'm the managing director. Therefore, I have legal authority to re-license this file to v2-or-later. Change-Id: I5a4fa18ef64c2f228e21fa2c067e55eaa4080508 --- M src/icmpv6.c 1 file changed, 16 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/76/42476/1 diff --git a/src/icmpv6.c b/src/icmpv6.c index b0f29a8..c0d5710 100644 --- a/src/icmpv6.c +++ b/src/icmpv6.c @@ -2,13 +2,24 @@ * relevant 3GPP specs for a GGSN with IPv6 PDP contexts */ /* (C) 2017 by Harald Welte <laforge(a)gnumonks.org> + * All Rights Reserved. * - * The contents of this file may be used under the terms of the GNU - * General Public License Version 2, provided that the above copyright - * notice and this permission notice is included in all copies or - * substantial portions of the software. + * SPDX-License-Identifier: GPL-2.0+ + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * */ - #include <stdint.h> #include <stdbool.h> #include <string.h> -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42476?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I5a4fa18ef64c2f228e21fa2c067e55eaa4080508 Gerrit-Change-Number: 42476 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in osmo-dev[master]: all.deps: osmo-ggsn now depends on libosmo-netif
by pespin 23 Mar '26

23 Mar '26
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/42466?usp=email ) Change subject: all.deps: osmo-ggsn now depends on libosmo-netif ...................................................................... all.deps: osmo-ggsn now depends on libosmo-netif Since osmo-ggsn.git Change-Id I8d8fae362f302d48afaed28a9c664f76ca4a2739, osmo-ggsn depends on libosmo-netif. Change-Id: I4d10fff6a6994c428c572fc10249ad95b0d7e8db --- M all.deps 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, approved Jenkins Builder: Verified diff --git a/all.deps b/all.deps index f0e99a1..f5148ca 100644 --- a/all.deps +++ b/all.deps @@ -7,7 +7,7 @@ libosmo-sigtran libosmo-netif libosmo-asn1-tcap libsmpp34 libasn1c -osmo-ggsn libosmocore libgtpnl +osmo-ggsn libosmocore libosmo-netif libgtpnl osmo-iuh libosmo-sigtran libasn1c osmo-hlr libosmo-abis osmo-mgw libosmo-netif libosmo-abis -- To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/42466?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-Change-Id: I4d10fff6a6994c428c572fc10249ad95b0d7e8db Gerrit-Change-Number: 42466 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: General_types.ttcn: Introduce type OCT4_20n
by pespin 23 Mar '26

23 Mar '26
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42471?usp=email ) Change subject: General_types.ttcn: Introduce type OCT4_20n ...................................................................... General_types.ttcn: Introduce type OCT4_20n This is useful to store EUAs of type v4,v6 or v4v6. Change-Id: I00a35c444e3fb498712fbb4b9c310375c527052f --- M library/General_Types.ttcn 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/library/General_Types.ttcn b/library/General_Types.ttcn index dca4ea2..1b9a732 100644 --- a/library/General_Types.ttcn +++ b/library/General_Types.ttcn @@ -155,6 +155,7 @@ type octetstring OCT3_17n length(3..17) with { variant "" }; type octetstring OCT4_8n length(4..8) with { variant "" }; type octetstring OCT4_16n length(4..16) with { variant "" }; + type octetstring OCT4_20n length(4..20) with { variant "" }; //**************************************************** -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42471?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I00a35c444e3fb498712fbb4b9c310375c527052f Gerrit-Change-Number: 42471 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in pysim[master]: pysim/pcsc: do not use getProtocol for protocol selection
by fixeria 23 Mar '26

23 Mar '26
Attention is currently required from: dexter. fixeria has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/42475?usp=email ) Change subject: pysim/pcsc: do not use getProtocol for protocol selection ...................................................................... Patch Set 1: Code-Review+1 (1 comment) Patchset: PS1: > Might make sense to add a comment explaining this is a workaround and linking to the issue Agreed. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/42475?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ib119948aa68c430e42ac84daec8b9bd542db7963 Gerrit-Change-Number: 42475 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Mon, 23 Mar 2026 19:07:39 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in libosmo-netif[master]: Introduce ip_checksum API
by laforge 23 Mar '26

23 Mar '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42463?usp=email ) Change subject: Introduce ip_checksum API ...................................................................... Introduce ip_checksum API ip_checksum.* files are copied from checksum.* in osmo-ggsn.git 1.14.0 (ebd1bf8adbc8d5bec9e36d70e3a78e8838226e7a). Change-Id: Ia09645a4715ac133036d7c89297b0fa10cf9aa3b --- M TODO-RELEASE M include/osmocom/netif/Makefile.am A include/osmocom/netif/ip_checksum.h M src/Makefile.am A src/ip_checksum.c 5 files changed, 226 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, approved laforge: Looks good to me, approved diff --git a/TODO-RELEASE b/TODO-RELEASE index 0ed7189..7aebf84 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +netif add osmo_ip_checksum API diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am index 71f0931..f509221 100644 --- a/include/osmocom/netif/Makefile.am +++ b/include/osmocom/netif/Makefile.am @@ -20,6 +20,7 @@ osmonetif_HEADERS = \ amr.h \ datagram.h \ + ip_checksum.h \ ipa.h \ ipa_unit.h \ jibuf.h \ diff --git a/include/osmocom/netif/ip_checksum.h b/include/osmocom/netif/ip_checksum.h new file mode 100644 index 0000000..b5130ee --- /dev/null +++ b/include/osmocom/netif/ip_checksum.h @@ -0,0 +1,11 @@ +#pragma once +#include <stdint.h> +#include <netinet/in.h> + +uint16_t osmo_ip_checksum_fast_csum(const void *iph, unsigned int ihl); +uint32_t osmo_ip_checksum_csum_partial(const void *buff, int len, uint32_t wsum); +uint16_t osmo_ip_checksum_compute_csum(const void *buff, int len); + +uint16_t osmo_ip_checksum_csum_ipv6_magic(const struct in6_addr *saddr, + const struct in6_addr *daddr, + uint32_t len, uint8_t proto, uint32_t csum); diff --git a/src/Makefile.am b/src/Makefile.am index 753bac2..4484e02 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ libosmonetif_la_SOURCES = amr.c \ datagram.c \ + ip_checksum.c \ ipa.c \ ipa_keepalive.c \ ipa_unit.c \ diff --git a/src/ip_checksum.c b/src/ip_checksum.c new file mode 100644 index 0000000..1fa6f42 --- /dev/null +++ b/src/ip_checksum.c @@ -0,0 +1,212 @@ +/* + * + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * IP/TCP/UDP checksumming routines + * + * Authors: Jorge Cwik, <jorge(a)laser.satlink.net> + * Arnt Gulbrandsen, <agulbra(a)nvg.unit.no> + * Tom May, <ftom(a)netcom.com> + * Andreas Schwab, <schwab(a)issan.informatik.uni-dortmund.de> + * Lots of code moved from tcp.c and ip.c; see those files + * for more names. + * + * 03/02/96 Jes Sorensen, Andreas Schwab, Roman Hodek: + * Fixed some nasty bugs, causing some horrible crashes. + * A: At some points, the sum (%0) was used as + * length-counter instead of the length counter + * (%1). Thanks to Roman Hodek for pointing this out. + * B: GCC seems to mess up if one uses too many + * data-registers to hold input values and one tries to + * specify d0 and d1 as scratch registers. Letting gcc + * choose these registers itself solves the problem. + * + * 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 the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +/* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access + kills, so most of the assembly has to go. */ + +#if defined(__FreeBSD__) +#define _KERNEL /* needed on FreeBSD 10.x for s6_addr32 */ +#include <sys/types.h> +#include <netinet/in.h> +#include <sys/endian.h> +#endif + +#include <arpa/inet.h> + +#include <osmocom/netif/ip_checksum.h> + +static inline unsigned short from32to16(unsigned int x) +{ + /* add up 16-bit and 16-bit for 16+c bit */ + x = (x & 0xffff) + (x >> 16); + /* add up carry.. */ + x = (x & 0xffff) + (x >> 16); + return x; +} + +static unsigned int do_csum(const unsigned char *buff, int len) +{ + int odd; + unsigned int result = 0; + + if (len <= 0) + goto out; + odd = 1 & (unsigned long) buff; + if (odd) { +#if BYTE_ORDER == LITTLE_ENDIAN + result += (*buff << 8); +#else + result = *buff; +#endif + len--; + buff++; + } + if (len >= 2) { + if (2 & (unsigned long) buff) { + result += *(unsigned short *) buff; + len -= 2; + buff += 2; + } + if (len >= 4) { + const unsigned char *end = buff + ((unsigned)len & ~3); + unsigned int carry = 0; + do { + unsigned int w = *(unsigned int *) buff; + buff += 4; + result += carry; + result += w; + carry = (w > result); + } while (buff < end); + result += carry; + result = (result & 0xffff) + (result >> 16); + } + if (len & 2) { + result += *(unsigned short *) buff; + buff += 2; + } + } + if (len & 1) +#if BYTE_ORDER == LITTLE_ENDIAN + result += *buff; +#else + result += (*buff << 8); +#endif + result = from32to16(result); + if (odd) + result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); +out: + return result; +} + +/* fold a partial checksum */ +static uint16_t csum_fold(uint32_t csum) +{ + uint32_t sum = (uint32_t)csum; + sum = (sum & 0xffff) + (sum >> 16); + sum = (sum & 0xffff) + (sum >> 16); + return (uint16_t)~sum; +} + +/* + * This is a version of ip_compute_csum() optimized for IP headers, + * which always checksum on 4 octet boundaries. + */ +uint16_t osmo_ip_checksum_fast_csum(const void *iph, unsigned int ihl) +{ + return (uint16_t)~do_csum(iph, ihl*4); +} + +/* + * computes the checksum of a memory block at buff, length len, + * and adds in "sum" (32-bit) + * + * returns a 32-bit number suitable for feeding into itself + * or csum_tcpudp_magic + * + * this function must be called with even lengths, except + * for the last fragment, which may be odd + * + * it's best to have buff aligned on a 32-bit boundary + */ +uint32_t osmo_ip_checksum_csum_partial(const void *buff, int len, uint32_t wsum) +{ + unsigned int sum = (unsigned int)wsum; + unsigned int result = do_csum(buff, len); + + /* add in old sum, and carry.. */ + result += sum; + if (sum > result) + result += 1; + return (uint32_t)result; +} + +/* + * this routine is used for miscellaneous IP-like checksums, mainly + * in icmp.c + */ +uint16_t osmo_ip_checksum_compute_csum(const void *buff, int len) +{ + return (uint16_t)~do_csum(buff, len); +} + +uint16_t osmo_ip_checksum_csum_ipv6_magic(const struct in6_addr *saddr, + const struct in6_addr *daddr, + uint32_t len, uint8_t proto, uint32_t csum) +{ + int carry; + uint32_t ulen; + uint32_t uproto; + uint32_t sum = (uint32_t)csum; + + sum += (uint32_t)saddr->s6_addr32[0]; + carry = (sum < (uint32_t)saddr->s6_addr32[0]); + sum += carry; + + sum += (uint32_t)saddr->s6_addr32[1]; + carry = (sum < (uint32_t)saddr->s6_addr32[1]); + sum += carry; + + sum += (uint32_t)saddr->s6_addr32[2]; + carry = (sum < (uint32_t)saddr->s6_addr32[2]); + sum += carry; + + sum += (uint32_t)saddr->s6_addr32[3]; + carry = (sum < (uint32_t)saddr->s6_addr32[3]); + sum += carry; + + sum += (uint32_t)daddr->s6_addr32[0]; + carry = (sum < (uint32_t)daddr->s6_addr32[0]); + sum += carry; + + sum += (uint32_t)daddr->s6_addr32[1]; + carry = (sum < (uint32_t)daddr->s6_addr32[1]); + sum += carry; + + sum += (uint32_t)daddr->s6_addr32[2]; + carry = (sum < (uint32_t)daddr->s6_addr32[2]); + sum += carry; + + sum += (uint32_t)daddr->s6_addr32[3]; + carry = (sum < (uint32_t)daddr->s6_addr32[3]); + sum += carry; + + ulen = (uint32_t)htonl((uint32_t) len); + sum += ulen; + carry = (sum < ulen); + sum += carry; + + uproto = (uint32_t)htonl(proto); + sum += uproto; + carry = (sum < uproto); + sum += carry; + + return csum_fold((uint32_t)sum); +} -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42463?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Ia09645a4715ac133036d7c89297b0fa10cf9aa3b Gerrit-Change-Number: 42463 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
1 0
0 0
[L] Change in libosmo-netif[master]: Introduce API osmo_icmpv6
by laforge 23 Mar '26

23 Mar '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42464?usp=email ) Change subject: Introduce API osmo_icmpv6 ...................................................................... Introduce API osmo_icmpv6 icmpv6.* files are copied from osmo-ggsn.git 1.14.0 (ebd1bf8adbc8d5bec9e36d70e3a78e8838226e7a). Change-Id: I78ec7270c717af0a1b8ffd9398cd69ea7a0dbee2 --- M TODO-RELEASE M include/osmocom/netif/Makefile.am A include/osmocom/netif/icmpv6.h M src/Makefile.am A src/icmpv6.c 5 files changed, 323 insertions(+), 0 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, approved laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index 7aebf84..89a240e 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,4 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line netif add osmo_ip_checksum API +netif add osmo_icmpv6 API diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am index f509221..1a0cce4 100644 --- a/include/osmocom/netif/Makefile.am +++ b/include/osmocom/netif/Makefile.am @@ -20,6 +20,7 @@ osmonetif_HEADERS = \ amr.h \ datagram.h \ + icmpv6.h \ ip_checksum.h \ ipa.h \ ipa_unit.h \ diff --git a/include/osmocom/netif/icmpv6.h b/include/osmocom/netif/icmpv6.h new file mode 100644 index 0000000..94d97fc --- /dev/null +++ b/include/osmocom/netif/icmpv6.h @@ -0,0 +1,105 @@ +#pragma once + +#include <stdint.h> +#include <stdbool.h> +#include <netinet/in.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/core/endian.h> + +#define ICMPv6_OPT_TYPE_PREFIX_INFO 0x03 + +struct osmo_icmpv6_hdr { + uint8_t type; + uint8_t code; + uint16_t csum; +} __attribute__ ((packed)); + +struct osmo_icmpv6_echo_hdr { + struct osmo_icmpv6_hdr hdr; + uint16_t ident; /* Identifier */ + uint16_t seq; /* Sequence number */ + uint8_t data[0]; /* Data */ +} __attribute__ ((packed)); + +/* RFC4861 Section 4.1 */ +struct osmo_icmpv6_rsol_hdr { + struct osmo_icmpv6_hdr hdr; + uint32_t reserved; + uint8_t options[0]; +} __attribute__ ((packed)); + +/* RFC4861 Section 4.2 */ +struct osmo_icmpv6_radv_hdr { + struct osmo_icmpv6_hdr hdr; + uint8_t cur_ho_limit; +#if OSMO_IS_LITTLE_ENDIAN + uint8_t res:6, + m:1, + o:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ + uint8_t o:1, m:1, res:6; +#endif + uint16_t router_lifetime; + uint32_t reachable_time; + uint32_t retrans_timer; + uint8_t options[0]; +} __attribute__ ((packed)); + + +/* RFC4861 Section 4.6 */ +struct osmo_icmpv6_opt_hdr { + uint8_t type; + /* length in units of 8 octets, including type+len! */ + uint8_t len; + uint8_t data[0]; +} __attribute__ ((packed)); + +/* RFC4861 Section 4.6.2 */ +struct osmo_icmpv6_opt_prefix { + struct osmo_icmpv6_opt_hdr hdr; + uint8_t prefix_len; +#if OSMO_IS_LITTLE_ENDIAN + uint8_t res:6, + a:1, + l:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ + uint8_t l:1, a:1, res:6; +#endif + uint32_t valid_lifetime; + uint32_t preferred_lifetime; + uint32_t res2; + uint8_t prefix[16]; +} __attribute__ ((packed)); + +/* RFC4861 Section 4.6.4 */ +struct osmo_icmpv6_opt_mtu { + struct osmo_icmpv6_opt_hdr hdr; + uint16_t reserved; + uint32_t mtu; +} __attribute__ ((packed)); + +uint16_t osmo_icmpv6_prepend_ip6hdr(struct msgb *msg, const struct in6_addr *saddr, + const struct in6_addr *daddr); + +struct msgb *osmo_icmpv6_construct_rs(const struct in6_addr *saddr); +struct msgb *osmo_icmpv6_construct_ra(const struct in6_addr *saddr, + const struct in6_addr *daddr, + const struct in6_addr *prefix, + uint32_t mtu); + +bool osmo_icmpv6_validate_router_solicit(const uint8_t *pack, unsigned len); +struct osmo_icmpv6_radv_hdr *osmo_icmpv6_validate_router_adv(const uint8_t *pack, unsigned len); + +#define foreach_icmpv6_opt(icmpv6_pkt, icmpv6_len, opt_hdr) \ + for (opt_hdr = (struct osmo_icmpv6_opt_hdr *)(icmpv6_pkt)->options; \ + (uint8_t *)(opt_hdr) + sizeof(struct osmo_icmpv6_opt_hdr) <= (((uint8_t *)(icmpv6_pkt)) + (icmpv6_len)); \ + opt_hdr = (struct osmo_icmpv6_opt_hdr *)((uint8_t *)(opt_hdr) + (opt_hdr)->len) \ + ) + +/* RFC3307 link-local scope multicast address */ +extern const struct in6_addr osmo_icmpv6_all_router_mcast_addr; + +extern const uint8_t osmo_icmpv6_solicited_node_mcast_addr_prefix[13]; diff --git a/src/Makefile.am b/src/Makefile.am index 4484e02..8c2b95b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ libosmonetif_la_SOURCES = amr.c \ datagram.c \ + icmpv6.c \ ip_checksum.c \ ipa.c \ ipa_keepalive.c \ diff --git a/src/icmpv6.c b/src/icmpv6.c new file mode 100644 index 0000000..b0f29a8 --- /dev/null +++ b/src/icmpv6.c @@ -0,0 +1,215 @@ +/* Minimal ICMPv6 code for generating router advertisements as required by + * relevant 3GPP specs for a GGSN with IPv6 PDP contexts */ + +/* (C) 2017 by Harald Welte <laforge(a)gnumonks.org> + * + * The contents of this file may be used under the terms of the GNU + * General Public License Version 2, provided that the above copyright + * notice and this permission notice is included in all copies or + * substantial portions of the software. + */ + +#include <stdint.h> +#include <stdbool.h> +#include <string.h> +#include <netinet/in.h> +#if defined(__FreeBSD__) +#include <sys/types.h> /* FreeBSD 10.x needs this before ip6.h */ +#include <sys/endian.h> +#endif +#include <netinet/ip6.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/core/utils.h> + +#include <osmocom/netif/ip_checksum.h> +#include <osmocom/netif/icmpv6.h> + +/* 29.061 11.2.1.3.4 IPv6 Router Configuration Variables in GGSN */ +#define GGSN_MaxRtrAdvInterval 21600 /* 6 hours */ +#define GGSN_MinRtrAdvInterval 16200 /* 4.5 hours */ +#define GGSN_AdvValidLifetime 0xffffffff /* infinite */ +#define GGSN_AdvPreferredLifetime 0xffffffff /* infinite */ + +/* RFC3307 link-local scope multicast address */ +const struct in6_addr osmo_icmpv6_all_router_mcast_addr = { + .s6_addr = { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 } +}; + + +/* RFC4291 link-local solicited-node multicast address, FF02:0:0:0:0:1:FF, 104 bits = 13 bytes */ +const uint8_t osmo_icmpv6_solicited_node_mcast_addr_prefix[13] = { + 0xff, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0xFF +}; + +/* Prepends the ipv6 header and returns checksum content */ +uint16_t osmo_icmpv6_prepend_ip6hdr(struct msgb *msg, const struct in6_addr *saddr, + const struct in6_addr *daddr) +{ + uint32_t len; + uint16_t skb_csum; + struct ip6_hdr *i6h; + + /* checksum */ + skb_csum = osmo_ip_checksum_csum_partial(msgb_data(msg), msgb_length(msg), 0); + len = msgb_length(msg); + skb_csum = osmo_ip_checksum_csum_ipv6_magic(saddr, daddr, len, IPPROTO_ICMPV6, skb_csum); + + /* Push IPv6 header in front of ICMPv6 packet */ + i6h = (struct ip6_hdr *) msgb_push(msg, sizeof(*i6h)); + /* 4 bits version, 8 bits TC, 20 bits flow-ID */ + i6h->ip6_ctlun.ip6_un1.ip6_un1_flow = htonl(0x60000000); + i6h->ip6_ctlun.ip6_un1.ip6_un1_plen = htons(len); + i6h->ip6_ctlun.ip6_un1.ip6_un1_nxt = IPPROTO_ICMPV6; + i6h->ip6_ctlun.ip6_un1.ip6_un1_hlim = 255; + i6h->ip6_src = *saddr; + i6h->ip6_dst = *daddr; + return skb_csum; +} + +/*! construct a RFC4861 compliant ICMPv6 router soliciation + * \param[in] saddr Source IPv6 address for router advertisement + * \param[in] daddr Destination IPv6 address for router advertisement IPv6 header + * \param[in] prefix The single prefix to be advertised (/64 implied!) + * \returns callee-allocated message buffer containing router advertisement */ +struct msgb *osmo_icmpv6_construct_rs(const struct in6_addr *saddr) +{ + struct msgb *msg = msgb_alloc_headroom(512, 128, "IPv6 RS"); + struct osmo_icmpv6_rsol_hdr *rs; + OSMO_ASSERT(msg); + rs = (struct osmo_icmpv6_rsol_hdr *) msgb_put(msg, sizeof(*rs)); + rs->hdr.type = 133; /* see RFC4861 4.1 */ + rs->hdr.code = 0; /* see RFC4861 4.1 */ + rs->hdr.csum = 0; /* updated below */ + rs->reserved = 0; /* see RFC4861 4.1 */ + + rs->hdr.csum = osmo_icmpv6_prepend_ip6hdr(msg, saddr, &osmo_icmpv6_all_router_mcast_addr); + + return msg; +} +/*! construct a 3GPP 29.061 compliant router advertisement for a given prefix + * \param[in] saddr Source IPv6 address for router advertisement + * \param[in] daddr Destination IPv6 address for router advertisement IPv6 header + * \param[in] prefix The single prefix to be advertised (/64 implied!) + * \returns callee-allocated message buffer containing router advertisement */ +struct msgb *osmo_icmpv6_construct_ra(const struct in6_addr *saddr, + const struct in6_addr *daddr, + const struct in6_addr *prefix, + uint32_t mtu) +{ + struct msgb *msg = msgb_alloc_headroom(512, 128, "IPv6 RA"); + struct osmo_icmpv6_radv_hdr *ra; + struct osmo_icmpv6_opt_prefix *ra_opt_pref; + struct osmo_icmpv6_opt_mtu *ra_opt_mtu; + + OSMO_ASSERT(msg); + + ra = (struct osmo_icmpv6_radv_hdr *) msgb_put(msg, sizeof(*ra)); + ra->hdr.type = 134; /* see RFC4861 4.2 */ + ra->hdr.code = 0; /* see RFC4861 4.2 */ + ra->hdr.csum = 0; /* updated below */ + ra->cur_ho_limit = 64; /* seems reasonable? */ + /* the GGSN shall leave the M-flag cleared in the Router + * Advertisement messages */ + ra->m = 0; + /* The GGSN may set the O-flag if there are additional + * configuration parameters that need to be fetched by the MS */ + ra->o = 0; /* no DHCPv6 */ + ra->res = 0; + /* RFC4861 Default: 3 * MaxRtrAdvInterval */ + ra->router_lifetime = htons(3*GGSN_MaxRtrAdvInterval); + ra->reachable_time = 0; /* Unspecified */ + + /* RFC4861 Section 4.6.2 */ + ra_opt_pref = (struct osmo_icmpv6_opt_prefix *) msgb_put(msg, sizeof(*ra_opt_pref)); + ra_opt_pref->hdr.type = 3; /* RFC4861 4.6.2 */ + ra_opt_pref->hdr.len = 4; /* RFC4861 4.6.2 */ + ra_opt_pref->prefix_len = 64; /* only prefix length as per 3GPP */ + /* The Prefix is contained in the Prefix Information Option of + * the Router Advertisements and shall have the A-flag set + * and the L-flag cleared */ + ra_opt_pref->a = 1; + ra_opt_pref->l = 0; + ra_opt_pref->res = 0; + /* The lifetime of the prefix shall be set to infinity */ + ra_opt_pref->valid_lifetime = htonl(GGSN_AdvValidLifetime); + ra_opt_pref->preferred_lifetime = htonl(GGSN_AdvPreferredLifetime); + ra_opt_pref->res2 = 0; + memcpy(ra_opt_pref->prefix, prefix, sizeof(ra_opt_pref->prefix)); + + /* RFC4861 Section 4.6.4, MTU */ + ra_opt_mtu = (struct osmo_icmpv6_opt_mtu *) msgb_put(msg, sizeof(*ra_opt_mtu)); + ra_opt_mtu->hdr.type = 5; /* RFC4861 4.6.4 */ + ra_opt_mtu->hdr.len = 1; /* RFC4861 4.6.4 */ + ra_opt_mtu->reserved = 0; + ra_opt_mtu->mtu = htonl(mtu); + + /* The Prefix is contained in the Prefix Information Option of + * the Router Advertisements and shall have the A-flag set + * and the L-flag cleared */ + ra_opt_pref->a = 1; + ra_opt_pref->l = 0; + ra_opt_pref->res = 0; + /* The lifetime of the prefix shall be set to infinity */ + ra_opt_pref->valid_lifetime = htonl(GGSN_AdvValidLifetime); + ra_opt_pref->preferred_lifetime = htonl(GGSN_AdvPreferredLifetime); + ra_opt_pref->res2 = 0; + memcpy(ra_opt_pref->prefix, prefix, sizeof(ra_opt_pref->prefix)); + + /* checksum */ + ra->hdr.csum = osmo_icmpv6_prepend_ip6hdr(msg, saddr, daddr); + + return msg; +} + +/* Validate an ICMPv6 router solicitation according to RFC4861 6.1.1 */ +bool osmo_icmpv6_validate_router_solicit(const uint8_t *pack, unsigned len) +{ + const struct ip6_hdr *ip6h = (struct ip6_hdr *)pack; + //const struct icmpv6_hdr *ic6h = (struct icmpv6_hdr *) (pack + sizeof(*ip6h)); + + /* Hop limit field must have 255 */ + if (ip6h->ip6_ctlun.ip6_un1.ip6_un1_hlim != 255) + return false; + /* FIXME: ICMP checksum is valid */ + /* ICMP length (derived from IP length) is 8 or more octets */ + if (ip6h->ip6_ctlun.ip6_un1.ip6_un1_plen < 8) + return false; + /* FIXME: All included options have a length > 0 */ + /* FIXME: If IP source is unspecified, no source link-layer addr option */ + return true; +} + +/* Validate an ICMPv6 router advertisement according to RFC4861 6.1.2. + Returns pointer packet header on success, NULL otherwise. */ +struct osmo_icmpv6_radv_hdr *osmo_icmpv6_validate_router_adv(const uint8_t *pack, unsigned len) +{ + const struct ip6_hdr *ip6h = (struct ip6_hdr *)pack; + const struct osmo_icmpv6_hdr *ic6h = (struct osmo_icmpv6_hdr *) (pack + sizeof(*ip6h)); + + /* ICMP length (derived from IP length) is 16 or more octets */ + if (len < sizeof(*ip6h) + 16) + return NULL; + + if (ic6h->type != 134) /* router advertismenet type */ + return NULL; + + /*Routers must use their link-local address */ + if (!IN6_IS_ADDR_LINKLOCAL(&ip6h->ip6_src)) + return NULL; + /* Hop limit field must have 255 */ + if (ip6h->ip6_ctlun.ip6_un1.ip6_un1_hlim != 255) + return NULL; + /* ICMP Code is 0 */ + if (ic6h->code != 0) + return NULL; + /* ICMP length (derived from IP length) is 16 or more octets */ + if (ip6h->ip6_ctlun.ip6_un1.ip6_un1_plen < 16) + return NULL; + /* FIXME: All included options have a length > 0 */ + /* FIXME: If IP source is unspecified, no source link-layer addr option */ + return (struct osmo_icmpv6_radv_hdr *)ic6h; +} -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42464?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I78ec7270c717af0a1b8ffd9398cd69ea7a0dbee2 Gerrit-Change-Number: 42464 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
1 0
0 0
[L] Change in libosmo-netif[master]: Introduce API osmo_icmpv6
by laforge 23 Mar '26

23 Mar '26
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42464?usp=email ) Change subject: Introduce API osmo_icmpv6 ...................................................................... Patch Set 2: Code-Review+2 (1 comment) File src/icmpv6.c: https://gerrit.osmocom.org/c/libosmo-netif/+/42464/comment/1a33a6f2_e4a7835… : PS2, Line 6: The contents of this file may be used under the terms of the GNU : * General Public License Version 2, provided that the above copyright : * notice and this permission notice is included in all copies or : * substantial portions of the software. ok, this looks like I want to relicense it unter GPL-v2-or-later like the rest of the library code. I'll try to remember to send a related commit. -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42464?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I78ec7270c717af0a1b8ffd9398cd69ea7a0dbee2 Gerrit-Change-Number: 42464 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 23 Mar 2026 19:06:13 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in libosmo-netif[master]: Introduce ip_checksum API
by laforge 23 Mar '26

23 Mar '26
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/42463?usp=email ) Change subject: Introduce ip_checksum API ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/42463?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Ia09645a4715ac133036d7c89297b0fa10cf9aa3b Gerrit-Change-Number: 42463 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 23 Mar 2026 19:05:02 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: General_types.ttcn: Introduce type OCT4_20n
by laforge 23 Mar '26

23 Mar '26
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42471?usp=email ) Change subject: General_types.ttcn: Introduce type OCT4_20n ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42471?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I00a35c444e3fb498712fbb4b9c310375c527052f Gerrit-Change-Number: 42471 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 23 Mar 2026 19:03:34 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • ...
  • 194
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.