The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Tuesday, April 23, 2019

Dealing with phone numbers

Project: Wolowizard only supports NANP numbers, but since those numbers come via The Protocol Stack From Hell clearly marked as NANP, it's easy to determine there if a number is NANP or not. It's not quite as simple in “Project: Sippy-Cup” since SIP is … a bit loose with the data formatting.

There, the numbers are formatted as a tel: URI (or a sip: URI but the differences are minor). If the number is “global,” it's easy to determine a NANP number because it will be marked with a “+1” (“1” being the country code for North America). So, tel:+1-501-555-1212 is most definitely a NANP number, while tel:+501-555-1212 is not.

Things get a bit more muddy when we receive a so-called “local” number. RFC-3966 clearly states that a “local” tel: URI MUST (as defined in RFC-2119) contain a phone-context attribute—except when it doesn't (I swear—the RFC contradicts itself on that point; tel:8005551212 is valid, even though it's a “local” number and missing a phone-context attribute because it's a “national freephone number”). So tel:555-1212;phone-context=+1501 is NANP, while tel:555-1212;phone-context=+501 is not (look closely at the two—one has a country code of “1” while the other has a country code of “501”). It's worse though, because while tel:555-1212;phone-context=+1501 is NANP, you cannot use the phone-context attribute to reconstruct a global number (the RFC contains the following example: tel:863-1234;phone-context=+1-914-555—um … yeah).

To further complicate things, the phone-context attribute does not have to contain digits—it can be a domain name. So tel:555-1212;phone-context=example.com is a valid number. Is it NANP? International? Who knows?

So what does “Project: Sippy-Cup” do? If it receives a “local” number with a “+1” country code in the phone-context attribute, it's marked as NANP; any other country code is it marked as non-NANP. If the phone-context attribute contains a domain name, it is treated as a NANP number (based on what I saw in production). And if there's a missing phone-context attribute for a “local” number, “Project: Sippy-Cup” treats it as a NANP number if it has at least 10 digits.

Now, why do I care about this? Because we want to avoid doing an expensive database query for non-NANP and invalid NANP numbers, but “Project: Heimdall” wants all the numbers for tracking potentially fraudulent calls.

Obligatory Picture

[It's the most wonderful time of the year!]

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: http://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

http://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2019 by Sean Conner. All Rights Reserved.