nickvsnetworking / pyhss

Python HSS / Diameter Server
GNU Affero General Public License v3.0
71 stars 59 forks source link

ULA failed to be generated #203

Open dchard opened 2 months ago

dchard commented 2 months ago

On v.1.0.2 auth succeeds, but the ULA fails:

2024-08-15T10:31:09.045802+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Current APN List: ['1']
2024-08-15T10:31:09.045854+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] APN list: ['1']
2024-08-15T10:31:09.045895+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Processing APN ID 1
2024-08-15T10:31:09.045947+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Getting APN 1
2024-08-15T10:31:09.045994+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Setting APN Configuration Profile
2024-08-15T10:31:09.046040+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Setting APN AMBR
2024-08-15T10:31:09.046086+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Setting APN Allocation-Retention-Priority
2024-08-15T10:31:09.046135+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] Get_SUBSCRIBER_ROUTING for subscriber_id 1 and apn_id 1
2024-08-15T10:31:09.046193+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] No static UE IP found: No row was found when one was required
2024-08-15T10:31:09.046244+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [DEBUG] MIP6-Agent-Info present (Static SMF/PGW-C), value string
2024-08-15T10:31:09.046293+00:00 testhss python3[15377]: [08/15/2024 12:30:09] [ERROR] [diameter.py] [generateDiameterResponse] [ULR] Error generating response: Traceback (most recent call last):
2024-08-15T10:31:09.046350+00:00 testhss python3[15377]:   File "/etc/pyhss/lib/diameter.py", line 822, in generateDiameterResponse
2024-08-15T10:31:09.046398+00:00 testhss python3[15377]:     response = diameterApplication["responseMethod"](packet_vars, avps)
2024-08-15T10:31:09.046484+00:00 testhss python3[15377]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-15T10:31:09.046528+00:00 testhss python3[15377]:   File "/etc/pyhss/lib/diameter.py", line 1608, in Answer_16777251_316
2024-08-15T10:31:09.046570+00:00 testhss python3[15377]:     MIP_Home_Agent_Address = self.generate_avp(334, '40', self.ip_to_hex(apn_data['pgw_address']))
2024-08-15T10:31:09.046611+00:00 testhss python3[15377]:                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-15T10:31:09.046661+00:00 testhss python3[15377]:   File "/etc/pyhss/lib/diameter.py", line 109, in ip_to_hex
2024-08-15T10:31:09.046702+00:00 testhss python3[15377]:     ip_hex += format(ipaddress.IPv6Address(ip), 'X')
2024-08-15T10:31:09.046741+00:00 testhss python3[15377]:                      ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-15T10:31:09.046780+00:00 testhss python3[15377]:   File "/usr/lib/python3.12/ipaddress.py", line 1958, in __init__
2024-08-15T10:31:09.046825+00:00 testhss python3[15377]:     self._ip = self._ip_int_from_string(addr_str)
2024-08-15T10:31:09.046865+00:00 testhss python3[15377]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-15T10:31:09.046905+00:00 testhss python3[15377]:   File "/usr/lib/python3.12/ipaddress.py", line 1674, in _ip_int_from_string
2024-08-15T10:31:09.046944+00:00 testhss python3[15377]:     raise AddressValueError(msg)
2024-08-15T10:31:09.046984+00:00 testhss python3[15377]: ipaddress.AddressValueError: At least 3 parts expected in 'string'

Simple single APN setup with dynamic IPv4 only addresses.

APN config:

[
  {
    "ip_version": 0,
    "qci": 9,
    "nidd_mechanism": 0,
    "nidd_rds": 0,
    "apn_id": 1,
    "arp_priority": 15,
    "arp_preemption_capability": true,
    "nidd_preferred_data_mode": 0,
    "pgw_address": "string",
    "arp_preemption_vulnerability": true,
    "last_modified": "2024-08-14T16:03:48Z",
    "sgw_address": "string",
    "charging_rule_list": "string",
    "charging_characteristics": "stri",
    "nbiot": true,
    "apn_ambr_dl": 0,
    "nidd_scef_id": "string",
    "apn": "internet",
    "apn_ambr_ul": 0,
    "nidd_scef_realm": "string"
  }
]

Subscriber config:

[
  {
    "subscriber_id": 1,
    "nam": 0,
    "last_modified": "2024-08-14T16:08:00Z",
    "enabled": true,
    "roaming_enabled": true,
    "auc_id": 1,
    "roaming_rule_list": "string",
    "default_apn": 1,
    "subscribed_rau_tau_timer": 0,
    "apn_list": "1",
    "serving_mme": "testmme.corenetwork.lte",
    "msisdn": "9990000001",
    "serving_mme_timestamp": "2024-08-15T10:30:09Z",
    "imsi": "999119990000001",
    "ue_ambr_dl": 1000000,
    "serving_mme_realm": "corenetwork.lte",
    "ue_ambr_ul": 1000000,
    "serving_mme_peer": "testmme.corenetwork.lte;testhss.corenetwork.lte"
  }
]

Not entirely user why the ULR code looks for any IP addresses, let alone V6 addresses.

killdashnine commented 2 months ago

Hi, you should set "pgw_address": "string" on your APN config, to null and not 'string' (or the real IP) as that cannot be converted to an IP address.