[MERGED] openggsn[master]: ippool: Extend pool to work with /64 prefixes
Harald Welte has submitted this change and it was merged. Change subject: ippool: Extend pool to work with /64 prefixes .. ippool: Extend pool to work with /64 prefixes In IPv6 GPRS, we actually don't want to allocate an individual v6 address (like in IPv4), but we want to allocate a prefix. The standard prefix lengh is 8 bytes, i.e. a /64 prefix. This patch extends the pool to be able to work with such v6 prefixes. Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443 --- M ggsn/ggsn.c M lib/in46_addr.c M lib/ippool.c 3 files changed, 17 insertions(+), 8 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 0629f9e..9b11884 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -241,7 +241,11 @@ dst.len = 4; dst.v4.s_addr = iph->daddr; } else if (iph->version == 6) { - dst.len = 16; + /* Due to the fact that 3GPP requires an allocation of a +* /64 prefix to each MS, we must instruct +* ippool_getip() below to match only the leading /64 +* prefix, i.e. the first 8 bytes of the address */ + dst.len = 8; dst.v6 = ip6h->ip6_dst; } else { LOGP(DGGSN, LOGL_NOTICE, "non-IPv packet received from tun\n"); diff --git a/lib/in46_addr.c b/lib/in46_addr.c index a220583..1785377 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -25,6 +25,7 @@ switch (in->len) { case 4: return AF_INET; + case 8: case 16: return AF_INET6; default: @@ -175,6 +176,7 @@ eua->v[1] = 0x21; /* IPv4 */ memcpy(>v[2], >v4, 4);/* Copy a 4 byte address */ break; + case 8: case 16: eua->l = 18; eua->v[0] = 0xf1; /* IETF */ diff --git a/lib/ippool.c b/lib/ippool.c index 007dc50..1729ec7 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -96,11 +96,10 @@ return lookup((unsigned char *)>s_addr, sizeof(addr->s_addr), 0); } -static unsigned long int ippool_hash6(struct in6_addr *addr) +static unsigned long int ippool_hash6(struct in6_addr *addr, unsigned int len) { /* TODO: Review hash spread for IPv6 */ - return lookup((unsigned char *)addr->s6_addr, sizeof(addr->s6_addr), - 0); + return lookup((unsigned char *)addr->s6_addr, len, 0); } unsigned long int ippool_hash(struct in46_addr *addr) @@ -108,7 +107,7 @@ if (addr->len == 4) return ippool_hash4(>v4); else - return ippool_hash6(>v6); + return ippool_hash6(>v6, addr->len); } /* Get IP address and mask */ @@ -209,6 +208,10 @@ "Failed to parse dynamic pool"); return -1; } + /* we want to work with /64 prefixes, i.e. allocate /64 prefixes rather +* than /128 (single IPv6 addresses) */ + if (addr.len == sizeof(struct in6_addr)) + addr.len = 64/8; /* Set IPPOOL_NONETWORK if IPPOOL_NOGATEWAY is set */ if (flags & IPPOOL_NOGATEWAY) { @@ -348,7 +351,7 @@ /* Find in hash table */ hash = ippool_hash(addr) & this->hashmask; for (p = this->hash[hash]; p; p = p->nexthash) { - if (in46a_equal(>addr, addr)) { + if (in46a_prefix_equal(>addr, addr)) { if (member) *member = p; return 0; @@ -421,7 +424,7 @@ /* Find in hash table */ hash = ippool_hash(addr) & this->hashmask; for (p = this->hash[hash]; p; p = p->nexthash) { - if (in46a_equal(>addr, addr)) { + if (in46a_prefix_equal(>addr, addr)) { p2 = p; break; } @@ -450,7 +453,7 @@ return -GTPCAUSE_SYS_FAIL; /* Allready in use / Should not happen */ } - if (p2->addr.len != addr->len) { + if (p2->addr.len != addr->len && !(addr->len == 16 && p2->addr.len == 8)) { SYS_ERR(DIP, LOGL_ERROR, 0, "MS requested unsupported PDP context type"); return -GTPCAUSE_UNKNOWN_PDP; } -- To view, visit https://gerrit.osmocom.org/3457 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte
openggsn[master]: ippool: Extend pool to work with /64 prefixes
Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3457 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
libosmo-sccp[master]: safer osmo_sccp_make_addr_pc_ssn(): clear all values
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3341 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I37395169d364050e45e99793c495a9848a4f8601 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] libosmo-sccp[master]: safer osmo_sccp_make_addr_pc_ssn(): clear all values
Harald Welte has submitted this change and it was merged. Change subject: safer osmo_sccp_make_addr_pc_ssn(): clear all values .. safer osmo_sccp_make_addr_pc_ssn(): clear all values Make sure that all values of the resulting sccp_addr are cleared to obtain a clean PC+SSN address. Before this, gt and ip remained unset/random, e.g. in osmo_sccp_tx_unitdata_ranap() Change-Id: I37395169d364050e45e99793c495a9848a4f8601 --- M src/sccp_helpers.c 1 file changed, 6 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 1e83c8c..4b24392 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -38,10 +38,12 @@ void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) { - addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; - addr->ri = OSMO_SCCP_RI_SSN_PC; - addr->ssn = ssn; - addr->pc = pc; + *addr = (struct osmo_sccp_addr){ + .presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC, + .ri = OSMO_SCCP_RI_SSN_PC, + .ssn = ssn, + .pc = pc, + }; } void osmo_sccp_addr_set_ssn(struct osmo_sccp_addr *addr, uint32_t ssn) -- To view, visit https://gerrit.osmocom.org/3341 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I37395169d364050e45e99793c495a9848a4f8601 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: vty: hide SG commands when running as ASP
Harald Welte has submitted this change and it was merged. Change subject: vty: hide SG commands when running as ASP .. vty: hide SG commands when running as ASP The SG (signal gateway) requires an extra set of VTY commands in order to be fully configurable. These VTY commands do not make sense in a situation where libosmo-sccp is used to implement an ASP (application server process). Detect in which role libosmo-sccp is used by which of the VTY initalization functions are called: osmo_ss7_vty_init_asp() ==> ASP osmo_ss7_vty_init_sg() ==> SG Prevent writing back of SG specific configuration when in running as ASP. Only write back the full parameter set when running as SG. Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf --- M src/osmo_ss7_vty.c 1 file changed, 13 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 21efcae..9343edd 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -50,6 +50,8 @@ * Core CS7 Configuration ***/ +enum cs7_role_t {CS7_ROLE_SG, CS7_ROLE_ASP}; +static enum cs7_role_t cs7_role; static void *g_ctx; static struct cmd_node cs7_node = { @@ -1559,12 +1561,16 @@ llist_for_each_entry(as, >as_list, list) write_one_as(vty, as); - /* now dump routes, as their target ASs exist */ - llist_for_each_entry(rtable, >rtable_list, list) - write_one_rtable(vty, rtable); + /* now dump everything that is relevent for the SG role */ + if (cs7_role == CS7_ROLE_SG) { - llist_for_each_entry(oxs, >xua_servers, list) - write_one_xua(vty, oxs); + /* dump routes, as their target ASs exist */ + llist_for_each_entry(rtable, >rtable_list, list) + write_one_rtable(vty, rtable); + + llist_for_each_entry(oxs, >xua_servers, list) + write_one_xua(vty, oxs); + } /* Append SCCP Addressbook */ write_sccp_addressbook(vty, inst); @@ -1717,11 +1723,13 @@ void osmo_ss7_vty_init_asp(void *ctx) { + cs7_role = CS7_ROLE_ASP; vty_init_shared(ctx); } void osmo_ss7_vty_init_sg(void *ctx) { + cs7_role = CS7_ROLE_SG; vty_init_shared(ctx); install_node(_node, NULL); -- To view, visit https://gerrit.osmocom.org/3453 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexterGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: sccp: fix creating of the default route in simple client
Harald Welte has submitted this change and it was merged. Change subject: sccp: fix creating of the default route in simple client .. sccp: fix creating of the default route in simple client The simple client (osmo_sccp_simple_client_on_ss7_id() and osmo_sccp_simple_client) does not create a default route if the user has already created an AS via VTY. Check the presence of a default route independently of the AS. If no default route exists, create one. Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a --- M src/sccp_user.c 1 file changed, 7 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp_user.c b/src/sccp_user.c index 1414572..1d59d3c 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -368,16 +368,20 @@ goto out_ss7; } as->cfg.routing_key.pc = ss7->cfg.primary_pc; + } + LOGP(DLSCCP, LOGL_NOTICE, "%s: Using AS instance %s\n", name, +as->cfg.name); - /* install default route */ + /* Create a default route if necessary */ + rt = osmo_ss7_route_find_dpc_mask(ss7->rtable_system, 0, 0); + if (!rt) { + LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating default route\n", name); rt = osmo_ss7_route_create(ss7->rtable_system, 0, 0, as->cfg.name); if (!rt) goto out_as; rt_created = true; } - LOGP(DLSCCP, LOGL_NOTICE, "%s: Using AS instance %s\n", name, -as->cfg.name); /* Check if we do already have an application server process * that is associated with the application server we have choosen -- To view, visit https://gerrit.osmocom.org/3452 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexterGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
libosmo-sccp[master]: sccp: fix creating of the default route in simple client
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3452 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexterGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
libosmo-sccp[master]: vty: hide SG commands when running as ASP
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3453 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexterGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
libosmocore[master]: Add osmo_gprs_{ul, dl}_block_size_{bits, bytes} functions
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3454 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I05ff75ef7dfae639886bbd09fe35f03a8af9d988 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] libosmocore[master]: tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs
Harald Welte has submitted this change and it was merged. Change subject: tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs .. tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs In the Protocol Configuration Options IE (see 3GPP TS 24.008 10.5.6.3) there is yet another new TLV format (derived from PPP IPCP/LCP/...) which uses 16bit tag and 8bit length. Let's add functions so we can generate related TLVs. Parsing is unfortunately not possible in our existing structure as our tlv_parsed array only has 256 entries and thus cannot cope with 16bit tags. Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694 --- M include/osmocom/gsm/tlv.h 1 file changed, 20 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index c356840..f903223 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -21,7 +21,7 @@ TLV16 8 8 N * 16 TvLV 8 8/16N * 8 vTvLV 8/168/16N * 8 - + T16LV 16 8 N * 8 */ /*! gross length of a LV type field */ @@ -34,6 +34,8 @@ #define TL16V_GROSS_LEN(x) (x+3) /*! gross length of a L16TV type field */ #define L16TV_GROSS_LEN(x) (x+3) +/*! gross length of a T16LV type field */ +#define T16LV_GROSS_LEN(x) (x+3) /*! maximum length of TLV of one byte length */ #define TVLV_MAX_ONEBYTE 0x7f @@ -119,6 +121,17 @@ return buf + len*2; } +/*! put (append) a TL16V field */ +static inline uint8_t *t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len, + const uint8_t *val) +{ + *buf++ = tag >> 8; + *buf++ = tag & 0xff; + *buf++ = len; + memcpy(buf, val, len); + return buf + len + 2; +} + /*! put (append) a TvLV field */ static inline uint8_t *tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val) @@ -185,6 +198,12 @@ return tl16v_put(buf, tag, len, val); } +static inline uint8_t *msgb_t16lv_put(struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val) +{ + uint8_t *buf = msgb_put(msg, T16LV_GROSS_LEN(len)); + return t16lv_put(buf, tag, len, val); +} + /*! put (append) a TvLV field to \ref msgb */ static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len, const uint8_t *val) -- To view, visit https://gerrit.osmocom.org/3455 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmocore[master]: Add osmo_gprs_{ul, dl}_block_size_{bits, bytes} functions
Harald Welte has submitted this change and it was merged. Change subject: Add osmo_gprs_{ul,dl}_block_size_{bits,bytes} functions .. Add osmo_gprs_{ul,dl}_block_size_{bits,bytes} functions Those functions can be used to look up the size of (E)GPRS blocks. Change-Id: I05ff75ef7dfae639886bbd09fe35f03a8af9d988 --- M include/osmocom/gprs/gprs_rlc.h M src/gsm/gprs_rlc.c M src/gsm/libosmogsm.map 3 files changed, 121 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gprs/gprs_rlc.h b/include/osmocom/gprs/gprs_rlc.h index 05d3de6..b74f9e4 100644 --- a/include/osmocom/gprs/gprs_rlc.h +++ b/include/osmocom/gprs/gprs_rlc.h @@ -26,4 +26,29 @@ EGPRS_HDR_TYPE3, }; +enum osmo_gprs_cs { + OSMO_GPRS_CS_NONE, + OSMO_GPRS_CS1, + OSMO_GPRS_CS2, + OSMO_GPRS_CS3, + OSMO_GPRS_CS4, + OSMO_GPRS_MCS1, + OSMO_GPRS_MCS2, + OSMO_GPRS_MCS3, + OSMO_GPRS_MCS4, + OSMO_GPRS_MCS5, + OSMO_GPRS_MCS6, + OSMO_GPRS_MCS7, + OSMO_GPRS_MCS8, + OSMO_GPRS_MCS9, + _NUM_OSMO_GPRS_CS +}; + int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits); + +int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs); +int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs); +int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs); +int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs); +enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size); +enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size); diff --git a/src/gsm/gprs_rlc.c b/src/gsm/gprs_rlc.c index b213b26..d2c05b7 100644 --- a/src/gsm/gprs_rlc.c +++ b/src/gsm/gprs_rlc.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -109,3 +110,92 @@ return 0; } + +struct gprs_cs_desc { + struct { + uint8_t bytes; + uint8_t bits; + } uplink, downlink; +}; + +const struct gprs_cs_desc gprs_cs_desc[_NUM_OSMO_GPRS_CS] = { + [OSMO_GPRS_CS1] = { {23, 0},{23, 0} }, + [OSMO_GPRS_CS2] = { {33, 7},{33, 7} }, + [OSMO_GPRS_CS3] = { {39, 3},{39, 3} }, + [OSMO_GPRS_CS4] = { {53, 7},{53, 7} }, + + [OSMO_GPRS_MCS1]= { {26, 1},{26, 1} }, + [OSMO_GPRS_MCS2]= { {32, 1},{32, 1} }, + [OSMO_GPRS_MCS3]= { {41, 1},{41, 1} }, + [OSMO_GPRS_MCS4]= { {48, 1},{48, 1} }, + + [OSMO_GPRS_MCS5]= { {60, 7},{59, 6} }, + [OSMO_GPRS_MCS6]= { {78, 7},{77, 6} }, + [OSMO_GPRS_MCS7]= { {118, 2}, {117, 4} }, + [OSMO_GPRS_MCS8]= { {142, 2}, {141, 4} }, + [OSMO_GPRS_MCS9]= { {154, 2}, {153, 4} }, +}; + +/*! Return size of (E)GPRS uplink block for given coding scheme in bits */ +int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs) +{ + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + return gprs_cs_desc[cs].uplink.bytes * 8 + gprs_cs_desc[cs].uplink.bits; +} + +/*! Return size of (E)GPRS downlink block for given coding scheme in bits */ +int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs) +{ + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + return gprs_cs_desc[cs].downlink.bytes * 8 + gprs_cs_desc[cs].downlink.bits; +} + +/*! Return size of (E)GPRS uplink block for given coding scheme in bytes */ +int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs) +{ + int rc; + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + rc = gprs_cs_desc[cs].uplink.bytes; + if (gprs_cs_desc[cs].uplink.bits) + rc++; + return rc; +} + +/*! Return size of (E)GPRS downlink block for given coding scheme in bytes */ +int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs) +{ + int rc; + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + rc = gprs_cs_desc[cs].downlink.bytes; + if (gprs_cs_desc[cs].downlink.bits) + rc++; + return rc; +} + +/*! Return coding scheme for given (E)GPRS uplink block size */ +enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gprs_cs_desc); i++) { + if (block_size == osmo_gprs_ul_block_size_bytes(i)) + return i; + } + return OSMO_GPRS_CS_NONE; +} + +/*! Return coding scheme for given (E)GPRS downlink block size */ +enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gprs_cs_desc); i++) { + if (block_size == osmo_gprs_dl_block_size_bytes(i)) + return i; + } + return OSMO_GPRS_CS_NONE; +} diff --git
[PATCH] openggsn[master]: Support setting TUN device IPv6 address + prefix
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3408 to look at the new patch set (#7). Support setting TUN device IPv6 address + prefix As we can now have PDP contexts with IPv6 user IP payload, it is useful to extend the TUN related code to be able to configure the tun device IPv6 address + prefix length Change-Id: I899d21e52d02e0b8384af29ddd489ff19c8f2cf6 --- M ggsn/ggsn.c M lib/tun.c M lib/tun.h 3 files changed, 111 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/08/3408/7 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 991b54c..05a56ae 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -70,7 +70,7 @@ int maxfd = 0; /* For select()*/ struct in_addr listen_; -struct in_addr netaddr, destaddr, net; /* Network interface */ +struct in46_addr netaddr, destaddr, net; /* Network interface */ size_t prefixlen; struct in46_addr dns1, dns2; /* PCO DNS address */ char *ipup, *ipdown; /* Filename of scripts */ @@ -547,16 +547,16 @@ /* net */ /* Store net as in_addr net and mask*/ if (args_info.net_arg) { - struct in46_addr in46; - if (ippool_aton(, , args_info.net_arg, 0)) { + if (ippool_aton(, , args_info.net_arg, 0)) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Invalid network address: %s!", args_info.net_arg); exit(1); } - net.s_addr = in46.v4.s_addr; - netaddr.s_addr = htonl(ntohl(net.s_addr) + 1); - destaddr.s_addr = htonl(ntohl(net.s_addr) + 1); + /* default for network + destination address = net + 1 */ + netaddr = net; + in46a_inc(); + destaddr = netaddr; } else { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Network address must be specified: %s!", @@ -710,7 +710,7 @@ maxfd = gsn->fd1u; /* use GTP kernel module for data packet encapsulation */ - if (gtp_kernel_init(gsn, , prefixlen, _info) < 0) + if (gtp_kernel_init(gsn, , prefixlen, _info) < 0) goto err; gtp_set_cb_data_ind(gsn, encaps_tun); @@ -735,7 +735,7 @@ } DEBUGP(DGGSN, "Setting tun IP address\n"); - if (tun_setaddr(tun, , , )) { + if (tun_setaddr(tun, , , prefixlen)) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Failed to set tun IP address"); exit(1); } diff --git a/lib/tun.c b/lib/tun.c index 8325f5d..7e0af12 100644 --- a/lib/tun.c +++ b/lib/tun.c @@ -1,6 +1,7 @@ /* * TUN interface functions. * Copyright (C) 2002, 2003, 2004 Mondru AB. + * Copyright (C) 2017 by Harald Welte* * The contents of this file may be used under the terms of the GNU * General Public License Version 2, provided that the above copyright @@ -65,7 +66,12 @@ #include "tun.h" #include "syserr.h" +static int tun_setaddr4(struct tun_t *this, struct in_addr *addr, + struct in_addr *dstaddr, struct in_addr *netmask); + #if defined(__linux__) + +#include int tun_nlattr(struct nlmsghdr *n, int nsize, int type, void *d, int dlen) { @@ -247,7 +253,7 @@ struct msghdr msg; if (!this->addrs) /* Use ioctl for first addr to make ping work */ - return tun_setaddr(this, addr, dstaddr, netmask); + return tun_setaddr4(this, addr, dstaddr, netmask); memset(, 0, sizeof(req)); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); @@ -345,7 +351,7 @@ /* TODO: Is this needed on FreeBSD? */ if (!this->addrs) /* Use ioctl for first addr to make ping work */ - return tun_setaddr(this, addr, dstaddr, netmask); /* TODO dstaddr */ + return tun_setaddr4(this, addr, dstaddr, netmask); /* TODO dstaddr */ memset(, 0, sizeof(areq)); @@ -391,7 +397,7 @@ #elif defined (__sun__) if (!this->addrs) /* Use ioctl for first addr to make ping work */ - return tun_setaddr(this, addr, dstaddr, netmask); + return tun_setaddr4(this, addr, dstaddr, netmask); SYS_ERR(DTUN, LOGL_ERROR, errno, "Setting multiple addresses not possible on Solaris"); @@ -403,9 +409,8 @@ } -int tun_setaddr(struct tun_t *this, - struct in_addr *addr, - struct in_addr *dstaddr, struct in_addr *netmask) +static int tun_setaddr4(struct tun_t *this, struct in_addr *addr, + struct in_addr *dstaddr, struct in_addr *netmask) { struct ifreq ifr; int fd; @@ -498,13 +503,99 @@ tun_sifflags(this, IFF_UP |
[PATCH] openggsn[master]: IPv6: in46_addr: OSMO_ASSERT() in case of unsupported calls
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3460 to look at the new patch set (#2). IPv6: in46_addr: OSMO_ASSERT() in case of unsupported calls There's a bit of trickery with the ip_pool and it's "lengty=8" IPv6 prefix handling, let's make sure we don't accidentially call any support functions with addresses of wrong length. Change-Id: I444c190bdcd18780344e1f0dad4faf3bcf9da5a5 --- M lib/in46_addr.c 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/60/3460/2 diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 1785377..8f5cc09 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -11,6 +11,8 @@ #include "../lib/in46_addr.h" +#include + #include #include #include @@ -29,6 +31,7 @@ case 16: return AF_INET6; default: + OSMO_ASSERT(0); return -1; } } @@ -49,6 +52,7 @@ sin6->sin6_addr = in->v6; break; default: + OSMO_ASSERT(0); return -1; } @@ -161,6 +165,7 @@ create_ipv6_netmask(, prefixlen); return ipv6_within_mask(>v6, >v6, ); default: + OSMO_ASSERT(0); return 0; } } @@ -184,6 +189,7 @@ memcpy(>v[2], >v6, 16); /* Copy a 16 byte address */ break; default: + OSMO_ASSERT(0); return -1; } return 0; -- To view, visit https://gerrit.osmocom.org/3460 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I444c190bdcd18780344e1f0dad4faf3bcf9da5a5 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Jenkins Builder
[PATCH] openggsn[master]: IPv6: Implement IPv6 prefix assignment via ICMPv6 router adv...
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3458 to look at the new patch set (#2). IPv6: Implement IPv6 prefix assignment via ICMPv6 router advertisement The 3GPP specs are quite strange when it comes to how an IPv6 address or rather prefix is assigned to an IPv6 PDP context. The designated method for allocating the IPv6 address via the PDP EUA (End User Address) Information Element in the GTP signalling plane is *not* used to allocate the address/prefix. Instead, the EUA is used to allocate an "interface identifier" to the MS, which it the uses to derive its link-local source address to send a router solicitation. The GGSN subsequently answers witha router advertisement, advertising a single/64 prefix, whihcthe MS then uses to generate it's real IPv6 source address for subsequent communication. Change-Id: Icddf7d30e01d76a4784bcef5787b36f52f703a9f --- M ggsn/Makefile.am A ggsn/checksum.c A ggsn/checksum.h M ggsn/ggsn.c A ggsn/icmpv6.c A ggsn/icmpv6.h M lib/debug.c M lib/syserr.h 8 files changed, 500 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/58/3458/2 diff --git a/ggsn/Makefile.am b/ggsn/Makefile.am index 3ad3a6e..c945f0b 100644 --- a/ggsn/Makefile.am +++ b/ggsn/Makefile.am @@ -12,7 +12,7 @@ endif ggsn_DEPENDENCIES = ../gtp/libgtp.la ../lib/libmisc.a -ggsn_SOURCES = ggsn.c cmdline.c cmdline.h gtp-kernel.h +ggsn_SOURCES = ggsn.c cmdline.c cmdline.h gtp-kernel.h icmpv6.c icmpv6.h checksum.c checksum.h if ENABLE_GTP_KERNEL ggsn_SOURCES += gtp-kernel.c diff --git a/ggsn/checksum.c b/ggsn/checksum.c new file mode 100644 index 000..1e9e58e --- /dev/null +++ b/ggsn/checksum.c @@ -0,0 +1,205 @@ +/* + * + * INETAn 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,+ * Arnt Gulbrandsen, + * Tom May, + * Andreas Schwab, + * Lots of code moved from tcp.c and ip.c; see those files + * for more names. + * + * 03/02/96Jes 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. */ + +#include "checksum.h" +#include +#include + +static inline unsigned short from32to16(unsigned int x) +{ + /* add up 16-bit and 16-bit for 16+c bit */ + x = (x & 0x) + (x >> 16); + /* add up carry.. */ + x = (x & 0x) + (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) { +#ifdef __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 & 0x) + (result >> 16); + } + if (len & 2) { +
[PATCH] openggsn[master]: IPv6: Support PCO for IPv6 DNS addresses
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3459 to look at the new patch set (#2). IPv6: Support PCO for IPv6 DNS addresses In IPv6, DNS server information is not passed along as IPCP6 like in IPv5 with IPCP. The reason is that IPCP6 (for PPP) doesn't support passing DNS server information. Rather, the relevant RFCs indicate DHCPv6 should be used even over point-to-point links. 3GPP decided to avoid DHCPv6 dependency for stateless autoconfiguration (the only mandatory IPv6 configuration mechanism) and added some new non-PPP-style PCO information elements ("containers") which can among other things inform a MS about IPV6 DNS servers. That same mechanism can also be used to inform the MS about IPv4 DNS servers, so for IPv4 there are now two competing mechanisms: IPCP and the new "native" PCO container. With this patch, we support both for IPv4. Change-Id: I21499afd61def8c925f7838bde76f34d28214b56 --- M ggsn/ggsn.c 1 file changed, 137 insertions(+), 42 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/59/3459/2 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index c307177..991b54c 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -72,7 +72,7 @@ struct in_addr listen_; struct in_addr netaddr, destaddr, net; /* Network interface */ size_t prefixlen; -struct in_addr dns1, dns2; /* PCO DNS address */ +struct in46_addr dns1, dns2; /* PCO DNS address */ char *ipup, *ipdown; /* Filename of scripts */ int debug; /* Print debug output */ struct ul255_t pco; @@ -175,6 +175,103 @@ return 0; } +#include + +/* 3GPP TS 24.008 10.6.5.3 */ +enum pco_protocols { + PCO_P_LCP = 0xC021, + PCO_P_PAP = 0xC023, + PCO_P_CHAP = 0xC223, + PCO_P_IPCP = 0x8021, + PCO_P_PCSCF_ADDR= 0x0001, + PCO_P_IM_CN_SS_F= 0x0002, + PCO_P_DNS_IPv6_ADDR = 0x0003, + PCO_P_POLICY_CTRL_REJ = 0x0004, /* only in Network->MS */ + PCO_P_MS_SUP_NETREQ_BCI = 0x0005, + /* reserved */ + PCO_P_DSMIPv6_HA_ADDR = 0x0007, + PCO_P_DSMIPv6_HN_PREF = 0x0008, + PCO_P_DSMIPv6_v4_HA_ADDR= 0x0009, + PCO_P_IP_ADDR_VIA_NAS = 0x000a, /* only MS->Network */ + PCO_P_IPv4_ADDR_VIA_DHCP= 0x000b, /* only MS->Netowrk */ + PCO_P_PCSCF_IPv4_ADDR = 0x000c, + PCO_P_DNS_IPv4_ADDR = 0x000d, + PCO_P_MSISDN= 0x000e, + PCO_P_IFOM_SUPPORT = 0x000f, + PCO_P_IPv4_LINK_MTU = 0x0010, + PCO_P_MS_SUPP_LOC_A_TFT = 0x0011, + PCO_P_PCSCF_RESEL_SUP = 0x0012, /* only MS->Network */ + PCO_P_NBIFOM_REQ= 0x0013, + PCO_P_NBIFOM_MODE = 0x0014, + PCO_P_NONIP_LINK_MTU= 0x0015, + PCO_P_APN_RATE_CTRL_SUP = 0x0016, + PCO_P_PS_DATA_OFF_UE= 0x0017, + PCO_P_REL_DATA_SVC = 0x0018, +}; + +/* determine if PCO contains given protocol */ +static bool pco_contains_proto(struct ul255_t *pco, uint16_t prot) +{ + uint8_t *cur = pco->v + 1; + + /* iterate over PCO and check if protocol contained */ + while (cur + 2 < pco->v + pco->l) { + uint16_t cur_prot = osmo_load16be(cur); + uint8_t cur_len = cur[2]; + if (cur_prot == prot) + return true; + if (cur_len == 0) + break; + cur += cur_len; + } + return false; +} + +/* determine if PDP context has IPv6 support */ +static bool pdp_has_v4(struct pdp_t *pdp) +{ + if (pdp->eua.l == 4+2) + return true; + else + return false; +} + +/* process one PCO request from a MS/UE, putting together the proper responses */ +static void process_pco(struct pdp_t *pdp) +{ + struct msgb *msg = msgb_alloc(256, "PCO"); + msgb_put_u8(msg, 0x80); /* ext-bit + configuration protocol byte */ + + /* FIXME: also check if primary / secondary DNS was requested */ + if (pdp_has_v4(pdp) && pco_contains_proto(>pco_req, PCO_P_IPCP)) { + /* FIXME: properly implement this for IPCP */ + uint8_t *cur = msgb_put(msg, pco.l-1); + memcpy(cur, pco.v+1, pco.l-1); + } + + if (pco_contains_proto(>pco_req, PCO_P_DNS_IPv6_ADDR)) { + if (dns1.len == 16) + msgb_t16lv_put(msg, PCO_P_DNS_IPv6_ADDR, dns1.len, dns1.v6.s6_addr); + if (dns2.len == 16) + msgb_t16lv_put(msg, PCO_P_DNS_IPv6_ADDR, dns2.len, dns2.v6.s6_addr); + } + + if (pco_contains_proto(>pco_req, PCO_P_DNS_IPv4_ADDR)) { + if (dns1.len == 4) + msgb_t16lv_put(msg, PCO_P_DNS_IPv4_ADDR, dns1.len, (uint8_t *)); + if (dns2.len == 4) + msgb_t16lv_put(msg,
libosmocore[master]: tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3455 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] openggsn[master]: ippool_new(): const-ify input arguments
Harald Welte has submitted this change and it was merged. Change subject: ippool_new(): const-ify input arguments .. ippool_new(): const-ify input arguments Change-Id: If3e53584e8c9c1f06bba4c183c9fd65fae913904 --- M lib/ippool.c M lib/ippool.h 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/lib/ippool.c b/lib/ippool.c index c3eb267..3ca1b86 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -186,7 +186,7 @@ } /* Create new address pool */ -int ippool_new(struct ippool_t **this, char *dyn, char *stat, +int ippool_new(struct ippool_t **this, const char *dyn, const char *stat, int allowdyn, int allowstat, int flags) { diff --git a/lib/ippool.h b/lib/ippool.h index 53154f2..e3c1c92 100644 --- a/lib/ippool.h +++ b/lib/ippool.h @@ -69,7 +69,7 @@ extern unsigned long int ippool_hash(struct in46_addr *addr); /* Create new address pool */ -extern int ippool_new(struct ippool_t **this, char *dyn, char *stat, +extern int ippool_new(struct ippool_t **this, const char *dyn, const char *stat, int allowdyn, int allowstat, int flags); /* Delete existing address pool */ -- To view, visit https://gerrit.osmocom.org/3405 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If3e53584e8c9c1f06bba4c183c9fd65fae913904 Gerrit-PatchSet: 6 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] openggsn[master]: lib/tun.h: Remove non-endian-safe redefinition of IP header
Harald Welte has submitted this change and it was merged. Change subject: lib/tun.h: Remove non-endian-safe redefinition of IP header .. lib/tun.h: Remove non-endian-safe redefinition of IP header We can simply use 'struct iphdr' from netinet/ip.h to achieve the same goal (and be portable). Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32 --- M configure.ac M ggsn/ggsn.c M lib/tun.h M sgsnemu/sgsnemu.c 4 files changed, 39 insertions(+), 20 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/configure.ac b/configure.ac index 45ab22b..b7e6793 100644 --- a/configure.ac +++ b/configure.ac @@ -112,6 +112,12 @@ AC_DEFINE([HAVE_RT_MSGHDR])], AC_MSG_RESULT(no)) +AC_MSG_CHECKING(whether struct iphdr exists) +AH_TEMPLATE(HAVE_IPHDR) +AC_EGREP_HEADER(struct iphdr, netinet/ip.h, +[AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_IPHDR])], + AC_MSG_RESULT(no)) # Checks for library functions. AC_PROG_GCC_TRADITIONAL diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 0d0e569..4fb2066 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include @@ -221,13 +223,13 @@ { struct ippoolm_t *ipm; struct in46_addr dst; - struct tun_packet_t *iph = (struct tun_packet_t *)pack; + struct iphdr *iph = (struct iphdr *)pack; - if (iph->ver == 4) { + if (iph->version == 4) { if (len < sizeof(*iph) || len < 4*iph->ihl) return -1; dst.len = 4; - dst.v4.s_addr = iph->dst; + dst.v4.s_addr = iph->daddr; } else { LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); return -1; diff --git a/lib/tun.h b/lib/tun.h index ce7b91c..c50bdf9 100644 --- a/lib/tun.h +++ b/lib/tun.h @@ -17,21 +17,31 @@ #define TUN_ADDRSIZE 128 #define TUN_NLBUFSIZE 1024 -struct tun_packet_t { - unsigned int ver:4; - unsigned int ihl:4; - unsigned int dscp:6; - unsigned int ecn:2; - unsigned int length:16; - unsigned int id:16; - unsigned int flags:3; - unsigned int fragment:13; - unsigned int ttl:8; - unsigned int protocol:8; - unsigned int check:16; - unsigned int src:32; - unsigned int dst:32; -}; +#include "config.h" +#ifndef HAVE_IPHDR +struct iphdr + { +#if __BYTE_ORDER == __LITTLE_ENDIAN +unsigned int ihl:4; +unsigned int version:4; +#elif __BYTE_ORDER == __BIG_ENDIAN +unsigned int version:4; +unsigned int ihl:4; +#else +# error"Please fix " +#endif +u_int8_t tos; +u_int16_t tot_len; +u_int16_t id; +u_int16_t frag_off; +u_int8_t ttl; +u_int8_t protocol; +u_int16_t check; +u_int32_t saddr; +u_int32_t daddr; +/*The options start here. */ + }; +#endif /* !HAVE_IPHDR */ /* *** * Information storage for each tun instance diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index 90a6200..af8f9fa 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1281,10 +1282,10 @@ { struct iphash_t *ipm; struct in46_addr src; - struct tun_packet_t *iph = (struct tun_packet_t *)pack; + struct iphdr *iph = (struct iphdr *)pack; src.len = 4; - src.v4.s_addr = iph->src; + src.v4.s_addr = iph->saddr; if (ipget(, )) { printf("Dropping packet from invalid source address: %s\n", -- To view, visit https://gerrit.osmocom.org/3404 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32 Gerrit-PatchSet: 6 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] openggsn[master]: ippool: Add IPv6 support to IP pool implementation
Harald Welte has submitted this change and it was merged. Change subject: ippool: Add IPv6 support to IP pool implementation .. ippool: Add IPv6 support to IP pool implementation Extend the IP pool implementation to be able to manage both pools of 32bit addresses (IPv4) as well as pools of 128bit addresses (IPv6) Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8 --- M ggsn/ggsn.c M ggsn/gtp-kernel.c M ggsn/gtp-kernel.h M lib/Makefile.am A lib/in46_addr.c A lib/in46_addr.h M lib/ippool.c M lib/ippool.h M sgsnemu/sgsnemu.c 9 files changed, 371 insertions(+), 169 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 168e907..0d0e569 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -56,6 +56,7 @@ #include "../lib/tun.h" #include "../lib/ippool.h" #include "../lib/syserr.h" +#include "../lib/in46_addr.h" #include "../gtp/pdp.h" #include "../gtp/gtp.h" #include "cmdline.h" @@ -65,7 +66,8 @@ int maxfd = 0; /* For select()*/ struct in_addr listen_; -struct in_addr netaddr, destaddr, net, mask; /* Network interface */ +struct in_addr netaddr, destaddr, net; /* Network interface */ +size_t prefixlen; struct in_addr dns1, dns2; /* PCO DNS address */ char *ipup, *ipdown; /* Filename of scripts */ int debug; /* Print debug output */ @@ -135,9 +137,12 @@ static bool send_trap(const struct gsn_t *gsn, const struct pdp_t *pdp, const struct ippoolm_t *member, const char *var) { + char addrbuf[256]; char val[NAMESIZE]; - snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, inet_ntoa(member->addr)); + const char *addrstr = in46a_ntop(>addr, addrbuf, sizeof(addrbuf)); + + snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, addrstr); if (ctrl_cmd_send_trap(gsn->ctrl, var, val) < 0) { LOGP(DGGSN, LOGL_ERROR, "Failed to create and send TRAP for IMSI %" PRIu64 " [%s].\n", pdp->imsi, var); @@ -168,7 +173,7 @@ int create_context_ind(struct pdp_t *pdp) { - struct in_addr addr; + struct in46_addr addr; struct ippoolm_t *member; DEBUGP(DGGSN, "Received create PDP context request\n"); @@ -183,8 +188,8 @@ memcpy(pdp->qos_neg.v, pdp->qos_req.v, pdp->qos_req.l); /* TODO */ pdp->qos_neg.l = pdp->qos_req.l; - if (pdp_euaton(>eua, )) { - addr.s_addr = 0;/* Request dynamic */ + if (pdp_euaton(>eua, )) { + addr.v4.s_addr = 0; /* Request dynamic */ } if (ippool_newip(ippool, , , 0)) { @@ -192,7 +197,7 @@ return 0; /* Allready in use, or no more available */ } - pdp_ntoeua(>addr, >eua); + pdp_ntoeua(>addr.v4, >eua); pdp->peer = member; pdp->ipif = tun;/* TODO */ member->peer = pdp; @@ -215,10 +220,18 @@ int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len) { struct ippoolm_t *ipm; - struct in_addr dst; + struct in46_addr dst; struct tun_packet_t *iph = (struct tun_packet_t *)pack; - dst.s_addr = iph->dst; + if (iph->ver == 4) { + if (len < sizeof(*iph) || len < 4*iph->ihl) + return -1; + dst.len = 4; + dst.v4.s_addr = iph->dst; + } else { + LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); + return -1; + } DEBUGP(DGGSN, "Received packet from tun!\n"); @@ -383,12 +396,14 @@ /* net */ /* Store net as in_addr net and mask*/ if (args_info.net_arg) { - if (ippool_aton(, , args_info.net_arg, 0)) { + struct in46_addr in46; + if (ippool_aton(, , args_info.net_arg, 0)) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Invalid network address: %s!", args_info.net_arg); exit(1); } + net.s_addr = in46.v4.s_addr; netaddr.s_addr = htonl(ntohl(net.s_addr) + 1); destaddr.s_addr = htonl(ntohl(net.s_addr) + 1); } else { @@ -547,7 +562,7 @@ maxfd = gsn->fd1u; /* use GTP kernel module for data packet encapsulation */ - if (gtp_kernel_init(gsn, , , _info) < 0) + if (gtp_kernel_init(gsn, , prefixlen, _info) < 0) goto err; gtp_set_cb_data_ind(gsn, encaps_tun); @@ -572,7 +587,7 @@ } DEBUGP(DGGSN, "Setting tun IP address\n"); - if (tun_setaddr(tun, , , )) { + if (tun_setaddr(tun, , , )) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Failed to set tun IP
[MERGED] openggsn[master]: ggsn: Send proper errors in create_context_ind()
Harald Welte has submitted this change and it was merged. Change subject: ggsn: Send proper errors in create_context_ind() .. ggsn: Send proper errors in create_context_ind() When we receive PDP context requests for unknown PDP types or if we run out of dynamic addresses, we need to inform the SGSN that PDP context creation failed. Change-Id: Ibf199c1726130d27c8f80230b30ee51101c93b06 --- M ggsn/ggsn.c M lib/ippool.c M lib/ippool.h 3 files changed, 20 insertions(+), 11 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 8e7d1e3..0629f9e 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -178,6 +178,7 @@ { struct in46_addr addr; struct ippoolm_t *member; + int rc; DEBUGP(DGGSN, "Received create PDP context request\n"); @@ -192,11 +193,16 @@ pdp->qos_neg.l = pdp->qos_req.l; if (in46a_from_eua(>eua, )) { - addr.v4.s_addr = 0; /* Request dynamic */ + SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot decode EUA from MS/SGSN: %s", + osmo_hexdump(pdp->eua.v, pdp->eua.l)); + gtp_create_context_resp(gsn, pdp, GTPCAUSE_UNKNOWN_PDP); + return 0; } - if (ippool_newip(ippool, , , 0)) { - gtp_create_context_resp(gsn, pdp, GTPCAUSE_NO_RESOURCES); + rc = ippool_newip(ippool, , , 0); + if (rc < 0) { + SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot allocate IP address in pool\n"); + gtp_create_context_resp(gsn, pdp, -rc); return 0; /* Allready in use, or no more available */ } @@ -208,6 +214,8 @@ if (gtp_kernel_tunnel_add(pdp) < 0) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot add tunnel to kernel: %s\n", strerror(errno)); + gtp_create_context_resp(gsn, pdp, GTPCAUSE_SYS_FAIL); + return 0; } if (!send_trap(gsn, pdp, member, "imsi-ass-ip")) { /* TRAP with IP assignment */ diff --git a/lib/ippool.c b/lib/ippool.c index 3ca1b86..007dc50 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -402,7 +402,7 @@ if (!this->allowstat) { SYS_ERR(DIP, LOGL_ERROR, 0, "Static IP address not allowed"); - return -1; + return -GTPCAUSE_NOT_SUPPORTED; } if (!in46a_within_mask(addr, >stataddr, this->stataddrprefixlen)) { SYS_ERR(DIP, LOGL_ERROR, 0, "Static out of range"); @@ -412,7 +412,7 @@ if (!this->allowdyn) { SYS_ERR(DIP, LOGL_ERROR, 0, "Dynamic IP address not allowed"); - return -1; + return -GTPCAUSE_NOT_SUPPORTED; } } @@ -438,7 +438,7 @@ if (!this->firstdyn) { SYS_ERR(DIP, LOGL_ERROR, 0, "No more IP addresses available"); - return -1; + return -GTPCAUSE_ADDR_OCCUPIED; } else p2 = this->firstdyn; } @@ -447,12 +447,12 @@ if (p2->inuse) { SYS_ERR(DIP, LOGL_ERROR, 0, "IP address allready in use"); - return -1; /* Allready in use / Should not happen */ + return -GTPCAUSE_SYS_FAIL; /* Allready in use / Should not happen */ } if (p2->addr.len != addr->len) { SYS_ERR(DIP, LOGL_ERROR, 0, "MS requested unsupported PDP context type"); - return -1; + return -GTPCAUSE_UNKNOWN_PDP; } /* Remove from linked list of free dynamic addresses */ @@ -481,13 +481,13 @@ if (!this->firststat) { SYS_ERR(DIP, LOGL_ERROR, 0, "No more IP addresses available"); - return -1; /* No more available */ + return -GTPCAUSE_ADDR_OCCUPIED; /* No more available */ } else p2 = this->firststat; if (p2->addr.len != addr->len) { SYS_ERR(DIP, LOGL_ERROR, 0, "MS requested unsupported PDP context type"); - return -1; + return -GTPCAUSE_UNKNOWN_PDP; } /* Remove from linked list of free static addresses */ @@ -512,7 +512,7 @@ SYS_ERR(DIP, LOGL_ERROR, 0, "Could not allocate IP address"); - return -1; /* Should never get here. TODO: Bad code */ + return -GTPCAUSE_SYS_FAIL;
[MERGED] openggsn[master]: IPv6 support for user IP
Harald Welte has submitted this change and it was merged. Change subject: IPv6 support for user IP .. IPv6 support for user IP This patch enables the use of IPv6 PDP contexts. The phone will have to request an IPv6 End-user-Address, and the GGSN will have to be configured for an IPv6 pool. The outer transport-layer IP between SGSN and GGSN must still be IPv4, it is not modified by this patch Change-Id: I22c3bf32a98e5daf99d6eaeac8c9f95cc7574774 --- M ggsn/ggsn.c M lib/in46_addr.c M lib/in46_addr.h M sgsnemu/sgsnemu.c 4 files changed, 74 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 4fb2066..8e7d1e3 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ memcpy(pdp->qos_neg.v, pdp->qos_req.v, pdp->qos_req.l); /* TODO */ pdp->qos_neg.l = pdp->qos_req.l; - if (pdp_euaton(>eua, )) { + if (in46a_from_eua(>eua, )) { addr.v4.s_addr = 0; /* Request dynamic */ } @@ -199,7 +200,7 @@ return 0; /* Allready in use, or no more available */ } - pdp_ntoeua(>addr.v4, >eua); + in46a_to_eua(>addr, >eua); pdp->peer = member; pdp->ipif = tun;/* TODO */ member->peer = pdp; @@ -224,14 +225,18 @@ struct ippoolm_t *ipm; struct in46_addr dst; struct iphdr *iph = (struct iphdr *)pack; + struct ip6_hdr *ip6h = (struct ip6_hdr *)pack; if (iph->version == 4) { if (len < sizeof(*iph) || len < 4*iph->ihl) return -1; dst.len = 4; dst.v4.s_addr = iph->daddr; + } else if (iph->version == 6) { + dst.len = 16; + dst.v6 = ip6h->ip6_dst; } else { - LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); + LOGP(DGGSN, LOGL_NOTICE, "non-IPv packet received from tun\n"); return -1; } diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 903ceec..844e318 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -146,3 +146,63 @@ return 0; } } + +/*! Convert given PDP End User Address to in46_addr + * \returns 0 on success; negative on error */ +int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua) +{ + switch (src->len) { + case 4: + eua->l = 6; + eua->v[0] = 0xf1; /* IETF */ + eua->v[1] = 0x21; /* IPv4 */ + memcpy(>v[2], >v4, 4);/* Copy a 4 byte address */ + break; + case 16: + eua->l = 18; + eua->v[0] = 0xf1; /* IETF */ + eua->v[1] = 0x57; /* IPv6 */ + memcpy(>v[2], >v6, 16); /* Copy a 16 byte address */ + break; + default: + return -1; + } + return 0; +} + +/*! Convert given in46_addr to PDP End User Address + * \returns 0 on success; negative on error */ +int in46a_from_eua(const struct ul66_t *eua, struct in46_addr *dst) +{ + if (eua->l < 2) + goto default_to_dyn_v4; + + if (eua->v[0] != 0xf1) + return -1; + + switch (eua->v[1]) { + case 0x21: + dst->len = 4; + if (eua->l >= 6) + memcpy(>v4, >v[2], 4);/* Copy a 4 byte address */ + else + dst->v4.s_addr = 0; + break; + case 0x57: + dst->len = 16; + if (eua->l >= 18) + memcpy(>v6, >v[2], 16); /* Copy a 16 byte address */ + else + memset(>v6, 0, 16); + break; + default: + return -1; + } + return 0; + +default_to_dyn_v4: + /* assume dynamic IPv4 by default */ + dst->len = 4; + dst->v4.s_addr = 0; + return 0; +} diff --git a/lib/in46_addr.h b/lib/in46_addr.h index f28fd8e..a0ad6e1 100644 --- a/lib/in46_addr.h +++ b/lib/in46_addr.h @@ -2,6 +2,8 @@ #include #include +#include "../gtp/pdp.h" + /* a simple wrapper around an in6_addr to also contain the length of the address, * thereby implicitly indicating the address family of the address */ struct in46_addr { @@ -17,3 +19,6 @@ extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size); extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b); extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen); + +int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua); +int in46a_from_eua(const struct ul66_t *eua, struct
[MERGED] openggsn[master]: Proper fix for "Force Dynamic IP" in Create PDP CTX
Harald Welte has submitted this change and it was merged. Change subject: Proper fix for "Force Dynamic IP" in Create PDP CTX .. Proper fix for "Force Dynamic IP" in Create PDP CTX An EUA length of *2* octets indicates dynamic IP address, while an EUA length of 0 is invalid. Let's fix this hack (which needs to finally be removed anyway). Change-Id: Ib1b57eb0654327882044d6862d955f4b32aa6bcd --- M ggsn/ggsn.c 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 4d07f11..168e907 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -173,7 +173,9 @@ DEBUGP(DGGSN, "Received create PDP context request\n"); - pdp->eua.l = 0; /* TODO: Indicates dynamic IP */ + /* FIXME: we manually force all context requests to dynamic here! */ + if (pdp->eua.l > 2) + pdp->eua.l = 2; memcpy(pdp->qos_neg0, pdp->qos_req0, sizeof(pdp->qos_req0)); memcpy(>pco_neg, , sizeof(pdp->pco_neg)); -- To view, visit https://gerrit.osmocom.org/3409 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib1b57eb0654327882044d6862d955f4b32aa6bcd Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
openggsn[master]: in46_addr: Add new function in46a_prefix_equal()
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3456 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] openggsn[master]: in46_addr: Add new function in46a_prefix_equal()
Harald Welte has submitted this change and it was merged. Change subject: in46_addr: Add new function in46a_prefix_equal() .. in46_addr: Add new function in46a_prefix_equal() This function is used to compare an IPv6 address against another, using the smaller of the two prefix lengths. Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d --- M lib/in46_addr.c M lib/in46_addr.h 2 files changed, 18 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 844e318..a220583 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -74,6 +74,23 @@ return 0; } +/*! Determine if two in46_addr prefix are equal or not + * The prefix length is determined by the shortest of the prefixes of a and b + * \returns 1 in case the common prefix are equal; 0 otherwise */ +int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b) +{ + unsigned int len; + if (a->len > b->len) + len = b->len; + else + len = a->len; + + if (!memcmp(>v6, >v6, len)) + return 1; + else + return 0; +} + /*! Match if IPv6 addr1 + addr2 are within same \a mask */ static int ipv6_within_mask(const struct in6_addr *addr1, const struct in6_addr *addr2, const struct in6_addr *mask) diff --git a/lib/in46_addr.h b/lib/in46_addr.h index a0ad6e1..0afd2b4 100644 --- a/lib/in46_addr.h +++ b/lib/in46_addr.h @@ -18,6 +18,7 @@ extern int in46a_to_sas(struct sockaddr_storage *out, const struct in46_addr *in); extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size); extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b); +extern int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b); extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen); int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua); -- To view, visit https://gerrit.osmocom.org/3456 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
openggsn[master]: IPv6 support for user IP
Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3406 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I22c3bf32a98e5daf99d6eaeac8c9f95cc7574774 Gerrit-PatchSet: 6 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] osmo-iuh[master]: make point codes configurable by SCCP address book
Harald Welte has submitted this change and it was merged. Change subject: make point codes configurable by SCCP address book .. make point codes configurable by SCCP address book In the vty config, use the SCCP address book to configure the local and remote SCCP addresses. Add VTY commands to set the remote SCCP addresses by name, derive the ss7 instance from these addresses: cs7 instance 1 point-code 0.23.0 sccp-address msc point-code 0.0.1 sccp-address sgsn point-code 0.0.2 hnbgw iucs remote-addr msc iups remote-addr sgsn Enforce that both IuCS and IuPS use the same ss7 instance. In the future, we may add the feature to use two separate instances. Depends: libosmo-sccp I75c67d289693f1c2a049ac61cf2b2097d6e5687d, Ie1aedd7894acd69ddc887cd65a8a0df4b38c, I85b46269dbe7909e52873ace3f720f6292a4516c Change-Id: I33a7ba11eb7c2d9a5dc74d10fb0cf04bf664477b --- M include/osmocom/iuh/hnbgw.h M include/osmocom/iuh/hnbgw_cn.h M src/hnbgw.c M src/hnbgw_cn.c M src/hnbgw_rua.c M src/hnbgw_vty.c 6 files changed, 120 insertions(+), 100 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h index db22d97..58bdab4 100644 --- a/include/osmocom/iuh/hnbgw.h +++ b/include/osmocom/iuh/hnbgw.h @@ -116,10 +116,8 @@ /*! The UDP port where we receive multiplexed CS user * plane traffic from HNBs */ uint16_t iuh_cs_mux_port; - const char *iucs_remote_ip; - uint16_t iucs_remote_port; - const char *iups_remote_ip; - uint16_t iups_remote_port; + const char *iucs_remote_addr_name; + const char *iups_remote_addr_name; uint16_t rnc_id; bool hnbap_allow_tmsi; } config; @@ -134,11 +132,11 @@ /* currently active CN links for CS and PS */ struct { - struct osmo_sccp_instance *instance; + struct osmo_sccp_instance *client; struct hnbgw_cnlink *cnlink; struct osmo_sccp_addr local_addr; - struct osmo_sccp_addr remote_addr_cs; - struct osmo_sccp_addr remote_addr_ps; + struct osmo_sccp_addr iucs_remote_addr; + struct osmo_sccp_addr iups_remote_addr; } sccp; }; diff --git a/include/osmocom/iuh/hnbgw_cn.h b/include/osmocom/iuh/hnbgw_cn.h index 93123f2..2e61d82 100644 --- a/include/osmocom/iuh/hnbgw_cn.h +++ b/include/osmocom/iuh/hnbgw_cn.h @@ -2,5 +2,4 @@ #include -int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, - const char *local_ip, uint32_t local_pc); +int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, const char *local_ip); diff --git a/src/hnbgw.c b/src/hnbgw.c index 5d9f87b..c9fdd53 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -79,14 +79,6 @@ gw->config.iuh_local_ip = talloc_strdup(gw, HNBGW_LOCAL_IP_DEFAULT); gw->config.iuh_local_port = IUH_DEFAULT_SCTP_PORT; - gw->config.iucs_remote_ip = talloc_strdup(gw, - HNBGW_IUCS_REMOTE_IP_DEFAULT); - gw->config.iucs_remote_port = M3UA_PORT; - - gw->config.iups_remote_ip = talloc_strdup(gw, - HNBGW_IUPS_REMOTE_IP_DEFAULT); - gw->config.iups_remote_port = M3UA_PORT; - gw->next_ue_ctx_id = 23; INIT_LLIST_HEAD(>hnb_list); INIT_LLIST_HEAD(>ue_list); @@ -465,6 +457,7 @@ vty_info.copyright = osmo_hnbgw_copyright; vty_init(_info); + osmo_ss7_vty_init_asp(tall_hnb_ctx); hnbgw_vty_init(g_hnb_gw, tall_hnb_ctx); logging_vty_add_cmds(_log_info); @@ -501,23 +494,12 @@ ranap_set_log_area(DRANAP); - OSMO_ASSERT(g_hnb_gw->config.iucs_remote_ip); rc = hnbgw_cnlink_init(g_hnb_gw, - g_hnb_gw->config.iucs_remote_ip, - g_hnb_gw->config.iucs_remote_port, - "127.0.0.5" /* FIXME: configurable */, - 23 /* FIXME: configurable */); + "127.0.0.1", M3UA_PORT, "127.0.0.5" /* FIXME: configurable */); if (rc < 0) { LOGP(DMAIN, LOGL_ERROR, "Failed to initialize SCCP link to CN\n"); exit(1); } - - osmo_sccp_make_addr_pc_ssn(_hnb_gw->sccp.remote_addr_cs, - 1 /* FIXME: configurable */, - OSMO_SCCP_SSN_RANAP); - osmo_sccp_make_addr_pc_ssn(_hnb_gw->sccp.remote_addr_ps, - 2 /* FIXME: configurable */, - OSMO_SCCP_SSN_RANAP);
openggsn[master]: ippool: Add IPv6 support to IP pool implementation
Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3403 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8 Gerrit-PatchSet: 5 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
osmo-iuh[master]: make point codes configurable by SCCP address book
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3394 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I33a7ba11eb7c2d9a5dc74d10fb0cf04bf664477b Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
Build failure of network:osmocom:nightly/libosmocore in xUbuntu_16.04/i586
Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/libosmocore/xUbuntu_16.04/i586 Package network:osmocom:nightly/libosmocore failed to build in xUbuntu_16.04/i586 Check out the package for editing: osc checkout network:osmocom:nightly libosmocore Last lines of build log: [ 251s] | [ 251s] | This file was extended by libosmocore config.status 0.9.6.20170809, which was [ 251s] | generated by GNU Autoconf 2.69. Invocation command line was [ 251s] | [ 251s] | CONFIG_FILES= [ 251s] | CONFIG_HEADERS = [ 251s] | CONFIG_LINKS= [ 251s] | CONFIG_COMMANDS = [ 251s] | $ ./config.status Doxyfile.core [ 251s] | [ 251s] | on build31 [ 251s] | [ 251s] | config.status:1172: creating Doxyfile.core [ 251s] [ 251s] debian/rules:26: recipe for target 'override_dh_auto_test' failed [ 251s] make[1]: *** [override_dh_auto_test] Error 1 [ 251s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 251s] debian/rules:15: recipe for target 'build' failed [ 251s] make: *** [build] Error 2 [ 251s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 251s] [ 251s] build31 failed "build libosmocore_0.9.6.20170809.dsc" at Wed Aug 9 19:54:26 UTC 2017. [ 251s] [ 251s] ### VM INTERACTION START ### [ 253s] [ 239.590395] reboot: Power down [ 254s] ### VM INTERACTION END ### [ 254s] [ 254s] build31 failed "build libosmocore_0.9.6.20170809.dsc" at Wed Aug 9 19:54:30 UTC 2017. [ 254s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/)
[PATCH] openggsn[master]: IPv6: Support PCO for IPv6 DNS addresses
Review at https://gerrit.osmocom.org/3459 IPv6: Support PCO for IPv6 DNS addresses In IPv6, DNS server information is not passed along as IPCP6 like in IPv5 with IPCP. The reason is that IPCP6 (for PPP) doesn't support passing DNS server information. Rather, the relevant RFCs indicate DHCPv6 should be used even over point-to-point links. 3GPP decided to avoid DHCPv6 dependency for stateless autoconfiguration (the only mandatory IPv6 configuration mechanism) and added some new non-PPP-style PCO information elements ("containers") which can among other things inform a MS about IPV6 DNS servers. That same mechanism can also be used to inform the MS about IPv4 DNS servers, so for IPv4 there are now two competing mechanisms: IPCP and the new "native" PCO container. With this patch, we support both for IPv4. Change-Id: I21499afd61def8c925f7838bde76f34d28214b56 --- M ggsn/ggsn.c 1 file changed, 137 insertions(+), 42 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/59/3459/1 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index c307177..991b54c 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -72,7 +72,7 @@ struct in_addr listen_; struct in_addr netaddr, destaddr, net; /* Network interface */ size_t prefixlen; -struct in_addr dns1, dns2; /* PCO DNS address */ +struct in46_addr dns1, dns2; /* PCO DNS address */ char *ipup, *ipdown; /* Filename of scripts */ int debug; /* Print debug output */ struct ul255_t pco; @@ -175,6 +175,103 @@ return 0; } +#include + +/* 3GPP TS 24.008 10.6.5.3 */ +enum pco_protocols { + PCO_P_LCP = 0xC021, + PCO_P_PAP = 0xC023, + PCO_P_CHAP = 0xC223, + PCO_P_IPCP = 0x8021, + PCO_P_PCSCF_ADDR= 0x0001, + PCO_P_IM_CN_SS_F= 0x0002, + PCO_P_DNS_IPv6_ADDR = 0x0003, + PCO_P_POLICY_CTRL_REJ = 0x0004, /* only in Network->MS */ + PCO_P_MS_SUP_NETREQ_BCI = 0x0005, + /* reserved */ + PCO_P_DSMIPv6_HA_ADDR = 0x0007, + PCO_P_DSMIPv6_HN_PREF = 0x0008, + PCO_P_DSMIPv6_v4_HA_ADDR= 0x0009, + PCO_P_IP_ADDR_VIA_NAS = 0x000a, /* only MS->Network */ + PCO_P_IPv4_ADDR_VIA_DHCP= 0x000b, /* only MS->Netowrk */ + PCO_P_PCSCF_IPv4_ADDR = 0x000c, + PCO_P_DNS_IPv4_ADDR = 0x000d, + PCO_P_MSISDN= 0x000e, + PCO_P_IFOM_SUPPORT = 0x000f, + PCO_P_IPv4_LINK_MTU = 0x0010, + PCO_P_MS_SUPP_LOC_A_TFT = 0x0011, + PCO_P_PCSCF_RESEL_SUP = 0x0012, /* only MS->Network */ + PCO_P_NBIFOM_REQ= 0x0013, + PCO_P_NBIFOM_MODE = 0x0014, + PCO_P_NONIP_LINK_MTU= 0x0015, + PCO_P_APN_RATE_CTRL_SUP = 0x0016, + PCO_P_PS_DATA_OFF_UE= 0x0017, + PCO_P_REL_DATA_SVC = 0x0018, +}; + +/* determine if PCO contains given protocol */ +static bool pco_contains_proto(struct ul255_t *pco, uint16_t prot) +{ + uint8_t *cur = pco->v + 1; + + /* iterate over PCO and check if protocol contained */ + while (cur + 2 < pco->v + pco->l) { + uint16_t cur_prot = osmo_load16be(cur); + uint8_t cur_len = cur[2]; + if (cur_prot == prot) + return true; + if (cur_len == 0) + break; + cur += cur_len; + } + return false; +} + +/* determine if PDP context has IPv6 support */ +static bool pdp_has_v4(struct pdp_t *pdp) +{ + if (pdp->eua.l == 4+2) + return true; + else + return false; +} + +/* process one PCO request from a MS/UE, putting together the proper responses */ +static void process_pco(struct pdp_t *pdp) +{ + struct msgb *msg = msgb_alloc(256, "PCO"); + msgb_put_u8(msg, 0x80); /* ext-bit + configuration protocol byte */ + + /* FIXME: also check if primary / secondary DNS was requested */ + if (pdp_has_v4(pdp) && pco_contains_proto(>pco_req, PCO_P_IPCP)) { + /* FIXME: properly implement this for IPCP */ + uint8_t *cur = msgb_put(msg, pco.l-1); + memcpy(cur, pco.v+1, pco.l-1); + } + + if (pco_contains_proto(>pco_req, PCO_P_DNS_IPv6_ADDR)) { + if (dns1.len == 16) + msgb_t16lv_put(msg, PCO_P_DNS_IPv6_ADDR, dns1.len, dns1.v6.s6_addr); + if (dns2.len == 16) + msgb_t16lv_put(msg, PCO_P_DNS_IPv6_ADDR, dns2.len, dns2.v6.s6_addr); + } + + if (pco_contains_proto(>pco_req, PCO_P_DNS_IPv4_ADDR)) { + if (dns1.len == 4) + msgb_t16lv_put(msg, PCO_P_DNS_IPv4_ADDR, dns1.len, (uint8_t *)); + if (dns2.len == 4) + msgb_t16lv_put(msg, PCO_P_DNS_IPv4_ADDR, dns2.len, (uint8_t *)); + } + + if (msgb_length(msg) > 1) { +
[PATCH] openggsn[master]: IPv6: in46_addr: OSMO_ASSERT() in case of unsupported calls
Review at https://gerrit.osmocom.org/3460 IPv6: in46_addr: OSMO_ASSERT() in case of unsupported calls There's a bit of trickery with the ip_pool and it's "lengty=8" IPv6 prefix handling, let's make sure we don't accidentially call any support functions with addresses of wrong length. Change-Id: I444c190bdcd18780344e1f0dad4faf3bcf9da5a5 --- M lib/in46_addr.c 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/60/3460/1 diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 1785377..8f5cc09 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -11,6 +11,8 @@ #include "../lib/in46_addr.h" +#include + #include #include #include @@ -29,6 +31,7 @@ case 16: return AF_INET6; default: + OSMO_ASSERT(0); return -1; } } @@ -49,6 +52,7 @@ sin6->sin6_addr = in->v6; break; default: + OSMO_ASSERT(0); return -1; } @@ -161,6 +165,7 @@ create_ipv6_netmask(, prefixlen); return ipv6_within_mask(>v6, >v6, ); default: + OSMO_ASSERT(0); return 0; } } @@ -184,6 +189,7 @@ memcpy(>v[2], >v6, 16); /* Copy a 16 byte address */ break; default: + OSMO_ASSERT(0); return -1; } return 0; -- To view, visit https://gerrit.osmocom.org/3460 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I444c190bdcd18780344e1f0dad4faf3bcf9da5a5 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte
[PATCH] openggsn[master]: in46_addr: Add new function in46a_prefix_equal()
Review at https://gerrit.osmocom.org/3456 in46_addr: Add new function in46a_prefix_equal() This function is used to compare an IPv6 address against another, using the smaller of the two prefix lengths. Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d --- M lib/in46_addr.c M lib/in46_addr.h 2 files changed, 18 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/56/3456/1 diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 844e318..a220583 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -74,6 +74,23 @@ return 0; } +/*! Determine if two in46_addr prefix are equal or not + * The prefix length is determined by the shortest of the prefixes of a and b + * \returns 1 in case the common prefix are equal; 0 otherwise */ +int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b) +{ + unsigned int len; + if (a->len > b->len) + len = b->len; + else + len = a->len; + + if (!memcmp(>v6, >v6, len)) + return 1; + else + return 0; +} + /*! Match if IPv6 addr1 + addr2 are within same \a mask */ static int ipv6_within_mask(const struct in6_addr *addr1, const struct in6_addr *addr2, const struct in6_addr *mask) diff --git a/lib/in46_addr.h b/lib/in46_addr.h index a0ad6e1..0afd2b4 100644 --- a/lib/in46_addr.h +++ b/lib/in46_addr.h @@ -18,6 +18,7 @@ extern int in46a_to_sas(struct sockaddr_storage *out, const struct in46_addr *in); extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size); extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b); +extern int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b); extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen); int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua); -- To view, visit https://gerrit.osmocom.org/3456 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte
[PATCH] openggsn[master]: IPv6: Implement IPv6 prefix assignment via ICMPv6 router adv...
Review at https://gerrit.osmocom.org/3458 IPv6: Implement IPv6 prefix assignment via ICMPv6 router advertisement The 3GPP specs are quite strange when it comes to how an IPv6 address or rather prefix is assigned to an IPv6 PDP context. The designated method for allocating the IPv6 address via the PDP EUA (End User Address) Information Element in the GTP signalling plane is *not* used to allocate the address/prefix. Instead, the EUA is used to allocate an "interface identifier" to the MS, which it the uses to derive its link-local source address to send a router solicitation. The GGSN subsequently answers witha router advertisement, advertising a single/64 prefix, whihcthe MS then uses to generate it's real IPv6 source address for subsequent communication. Change-Id: Icddf7d30e01d76a4784bcef5787b36f52f703a9f --- M ggsn/Makefile.am A ggsn/checksum.c A ggsn/checksum.h M ggsn/ggsn.c A ggsn/icmpv6.c A ggsn/icmpv6.h M lib/debug.c M lib/in46_addr.c M lib/ippool.c M lib/syserr.h 10 files changed, 505 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/58/3458/1 diff --git a/ggsn/Makefile.am b/ggsn/Makefile.am index 3ad3a6e..c945f0b 100644 --- a/ggsn/Makefile.am +++ b/ggsn/Makefile.am @@ -12,7 +12,7 @@ endif ggsn_DEPENDENCIES = ../gtp/libgtp.la ../lib/libmisc.a -ggsn_SOURCES = ggsn.c cmdline.c cmdline.h gtp-kernel.h +ggsn_SOURCES = ggsn.c cmdline.c cmdline.h gtp-kernel.h icmpv6.c icmpv6.h checksum.c checksum.h if ENABLE_GTP_KERNEL ggsn_SOURCES += gtp-kernel.c diff --git a/ggsn/checksum.c b/ggsn/checksum.c new file mode 100644 index 000..1e9e58e --- /dev/null +++ b/ggsn/checksum.c @@ -0,0 +1,205 @@ +/* + * + * INETAn 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,+ * Arnt Gulbrandsen, + * Tom May, + * Andreas Schwab, + * Lots of code moved from tcp.c and ip.c; see those files + * for more names. + * + * 03/02/96Jes 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. */ + +#include "checksum.h" +#include +#include + +static inline unsigned short from32to16(unsigned int x) +{ + /* add up 16-bit and 16-bit for 16+c bit */ + x = (x & 0x) + (x >> 16); + /* add up carry.. */ + x = (x & 0x) + (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) { +#ifdef __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 & 0x) + (result >> 16); + } + if (len & 2) { + result += *(unsigned short *) buff; + buff +=
[PATCH] openggsn[master]: IPv6 support for user IP
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3406 to look at the new patch set (#6). IPv6 support for user IP This patch enables the use of IPv6 PDP contexts. The phone will have to request an IPv6 End-user-Address, and the GGSN will have to be configured for an IPv6 pool. The outer transport-layer IP between SGSN and GGSN must still be IPv4, it is not modified by this patch Change-Id: I22c3bf32a98e5daf99d6eaeac8c9f95cc7574774 --- M ggsn/ggsn.c M lib/in46_addr.c M lib/in46_addr.h M sgsnemu/sgsnemu.c 4 files changed, 74 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/06/3406/6 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 4fb2066..8e7d1e3 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ memcpy(pdp->qos_neg.v, pdp->qos_req.v, pdp->qos_req.l); /* TODO */ pdp->qos_neg.l = pdp->qos_req.l; - if (pdp_euaton(>eua, )) { + if (in46a_from_eua(>eua, )) { addr.v4.s_addr = 0; /* Request dynamic */ } @@ -199,7 +200,7 @@ return 0; /* Allready in use, or no more available */ } - pdp_ntoeua(>addr.v4, >eua); + in46a_to_eua(>addr, >eua); pdp->peer = member; pdp->ipif = tun;/* TODO */ member->peer = pdp; @@ -224,14 +225,18 @@ struct ippoolm_t *ipm; struct in46_addr dst; struct iphdr *iph = (struct iphdr *)pack; + struct ip6_hdr *ip6h = (struct ip6_hdr *)pack; if (iph->version == 4) { if (len < sizeof(*iph) || len < 4*iph->ihl) return -1; dst.len = 4; dst.v4.s_addr = iph->daddr; + } else if (iph->version == 6) { + dst.len = 16; + dst.v6 = ip6h->ip6_dst; } else { - LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); + LOGP(DGGSN, LOGL_NOTICE, "non-IPv packet received from tun\n"); return -1; } diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 903ceec..844e318 100644 --- a/lib/in46_addr.c +++ b/lib/in46_addr.c @@ -146,3 +146,63 @@ return 0; } } + +/*! Convert given PDP End User Address to in46_addr + * \returns 0 on success; negative on error */ +int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua) +{ + switch (src->len) { + case 4: + eua->l = 6; + eua->v[0] = 0xf1; /* IETF */ + eua->v[1] = 0x21; /* IPv4 */ + memcpy(>v[2], >v4, 4);/* Copy a 4 byte address */ + break; + case 16: + eua->l = 18; + eua->v[0] = 0xf1; /* IETF */ + eua->v[1] = 0x57; /* IPv6 */ + memcpy(>v[2], >v6, 16); /* Copy a 16 byte address */ + break; + default: + return -1; + } + return 0; +} + +/*! Convert given in46_addr to PDP End User Address + * \returns 0 on success; negative on error */ +int in46a_from_eua(const struct ul66_t *eua, struct in46_addr *dst) +{ + if (eua->l < 2) + goto default_to_dyn_v4; + + if (eua->v[0] != 0xf1) + return -1; + + switch (eua->v[1]) { + case 0x21: + dst->len = 4; + if (eua->l >= 6) + memcpy(>v4, >v[2], 4);/* Copy a 4 byte address */ + else + dst->v4.s_addr = 0; + break; + case 0x57: + dst->len = 16; + if (eua->l >= 18) + memcpy(>v6, >v[2], 16); /* Copy a 16 byte address */ + else + memset(>v6, 0, 16); + break; + default: + return -1; + } + return 0; + +default_to_dyn_v4: + /* assume dynamic IPv4 by default */ + dst->len = 4; + dst->v4.s_addr = 0; + return 0; +} diff --git a/lib/in46_addr.h b/lib/in46_addr.h index f28fd8e..a0ad6e1 100644 --- a/lib/in46_addr.h +++ b/lib/in46_addr.h @@ -2,6 +2,8 @@ #include #include +#include "../gtp/pdp.h" + /* a simple wrapper around an in6_addr to also contain the length of the address, * thereby implicitly indicating the address family of the address */ struct in46_addr { @@ -17,3 +19,6 @@ extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size); extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b); extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen); + +int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua); +int in46a_from_eua(const struct ul66_t *eua, struct in46_addr *dst); diff --git
[PATCH] openggsn[master]: ggsn: Send proper errors in create_context_ind()
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3407 to look at the new patch set (#6). ggsn: Send proper errors in create_context_ind() When we receive PDP context requests for unknown PDP types or if we run out of dynamic addresses, we need to inform the SGSN that PDP context creation failed. Change-Id: Ibf199c1726130d27c8f80230b30ee51101c93b06 --- M ggsn/ggsn.c M lib/ippool.c M lib/ippool.h 3 files changed, 20 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/07/3407/6 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 8e7d1e3..0629f9e 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -178,6 +178,7 @@ { struct in46_addr addr; struct ippoolm_t *member; + int rc; DEBUGP(DGGSN, "Received create PDP context request\n"); @@ -192,11 +193,16 @@ pdp->qos_neg.l = pdp->qos_req.l; if (in46a_from_eua(>eua, )) { - addr.v4.s_addr = 0; /* Request dynamic */ + SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot decode EUA from MS/SGSN: %s", + osmo_hexdump(pdp->eua.v, pdp->eua.l)); + gtp_create_context_resp(gsn, pdp, GTPCAUSE_UNKNOWN_PDP); + return 0; } - if (ippool_newip(ippool, , , 0)) { - gtp_create_context_resp(gsn, pdp, GTPCAUSE_NO_RESOURCES); + rc = ippool_newip(ippool, , , 0); + if (rc < 0) { + SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot allocate IP address in pool\n"); + gtp_create_context_resp(gsn, pdp, -rc); return 0; /* Allready in use, or no more available */ } @@ -208,6 +214,8 @@ if (gtp_kernel_tunnel_add(pdp) < 0) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Cannot add tunnel to kernel: %s\n", strerror(errno)); + gtp_create_context_resp(gsn, pdp, GTPCAUSE_SYS_FAIL); + return 0; } if (!send_trap(gsn, pdp, member, "imsi-ass-ip")) { /* TRAP with IP assignment */ diff --git a/lib/ippool.c b/lib/ippool.c index 3ca1b86..007dc50 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -402,7 +402,7 @@ if (!this->allowstat) { SYS_ERR(DIP, LOGL_ERROR, 0, "Static IP address not allowed"); - return -1; + return -GTPCAUSE_NOT_SUPPORTED; } if (!in46a_within_mask(addr, >stataddr, this->stataddrprefixlen)) { SYS_ERR(DIP, LOGL_ERROR, 0, "Static out of range"); @@ -412,7 +412,7 @@ if (!this->allowdyn) { SYS_ERR(DIP, LOGL_ERROR, 0, "Dynamic IP address not allowed"); - return -1; + return -GTPCAUSE_NOT_SUPPORTED; } } @@ -438,7 +438,7 @@ if (!this->firstdyn) { SYS_ERR(DIP, LOGL_ERROR, 0, "No more IP addresses available"); - return -1; + return -GTPCAUSE_ADDR_OCCUPIED; } else p2 = this->firstdyn; } @@ -447,12 +447,12 @@ if (p2->inuse) { SYS_ERR(DIP, LOGL_ERROR, 0, "IP address allready in use"); - return -1; /* Allready in use / Should not happen */ + return -GTPCAUSE_SYS_FAIL; /* Allready in use / Should not happen */ } if (p2->addr.len != addr->len) { SYS_ERR(DIP, LOGL_ERROR, 0, "MS requested unsupported PDP context type"); - return -1; + return -GTPCAUSE_UNKNOWN_PDP; } /* Remove from linked list of free dynamic addresses */ @@ -481,13 +481,13 @@ if (!this->firststat) { SYS_ERR(DIP, LOGL_ERROR, 0, "No more IP addresses available"); - return -1; /* No more available */ + return -GTPCAUSE_ADDR_OCCUPIED; /* No more available */ } else p2 = this->firststat; if (p2->addr.len != addr->len) { SYS_ERR(DIP, LOGL_ERROR, 0, "MS requested unsupported PDP context type"); - return -1; + return -GTPCAUSE_UNKNOWN_PDP; } /* Remove from linked list of free static addresses */ @@ -512,7 +512,7 @@ SYS_ERR(DIP, LOGL_ERROR, 0, "Could not allocate IP address"); - return -1; /* Should never get here. TODO: Bad code */ + return -GTPCAUSE_SYS_FAIL; /* Should never get here. TODO: Bad code */ }
[PATCH] openggsn[master]: ippool_new(): const-ify input arguments
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3405 to look at the new patch set (#6). ippool_new(): const-ify input arguments Change-Id: If3e53584e8c9c1f06bba4c183c9fd65fae913904 --- M lib/ippool.c M lib/ippool.h 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/05/3405/6 diff --git a/lib/ippool.c b/lib/ippool.c index c3eb267..3ca1b86 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -186,7 +186,7 @@ } /* Create new address pool */ -int ippool_new(struct ippool_t **this, char *dyn, char *stat, +int ippool_new(struct ippool_t **this, const char *dyn, const char *stat, int allowdyn, int allowstat, int flags) { diff --git a/lib/ippool.h b/lib/ippool.h index 53154f2..e3c1c92 100644 --- a/lib/ippool.h +++ b/lib/ippool.h @@ -69,7 +69,7 @@ extern unsigned long int ippool_hash(struct in46_addr *addr); /* Create new address pool */ -extern int ippool_new(struct ippool_t **this, char *dyn, char *stat, +extern int ippool_new(struct ippool_t **this, const char *dyn, const char *stat, int allowdyn, int allowstat, int flags); /* Delete existing address pool */ -- To view, visit https://gerrit.osmocom.org/3405 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If3e53584e8c9c1f06bba4c183c9fd65fae913904 Gerrit-PatchSet: 6 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[PATCH] openggsn[master]: ippool: Extend pool to work with /64 prefixes
Review at https://gerrit.osmocom.org/3457 ippool: Extend pool to work with /64 prefixes In IPv6 GPRS, we actually don't want to allocate an individual v6 address (like in IPv4), but we want to allocate a prefix. The standard prefix lengh is 8 bytes, i.e. a /64 prefix. This patch extends the pool to be able to work with such v6 prefixes. Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443 --- M ggsn/ggsn.c M lib/ippool.c 2 files changed, 14 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/57/3457/1 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 0629f9e..9b11884 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -241,7 +241,11 @@ dst.len = 4; dst.v4.s_addr = iph->daddr; } else if (iph->version == 6) { - dst.len = 16; + /* Due to the fact that 3GPP requires an allocation of a +* /64 prefix to each MS, we must instruct +* ippool_getip() below to match only the leading /64 +* prefix, i.e. the first 8 bytes of the address */ + dst.len = 8; dst.v6 = ip6h->ip6_dst; } else { LOGP(DGGSN, LOGL_NOTICE, "non-IPv packet received from tun\n"); diff --git a/lib/ippool.c b/lib/ippool.c index 007dc50..683d2d8 100644 --- a/lib/ippool.c +++ b/lib/ippool.c @@ -96,11 +96,10 @@ return lookup((unsigned char *)>s_addr, sizeof(addr->s_addr), 0); } -static unsigned long int ippool_hash6(struct in6_addr *addr) +static unsigned long int ippool_hash6(struct in6_addr *addr, unsigned int len) { /* TODO: Review hash spread for IPv6 */ - return lookup((unsigned char *)addr->s6_addr, sizeof(addr->s6_addr), - 0); + return lookup((unsigned char *)addr->s6_addr, len, 0); } unsigned long int ippool_hash(struct in46_addr *addr) @@ -108,7 +107,7 @@ if (addr->len == 4) return ippool_hash4(>v4); else - return ippool_hash6(>v6); + return ippool_hash6(>v6, addr->len); } /* Get IP address and mask */ @@ -209,6 +208,10 @@ "Failed to parse dynamic pool"); return -1; } + /* we want to work with /64 prefixes, i.e. allocate /64 prefixes rather +* than /128 (single IPv6 addresses) */ + if (addr->len == sizeof(in6_addr)) + addr->len = 64/8; /* Set IPPOOL_NONETWORK if IPPOOL_NOGATEWAY is set */ if (flags & IPPOOL_NOGATEWAY) { @@ -348,7 +351,7 @@ /* Find in hash table */ hash = ippool_hash(addr) & this->hashmask; for (p = this->hash[hash]; p; p = p->nexthash) { - if (in46a_equal(>addr, addr)) { + if (in46a_prefix_equal(>addr, addr)) { if (member) *member = p; return 0; @@ -421,7 +424,7 @@ /* Find in hash table */ hash = ippool_hash(addr) & this->hashmask; for (p = this->hash[hash]; p; p = p->nexthash) { - if (in46a_equal(>addr, addr)) { + if (in46a_prefix_equal(>addr, addr)) { p2 = p; break; } -- To view, visit https://gerrit.osmocom.org/3457 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte
[PATCH] openggsn[master]: lib/tun.h: Remove non-endian-safe redefinition of IP header
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3404 to look at the new patch set (#6). lib/tun.h: Remove non-endian-safe redefinition of IP header We can simply use 'struct iphdr' from netinet/ip.h to achieve the same goal (and be portable). Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32 --- M configure.ac M ggsn/ggsn.c M lib/tun.h M sgsnemu/sgsnemu.c 4 files changed, 39 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/04/3404/6 diff --git a/configure.ac b/configure.ac index 45ab22b..b7e6793 100644 --- a/configure.ac +++ b/configure.ac @@ -112,6 +112,12 @@ AC_DEFINE([HAVE_RT_MSGHDR])], AC_MSG_RESULT(no)) +AC_MSG_CHECKING(whether struct iphdr exists) +AH_TEMPLATE(HAVE_IPHDR) +AC_EGREP_HEADER(struct iphdr, netinet/ip.h, +[AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_IPHDR])], + AC_MSG_RESULT(no)) # Checks for library functions. AC_PROG_GCC_TRADITIONAL diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 0d0e569..4fb2066 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include @@ -221,13 +223,13 @@ { struct ippoolm_t *ipm; struct in46_addr dst; - struct tun_packet_t *iph = (struct tun_packet_t *)pack; + struct iphdr *iph = (struct iphdr *)pack; - if (iph->ver == 4) { + if (iph->version == 4) { if (len < sizeof(*iph) || len < 4*iph->ihl) return -1; dst.len = 4; - dst.v4.s_addr = iph->dst; + dst.v4.s_addr = iph->daddr; } else { LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); return -1; diff --git a/lib/tun.h b/lib/tun.h index ce7b91c..c50bdf9 100644 --- a/lib/tun.h +++ b/lib/tun.h @@ -17,21 +17,31 @@ #define TUN_ADDRSIZE 128 #define TUN_NLBUFSIZE 1024 -struct tun_packet_t { - unsigned int ver:4; - unsigned int ihl:4; - unsigned int dscp:6; - unsigned int ecn:2; - unsigned int length:16; - unsigned int id:16; - unsigned int flags:3; - unsigned int fragment:13; - unsigned int ttl:8; - unsigned int protocol:8; - unsigned int check:16; - unsigned int src:32; - unsigned int dst:32; -}; +#include "config.h" +#ifndef HAVE_IPHDR +struct iphdr + { +#if __BYTE_ORDER == __LITTLE_ENDIAN +unsigned int ihl:4; +unsigned int version:4; +#elif __BYTE_ORDER == __BIG_ENDIAN +unsigned int version:4; +unsigned int ihl:4; +#else +# error"Please fix " +#endif +u_int8_t tos; +u_int16_t tot_len; +u_int16_t id; +u_int16_t frag_off; +u_int8_t ttl; +u_int8_t protocol; +u_int16_t check; +u_int32_t saddr; +u_int32_t daddr; +/*The options start here. */ + }; +#endif /* !HAVE_IPHDR */ /* *** * Information storage for each tun instance diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index 90a6200..af8f9fa 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1281,10 +1282,10 @@ { struct iphash_t *ipm; struct in46_addr src; - struct tun_packet_t *iph = (struct tun_packet_t *)pack; + struct iphdr *iph = (struct iphdr *)pack; src.len = 4; - src.v4.s_addr = iph->src; + src.v4.s_addr = iph->saddr; if (ipget(, )) { printf("Dropping packet from invalid source address: %s\n", -- To view, visit https://gerrit.osmocom.org/3404 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32 Gerrit-PatchSet: 6 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[PATCH] openggsn[master]: ippool: Add IPv6 support to IP pool implementation
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3403 to look at the new patch set (#5). ippool: Add IPv6 support to IP pool implementation Extend the IP pool implementation to be able to manage both pools of 32bit addresses (IPv4) as well as pools of 128bit addresses (IPv6) Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8 --- M ggsn/ggsn.c M ggsn/gtp-kernel.c M ggsn/gtp-kernel.h M lib/Makefile.am A lib/in46_addr.c A lib/in46_addr.h M lib/ippool.c M lib/ippool.h M sgsnemu/sgsnemu.c 9 files changed, 371 insertions(+), 169 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/03/3403/5 diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index 168e907..0d0e569 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -56,6 +56,7 @@ #include "../lib/tun.h" #include "../lib/ippool.h" #include "../lib/syserr.h" +#include "../lib/in46_addr.h" #include "../gtp/pdp.h" #include "../gtp/gtp.h" #include "cmdline.h" @@ -65,7 +66,8 @@ int maxfd = 0; /* For select()*/ struct in_addr listen_; -struct in_addr netaddr, destaddr, net, mask; /* Network interface */ +struct in_addr netaddr, destaddr, net; /* Network interface */ +size_t prefixlen; struct in_addr dns1, dns2; /* PCO DNS address */ char *ipup, *ipdown; /* Filename of scripts */ int debug; /* Print debug output */ @@ -135,9 +137,12 @@ static bool send_trap(const struct gsn_t *gsn, const struct pdp_t *pdp, const struct ippoolm_t *member, const char *var) { + char addrbuf[256]; char val[NAMESIZE]; - snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, inet_ntoa(member->addr)); + const char *addrstr = in46a_ntop(>addr, addrbuf, sizeof(addrbuf)); + + snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, addrstr); if (ctrl_cmd_send_trap(gsn->ctrl, var, val) < 0) { LOGP(DGGSN, LOGL_ERROR, "Failed to create and send TRAP for IMSI %" PRIu64 " [%s].\n", pdp->imsi, var); @@ -168,7 +173,7 @@ int create_context_ind(struct pdp_t *pdp) { - struct in_addr addr; + struct in46_addr addr; struct ippoolm_t *member; DEBUGP(DGGSN, "Received create PDP context request\n"); @@ -183,8 +188,8 @@ memcpy(pdp->qos_neg.v, pdp->qos_req.v, pdp->qos_req.l); /* TODO */ pdp->qos_neg.l = pdp->qos_req.l; - if (pdp_euaton(>eua, )) { - addr.s_addr = 0;/* Request dynamic */ + if (pdp_euaton(>eua, )) { + addr.v4.s_addr = 0; /* Request dynamic */ } if (ippool_newip(ippool, , , 0)) { @@ -192,7 +197,7 @@ return 0; /* Allready in use, or no more available */ } - pdp_ntoeua(>addr, >eua); + pdp_ntoeua(>addr.v4, >eua); pdp->peer = member; pdp->ipif = tun;/* TODO */ member->peer = pdp; @@ -215,10 +220,18 @@ int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len) { struct ippoolm_t *ipm; - struct in_addr dst; + struct in46_addr dst; struct tun_packet_t *iph = (struct tun_packet_t *)pack; - dst.s_addr = iph->dst; + if (iph->ver == 4) { + if (len < sizeof(*iph) || len < 4*iph->ihl) + return -1; + dst.len = 4; + dst.v4.s_addr = iph->dst; + } else { + LOGP(DGGSN, LOGL_NOTICE, "non-IPv4 packet received from tun\n"); + return -1; + } DEBUGP(DGGSN, "Received packet from tun!\n"); @@ -383,12 +396,14 @@ /* net */ /* Store net as in_addr net and mask*/ if (args_info.net_arg) { - if (ippool_aton(, , args_info.net_arg, 0)) { + struct in46_addr in46; + if (ippool_aton(, , args_info.net_arg, 0)) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Invalid network address: %s!", args_info.net_arg); exit(1); } + net.s_addr = in46.v4.s_addr; netaddr.s_addr = htonl(ntohl(net.s_addr) + 1); destaddr.s_addr = htonl(ntohl(net.s_addr) + 1); } else { @@ -547,7 +562,7 @@ maxfd = gsn->fd1u; /* use GTP kernel module for data packet encapsulation */ - if (gtp_kernel_init(gsn, , , _info) < 0) + if (gtp_kernel_init(gsn, , prefixlen, _info) < 0) goto err; gtp_set_cb_data_ind(gsn, encaps_tun); @@ -572,7 +587,7 @@ } DEBUGP(DGGSN, "Setting tun IP address\n"); - if (tun_setaddr(tun, , , )) { + if (tun_setaddr(tun, , , )) { SYS_ERR(DGGSN, LOGL_ERROR, 0, "Failed to set tun IP address"); exit(1); } diff --git
[PATCH] libosmocore[master]: tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs
Review at https://gerrit.osmocom.org/3455 tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVs In the Protocol Configuration Options IE (see 3GPP TS 24.008 10.5.6.3) there is yet another new TLV format (derived from PPP IPCP/LCP/...) which uses 16bit tag and 8bit length. Let's add functions so we can generate related TLVs. Parsing is unfortunately not possible in our existing structure as our tlv_parsed array only has 256 entries and thus cannot cope with 16bit tags. Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694 --- M include/osmocom/gsm/tlv.h 1 file changed, 20 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/3455/1 diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index c356840..f903223 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -21,7 +21,7 @@ TLV16 8 8 N * 16 TvLV 8 8/16N * 8 vTvLV 8/168/16N * 8 - + T16LV 16 8 N * 8 */ /*! gross length of a LV type field */ @@ -34,6 +34,8 @@ #define TL16V_GROSS_LEN(x) (x+3) /*! gross length of a L16TV type field */ #define L16TV_GROSS_LEN(x) (x+3) +/*! gross length of a T16LV type field */ +#define T16LV_GROSS_LEN(x) (x+3) /*! maximum length of TLV of one byte length */ #define TVLV_MAX_ONEBYTE 0x7f @@ -119,6 +121,17 @@ return buf + len*2; } +/*! put (append) a TL16V field */ +static inline uint8_t *t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len, + const uint8_t *val) +{ + *buf++ = tag >> 8; + *buf++ = tag & 0xff; + *buf++ = len; + memcpy(buf, val, len); + return buf + len + 2; +} + /*! put (append) a TvLV field */ static inline uint8_t *tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val) @@ -185,6 +198,12 @@ return tl16v_put(buf, tag, len, val); } +static inline uint8_t *msgb_t16lv_put(struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val) +{ + uint8_t *buf = msgb_put(msg, T16LV_GROSS_LEN(len)); + return t16lv_put(buf, tag, len, val); +} + /*! put (append) a TvLV field to \ref msgb */ static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len, const uint8_t *val) -- To view, visit https://gerrit.osmocom.org/3455 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte
[PATCH] libosmocore[master]: Add osmo_gprs_{ul, dl}_block_size_{bits, bytes} functions
Review at https://gerrit.osmocom.org/3454 Add osmo_gprs_{ul,dl}_block_size_{bits,bytes} functions Those functions can be used to look up the size of (E)GPRS blocks. Change-Id: I05ff75ef7dfae639886bbd09fe35f03a8af9d988 --- M include/osmocom/gprs/gprs_rlc.h M src/gsm/gprs_rlc.c M src/gsm/libosmogsm.map 3 files changed, 121 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/3454/1 diff --git a/include/osmocom/gprs/gprs_rlc.h b/include/osmocom/gprs/gprs_rlc.h index 05d3de6..b74f9e4 100644 --- a/include/osmocom/gprs/gprs_rlc.h +++ b/include/osmocom/gprs/gprs_rlc.h @@ -26,4 +26,29 @@ EGPRS_HDR_TYPE3, }; +enum osmo_gprs_cs { + OSMO_GPRS_CS_NONE, + OSMO_GPRS_CS1, + OSMO_GPRS_CS2, + OSMO_GPRS_CS3, + OSMO_GPRS_CS4, + OSMO_GPRS_MCS1, + OSMO_GPRS_MCS2, + OSMO_GPRS_MCS3, + OSMO_GPRS_MCS4, + OSMO_GPRS_MCS5, + OSMO_GPRS_MCS6, + OSMO_GPRS_MCS7, + OSMO_GPRS_MCS8, + OSMO_GPRS_MCS9, + _NUM_OSMO_GPRS_CS +}; + int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits); + +int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs); +int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs); +int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs); +int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs); +enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size); +enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size); diff --git a/src/gsm/gprs_rlc.c b/src/gsm/gprs_rlc.c index b213b26..d2c05b7 100644 --- a/src/gsm/gprs_rlc.c +++ b/src/gsm/gprs_rlc.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -109,3 +110,92 @@ return 0; } + +struct gprs_cs_desc { + struct { + uint8_t bytes; + uint8_t bits; + } uplink, downlink; +}; + +const struct gprs_cs_desc gprs_cs_desc[_NUM_OSMO_GPRS_CS] = { + [OSMO_GPRS_CS1] = { {23, 0},{23, 0} }, + [OSMO_GPRS_CS2] = { {33, 7},{33, 7} }, + [OSMO_GPRS_CS3] = { {39, 3},{39, 3} }, + [OSMO_GPRS_CS4] = { {53, 7},{53, 7} }, + + [OSMO_GPRS_MCS1]= { {26, 1},{26, 1} }, + [OSMO_GPRS_MCS2]= { {32, 1},{32, 1} }, + [OSMO_GPRS_MCS3]= { {41, 1},{41, 1} }, + [OSMO_GPRS_MCS4]= { {48, 1},{48, 1} }, + + [OSMO_GPRS_MCS5]= { {60, 7},{59, 6} }, + [OSMO_GPRS_MCS6]= { {78, 7},{77, 6} }, + [OSMO_GPRS_MCS7]= { {118, 2}, {117, 4} }, + [OSMO_GPRS_MCS8]= { {142, 2}, {141, 4} }, + [OSMO_GPRS_MCS9]= { {154, 2}, {153, 4} }, +}; + +/*! Return size of (E)GPRS uplink block for given coding scheme in bits */ +int osmo_gprs_ul_block_size_bits(enum osmo_gprs_cs cs) +{ + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + return gprs_cs_desc[cs].uplink.bytes * 8 + gprs_cs_desc[cs].uplink.bits; +} + +/*! Return size of (E)GPRS downlink block for given coding scheme in bits */ +int osmo_gprs_dl_block_size_bits(enum osmo_gprs_cs cs) +{ + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + return gprs_cs_desc[cs].downlink.bytes * 8 + gprs_cs_desc[cs].downlink.bits; +} + +/*! Return size of (E)GPRS uplink block for given coding scheme in bytes */ +int osmo_gprs_ul_block_size_bytes(enum osmo_gprs_cs cs) +{ + int rc; + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + rc = gprs_cs_desc[cs].uplink.bytes; + if (gprs_cs_desc[cs].uplink.bits) + rc++; + return rc; +} + +/*! Return size of (E)GPRS downlink block for given coding scheme in bytes */ +int osmo_gprs_dl_block_size_bytes(enum osmo_gprs_cs cs) +{ + int rc; + if (cs >= ARRAY_SIZE(gprs_cs_desc)) + return -EINVAL; + rc = gprs_cs_desc[cs].downlink.bytes; + if (gprs_cs_desc[cs].downlink.bits) + rc++; + return rc; +} + +/*! Return coding scheme for given (E)GPRS uplink block size */ +enum osmo_gprs_cs osmo_gprs_ul_cs_by_block_bytes(uint8_t block_size) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gprs_cs_desc); i++) { + if (block_size == osmo_gprs_ul_block_size_bytes(i)) + return i; + } + return OSMO_GPRS_CS_NONE; +} + +/*! Return coding scheme for given (E)GPRS downlink block size */ +enum osmo_gprs_cs osmo_gprs_dl_cs_by_block_bytes(uint8_t block_size) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gprs_cs_desc); i++) { + if (block_size == osmo_gprs_dl_block_size_bytes(i)) + return i; + } + return OSMO_GPRS_CS_NONE; +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 714cb25..066f410 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -65,6 +65,12 @@
[PATCH] libosmo-sccp[master]: vty: hide SG commands when running as ASP
Review at https://gerrit.osmocom.org/3453 vty: hide SG commands when running as ASP The SG (signal gateway) requires an extra set of VTY commands in order to be fully configurable. These VTY commands do not make sense in a situation where libosmo-sccp is used to implement an ASP (application server process). Detect in which role libosmo-sccp is used by which of the VTY initalization functions are called: osmo_ss7_vty_init_asp() ==> ASP osmo_ss7_vty_init_sg() ==> SG Prevent writing back of SG specific configuration when in running as ASP. Only write back the full parameter set when running as SG. Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf --- M src/osmo_ss7_vty.c 1 file changed, 13 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/53/3453/1 diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 21efcae..9343edd 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -50,6 +50,8 @@ * Core CS7 Configuration ***/ +enum cs7_role_t {CS7_ROLE_SG, CS7_ROLE_ASP}; +static enum cs7_role_t cs7_role; static void *g_ctx; static struct cmd_node cs7_node = { @@ -1559,12 +1561,16 @@ llist_for_each_entry(as, >as_list, list) write_one_as(vty, as); - /* now dump routes, as their target ASs exist */ - llist_for_each_entry(rtable, >rtable_list, list) - write_one_rtable(vty, rtable); + /* now dump everything that is relevent for the SG role */ + if (cs7_role == CS7_ROLE_SG) { - llist_for_each_entry(oxs, >xua_servers, list) - write_one_xua(vty, oxs); + /* dump routes, as their target ASs exist */ + llist_for_each_entry(rtable, >rtable_list, list) + write_one_rtable(vty, rtable); + + llist_for_each_entry(oxs, >xua_servers, list) + write_one_xua(vty, oxs); + } /* Append SCCP Addressbook */ write_sccp_addressbook(vty, inst); @@ -1717,11 +1723,13 @@ void osmo_ss7_vty_init_asp(void *ctx) { + cs7_role = CS7_ROLE_ASP; vty_init_shared(ctx); } void osmo_ss7_vty_init_sg(void *ctx) { + cs7_role = CS7_ROLE_SG; vty_init_shared(ctx); install_node(_node, NULL); -- To view, visit https://gerrit.osmocom.org/3453 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I707bcd790f4c6d0f618e41163b51d2179ea3aeaf Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexter
[PATCH] libosmo-sccp[master]: sccp: fix creating of the default route in simple client
Review at https://gerrit.osmocom.org/3452 sccp: fix creating of the default route in simple client The simple client (osmo_sccp_simple_client_on_ss7_id() and osmo_sccp_simple_client) does not create a default route if the user has already created an AS via VTY. Check the presence of a default route independently of the AS. If no default route exists, create one. Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a --- M src/sccp_user.c 1 file changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/52/3452/1 diff --git a/src/sccp_user.c b/src/sccp_user.c index 1414572..1d59d3c 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -368,16 +368,20 @@ goto out_ss7; } as->cfg.routing_key.pc = ss7->cfg.primary_pc; + } + LOGP(DLSCCP, LOGL_NOTICE, "%s: Using AS instance %s\n", name, +as->cfg.name); - /* install default route */ + /* Create a default route if necessary */ + rt = osmo_ss7_route_find_dpc_mask(ss7->rtable_system, 0, 0); + if (!rt) { + LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating default route\n", name); rt = osmo_ss7_route_create(ss7->rtable_system, 0, 0, as->cfg.name); if (!rt) goto out_as; rt_created = true; } - LOGP(DLSCCP, LOGL_NOTICE, "%s: Using AS instance %s\n", name, -as->cfg.name); /* Check if we do already have an application server process * that is associated with the application server we have choosen -- To view, visit https://gerrit.osmocom.org/3452 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7516fa5509bade4ba10e9d8eaa3e46cfe3696b3a Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: dexter
[ABANDON] osmo-iuh[master]: apply ctx arg to osmo_ss7_vty_init_asp()
Neels Hofmeyr has abandoned this change. Change subject: apply ctx arg to osmo_ss7_vty_init_asp() .. Abandoned now part of 'make point codes configurable by SCCP address book' https://gerrit.osmocom.org/3394 -- To view, visit https://gerrit.osmocom.org/3369 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Idccbdc669d740179153d0a73096745785bd2f5af Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[PATCH] osmo-iuh[master]: make point codes configurable by SCCP address book
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3394 to look at the new patch set (#3). make point codes configurable by SCCP address book In the vty config, use the SCCP address book to configure the local and remote SCCP addresses. Add VTY commands to set the remote SCCP addresses by name, derive the ss7 instance from these addresses: cs7 instance 1 point-code 0.23.0 sccp-address msc point-code 0.0.1 sccp-address sgsn point-code 0.0.2 hnbgw iucs remote-addr msc iups remote-addr sgsn Enforce that both IuCS and IuPS use the same ss7 instance. In the future, we may add the feature to use two separate instances. Depends: libosmo-sccp I75c67d289693f1c2a049ac61cf2b2097d6e5687d, Ie1aedd7894acd69ddc887cd65a8a0df4b38c, I85b46269dbe7909e52873ace3f720f6292a4516c Change-Id: I33a7ba11eb7c2d9a5dc74d10fb0cf04bf664477b --- M include/osmocom/iuh/hnbgw.h M include/osmocom/iuh/hnbgw_cn.h M src/hnbgw.c M src/hnbgw_cn.c M src/hnbgw_rua.c M src/hnbgw_vty.c 6 files changed, 120 insertions(+), 100 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/94/3394/3 diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h index db22d97..58bdab4 100644 --- a/include/osmocom/iuh/hnbgw.h +++ b/include/osmocom/iuh/hnbgw.h @@ -116,10 +116,8 @@ /*! The UDP port where we receive multiplexed CS user * plane traffic from HNBs */ uint16_t iuh_cs_mux_port; - const char *iucs_remote_ip; - uint16_t iucs_remote_port; - const char *iups_remote_ip; - uint16_t iups_remote_port; + const char *iucs_remote_addr_name; + const char *iups_remote_addr_name; uint16_t rnc_id; bool hnbap_allow_tmsi; } config; @@ -134,11 +132,11 @@ /* currently active CN links for CS and PS */ struct { - struct osmo_sccp_instance *instance; + struct osmo_sccp_instance *client; struct hnbgw_cnlink *cnlink; struct osmo_sccp_addr local_addr; - struct osmo_sccp_addr remote_addr_cs; - struct osmo_sccp_addr remote_addr_ps; + struct osmo_sccp_addr iucs_remote_addr; + struct osmo_sccp_addr iups_remote_addr; } sccp; }; diff --git a/include/osmocom/iuh/hnbgw_cn.h b/include/osmocom/iuh/hnbgw_cn.h index 93123f2..2e61d82 100644 --- a/include/osmocom/iuh/hnbgw_cn.h +++ b/include/osmocom/iuh/hnbgw_cn.h @@ -2,5 +2,4 @@ #include -int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, - const char *local_ip, uint32_t local_pc); +int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, const char *local_ip); diff --git a/src/hnbgw.c b/src/hnbgw.c index 5d9f87b..c9fdd53 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -79,14 +79,6 @@ gw->config.iuh_local_ip = talloc_strdup(gw, HNBGW_LOCAL_IP_DEFAULT); gw->config.iuh_local_port = IUH_DEFAULT_SCTP_PORT; - gw->config.iucs_remote_ip = talloc_strdup(gw, - HNBGW_IUCS_REMOTE_IP_DEFAULT); - gw->config.iucs_remote_port = M3UA_PORT; - - gw->config.iups_remote_ip = talloc_strdup(gw, - HNBGW_IUPS_REMOTE_IP_DEFAULT); - gw->config.iups_remote_port = M3UA_PORT; - gw->next_ue_ctx_id = 23; INIT_LLIST_HEAD(>hnb_list); INIT_LLIST_HEAD(>ue_list); @@ -465,6 +457,7 @@ vty_info.copyright = osmo_hnbgw_copyright; vty_init(_info); + osmo_ss7_vty_init_asp(tall_hnb_ctx); hnbgw_vty_init(g_hnb_gw, tall_hnb_ctx); logging_vty_add_cmds(_log_info); @@ -501,23 +494,12 @@ ranap_set_log_area(DRANAP); - OSMO_ASSERT(g_hnb_gw->config.iucs_remote_ip); rc = hnbgw_cnlink_init(g_hnb_gw, - g_hnb_gw->config.iucs_remote_ip, - g_hnb_gw->config.iucs_remote_port, - "127.0.0.5" /* FIXME: configurable */, - 23 /* FIXME: configurable */); + "127.0.0.1", M3UA_PORT, "127.0.0.5" /* FIXME: configurable */); if (rc < 0) { LOGP(DMAIN, LOGL_ERROR, "Failed to initialize SCCP link to CN\n"); exit(1); } - - osmo_sccp_make_addr_pc_ssn(_hnb_gw->sccp.remote_addr_cs, - 1 /* FIXME: configurable */, - OSMO_SCCP_SSN_RANAP); - osmo_sccp_make_addr_pc_ssn(_hnb_gw->sccp.remote_addr_ps, - 2 /* FIXME: configurable */, - OSMO_SCCP_SSN_RANAP); OSMO_ASSERT(g_hnb_gw->config.iuh_local_ip);
[MERGED] openbsc[master]: libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03...
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report .. libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report This patch adds gsm340_sms_send_status_report_tpdu() to build a status-report. Moreover, set sms->report field if we see a SMPP SUBMIT_SM with Delivery Acknowledgment esm_class, so this identifies that this is a delivery report. MSGSM 03.40 SMSC SMPP 3.4 ESME | || | | SUBMIT-SM| | |esm_class = Delivery Ack| | |<---| | | SUBMIT-SM-RESP | | |--->| | || | SMS-STATUS-REPORT || |<|| | GSM 04.11 RP-ACK|| |>|| | || There is a FIXME message in this patch, that I just copied from gsm340_gen_sms_deliver_tpdu() since TP-MMS is not supported by OpenBSC. Change-Id: Ib70e534840308ed315f7add440351e649de3f907 --- M openbsc/src/libmsc/gsm_04_11.c M openbsc/src/libmsc/smpp_openbsc.c 2 files changed, 54 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Pablo Neira Ayuso: Verified diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 0edbe0b..80c3d77 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -277,6 +277,49 @@ return msg->len - old_msg_len; } +/* As defined by GSM 03.40, Section 9.2.2.3. */ +static int gsm340_gen_sms_status_report_tpdu(struct msgb *msg, +struct gsm_sms *sms) +{ + unsigned int old_msg_len = msg->len; + uint8_t oa_len = 0; + uint8_t oa[12]; /* max len per 03.40 */ + uint8_t *smsp; + + /* generate first octet with masked bits */ + smsp = msgb_put(msg, 1); + /* TP-MTI (message type indicator) */ + *smsp = GSM340_SMS_STATUS_REP_SC2MS; + /* TP-MMS (more messages to send) */ + if (0 /* FIXME */) + *smsp |= 0x04; + /* TP-MR (message reference) */ + smsp = msgb_put(msg, 1); + *smsp = sms->msg_ref; + /* generate recipient address */ + oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >dst); + smsp = msgb_put(msg, oa_len); + memcpy(smsp, oa, oa_len); + + /* generate TP-SCTS (Service centre timestamp) */ + smsp = msgb_put(msg, 7); + gsm340_gen_scts(smsp, time(NULL)); + + /* generate TP-DT (Discharge time, in TP-SCTS format). */ + smsp = msgb_put(msg, 7); + gsm340_gen_scts(smsp, time(NULL)); + + /* TP-ST (status) */ + smsp = msgb_put(msg, 1); + /* From GSM 03.40, Section 9.2.3.15, 0x00 means OK. */ + *smsp = 0x00; + + LOGP(DLSMS, LOGL_INFO, "sending status report for SMS reference %x\n", +sms->msg_ref); + + return msg->len - old_msg_len; +} + static int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *gsms) { @@ -989,8 +1032,13 @@ /* obtain a pointer for the rp_ud_len, so we can fill it later */ rp_ud_len = (uint8_t *)msgb_put(msg, 1); - /* generate the 03.40 SMS-DELIVER TPDU */ - rc = gsm340_gen_sms_deliver_tpdu(msg, sms); + if (sms->is_report) { + /* generate the 03.40 SMS-STATUS-REPORT TPDU */ + rc = gsm340_gen_sms_status_report_tpdu(msg, sms); + } else { + /* generate the 03.40 SMS-DELIVER TPDU */ + rc = gsm340_gen_sms_deliver_tpdu(msg, sms); + } if (rc < 0) { send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0); sms_free(sms); diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index c0aa89b..85de040 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -143,6 +143,10 @@ osmo_strlcpy(sms->src.addr, (char *)submit->source_addr, sizeof(sms->src.addr)); + /* This is a Delivery Acknowledgment. */ + if (submit->esm_class == 0x08) + sms->is_report = true; + if (submit->esm_class & 0x40) sms->ud_hdr_ind = 1; -- To view, visit https://gerrit.osmocom.org/3437 To unsubscribe, visit
[MERGED] openbsc[master]: libmsc: support GSM 03.40 status report for nitb
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: support GSM 03.40 status report for nitb .. libmsc: support GSM 03.40 status report for nitb This patch adds support for GSM 03.40 in nitb mode. MS GSM 03.40 SMSC || | SMS-SUBMIT | |--->| | GSM 04.11 RP-ACK | |<---| | SMS-DELIVER| |<---| | GSM 04.11 RP-ACK | |--->| | SMS-STATUS-REPORT | |<---| | GSM 04.11 RP-ACK | |--->| || Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160 --- M openbsc/src/libmsc/gsm_04_11.c 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Keith Whyte: Verified Harald Welte: Looks good to me, approved diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 80c3d77..73e0f55 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -682,6 +682,11 @@ LOGP(DLSMS, LOGL_ERROR, "Failed to send status report! err=%d\n", rc); } + + /* No route via SMPP, send the GSM 03.40 status-report now. */ + if (gsms->receiver) + gsm340_rx_sms_submit(sms_report); + LOGP(DLSMS, LOGL_NOTICE, "Status report has been sent\n"); sms_free(sms_report); -- To view, visit https://gerrit.osmocom.org/3438 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso
openbsc[master]: libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03...
Patch Set 4: Verified+1 -- To view, visit https://gerrit.osmocom.org/3437 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib70e534840308ed315f7add440351e649de3f907 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
[MERGED] openbsc[master]: utils: smpp_mirror: bounce Delivery Receipts as Delivery Ack...
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: utils: smpp_mirror: bounce Delivery Receipts as Delivery Acknowledgments .. utils: smpp_mirror: bounce Delivery Receipts as Delivery Acknowledgments Simple patch to test the new status-report support code, remove previous code before Delivery Acknowledgement support was in place. Use LOGL_DEBUG for logging messages here as suggested by Neels and Harald. Change-Id: I877e228d8e174430f700631edbf9955972da7892 --- M openbsc/src/utils/smpp_mirror.c 1 file changed, 8 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Pablo Neira Ayuso: Verified diff --git a/openbsc/src/utils/smpp_mirror.c b/openbsc/src/utils/smpp_mirror.c index 88545de..c570505 100644 --- a/openbsc/src/utils/smpp_mirror.c +++ b/openbsc/src/utils/smpp_mirror.c @@ -123,14 +123,6 @@ PACK_AND_SEND(esme, _r); - /* This is a delivery receipt, temporarily munch it until we teach -* openbsc what to do with this. -*/ - if (deliver.esm_class == 0x04) { - LOGP(DSMPP, LOGL_NOTICE, "%s\n", deliver.short_message); - return 0; - } - memset(, 0, sizeof(submit)); submit.command_id = SUBMIT_SM; submit.command_status = ESME_ROK; @@ -148,7 +140,14 @@ OSMO_MIN(sizeof(submit.source_addr), sizeof(deliver.destination_addr))); - submit.esm_class = deliver.esm_class; + /* Mirror delivery receipts as a delivery acknowledgements. */ + if (deliver.esm_class == 0x04) { + LOGP(DSMPP, LOGL_DEBUG, "%s\n", deliver.short_message); + submit.esm_class = 0x08; + } else { + submit.esm_class = deliver.esm_class; + } + submit.registered_delivery = deliver.registered_delivery; submit.protocol_id = deliver.protocol_id; submit.priority_flag = deliver.priority_flag; -- To view, visit https://gerrit.osmocom.org/3436 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I877e228d8e174430f700631edbf9955972da7892 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso
openbsc[master]: utils: smpp_mirror: bounce Delivery Receipts as Delivery Ack...
Patch Set 4: Verified+1 -- To view, visit https://gerrit.osmocom.org/3436 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I877e228d8e174430f700631edbf9955972da7892 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Patch Set 4: Verified+1 (1 comment) https://gerrit.osmocom.org/#/c/3435/1/openbsc/src/libmsc/db.c File openbsc/src/libmsc/db.c: Line 375: /* Just like v3, but there is a new message reference field for status reports, > "just like v5"? Right, just like v3 actually. -- To view, visit https://gerrit.osmocom.org/3435 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: Yes
[MERGED] openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: update database to accomodate SMS status-report fields .. libmsc: update database to accomodate SMS status-report fields SMPP DELIVER_SM messages with esm_class = Delivery Receipt need to send this message reference (that the mobile phone allocates) to the ESME. Thus, the ESME propagates it via SUBMIT_SM with esm_class = Delivery Acknoledgment so that the SMSC sends the GSM 03.40 status-report to the origin including this. Given this field is useful for status-reports, we need to store it in the HLR database. Moreover, we need a new field that specifies if the entry represents a SMS status-report, to do the right handling from the gsm411_send_sms() - such new handling comes in a follow up patch entitled "libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report". This patch includes the migration routines to the new database schema revision 5, it's quite a bit of dbi boilerplate code - copied-pasted and adapted. Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 --- M openbsc/src/libmsc/db.c M openbsc/tests/db/db_test.err 2 files changed, 163 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Pablo Neira Ayuso: Verified diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 5fe2a3c..9945dca 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -50,7 +50,7 @@ static char *db_dirname = NULL; static dbi_conn conn; -#define SCHEMA_REVISION "4" +#define SCHEMA_REVISION "5" enum { SCHEMA_META, @@ -124,6 +124,8 @@ "valid_until TIMESTAMP, " "reply_path_req INTEGER NOT NULL, " "status_rep_req INTEGER NOT NULL, " + "is_report INTEGER NOT NULL, " + "msg_ref INTEGER NOT NULL, " "protocol_id INTEGER NOT NULL, " "data_coding_scheme INTEGER NOT NULL, " "ud_hdr_ind INTEGER NOT NULL, " @@ -370,6 +372,152 @@ return -EINVAL; } +/* Just like v3, but there is a new message reference field for status reports, + * that is set to zero for existing entries since there is no way we can infer + * this. + */ +static struct gsm_sms *sms_from_result_v4(dbi_result result) +{ + struct gsm_sms *sms = sms_alloc(); + const unsigned char *user_data; + const char *text, *addr; + + if (!sms) + return NULL; + + sms->id = dbi_result_get_ulonglong(result, "id"); + + sms->reply_path_req = dbi_result_get_ulonglong(result, "reply_path_req"); + sms->status_rep_req = dbi_result_get_ulonglong(result, "status_rep_req"); + sms->ud_hdr_ind = dbi_result_get_ulonglong(result, "ud_hdr_ind"); + sms->protocol_id = dbi_result_get_ulonglong(result, "protocol_id"); + sms->data_coding_scheme = dbi_result_get_ulonglong(result, + "data_coding_scheme"); + + addr = dbi_result_get_string(result, "src_addr"); + osmo_strlcpy(sms->src.addr, addr, sizeof(sms->src.addr)); + sms->src.ton = dbi_result_get_ulonglong(result, "src_ton"); + sms->src.npi = dbi_result_get_ulonglong(result, "src_npi"); + + addr = dbi_result_get_string(result, "dest_addr"); + osmo_strlcpy(sms->dst.addr, addr, sizeof(sms->dst.addr)); + sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton"); + sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi"); + + sms->user_data_len = dbi_result_get_field_length(result, "user_data"); + user_data = dbi_result_get_binary(result, "user_data"); + if (sms->user_data_len > sizeof(sms->user_data)) + sms->user_data_len = (uint8_t) sizeof(sms->user_data); + memcpy(sms->user_data, user_data, sms->user_data_len); + + text = dbi_result_get_string(result, "text"); + if (text) + osmo_strlcpy(sms->text, text, sizeof(sms->text)); + return sms; +} + +static int update_db_revision_4(void) +{ + dbi_result result; + struct gsm_sms *sms; + + LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 4\n"); + + result = dbi_conn_query(conn, "BEGIN EXCLUSIVE TRANSACTION"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to begin transaction (upgrade from rev 4)\n"); + return -EINVAL; + } + dbi_result_free(result); + + /* Rename old SMS table to be able create a new one */ + result = dbi_conn_query(conn, "ALTER TABLE SMS RENAME TO SMS_4"); + if (!result) { + LOGP(DDB, LOGL_ERROR, +"Failed to rename the old SMS table (upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* Create new SMS table with all the bells and whistles! */ + result =
osmo-pcu[master]: Add pcu-socket vty config
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3443 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[MERGED] osmo-pcu[master]: Add pcu-socket vty config
Harald Welte has submitted this change and it was merged. Change subject: Add pcu-socket vty config .. Add pcu-socket vty config osmo-bts already supports configuring a different path for the bts<->pcu socket by using the 'pcu-socket' config field. Change-Id: I9b3e1171da467519750b201849ec892a1e318129 --- M include/osmocom/pcu/pcuif_proto.h M src/bts.h M src/osmobts_sock.cpp M src/pcu_main.cpp M src/pcu_vty.c 5 files changed, 30 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/pcu/pcuif_proto.h b/include/osmocom/pcu/pcuif_proto.h index 88dc09e..39103ee 100644 --- a/include/osmocom/pcu/pcuif_proto.h +++ b/include/osmocom/pcu/pcuif_proto.h @@ -3,6 +3,8 @@ #include +#define PCU_SOCK_DEFAULT "/tmp/pcu_bts" + #define PCU_IF_VERSION 0x07 #define TXT_MAX_LEN128 diff --git a/src/bts.h b/src/bts.h index 25193f9..cff0020 100644 --- a/src/bts.h +++ b/src/bts.h @@ -233,6 +233,9 @@ * period. */ struct BTS *bts; + + /* Path to be used for the pcu-bts socket */ + char *pcu_sock_path; }; #ifdef __cplusplus diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp index d7e55e7..e9b85ab 100644 --- a/src/osmobts_sock.cpp +++ b/src/osmobts_sock.cpp @@ -223,6 +223,7 @@ struct sockaddr_un local; unsigned int namelen; int rc; + struct gprs_rlcmac_bts *bts = bts_main_data(); LOGP(DL1IF, LOGL_INFO, "Opening OsmoPCU L1 interface to OsmoBTS\n"); @@ -244,7 +245,7 @@ } local.sun_family = AF_UNIX; - strncpy(local.sun_path, "/tmp/pcu_bts", sizeof(local.sun_path)); + strncpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path)); local.sun_path[sizeof(local.sun_path) - 1] = '\0'; /* we use the same magic that X11 uses in Xtranssock.c for diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index b69e446..8e7cde8 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -216,6 +216,8 @@ */ bts->dl_arq_type = EGPRS_ARQ1; + bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(_log_info); diff --git a/src/pcu_vty.c b/src/pcu_vty.c index cd22e38..68d2f55 100644 --- a/src/pcu_vty.c +++ b/src/pcu_vty.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "pcu_vty.h" #include "gprs_rlcmac.h" #include "bts.h" @@ -233,6 +234,8 @@ if (bts->dl_tbf_idle_msec) vty_out(vty, " dl-tbf-idle-time %d%s", bts->dl_tbf_idle_msec, VTY_NEWLINE); + if (strcmp(bts->pcu_sock_path, PCU_SOCK_DEFAULT)) + vty_out(vty, " pcu-socket %s%s", bts->pcu_sock_path, VTY_NEWLINE); for (i = 0; i < 32; i++) { unsigned int cs = (1 << i); @@ -966,6 +969,23 @@ return CMD_SUCCESS; } +DEFUN(cfg_pcu_sock, + cfg_pcu_sock_cmd, + "pcu-socket PATH", + "Configure the osmo-bts PCU socket file/path name\n" + "Path of the socket to connect to\n") +{ + struct gprs_rlcmac_bts *bts = bts_main_data(); + + if (bts->pcu_sock_path) { + /* FIXME: close the interface? */ + talloc_free(bts->pcu_sock_path); + } + bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, argv[0]); + /* FIXME: re-open the interface? */ + + return CMD_SUCCESS; +} DEFUN(show_tbf, show_tbf_cmd, @@ -1096,6 +1116,7 @@ install_element(PCU_NODE, _pcu_no_ms_idle_time_cmd); install_element(PCU_NODE, _pcu_gsmtap_categ_cmd); install_element(PCU_NODE, _pcu_no_gsmtap_categ_cmd); + install_element(PCU_NODE, _pcu_sock_cmd); install_element_ve(_bts_stats_cmd); install_element_ve(_tbf_cmd); -- To view, visit https://gerrit.osmocom.org/3443 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr
[MERGED] osmo-bts[master]: TRX: Remove global variables, move SETBSIC/SETTSC handling i...
Harald Welte has submitted this change and it was merged. Change subject: TRX: Remove global variables, move SETBSIC/SETTSC handling into phy_link .. TRX: Remove global variables, move SETBSIC/SETTSC handling into phy_link Whether or not we are talking to an OpenBTS (SETBSIC) or OsmoTRX (SETTSC) transceiver is a property of the phy_link, and not a property of the BTS. Also, we *really, really* should never use global variables. I'm very happy this is being cleaned up, finally. Change-Id: I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c --- M include/osmo-bts/phy_link.h M src/osmo-bts-trx/trx_if.c M src/osmo-bts-trx/trx_if.h M src/osmo-bts-trx/trx_vty.c 4 files changed, 38 insertions(+), 66 deletions(-) Approvals: Vadim Yanitskiy: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index 3d4bf91..7011622 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -47,6 +47,7 @@ uint32_t clock_advance; uint32_t rts_advance; + bool use_legacy_setbsic; } osmotrx; struct { char *mcast_dev;/* Network device for multicast */ diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 8ce2893..86a3b9b 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -51,8 +51,6 @@ //#define TOA_RSSI_DEBUG int transceiver_available = 0; -int settsc_enabled = 0; -int setbsic_enabled = 0; #define TRX_MAX_BURST_LEN 512 @@ -248,21 +246,21 @@ /*! Send "SETTSC" command to TRX */ int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc) { - if (!settsc_enabled) + struct phy_instance *pinst = l1h->phy_inst; + if (pinst->phy_link->u.osmotrx.use_legacy_setbsic) return 0; - /* if TSC is enabled only, the positive response is mandatory */ - return trx_ctrl_cmd(l1h, (setbsic_enabled) ? 0 : 1, "SETTSC", "%d", - tsc); + + return trx_ctrl_cmd(l1h, 1, "SETTSC", "%d", tsc); } /*! Send "SETBSIC" command to TRX */ int trx_if_cmd_setbsic(struct trx_l1h *l1h, uint8_t bsic) { - if (!setbsic_enabled) + struct phy_instance *pinst = l1h->phy_inst; + if (!pinst->phy_link->u.osmotrx.use_legacy_setbsic) return 0; - /* if BSIC is enabled only, the positive response is mandatory */ - return trx_ctrl_cmd(l1h, (settsc_enabled) ? 0 : 1, "SETBSIC", "%d", - bsic); + + return trx_ctrl_cmd(l1h, 1, "SETBSIC", "%d", bsic); } /*! Send "SETRXGAIN" command to TRX */ diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index 86fb18f..076e35e 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -2,8 +2,6 @@ #define TRX_IF_H extern int transceiver_available; -extern int settsc_enabled; -extern int setbsic_enabled; struct trx_l1h; diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index 6d6cded..482248c 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -197,51 +197,6 @@ return CMD_SUCCESS; } -DEFUN(cfg_bts_settsc, cfg_bts_settsc_cmd, - "settsc", - "Use SETTSC to configure transceiver\n") -{ - settsc_enabled = 1; - - return CMD_SUCCESS; -} - -DEFUN(cfg_bts_setbsic, cfg_bts_setbsic_cmd, - "setbsic", - "Use SETBSIC to configure transceiver\n") -{ - setbsic_enabled = 1; - - return CMD_SUCCESS; -} - -DEFUN(cfg_bts_no_settsc, cfg_bts_no_settsc_cmd, - "no settsc", - NO_STR "Disable SETTSC to configure transceiver\n") -{ - settsc_enabled = 0; - if (!setbsic_enabled) { - vty_out(vty, "%% Auto enabling SETBSIC.%s", VTY_NEWLINE); - setbsic_enabled = 1; - } - - return CMD_SUCCESS; -} - -DEFUN(cfg_bts_no_setbsic, cfg_bts_no_setbsic_cmd, - "no setbsic", - NO_STR "Disable SETBSIC to configure transceiver\n") -{ - setbsic_enabled = 0; - if (!settsc_enabled) { - vty_out(vty, "%% Auto enabling SETTSC.%s", VTY_NEWLINE); - settsc_enabled = 1; - } - - return CMD_SUCCESS; -} - - DEFUN(cfg_phyinst_maxdly, cfg_phyinst_maxdly_cmd, "osmotrx maxdly <0-31>", "Set the maximum acceptable delay of an Access Burst (in GSM symbols)." @@ -322,7 +277,6 @@ vty_out(vty, "OFF: %d%s", trx_if_cmd_poweroff(l1h), VTY_NEWLINE); else { vty_out(vty, "ON: %d%s", trx_if_cmd_poweron(l1h), VTY_NEWLINE); - settsc_enabled = 1; } return CMD_SUCCESS; @@ -503,6 +457,30 @@ return CMD_SUCCESS; } +DEFUN(cfg_phy_setbsic, cfg_phy_setbsic_cmd, + "osmotrx legacy-setbsic", + "Use SETBSIC to
[MERGED] osmo-bts[master]: l1sap/osmo-bts-sysmo: Improve logging
Harald Welte has submitted this change and it was merged. Change subject: l1sap/osmo-bts-sysmo: Improve logging .. l1sap/osmo-bts-sysmo: Improve logging Change-Id: I339db0e5f3fd5e44bac974f2447afc80388802af --- M src/common/l1sap.c 1 file changed, 23 insertions(+), 12 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 97cbac1..21d9dc6 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -500,12 +500,16 @@ struct bts_ul_meas ulm; struct gsm_lchan *lchan; - DEBUGP(DL1P, "MPH_INFO meas ind chan_nr=0x%02x\n", - info_meas_ind->chan_nr); - lchan = get_active_lchan_by_chan_nr(trx, info_meas_ind->chan_nr); - if (!lchan) + if (!lchan) { + LOGP(DL1P, LOGL_ERROR, "No lchan for MPH INFO MEAS IND (chan_nr=%u)\n", +info_meas_ind->chan_nr); return 0; + } + + DEBUGP(DL1P, "%s MPH_INFO meas ind, ta_offs_qbits=%d, ber10k=%d, inv_rssi=%u\n", + gsm_lchan_name(lchan), info_meas_ind->ta_offs_qbits, + info_meas_ind->ber10k, info_meas_ind->inv_rssi); /* in the GPRS case we are not interested in measurement * processing. The PCU will take care of it */ @@ -727,8 +731,10 @@ memcpy(p, fill_frame, GSM_MACBLOCK_LEN); } else if (!(chan_nr & 0x80)) { /* only TCH/F, TCH/H, SDCCH/4 and SDCCH/8 have C5 bit cleared */ lchan = get_active_lchan_by_chan_nr(trx, chan_nr); - if (!lchan) + if (!lchan) { + LOGP(DL1P, LOGL_ERROR, "No lchan for PH-RTS.ind (chan_nr=%u)\n", chan_nr); return 0; + } if (L1SAP_IS_LINK_SACCH(link_id)) { p = msgb_put(msg, GSM_MACBLOCK_LEN); /* L1-header, if not set/modified by layer 1 */ @@ -779,8 +785,8 @@ memcpy(p, fill_frame, GSM_MACBLOCK_LEN); } - DEBUGP(DL1P, "Tx PH-DATA.req %02u/%02u/%02u chan_nr=%02x link_id=0x%02x\n", - g_time.t1, g_time.t2, g_time.t3, chan_nr, link_id); + DEBUGP(DL1P, "Tx PH-DATA.req %s chan_nr=0x%02x link_id=0x%02x\n", + osmo_dump_gsmtime(_time), chan_nr, link_id); l1sap_down(trx, l1sap); @@ -830,8 +836,10 @@ DEBUGP(DL1P, "Rx TCH-RTS.ind %s chan_nr=0x%02x\n", osmo_dump_gsmtime(_time), chan_nr); lchan = get_active_lchan_by_chan_nr(trx, chan_nr); - if (!lchan) + if (!lchan) { + LOGP(DL1P, LOGL_ERROR, "No lchan for PH-RTS.ind (chan_nr=%u)\n", chan_nr); return 0; + } if (!lchan->loopback && lchan->abis_ip.rtp_socket) { osmo_rtp_socket_poll(lchan->abis_ip.rtp_socket); @@ -880,8 +888,7 @@ resp_l1sap->u.tch.fn = fn; resp_l1sap->u.tch.marker = marker; - DEBUGP(DL1P, "Tx TCH.req %02u/%02u/%02u chan_nr=0x%02x\n", - g_time.t1, g_time.t2, g_time.t3, chan_nr); + DEBUGP(DL1P, "Tx TCH.req %s chan_nr=0x%02x\n", osmo_dump_gsmtime(_time), chan_nr); l1sap_down(trx, resp_l1sap); @@ -1024,8 +1031,10 @@ } lchan = get_active_lchan_by_chan_nr(trx, chan_nr); - if (!lchan) + if (!lchan) { + LOGP(DL1P, LOGL_ERROR, "No lchan for chan_nr=%d\n", chan_nr); return 0; + } /* bad frame */ if (len == 0) { @@ -1091,8 +1100,10 @@ DEBUGP(DL1P, "Rx TCH.ind %s chan_nr=0x%02x\n", osmo_dump_gsmtime(_time), chan_nr); lchan = get_active_lchan_by_chan_nr(trx, chan_nr); - if (!lchan) + if (!lchan) { + LOGP(DL1P, LOGL_ERROR, "No lchan for TCH.ind (chan_nr=%u)\n", chan_nr); return 0; + } msgb_pull(msg, sizeof(*l1sap)); -- To view, visit https://gerrit.osmocom.org/3038 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I339db0e5f3fd5e44bac974f2447afc80388802af Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
osmo-bts[master]: TRX: Remove global variables, move SETBSIC/SETTSC handling i...
Patch Set 4: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/3044/4//COMMIT_MSG Commit Message: PS4, Line 10: transceiver is a property > What is a property? property: https://en.wikipedia.org/wiki/Property_(programming) and no, my original sentence is what I want. "[The question of] whether we are talking to an OpenBTS or OsmoTRX transceiver is a property [...]" -- To view, visit https://gerrit.osmocom.org/3044 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: Yes
osmo-bts[master]: l1sap/osmo-bts-sysmo: Improve logging
Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3038 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I339db0e5f3fd5e44bac974f2447afc80388802af Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[MERGED] libosmo-sccp[master]: cosmetic: ws in log
Harald Welte has submitted this change and it was merged. Change subject: cosmetic: ws in log .. cosmetic: ws in log Change-Id: If5a56ec170d4e91ce070f6fa9c9cfe5bbc121186 --- M src/sccp2sua.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp2sua.c b/src/sccp2sua.c index 499b55b..ad948c9 100644 --- a/src/sccp2sua.c +++ b/src/sccp2sua.c @@ -231,7 +231,7 @@ break; default: LOGP(DLSUA, LOGL_ERROR, "Unknown CCP Routing Indicator %u" - "requested\n", in->ri); + " requested\n", in->ri); return -EINVAL; } -- To view, visit https://gerrit.osmocom.org/3367 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If5a56ec170d4e91ce070f6fa9c9cfe5bbc121186 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: sccp-addr vty: set RI to SSN_PC when setting a point-code
Harald Welte has submitted this change and it was merged. Change subject: sccp-addr vty: set RI to SSN_PC when setting a point-code .. sccp-addr vty: set RI to SSN_PC when setting a point-code Change-Id: I75c67d289693f1c2a049ac61cf2b2097d6e5687d --- M src/osmo_ss7_vty.c 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index b70f892..21efcae 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1300,6 +1300,8 @@ entry->addr.presence |= OSMO_SCCP_ADDR_T_PC; entry->addr.pc = pc; + if (entry->addr.ri == OSMO_SCCP_RI_NONE) + entry->addr.ri = OSMO_SCCP_RI_SSN_PC; return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/3365 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I75c67d289693f1c2a049ac61cf2b2097d6e5687d Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
openbsc[master]: libmsc: support GSM 03.40 status report for nitb
Patch Set 4: > Patch Set 4: Verified+1 Not sure why I am permitted to Verify this... :-/ -- To view, visit https://gerrit.osmocom.org/3438 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
[MERGED] libosmo-sccp[master]: add osmo_sccp_addr_name() and three value_string[]s
Harald Welte has submitted this change and it was merged. Change subject: add osmo_sccp_addr_name() and three value_string[]s .. add osmo_sccp_addr_name() and three value_string[]s osmo_sccp_addr_dump() just prints the raw values. In osmo_sccp_addr_name(), use osmo_ss7_pointcode_print() and newly added RI, SSN and GT value_string[] to print more human readable log output. Change-Id: Ie1aedd7894acd69ddc887cd65a8a0df4b38c --- M include/osmocom/sigtran/sccp_sap.h M src/sccp_helpers.c M src/sccp_sap.c 3 files changed, 84 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h index 13b1022..796597f 100644 --- a/include/osmocom/sigtran/sccp_sap.h +++ b/include/osmocom/sigtran/sccp_sap.h @@ -60,6 +60,11 @@ OSMO_SCCP_RI_SSN_IP, }; +extern const struct value_string osmo_sccp_routing_ind_names[]; +static inline const char *osmo_sccp_routing_ind_name(enum osmo_sccp_routing_ind val) +{ return get_value_string(osmo_sccp_routing_ind_names, val); } + + /* Q.713 3.4.1 + RFC 3868 3.10.2.3 */ enum osmo_sccp_gti { OSMO_SCCP_GTI_NO_GT, @@ -68,6 +73,10 @@ OSMO_SCCP_GTI_TT_NPL_ENC, OSMO_SCCP_GTI_TT_NPL_ENC_NAI, }; + +extern const struct value_string osmo_sccp_gti_names[]; +static inline const char *osmo_sccp_gti_name(enum osmo_sccp_gti val) +{ return get_value_string(osmo_sccp_gti_names, val); } /* RFC 3868 3.10.2.3 */ enum osmo_sccp_npi { @@ -126,6 +135,10 @@ OSMO_SCCP_SSN_BSS_OAM = 253, }; +extern const struct value_string osmo_sccp_ssn_names[]; +static inline const char *osmo_sccp_ssn_name(enum osmo_sccp_ssn val) +{ return get_value_string(osmo_sccp_ssn_names, val); } + struct osmo_sccp_gt { uint8_t gti; uint8_t tt; diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 2320fe5..471c9cb 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -274,6 +274,7 @@ return buf; } +/* Return string representation of SCCP address raw bytes in a static string. */ char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) { static char buf[256]; @@ -295,3 +296,26 @@ return buf; } + +/* Like osmo_sccp_addr_dump() but print human readable representations instead of raw values. */ +char *osmo_sccp_addr_name(const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, , "RI=%s", osmo_sccp_routing_ind_name(addr->ri)); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, , "PC=%s", osmo_ss7_pointcode_print(ss7, addr->pc)); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, , "SSN=%s", osmo_sccp_ssn_name(addr->ssn)); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, , "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, , "GTI=%s", osmo_sccp_gti_name(addr->gt.gti)); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, , "GT=(%s)", osmo_sccp_gt_dump(>gt)); + + return buf; +} diff --git a/src/sccp_sap.c b/src/sccp_sap.c index d4580ae..e5addb1 100644 --- a/src/sccp_sap.c +++ b/src/sccp_sap.c @@ -85,3 +85,50 @@ return prim_name_buf; } + +const struct value_string osmo_sccp_routing_ind_names[] = { + { OSMO_SCCP_RI_NONE,"NONE" }, + { OSMO_SCCP_RI_GT, "GT" }, + { OSMO_SCCP_RI_SSN_PC, "SSN_PC" }, + { OSMO_SCCP_RI_SSN_IP, "SSN_IP" }, + { 0, NULL } +}; + +const struct value_string osmo_sccp_gti_names[] = { + { OSMO_SCCP_GTI_NO_GT, "NO_GT" }, + { OSMO_SCCP_GTI_NAI_ONLY, "NAI_ONLY" }, + { OSMO_SCCP_GTI_TT_ONLY,"TT_ONLY" }, + { OSMO_SCCP_GTI_TT_NPL_ENC, "TT_NPL_ENC" }, + { OSMO_SCCP_GTI_TT_NPL_ENC_NAI, "TT_NPL_ENC_NAI" }, + { 0, NULL } +}; + +const struct value_string osmo_sccp_ssn_names[] = { + { OSMO_SCCP_SSN_MGMT, "MGMT" }, + { OSMO_SCCP_SSN_ISUP, "ISUP" }, + { OSMO_SCCP_SSN_OMAP, "OMAP" }, + { OSMO_SCCP_SSN_MAP,"MAP" }, + { OSMO_SCCP_SSN_HLR,"HLR" }, + { OSMO_SCCP_SSN_VLR,"VLR" }, + { OSMO_SCCP_SSN_MSC,"MSC" }, + { OSMO_SCCP_SSN_EIR,"EIR" }, + { OSMO_SCCP_SSN_AUC,"AUC" }, + { OSMO_SCCP_SSN_ISDN_SS,"ISDN_SS" }, + { OSMO_SCCP_SSN_RES_INTL, "RES_INTL" }, + { OSMO_SCCP_SSN_BISDN, "BISDN" }, + { OSMO_SCCP_SSN_TC_TEST,"TC_TEST" }, + { OSMO_SCCP_SSN_RANAP, "RANAP" }, + { OSMO_SCCP_SSN_RNSAP, "RNSAP" }, + { OSMO_SCCP_SSN_GMLC_MAP, "GMLC_MAP" }, + { OSMO_SCCP_SSN_CAP,
[MERGED] libosmo-sccp[master]: constify ss7_instance arg of osmo_ss7_pointcode_print()
Harald Welte has submitted this change and it was merged. Change subject: constify ss7_instance arg of osmo_ss7_pointcode_print() .. constify ss7_instance arg of osmo_ss7_pointcode_print() Change-Id: I8c6b7188d004033e75e9c41f4a65c418d13a79c5 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c 2 files changed, 5 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 967912a..a457709 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -23,8 +23,8 @@ bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc); int osmo_ss7_pointcode_parse(struct osmo_ss7_instance *inst, const char *str); int osmo_ss7_pointcode_parse_mask_or_len(struct osmo_ss7_instance *inst, const char *in); -const char *osmo_ss7_pointcode_print(struct osmo_ss7_instance *inst, uint32_t pc); -const char *osmo_ss7_pointcode_print2(struct osmo_ss7_instance *inst, uint32_t pc); +const char *osmo_ss7_pointcode_print(const struct osmo_ss7_instance *inst, uint32_t pc); +const char *osmo_ss7_pointcode_print2(const struct osmo_ss7_instance *inst, uint32_t pc); /* All known point-code formats have a length of or below 24 bit. * A point-code value exceeding that is used to indicate an unset PC. */ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index f82f952..7b0b0e4 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -245,7 +245,7 @@ return -EINVAL; } -const char *_osmo_ss7_pointcode_print(char *buf, size_t len, struct osmo_ss7_instance *inst, uint32_t pc) +const char *_osmo_ss7_pointcode_print(char *buf, size_t len, const struct osmo_ss7_instance *inst, uint32_t pc) { const struct osmo_ss7_pc_fmt *pc_fmt; unsigned int num_comp_exp; @@ -269,7 +269,7 @@ /* print a pointcode according to the structure configured for this * ss7_instance */ -const char *osmo_ss7_pointcode_print(struct osmo_ss7_instance *inst, uint32_t pc) +const char *osmo_ss7_pointcode_print(const struct osmo_ss7_instance *inst, uint32_t pc) { static char buf[MAX_PC_STR_LEN]; return _osmo_ss7_pointcode_print(buf, sizeof(buf), inst, pc); @@ -277,7 +277,7 @@ /* same as osmo_ss7_pointcode_print() but using a separate buffer, useful for multiple point codes in the * same LOGP/printf. */ -const char *osmo_ss7_pointcode_print2(struct osmo_ss7_instance *inst, uint32_t pc) +const char *osmo_ss7_pointcode_print2(const struct osmo_ss7_instance *inst, uint32_t pc) { static char buf[MAX_PC_STR_LEN]; return _osmo_ss7_pointcode_print(buf, sizeof(buf), inst, pc); -- To view, visit https://gerrit.osmocom.org/3361 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c6b7188d004033e75e9c41f4a65c418d13a79c5 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: fix osmo_sccp_addr_dump(): actually print RI
Harald Welte has submitted this change and it was merged. Change subject: fix osmo_sccp_addr_dump(): actually print RI .. fix osmo_sccp_addr_dump(): actually print RI Adjust xua_test accordingly. Change-Id: I93e0aa706867e7b1de7f7a6071e3c8af89772af0 --- M src/sccp_helpers.c M tests/xua/xua_test.ok 2 files changed, 7 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 471c9cb..db562db 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -282,7 +282,7 @@ buf[0] = '\0'; - append_to_buf(buf, , "RI=7"); + append_to_buf(buf, , "RI=%d", addr->ri); if (addr->presence & OSMO_SCCP_ADDR_T_PC) append_to_buf(buf, , "PC=%u", addr->pc); diff --git a/tests/xua/xua_test.ok b/tests/xua/xua_test.ok index ca8572a..12d817d 100644 --- a/tests/xua/xua_test.ok +++ b/tests/xua/xua_test.ok @@ -1,14 +1,14 @@ digits='01234567' (8) digits='0123456' (7) sccp_addr_parse test case 0 -expected: RI=7,SSN=6,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919969679389) -parsed: RI=7,SSN=6,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919969679389) +expected: RI=1,SSN=6,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919969679389) +parsed: RI=1,SSN=6,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919969679389) sccp_addr_parse test case 1 -expected: RI=7,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=91986922) -parsed: RI=7,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=91986922) +expected: RI=1,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=91986922) +parsed: RI=1,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=91986922) sccp_addr_parse test case 2 -expected: RI=7,SSN=254,GTI=0 -parsed: RI=7,SSN=254,GTI=0 +expected: RI=2,SSN=254,GTI=0 +parsed: RI=2,SSN=254,GTI=0 Testing Decoded GT -> SUA encoding IN: TT=0,NPL=1,NAI=4,DIG=919969679389 040001000400393139393639363739333839 -- To view, visit https://gerrit.osmocom.org/3364 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I93e0aa706867e7b1de7f7a6071e3c8af89772af0 Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: introduce OSMO_SCCP_RI_NONE to indicate unset RI
Harald Welte has submitted this change and it was merged. Change subject: introduce OSMO_SCCP_RI_NONE to indicate unset RI .. introduce OSMO_SCCP_RI_NONE to indicate unset RI Allows to automatically set an RI in future change I75c67d289693f1c2a049ac61cf2b2097d6e5687d "sccp-addr vty: set RI to SSN_PC when setting a point-code" Change-Id: I6e2f31b023b08cba2f2ee8234e6108efcaca41c0 --- M include/osmocom/sigtran/sccp_sap.h M src/osmo_ss7_vty.c 2 files changed, 6 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h index 90da686..13b1022 100644 --- a/include/osmocom/sigtran/sccp_sap.h +++ b/include/osmocom/sigtran/sccp_sap.h @@ -54,6 +54,7 @@ /* Q.713 3.4.1 + RFC 3868 3.10.2.3 */ enum osmo_sccp_routing_ind { + OSMO_SCCP_RI_NONE, OSMO_SCCP_RI_GT, OSMO_SCCP_RI_SSN_PC, OSMO_SCCP_RI_SSN_IP, diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 164b7f2..b70f892 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1048,6 +1048,11 @@ case OSMO_SCCP_RI_SSN_IP: vty_out(vty, " routing-indicator IP%s", VTY_NEWLINE); break; + case OSMO_SCCP_RI_NONE: + break; + default: + vty_out(vty, " ! invalid routing-indicator value: %u%s", entry->addr.ri, VTY_NEWLINE); + break; } if (entry->addr.presence & OSMO_SCCP_ADDR_T_PC) vty_out(vty, " point-code %s%s", -- To view, visit https://gerrit.osmocom.org/3362 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6e2f31b023b08cba2f2ee8234e6108efcaca41c0 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: sccp_helpers: check buf len in append_to_buf()
Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers: check buf len in append_to_buf() .. sccp_helpers: check buf len in append_to_buf() Change-Id: I2e6d656871f952be8e719573fedf2154832841d7 --- M src/sccp_helpers.c 1 file changed, 21 insertions(+), 18 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index db562db..1e83c8c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -230,16 +230,19 @@ return osmo_sccp_tx_conn_resp_msg(scu, conn_id, resp_addr, msg); } -static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +static void append_to_buf(char *buf, size_t size, bool *comma, const char *fmt, ...) { va_list ap; + size_t printed; va_start(ap, fmt); if (*comma == true) { strcat(buf, ","); } else *comma = true; - vsprintf(buf+strlen(buf), fmt, ap); + printed = strlen(buf); + OSMO_ASSERT(printed <= size); + vsnprintf(buf + printed, size - printed, fmt, ap); va_end(ap); } @@ -260,16 +263,16 @@ if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) - append_to_buf(buf, , "TT=%u", gt->tt); + append_to_buf(buf, sizeof(buf), , "TT=%u", gt->tt); if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) - append_to_buf(buf, , "NPL=%u", gt->npi); + append_to_buf(buf, sizeof(buf), , "NPL=%u", gt->npi); if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) - append_to_buf(buf, , "NAI=%u", gt->nai); + append_to_buf(buf, sizeof(buf), , "NAI=%u", gt->nai); - append_to_buf(buf, , "DIG=%s", gt->digits); + append_to_buf(buf, sizeof(buf), , "DIG=%s", gt->digits); return buf; } @@ -282,17 +285,17 @@ buf[0] = '\0'; - append_to_buf(buf, , "RI=%d", addr->ri); + append_to_buf(buf, sizeof(buf), , "RI=%d", addr->ri); if (addr->presence & OSMO_SCCP_ADDR_T_PC) - append_to_buf(buf, , "PC=%u", addr->pc); + append_to_buf(buf, sizeof(buf), , "PC=%u", addr->pc); if (addr->presence & OSMO_SCCP_ADDR_T_SSN) - append_to_buf(buf, , "SSN=%u", addr->ssn); + append_to_buf(buf, sizeof(buf), , "SSN=%u", addr->ssn); if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) - append_to_buf(buf, , "IP=%s", inet_ntoa(addr->ip.v4)); - append_to_buf(buf, , "GTI=%u", addr->gt.gti); + append_to_buf(buf, sizeof(buf), , "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, sizeof(buf), , "GTI=%u", addr->gt.gti); if (addr->presence & OSMO_SCCP_ADDR_T_GT) - append_to_buf(buf, , "GT=(%s)", osmo_sccp_gt_dump(>gt)); + append_to_buf(buf, sizeof(buf), , "GT=(%s)", osmo_sccp_gt_dump(>gt)); return buf; } @@ -305,17 +308,17 @@ buf[0] = '\0'; - append_to_buf(buf, , "RI=%s", osmo_sccp_routing_ind_name(addr->ri)); + append_to_buf(buf, sizeof(buf), , "RI=%s", osmo_sccp_routing_ind_name(addr->ri)); if (addr->presence & OSMO_SCCP_ADDR_T_PC) - append_to_buf(buf, , "PC=%s", osmo_ss7_pointcode_print(ss7, addr->pc)); + append_to_buf(buf, sizeof(buf), , "PC=%s", osmo_ss7_pointcode_print(ss7, addr->pc)); if (addr->presence & OSMO_SCCP_ADDR_T_SSN) - append_to_buf(buf, , "SSN=%s", osmo_sccp_ssn_name(addr->ssn)); + append_to_buf(buf, sizeof(buf), , "SSN=%s", osmo_sccp_ssn_name(addr->ssn)); if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) - append_to_buf(buf, , "IP=%s", inet_ntoa(addr->ip.v4)); - append_to_buf(buf, , "GTI=%s", osmo_sccp_gti_name(addr->gt.gti)); + append_to_buf(buf, sizeof(buf), , "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, sizeof(buf), , "GTI=%s", osmo_sccp_gti_name(addr->gt.gti)); if (addr->presence & OSMO_SCCP_ADDR_T_GT) - append_to_buf(buf, , "GT=(%s)", osmo_sccp_gt_dump(>gt)); + append_to_buf(buf, sizeof(buf), , "GT=(%s)", osmo_sccp_gt_dump(>gt)); return buf; } -- To view, visit https://gerrit.osmocom.org/3366 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2e6d656871f952be8e719573fedf2154832841d7 Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder
[MERGED] libosmo-sccp[master]: consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user
Harald Welte has submitted this change and it was merged. Change subject: consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user .. consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user A previous patch added ss7_instance primary_pc validity checks by means of OSMO_SS7_PC_INVALID. To be consistent, also adjust sccp_user accordingly. (see I7f0f0c89b7335d9da24161bfac8234be214ca00c) Remove the osmo_sccp_user's pc_valid field, replaced by pc=OSMO_SS7_PC_INVALID. Adjust all code paths. Simplify some log printing, using the fact that osmo_ss7_pointcode_print() now outputs "(no PC)" for unset point codes. Change-Id: I8684c9b559712072c772012890bbf7efa7c8eb35 --- M src/sccp_internal.h M src/sccp_scoc.c M src/sccp_user.c M src/sccp_vty.c 4 files changed, 16 insertions(+), 21 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sccp_internal.h b/src/sccp_internal.h index 17dda13..66d768d 100644 --- a/src/sccp_internal.h +++ b/src/sccp_internal.h @@ -34,7 +34,6 @@ /*! \brief SSN and/or point code to which we are bound */ uint16_t ssn; uint32_t pc; - bool pc_valid; /* set if we are a server */ struct llist_head links; diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c index 9820c40..74fb0e7 100644 --- a/src/sccp_scoc.c +++ b/src/sccp_scoc.c @@ -1672,7 +1672,7 @@ struct osmo_sccp_addr *remote_addr; uint32_t local_pc = OSMO_SS7_PC_INVALID; - if (conn->user->pc_valid) + if (osmo_ss7_pc_is_valid(conn->user->pc)) local_pc = conn->user->pc; else if (osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) local_pc = s7i->cfg.primary_pc; diff --git a/src/sccp_user.c b/src/sccp_user.c index d49da29..1414572 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -48,13 +48,13 @@ /* First try to find match for PC + SSN */ llist_for_each_entry(scu, >users, list) { - if (scu->pc_valid && scu->pc == pc && scu->ssn == ssn) + if (osmo_ss7_pc_is_valid(scu->pc) && scu->pc == pc && scu->ssn == ssn) return scu; } /* Then try to match on SSN only */ llist_for_each_entry(scu, >users, list) { - if (!scu->pc_valid && scu->ssn == ssn) + if (!osmo_ss7_pc_is_valid(scu->pc) && scu->ssn == ssn) return scu; } @@ -65,28 +65,25 @@ * \param[in] inst SCCP Instance * \param[in] name human-readable name * \param[in] ssn Sub-System Number to bind to - * \param[in] pc Point Code to bind to (if any) - * \param[in] pc_valid Whether or not \ref pc is valid/used + * \param[in] pc Point Code to bind to, or OSMO_SS7_PC_INVALID if none. * \returns Callee-allocated SCCP User on success; negative otherwise */ static struct osmo_sccp_user * sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name, - osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc, bool pc_valid) + osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc) { struct osmo_sccp_user *scu; - if (!pc_valid) - pc = 0; scu = sccp_user_find(inst, ssn, pc); if (scu) { LOGP(DLSCCP, LOGL_ERROR, -"Cannot bind user '%s' to SSN=%u PC=%u=%s (pc_valid=%u), this SSN and PC" +"Cannot bind user '%s' to SSN=%u PC=%s, this SSN and PC" " is already bound by '%s'\n", -name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid, scu->name); +name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc), scu->name); return NULL; } - LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%u=%s (pc_valid=%u)\n", - name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid); + LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%s\n", + name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc)); scu = talloc_zero(inst, struct osmo_sccp_user); scu->name = talloc_strdup(scu, name); @@ -94,7 +91,6 @@ scu->prim_cb = prim_cb; scu->ssn = ssn; scu->pc = pc; - scu->pc_valid = pc_valid; llist_add_tail(>list, >users); return scu; @@ -104,13 +100,13 @@ * \param[in] inst SCCP Instance * \param[in] name human-readable name * \param[in] ssn Sub-System Number to bind to - * \param[in] pc Point Code to bind to (if any) + * \param[in] pc Point Code to bind to * \returns Callee-allocated SCCP User on success; negative otherwise */ struct osmo_sccp_user * osmo_sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name, osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc) { - return sccp_user_bind_pc(inst, name, prim_cb, ssn, pc, true); + return
libosmo-sccp[master]: ensure valid primary_pc in osmo_ss7_instance
Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3355 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
libosmo-sccp[master]: consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3451 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8684c9b559712072c772012890bbf7efa7c8eb35 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
libosmo-sccp[master]: add OSMO_SS7_PC_INVALID, add osmo_ss7_pc_is_valid()
Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3450 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib5715bf03a4de7713a7a809dfd821c700255ba8c Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
openbsc[master]: libmsc: support GSM 03.40 status report for nitb
Patch Set 4: Verified+1 -- To view, visit https://gerrit.osmocom.org/3438 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
[MERGED] osmo-bts[master]: TRX: Remove bogus extern global variable declarations
Harald Welte has submitted this change and it was merged. Change subject: TRX: Remove bogus extern global variable declarations .. TRX: Remove bogus extern global variable declarations Those global variable declarations for non-existing variables were introduced in 8a8d73a691c709403be4adbe8f2a7150b4d5998a, let's remove them again. The source / destination IP address is a parameter of the phy_link, and not a global variable. Related: OS#1848 Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 --- M src/osmo-bts-trx/trx_if.h 1 file changed, 0 insertions(+), 2 deletions(-) Approvals: Vadim Yanitskiy: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index 1fc454d..86fb18f 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -2,8 +2,6 @@ #define TRX_IF_H extern int transceiver_available; -extern const char *local_ip; -extern const char *remote_ip; extern int settsc_enabled; extern int setbsic_enabled; -- To view, visit https://gerrit.osmocom.org/3045 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy
openbsc[master]: libmsc: support GSM 03.40 status report for nitb
Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3438 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
[MERGED] openbsc[master]: utils: smpp_mirror: temporarily munch SMPP delivery receipts
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: utils: smpp_mirror: temporarily munch SMPP delivery receipts .. utils: smpp_mirror: temporarily munch SMPP delivery receipts Just munch and log SMPP delivery receipts by now, don't mirror this, it is going to break things in openbsc. Follow up patch removes this and mirrors this SMPP message as a SUBMIT_SM with esm_class = Delivery Acknowledgement. Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b --- M openbsc/src/utils/smpp_mirror.c 1 file changed, 8 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/utils/smpp_mirror.c b/openbsc/src/utils/smpp_mirror.c index ec28f0a..edb40b5 100644 --- a/openbsc/src/utils/smpp_mirror.c +++ b/openbsc/src/utils/smpp_mirror.c @@ -112,6 +112,14 @@ PACK_AND_SEND(esme, _r); + /* This is a delivery receipt, temporarily munch it until we teach +* openbsc what to do with this. +*/ + if (deliver.esm_class == 0x04) { + LOGP(DSMPP, LOGL_NOTICE, "%s\n", deliver.short_message); + return 0; + } + memset(, 0, sizeof(submit)); submit.command_id = SUBMIT_SM; submit.command_status = ESME_ROK; -- To view, visit https://gerrit.osmocom.org/3432 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Pablo Neira Ayuso
[MERGED] openbsc[master]: utils: smpp_mirror: set registered_delivery field in SMPP SU...
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: utils: smpp_mirror: set registered_delivery field in SMPP SUBMIT_SM .. utils: smpp_mirror: set registered_delivery field in SMPP SUBMIT_SM To test delivery reports using this utility. Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f --- M openbsc/src/utils/smpp_mirror.c 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/utils/smpp_mirror.c b/openbsc/src/utils/smpp_mirror.c index 95df5f2..ec28f0a 100644 --- a/openbsc/src/utils/smpp_mirror.c +++ b/openbsc/src/utils/smpp_mirror.c @@ -130,6 +130,7 @@ sizeof(deliver.destination_addr))); submit.esm_class = deliver.esm_class; + submit.registered_delivery = deliver.registered_delivery; submit.protocol_id = deliver.protocol_id; submit.priority_flag = deliver.priority_flag; memcpy(submit.schedule_delivery_time, deliver.schedule_delivery_time, -- To view, visit https://gerrit.osmocom.org/3431 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Pablo Neira Ayuso
[MERGED] openbsc[master]: libmsc: add support for SMPP delivery receipts
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: add support for SMPP delivery receipts .. libmsc: add support for SMPP delivery receipts If the mobile phone requests a status report via SMS, send a DELIVER_SM with esm_class = Delivery Receipt to ESME to indicate that the SMS has been already delivered to its destination. MSGSM 03.40 SMSC SMPP 3.4 ESME | || | SMS-DELIVER || |<|| | GSM 04.11 RP-ACK|| |>|| | | DELIVER-SM | | | esm_class = Delivery Receipt | | |--->| | | DELIVER-SM-RESP| | |<---| | || This patch implements "Appendix B. Delivery Receipt Format" as specified in the SMPP 3.4 specs. This string is conveyed in the SMS message as data, and it is only meaningful to the ESME, for logging purposes. The "submit date" and "done date" are not yet set, and other fields are just sent with dummy values, so they are left to be finished as future work. The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP messages inconditionally now since this information is required by delivery-reports to associate the status-report with the original SMS. Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a --- M openbsc/include/openbsc/gsm_data.h M openbsc/src/libmsc/gsm_04_11.c M openbsc/src/libmsc/smpp_openbsc.c M openbsc/src/libmsc/smpp_smsc.h 4 files changed, 76 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 37a341c..6829d22 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -456,6 +456,7 @@ } smpp; unsigned long validity_minutes; + bool is_report; uint8_t reply_path_req; uint8_t status_rep_req; uint8_t ud_hdr_ind; diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 1aed60e..0edbe0b 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -593,6 +593,57 @@ rpud_len, rp_ud); } +static struct gsm_sms *sms_report_alloc(struct gsm_sms *sms) +{ + struct gsm_sms *sms_report; + int len; + + sms_report = sms_alloc(); + OSMO_ASSERT(sms_report); + + sms_report->msg_ref = sms->msg_ref; + sms_report->protocol_id = sms->protocol_id; + sms_report->data_coding_scheme = GSM338_DCS__8BIT_DATA; + + /* Invert address to send status report back to origin. */ + sms_report->src = sms->dst; + sms_report->dst = sms->src; + + /* As specified by Appendix B. Delivery Receipt Format. +* TODO: Many fields in this string are just set with dummy values, +* revisit this. +*/ + len = snprintf((char *)sms_report->user_data, + sizeof(sms_report->user_data), + "id:%.08llu sub:000 dlvrd:000 submit date:YYMMDDhhmm done date:YYMMDDhhmm stat:DELIVRD err:000 text:%.20s", + sms->id, sms->user_data); + sms_report->user_data_len = len; + LOGP(DLSMS, LOGL_NOTICE, "%s\n", sms_report->user_data); + + /* This represents a sms report. */ + sms_report->is_report = true; + + return sms_report; +} + +static void sms_status_report(struct gsm_sms *gsms, + struct gsm_subscriber_connection *conn) +{ + struct gsm_sms *sms_report; + int rc; + + sms_report = sms_report_alloc(gsms); + + rc = sms_route_mt_sms(conn, sms_report); + if (rc < 0) { + LOGP(DLSMS, LOGL_ERROR, +"Failed to send status report! err=%d\n", rc); + } + LOGP(DLSMS, LOGL_NOTICE, "Status report has been sent\n"); + + sms_free(sms_report); +} + /* Receive a 04.11 RP-ACK message (response to RP-DATA from us) */ static int gsm411_rx_rp_ack(struct msgb *msg, struct gsm_trans *trans, struct gsm411_rp_hdr *rph) @@ -614,6 +665,9 @@ send_signal(S_SMS_DELIVERED, trans, sms, 0); + if (sms->status_rep_req) + sms_status_report(sms, trans->conn); + sms_free(sms); trans->sms.sms = NULL; diff --git
[MERGED] openbsc[master]: libmsc: report status report request flag from SMPP SUBMIT_SM
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: report status report request flag from SMPP SUBMIT_SM .. libmsc: report status report request flag from SMPP SUBMIT_SM Restore the sms status report request flag from SUBMIT_SM. Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b --- M openbsc/src/libmsc/smpp_openbsc.c 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified Pablo Neira Ayuso: Verified diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index cf78676..a803763 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -129,6 +129,7 @@ sms = sms_alloc(); sms->source = SMS_SOURCE_SMPP; sms->smpp.sequence_nr = submit->sequence_number; + sms->status_rep_req = submit->registered_delivery; /* fill in the destination address */ sms->receiver = dest; -- To view, visit https://gerrit.osmocom.org/3429 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso
[MERGED] openbsc[master]: libmsc: missing bit shift in status report flag when stored ...
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: missing bit shift in status report flag when stored in sms object .. libmsc: missing bit shift in status report flag when stored in sms object So we just store 0 or 1 depending on what the mobile phone requests. Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201 --- M openbsc/src/libmsc/gsm_04_11.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 7294153..1aed60e 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -366,7 +366,7 @@ /* invert those fields where 0 means active/present */ sms_mti = *smsp & 0x03; sms_vpf = (*smsp & 0x18) >> 3; - gsms->status_rep_req = (*smsp & 0x20); + gsms->status_rep_req = (*smsp & 0x20) >> 5; gsms->ud_hdr_ind = (*smsp & 0x40); /* * Not evaluating MMS (More Messages to Send) because the -- To view, visit https://gerrit.osmocom.org/3430 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Pablo Neira Ayuso
openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3435 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[MERGED] openbsc[master]: libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM...
Pablo Neira Ayuso has submitted this change and it was merged. Change subject: libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messages .. libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messages Propagate the status report request field to the SMPP message through the registered_delivery field, so the ESME knows that the mobile phone is asking for explicit delivery acknowledgment is required. See SMPP 3.4 specs section 5.2.17. Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee --- M openbsc/src/libmsc/smpp_openbsc.c 1 file changed, 8 insertions(+), 1 deletion(-) Approvals: Neels Hofmeyr: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved; Verified diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index 6b89df2..cf78676 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -602,6 +602,10 @@ return NULL; } +/* See SMPP 3.4, Section 5.2.17. registered_delivery (1 byte field). */ +#define SMPP34_NO_DELIVERY_RECEIPT 0x0 +#define SMPP34_DELIVERY_RECEIPT_REQ0x1 + static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms, struct gsm_subscriber_connection *conn) { @@ -642,7 +646,10 @@ deliver.protocol_id = sms->protocol_id; deliver.priority_flag = 0; - deliver.registered_delivery = 0; + if (sms->status_rep_req) + deliver.registered_delivery = SMPP34_DELIVERY_RECEIPT_REQ; + else + deliver.registered_delivery = SMPP34_NO_DELIVERY_RECEIPT; /* Figure out SMPP DCS from TP-DCS */ dcs = sms->data_coding_scheme; -- To view, visit https://gerrit.osmocom.org/3428 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-Reviewer: Pau Espin Pedrol
openbsc[master]: libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM...
Patch Set 2: Verified+1 -- To view, visit https://gerrit.osmocom.org/3428 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-Reviewer: Pau Espin Pedrol Gerrit-HasComments: No
[PATCH] openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3435 to look at the new patch set (#4). libmsc: update database to accomodate SMS status-report fields SMPP DELIVER_SM messages with esm_class = Delivery Receipt need to send this message reference (that the mobile phone allocates) to the ESME. Thus, the ESME propagates it via SUBMIT_SM with esm_class = Delivery Acknoledgment so that the SMSC sends the GSM 03.40 status-report to the origin including this. Given this field is useful for status-reports, we need to store it in the HLR database. Moreover, we need a new field that specifies if the entry represents a SMS status-report, to do the right handling from the gsm411_send_sms() - such new handling comes in a follow up patch entitled "libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report". This patch includes the migration routines to the new database schema revision 5, it's quite a bit of dbi boilerplate code - copied-pasted and adapted. Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 --- M openbsc/src/libmsc/db.c M openbsc/tests/db/db_test.err 2 files changed, 163 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/35/3435/4 diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 5fe2a3c..9945dca 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -50,7 +50,7 @@ static char *db_dirname = NULL; static dbi_conn conn; -#define SCHEMA_REVISION "4" +#define SCHEMA_REVISION "5" enum { SCHEMA_META, @@ -124,6 +124,8 @@ "valid_until TIMESTAMP, " "reply_path_req INTEGER NOT NULL, " "status_rep_req INTEGER NOT NULL, " + "is_report INTEGER NOT NULL, " + "msg_ref INTEGER NOT NULL, " "protocol_id INTEGER NOT NULL, " "data_coding_scheme INTEGER NOT NULL, " "ud_hdr_ind INTEGER NOT NULL, " @@ -370,6 +372,152 @@ return -EINVAL; } +/* Just like v3, but there is a new message reference field for status reports, + * that is set to zero for existing entries since there is no way we can infer + * this. + */ +static struct gsm_sms *sms_from_result_v4(dbi_result result) +{ + struct gsm_sms *sms = sms_alloc(); + const unsigned char *user_data; + const char *text, *addr; + + if (!sms) + return NULL; + + sms->id = dbi_result_get_ulonglong(result, "id"); + + sms->reply_path_req = dbi_result_get_ulonglong(result, "reply_path_req"); + sms->status_rep_req = dbi_result_get_ulonglong(result, "status_rep_req"); + sms->ud_hdr_ind = dbi_result_get_ulonglong(result, "ud_hdr_ind"); + sms->protocol_id = dbi_result_get_ulonglong(result, "protocol_id"); + sms->data_coding_scheme = dbi_result_get_ulonglong(result, + "data_coding_scheme"); + + addr = dbi_result_get_string(result, "src_addr"); + osmo_strlcpy(sms->src.addr, addr, sizeof(sms->src.addr)); + sms->src.ton = dbi_result_get_ulonglong(result, "src_ton"); + sms->src.npi = dbi_result_get_ulonglong(result, "src_npi"); + + addr = dbi_result_get_string(result, "dest_addr"); + osmo_strlcpy(sms->dst.addr, addr, sizeof(sms->dst.addr)); + sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton"); + sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi"); + + sms->user_data_len = dbi_result_get_field_length(result, "user_data"); + user_data = dbi_result_get_binary(result, "user_data"); + if (sms->user_data_len > sizeof(sms->user_data)) + sms->user_data_len = (uint8_t) sizeof(sms->user_data); + memcpy(sms->user_data, user_data, sms->user_data_len); + + text = dbi_result_get_string(result, "text"); + if (text) + osmo_strlcpy(sms->text, text, sizeof(sms->text)); + return sms; +} + +static int update_db_revision_4(void) +{ + dbi_result result; + struct gsm_sms *sms; + + LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 4\n"); + + result = dbi_conn_query(conn, "BEGIN EXCLUSIVE TRANSACTION"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to begin transaction (upgrade from rev 4)\n"); + return -EINVAL; + } + dbi_result_free(result); + + /* Rename old SMS table to be able create a new one */ + result = dbi_conn_query(conn, "ALTER TABLE SMS RENAME TO SMS_4"); + if (!result) { + LOGP(DDB, LOGL_ERROR, +"Failed to rename the old SMS table (upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* Create new SMS table with all the bells and whistles! */ + result = dbi_conn_query(conn, create_stmts[SCHEMA_SMS]); +
libasn1c[master]: add /debian to build a package
Patch Set 1: Code-Review-1 lynxis, let's enhance the copyright notice as in above comments -- To view, visit https://gerrit.osmocom.org/3440 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I135d975b84027d51cb1dc534e04dd314bbd20289 Gerrit-PatchSet: 1 Gerrit-Project: libasn1c Gerrit-Branch: master Gerrit-Owner: lynxis lazusGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
libosmo-sccp[master]: ensure valid primary_pc in osmo_ss7_instance
Patch Set 4: Now using 0x to mark invalid PC, this commit spread out into three: adding the invalid value, ensuring set primary_pc, and then adjusting osmo_sccp_user to use the same invalidity marking. -- To view, visit https://gerrit.osmocom.org/3355 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] libosmo-sccp[master]: add OSMO_SS7_PC_INVALID, add osmo_ss7_pc_is_valid()
Review at https://gerrit.osmocom.org/3450 add OSMO_SS7_PC_INVALID, add osmo_ss7_pc_is_valid() Introduce OSMO_SS7_PC_INVALID to mark an unset point code. Add static osmo_ss7_pc_is_valid() (name matches schema of osmo_ss7_pc_is_local()). In osmo_ss7_pointcode_print(), return "(no PC)" if !osmo_ss7_pc_is_valid(), for convenient printing of any PC state. Subsequent patches will use this for osmo_ss7_instance (I7f0f0c89b7335d9da24161bfac8234be214ca00c) as well as osmo_sccp_user (I8684c9b559712072c772012890bbf7efa7c8eb35). Rationale: Currently, in osmo_ss7_vty.c we had "if (inst->cfg.primary_pc)" suggesting 0 is invalid, but in struct osmo_sccp_user we have flag pc_valid suggesting 0 is indeed valid. All known point code formats are <= 24bit, so we can easily use 0x as indicator for an unset PC, which removes the need to remember to set a second field for validity and keeps the structs nice and lean. Change-Id: Ib5715bf03a4de7713a7a809dfd821c700255ba8c --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c 2 files changed, 17 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/50/3450/1 diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index bbe425c..967912a 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -26,6 +26,14 @@ const char *osmo_ss7_pointcode_print(struct osmo_ss7_instance *inst, uint32_t pc); const char *osmo_ss7_pointcode_print2(struct osmo_ss7_instance *inst, uint32_t pc); +/* All known point-code formats have a length of or below 24 bit. + * A point-code value exceeding that is used to indicate an unset PC. */ +#define OSMO_SS7_PC_INVALID 0x +static inline bool osmo_ss7_pc_is_valid(uint32_t pc) +{ + return pc <= 0x00ff; +} + /*** * SS7 Routing Tables ***/ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index eb5a4ef..6db3f14 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -247,10 +247,16 @@ const char *_osmo_ss7_pointcode_print(char *buf, size_t len, struct osmo_ss7_instance *inst, uint32_t pc) { - const struct osmo_ss7_pc_fmt *pc_fmt = inst ? >cfg.pc_fmt : _pc_fmt; - unsigned int num_comp_exp = num_pc_comp_exp(pc_fmt); - const char *fmtstr = gen_pc_fmtstr(pc_fmt, _comp_exp); + const struct osmo_ss7_pc_fmt *pc_fmt; + unsigned int num_comp_exp; + const char *fmtstr; + if (!osmo_ss7_pc_is_valid(pc)) + return "(no PC)"; + + pc_fmt = inst ? >cfg.pc_fmt : _pc_fmt; + num_comp_exp = num_pc_comp_exp(pc_fmt); + fmtstr = gen_pc_fmtstr(pc_fmt, _comp_exp); OSMO_ASSERT(fmtstr); snprintf(buf, len, fmtstr, pc_comp_shift_and_mask(pc_fmt, 0, pc), -- To view, visit https://gerrit.osmocom.org/3450 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib5715bf03a4de7713a7a809dfd821c700255ba8c Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr
[PATCH] libosmo-sccp[master]: consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user
Review at https://gerrit.osmocom.org/3451 consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user A previous patch added ss7_instance primary_pc validity checks by means of OSMO_SS7_PC_INVALID. To be consistent, also adjust sccp_user accordingly. (see I7f0f0c89b7335d9da24161bfac8234be214ca00c) Remove the osmo_sccp_user's pc_valid field, replaced by pc=OSMO_SS7_PC_INVALID. Adjust all code paths. Simplify some log printing, using the fact that osmo_ss7_pointcode_print() now outputs "(no PC)" for unset point codes. Change-Id: I8684c9b559712072c772012890bbf7efa7c8eb35 --- M src/sccp_internal.h M src/sccp_scoc.c M src/sccp_user.c M src/sccp_vty.c 4 files changed, 16 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/51/3451/1 diff --git a/src/sccp_internal.h b/src/sccp_internal.h index 17dda13..66d768d 100644 --- a/src/sccp_internal.h +++ b/src/sccp_internal.h @@ -34,7 +34,6 @@ /*! \brief SSN and/or point code to which we are bound */ uint16_t ssn; uint32_t pc; - bool pc_valid; /* set if we are a server */ struct llist_head links; diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c index 9820c40..74fb0e7 100644 --- a/src/sccp_scoc.c +++ b/src/sccp_scoc.c @@ -1672,7 +1672,7 @@ struct osmo_sccp_addr *remote_addr; uint32_t local_pc = OSMO_SS7_PC_INVALID; - if (conn->user->pc_valid) + if (osmo_ss7_pc_is_valid(conn->user->pc)) local_pc = conn->user->pc; else if (osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) local_pc = s7i->cfg.primary_pc; diff --git a/src/sccp_user.c b/src/sccp_user.c index d49da29..1414572 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -48,13 +48,13 @@ /* First try to find match for PC + SSN */ llist_for_each_entry(scu, >users, list) { - if (scu->pc_valid && scu->pc == pc && scu->ssn == ssn) + if (osmo_ss7_pc_is_valid(scu->pc) && scu->pc == pc && scu->ssn == ssn) return scu; } /* Then try to match on SSN only */ llist_for_each_entry(scu, >users, list) { - if (!scu->pc_valid && scu->ssn == ssn) + if (!osmo_ss7_pc_is_valid(scu->pc) && scu->ssn == ssn) return scu; } @@ -65,28 +65,25 @@ * \param[in] inst SCCP Instance * \param[in] name human-readable name * \param[in] ssn Sub-System Number to bind to - * \param[in] pc Point Code to bind to (if any) - * \param[in] pc_valid Whether or not \ref pc is valid/used + * \param[in] pc Point Code to bind to, or OSMO_SS7_PC_INVALID if none. * \returns Callee-allocated SCCP User on success; negative otherwise */ static struct osmo_sccp_user * sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name, - osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc, bool pc_valid) + osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc) { struct osmo_sccp_user *scu; - if (!pc_valid) - pc = 0; scu = sccp_user_find(inst, ssn, pc); if (scu) { LOGP(DLSCCP, LOGL_ERROR, -"Cannot bind user '%s' to SSN=%u PC=%u=%s (pc_valid=%u), this SSN and PC" +"Cannot bind user '%s' to SSN=%u PC=%s, this SSN and PC" " is already bound by '%s'\n", -name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid, scu->name); +name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc), scu->name); return NULL; } - LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%u=%s (pc_valid=%u)\n", - name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid); + LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%s\n", + name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc)); scu = talloc_zero(inst, struct osmo_sccp_user); scu->name = talloc_strdup(scu, name); @@ -94,7 +91,6 @@ scu->prim_cb = prim_cb; scu->ssn = ssn; scu->pc = pc; - scu->pc_valid = pc_valid; llist_add_tail(>list, >users); return scu; @@ -104,13 +100,13 @@ * \param[in] inst SCCP Instance * \param[in] name human-readable name * \param[in] ssn Sub-System Number to bind to - * \param[in] pc Point Code to bind to (if any) + * \param[in] pc Point Code to bind to * \returns Callee-allocated SCCP User on success; negative otherwise */ struct osmo_sccp_user * osmo_sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name, osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc) { - return sccp_user_bind_pc(inst, name, prim_cb, ssn, pc, true); + return sccp_user_bind_pc(inst, name, prim_cb, ssn, pc); } /*! \brief Bind a given SCCP User to a given SSN (at any PC) @@ -122,7 +118,7 @@ osmo_sccp_user_bind(struct
[PATCH] libosmo-sccp[master]: ensure valid primary_pc in osmo_ss7_instance
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3355 to look at the new patch set (#4). ensure valid primary_pc in osmo_ss7_instance Initialize osmo_ss7_instance.cfg.primary_pc = OSMO_SS7_PC_INVALID. Adjust all code paths using primary_pc to ensure it is indeed valid. Rationale: It looks like we are going to use the primary point-code of an SS7 instance to derive a local SCCP address, e.g. for osmo-bsc and osmo-hnbgw. cs7-instance 1 point-code 1.2.3 ! sets osmo_ss7_instance.primary_pc = 1.2.3 sccp-address msc point-code 0.0.1 routing-indicator PC hnb iucs remote-addr msc ! derives cs7 instance 1 and local pc 1.2.3 If 'point-code 1.2.3' is omitted, this becomes '0.0.0' without the user noticing, and this happens for each client that omits it. I would like to barf when no local PC is set. Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c --- M src/osmo_ss7.c M src/osmo_ss7_vty.c M src/sccp_scoc.c M src/sccp_scrc.c M src/sccp_user.c 5 files changed, 19 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/55/3355/4 diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 6db3f14..f82f952 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -354,6 +354,8 @@ if (!inst) return NULL; + inst->cfg.primary_pc = OSMO_SS7_PC_INVALID; + inst->cfg.id = id; LOGSS7(inst, LOGL_INFO, "Creating SS7 Instance\n"); @@ -1825,7 +1827,7 @@ bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc) { OSMO_ASSERT(ss7_initialized); - if (pc == inst->cfg.primary_pc) + if (osmo_ss7_pc_is_valid(inst->cfg.primary_pc) && pc == inst->cfg.primary_pc) return true; /* FIXME: Secondary and Capability Point Codes */ return false; diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 476aedf..164b7f2 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -166,7 +166,7 @@ { struct osmo_ss7_instance *inst = vty->index; int pc = osmo_ss7_pointcode_parse(inst, argv[0]); - if (pc < 0) { + if (pc < 0 || !osmo_ss7_pc_is_valid((uint32_t)pc)) { vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } @@ -1536,7 +1536,7 @@ if (inst->cfg.pc_fmt.delimiter != '.') vty_out(vty, " point-code delimiter dash%s", VTY_NEWLINE); - if (inst->cfg.primary_pc) + if (osmo_ss7_pc_is_valid(inst->cfg.primary_pc)) vty_out(vty, " point-code %s%s", osmo_ss7_pointcode_print(inst, inst->cfg.primary_pc), VTY_NEWLINE); diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c index 3d43448..9820c40 100644 --- a/src/sccp_scoc.c +++ b/src/sccp_scoc.c @@ -1670,11 +1670,11 @@ { struct osmo_ss7_instance *s7i = conn->inst->ss7; struct osmo_sccp_addr *remote_addr; - uint32_t local_pc; + uint32_t local_pc = OSMO_SS7_PC_INVALID; if (conn->user->pc_valid) local_pc = conn->user->pc; - else + else if (osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) local_pc = s7i->cfg.primary_pc; if (conn->incoming) diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index e44201a..2afd696 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -91,8 +91,14 @@ param = >u.transfer; if (sua->mtp.opc) param->opc = sua->mtp.opc; - else + else { + if (!osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) { + LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n", +s7i->cfg.id); + return -1; + } param->opc = s7i->cfg.primary_pc; + } param->dpc = remote_pc; param->sls = sua->mtp.sls; param->sio = MTP_SIO(MTP_SI_SCCP, s7i->cfg.network_indicator); diff --git a/src/sccp_user.c b/src/sccp_user.c index 71b3262..d49da29 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -366,6 +366,11 @@ goto out_ss7; as_created = true; + if (!osmo_ss7_pc_is_valid(ss7->cfg.primary_pc)) { + LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n", +ss7->cfg.id); + goto out_ss7; + } as->cfg.routing_key.pc = ss7->cfg.primary_pc; /* install default route */ -- To view, visit https://gerrit.osmocom.org/3355 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c Gerrit-PatchSet: 4 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte
openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Patch Set 3: > Can it work here? I don't believe so, SQLITE3 ALTER TABLE is limited to adding new columns to the end of the table. Probably why it's done like this in previous db version upgrades. https://www.sqlite.org/lang_altertable.html -- To view, visit https://gerrit.osmocom.org/3435 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
osmo-bts[master]: TRX: Remove bogus extern global variable declarations
Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/3045 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: No
openbsc[master]: libcommon: Fix log output for bts>0.
Patch Set 2: Hi Harald, thank you for a reminder. I'll try to find some time to extend the patch. -- To view, visit https://gerrit.osmocom.org/3185 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Alexander ChemerisGerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No
[PATCH] osmo-bts[master]: TRX: Remove bogus extern global variable declarations
Hello Vadim Yanitskiy, Max, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3045 to look at the new patch set (#5). TRX: Remove bogus extern global variable declarations Those global variable declarations for non-existing variables were introduced in 8a8d73a691c709403be4adbe8f2a7150b4d5998a, let's remove them again. The source / destination IP address is a parameter of the phy_link, and not a global variable. Related: OS#1848 Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 --- M src/osmo-bts-trx/trx_if.h 1 file changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/45/3045/5 diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index 1fc454d..86fb18f 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -2,8 +2,6 @@ #define TRX_IF_H extern int transceiver_available; -extern const char *local_ip; -extern const char *remote_ip; extern int settsc_enabled; extern int setbsic_enabled; -- To view, visit https://gerrit.osmocom.org/3045 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy
osmo-bts[master]: TRX: Remove bogus extern global variable declarations
Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3045 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: No
openbsc[master]: SGSN: Fix RAN information exposed on GTP during PDP CTX CREATE
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3400 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6c79e42c5e08b28fe8182555302a5505fbbaa313 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
osmo-bts[master]: TRX: Remove bogus extern global variable declarations
Patch Set 4: Code-Review+1 Maxim has added the 'Related: OS#1848' label in the previous patch set. I think it makes sense to keep it. -- To view, visit https://gerrit.osmocom.org/3045 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald WelteGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: No
openbsc[master]: libmsc: report status report request flag from SMPP SUBMIT_SM
Patch Set 3: Verified+1 -- To view, visit https://gerrit.osmocom.org/3429 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
openbsc[master]: libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03...
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3437 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib70e534840308ed315f7add440351e649de3f907 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
openbsc[master]: utils: smpp_mirror: bounce Delivery Receipts as Delivery Ack...
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3436 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I877e228d8e174430f700631edbf9955972da7892 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
openbsc[master]: libmsc: add support for SMPP delivery receipts
Patch Set 2: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/3434/1/openbsc/src/libmsc/gsm_04_11.c File openbsc/src/libmsc/gsm_04_11.c: Line 637: rc = sms_route_mt_sms(conn, sms_report); > if mem is up, the program will likely not do *anything* useful anymore. Ins It is our general practise/consensus that we should not try to resolve memory allocation failures. There is some old code that does try to cope with it, and most probably in a bad way. So indeed, I think the best approach to deal with allocation failures is to terminate the program. WE don't allocate large amounts of memory anyway, and if our small allocations fail, the system is beyond hope. The difference to the kernel is that the NITB/MSC/... process will simply be restarted very quickly, without having an impact on other processes on the system. And if we have a leak, we should fix it, and users should complain with a meaningful error message (e.g. the assert). We could consider moving the ASSERT()s into the allocator, or have something like talloc macros that assert if they fail. But that's outside of the scope of this patch. -- To view, visit https://gerrit.osmocom.org/3434 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: Yes
openbsc[master]: libmsc: report status report request flag from SMPP SUBMIT_SM
Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/3429 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pablo Neira Ayuso Gerrit-HasComments: No
openbsc[master]: libmsc: update database to accomodate SMS status-report fields
Patch Set 3: Have you considered using ALTER TABLE? Can it work here? -- To view, visit https://gerrit.osmocom.org/3435 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Pablo Neira AyusoGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No