Kamailio – Changing the From URI for Level3

So Level3 uses the E.164 recommendation for sending caller information. The problem with this is that they send a + prefix to the phone number. The problem with sending the + in the caller number, is that a common desk phone (Polycom/Cisco/Yealink/Aastra) will try to make an IP call to the number, or just fail. It seems like only cell phones handle the + character in a number.

So to keep that plus out of the network, I added the following code to my kamailio.cfg to “filter” out the + before sending to the caller.

$avp(s:from)=$fu;
$avp(s:from) = $(fu{re.subst,/\+1//g});
  if ($(avp(s:from){s.len}) == 0) { $avp(s:from)  = $fu; }
uac_replace_from("$avp(s:from)");

Maybe there is a better way, but this is working in production. Let me know if anyone has a better method!

Cisco OIP – Registering deals can suck

Sometimes the Cisco OIP program can be a pain in the ass!

Another partner registers the deal. You are awarded the business, taking less margin than the behemoth vendor in town, to get the deal. Now you’d like to increase your margins and you aren’t able to get the best pricing because behemoth vendor has protected pricing.

Kinda makes for an unfair advantage, and prohibits Cisco’s other partners from growing their business. Keeping the big guy in town big and the small guys small.

My suggestion, OIP Rebate program. When the deal is registered by someone else, but I am awarded the business. I should get that OIP discount as a rebate check.

Come on Cisco! Help your partners grow!

The Microsoft/Android war: Which patents are at stake?

Good article over at Network World about Patents Microsoft has claimed to hold. I’ve blogged about the silliness of patents like this in the past. People at the patent offices must be not tech savvy. I would NEVER have let such vague patents be allowed through.

Check some of them out: The Microsoft/Android war: Which patents are at stake?

Get an array of months in perl

I had a need to build an array of months between a set month and the current month. My purpose was to let the user choose a month to build a report for.

I’m using HTML::Mason, but you get the idea.

You’ll need Date::Manip::Recur

<select name="months" id="months">
% # Loop through the date objects
% for (@dates) {
%   # Assign the current month value to a scalar.
%   my $curMonth = $_->value();
%   # I only cared to see YYYYMM so I regex'd it.
%   $curMonth =~ s/^(\d{4})(\d{2}).*$/$1$2/;
      <option value="<% $curMonth %>"><% parseMonth($curMonth) %></option>
% }
</select>

<%init>
# Returns a date like "2011-01-01"
my $monStart = getOldestEntry($account);

use Date::Manip::Recur;
  my $recur = new Date::Manip::Recur;
  # Parse out the first of the month for every month since start until today.
  my $err = $recur->parse('0:0*0:0:0:0:0',$monStart,$monStart,"Today");
  # Return an array object of dates
  my @dates = $recur->dates();

sub parseMonth {
use Time::Local;
use Date::Format;
  my $md = shift;

  # Match on YYYYMM
  $date =~ m/^(\d{4})(\d{2})/;
  my $year = $1; my $mon = $2;

  # Convert to epoch
  my $time = timelocal(0,0,0,1,$mon-1,$year);

# Return back (%B %Y) as "August 2010"
return(time2str("%B %Y", $time));
}
</%init>

Ryobi s430 4-Stroke leaky gas cap.

My 4-Stroke Ryobi S430 Weed Trimmer has been great, I’ve not had problems like others have had with their, except it leaks gas on my right arm my from the fuel cap breather while I’m weed eating.

I haven’t hung it up in my garage because when I do, it constantly drips fuel out. I’m about to see if I can find a non-vented cap for storage, so I can hang it up without leaking. I know it needs the breather to run. I kinda wish I spent more money for a better built unit.

Any ideas?

Introducing Amazon Silk

Amazon just released a video with their new idea on web browsing. They’re going to implement it with the new Kindle Fire edition. It sounds pretty cool, but what about privacy? Amazon filtering your internets??

Trixbox Polycom Directory of all extensions for IP650

I needed to quickly generate a full directory for a receptionist console. Since Trixbox doesn’t do this, I wrote some Perl to do so. It’s pretty simple, you will need to install Polycom::Contact::Directory from CPAN. It will connect to the localhost MySQL server and pull all extensions out, make an xml and save it to the appropriate path. You will need to supply the MAC address, I guess I could modify a bit to pull the MAC out of the Endpoint Manager table, but I like being able to just supply the MAC.

Thanks Zachary Blair for the easy module!


#!/usr/bin/perl -w
# Quick script to hack out a directory for a mac address. I use it for the
# receptionist's BLF on her IP650 with sidecars.
use strict;
use Polycom::Contact::Directory;
use DBI;

# Grab the MAC address from ARGV and make a file
my $mac = $ARGV[0] or die "No MAC Specified\n";
my $contactFile = "/tftpboot/polycom/contacts/$mac-directory.xml";

# Create a new Empty Directory
my $dir = Polycom::Contact::Directory->new();
# Connect to the trixbox MySQL DB
my $dbh = DBI->connect('dbi:mysql:asterisk:localhost:3306','root','passw0rd',{ RaiseError => 1});

# Pull an array ref for the extensions
my $userAry = $dbh->selectall_arrayref("SELECT extension,name FROM users ORDER BY extension");

$dbh->disconnect();

# Set counter for speed dial index
my $x = 1;

# Loop through extensions
for my $a (@$userAry) {
# Split the trixbox name into first and last.
my ($fn,$ln) = split(/\s+/,$a->[1],2);

# My contacts are generally dirty, I'll make them look better. Some people may want
# to comment this out if you have people with unique capitalization.
$fn = ucfirst(lc($fn));
$ln = ucfirst(lc($ln));

# Insert the record into the object.
# I like the labels to be: extension firstname lastname "3721 Awesome Dude"
#  -- buddy_watching lets the polycom monitor BLF status. For this to work,
#     you must have feature.1.name="presence" feature.1.enabled="1" in
#     /tftpboot/sip.cfg
#  -- Check Polycom::Contact Documentation for Options
$dir->insert(
{   first_name => $fn,                  # <fn> in xml
last_name  => $ln,                  # <ln> in xml
contact    => "$a->[0]",            # <ct> in xml
label      => "$a->[0] $fn $ln",    # <lb> in xml
buddy_watching => 1,                # <bw> in xml
speed_index => $x,                  # <sd> in xml
buddy_block => 0,                   # <bb> in xml
auto_divert => 0,                   # <ad> in xml
auto_reject => 0,                   # <ar> in xml

},
);
$x++;
}

# Save the contact file.
$dir->save($contactFile);

1;

Oracle sues Google over Android and Java

Oracle sues Google over Android and Java | Relevant Results – CNET News.

Wow, I must have missed this news. Not sure how I feel. IMHO programming languages should be free and open. You can make your own IDE and sell it, but really the right to use the language should be free, or even in the case of Java, sell your VM to people.

Maybe I’m not well versed enough on the whole ordeal. Any insight anyone?