Upgrade Kamailio from v3.3.x to v4.0.0

The page contains the details about the changes that were made to old components during the development of v4.0.0 compared with what existed in v3.3.x. It does not include the brand new modules, focusing on how to upgrade database and configuration file from v3.3.x to run with Kamailio devel.

Modules

These sections presents notes, listed by modules, about changes that need to be made to Kamailio configuration file when upgrading from Kamailio v3.3.x to devel.

kex

  • km_append_branch() has been replaced with append_branch() from corex module

tm

  • Changed value of module parameter contacts_avp from AVP definition to XAVP name (string).
  • Added new module parameter contact_flows_avp that needs to be defined if contacts_avp parameter has been defined.

Database

MySQL - Updates to old database tables

Next are the SQL statements that must be executed to get the database structure required by modules that existed in v3.3.x.

ALTER TABLE address CHANGE COLUMN ip_addr ip_addr varchar(50) NOT NULL; # was varchar(48) NOT NULL

ALTER TABLE aliases CHANGE COLUMN expires expires datetime NOT NULL DEFAULT '2030-05-28 21:32:15'; # was datetime NOT NULL DEFAULT '2020-05-28 21:32:15'
ALTER TABLE aliases ADD UNIQUE ruid_idx (ruid);

ALTER TABLE lcr_gw CHANGE COLUMN ip_addr ip_addr varchar(50) DEFAULT NULL; # was varchar(47) DEFAULT NULL

ALTER TABLE location CHANGE COLUMN path path varchar(512) DEFAULT NULL; # was varchar(128) DEFAULT NULL
ALTER TABLE location CHANGE COLUMN expires expires datetime NOT NULL DEFAULT '2030-05-28 21:32:15'; # was datetime NOT NULL DEFAULT '2020-05-28 21:32:15'
ALTER TABLE location ADD UNIQUE ruid_idx (ruid);
ALTER TABLE location ADD INDEX expires_idx (expires);

ALTER TABLE active_watchers DROP INDEX active_watchers_pres; # was INDEX (presentity_uri)
ALTER TABLE active_watchers ADD INDEX active_watchers_pres (presentity_uri,event);

ALTER TABLE pua DROP INDEX tmp_record2_idx; # was INDEX (pres_id,etag)
ALTER TABLE pua DROP INDEX tmp_dlg2_idx; # was INDEX (pres_id,pres_uri,call_id,from_tag)
ALTER TABLE pua DROP INDEX tmp_record1_idx; # was INDEX (pres_id)
ALTER TABLE pua DROP INDEX dialog2_idx; # was INDEX (pres_id,pres_uri)
ALTER TABLE pua ADD INDEX dialog2_idx (call_id,from_tag);
ALTER TABLE pua DROP INDEX dialog1_idx; # was INDEX (call_id,from_tag,to_tag)
ALTER TABLE pua ADD INDEX dialog1_idx (pres_id,pres_uri);
ALTER TABLE pua DROP INDEX tmp_dlg1_idx; # was INDEX (call_id,from_tag)
ALTER TABLE pua ADD INDEX record_idx (pres_id);

ALTER TABLE rls_watchers DROP INDEX rls_watchers_delete; # was INDEX (callid,to_tag)

ALTER TABLE version ADD UNIQUE table_name_idx (table_name);

CREATE TABLE location_attrs (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  ruid varchar(64) NOT NULL DEFAULT '',
  username varchar(64) NOT NULL DEFAULT '',
  `domain` varchar(64) DEFAULT NULL,
  aname varchar(64) NOT NULL DEFAULT '',
  atype int(11) NOT NULL DEFAULT '0',
  avalue varchar(255) NOT NULL DEFAULT '',
  last_modified datetime NOT NULL DEFAULT '1900-01-01 00:00:01',
  PRIMARY KEY (id),
  KEY account_record_idx (username,domain,ruid),
  KEY last_modified_idx (last_modified)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO version (table_name, table_version) values ('location_attrs','1');
DELETE FROM version WHERE table_name='address';
INSERT INTO version (table_name, table_version) values ('address','6');
DELETE FROM version WHERE table_name='lcr_gw';
INSERT INTO version (table_name, table_version) values ('lcr_gw','3');
DELETE FROM version WHERE table_name='aliases';
INSERT INTO version (table_name, table_version) values ('aliases','6');
DELETE FROM version WHERE table_name='location';
INSERT INTO version (table_name, table_version) values ('location','6');

MySQL - New database tables

Next are the SQL statements that must be executed to get the database structure required by new modules added in v4.0.0.

CREATE TABLE sca_subscriptions (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  subscriber varchar(255) NOT NULL,
  aor varchar(255) NOT NULL,
  event int(11) NOT NULL DEFAULT '0',
  expires int(11) NOT NULL DEFAULT '0',
  state int(11) NOT NULL DEFAULT '0',
  app_idx int(11) NOT NULL DEFAULT '0',
  call_id varchar(255) NOT NULL,
  from_tag varchar(64) NOT NULL,
  to_tag varchar(64) NOT NULL,
  record_route text,
  notify_cseq int(11) NOT NULL,
  subscribe_cseq int(11) NOT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY sca_subscriptions_idx (subscriber,call_id,from_tag,to_tag),
  KEY sca_expires_idx (expires),
  KEY sca_subscribers_idx (subscriber,event)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_credentials (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  auth_username varchar(64) NOT NULL,
  did varchar(64) NOT NULL DEFAULT '_default',
  realm varchar(64) NOT NULL,
  password varchar(28) NOT NULL DEFAULT '',
  flags int(11) NOT NULL DEFAULT '0',
  ha1 varchar(32) NOT NULL,
  ha1b varchar(32) NOT NULL DEFAULT '',
  uid varchar(64) NOT NULL,
  PRIMARY KEY (id),
  KEY cred_idx (auth_username,did),
  KEY uid (uid),
  KEY did_idx (did),
  KEY realm_idx (realm)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_domain (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  did varchar(64) NOT NULL,
  domain varchar(64) NOT NULL,
  flags int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  UNIQUE KEY domain_idx (domain),
  KEY did_idx (did)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_domain_attrs (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  did varchar(64) DEFAULT NULL,
  name varchar(32) NOT NULL,
  type int(11) NOT NULL DEFAULT '0',
  value varchar(128) DEFAULT NULL,
  flags int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  UNIQUE KEY domain_attr_idx (did,name,value),
  KEY domain_did (did,flags)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_global_attrs (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  name varchar(32) NOT NULL,
  type int(11) NOT NULL DEFAULT '0',
  value varchar(128) DEFAULT NULL,
  flags int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  UNIQUE KEY global_attrs_idx (name,value)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_uri (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  uid varchar(64) NOT NULL,
  did varchar(64) NOT NULL,
  username varchar(64) NOT NULL,
  flags int(10) unsigned NOT NULL DEFAULT '0',
  scheme varchar(8) NOT NULL DEFAULT 'sip',
  PRIMARY KEY (id),
  KEY uri_idx1 (username,did,scheme),
  KEY uri_uid (uid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_uri_attrs (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  username varchar(64) NOT NULL,
  did varchar(64) NOT NULL,
  name varchar(32) NOT NULL,
  value varchar(128) DEFAULT NULL,
  type int(11) NOT NULL DEFAULT '0',
  flags int(10) unsigned NOT NULL DEFAULT '0',
  scheme varchar(8) NOT NULL DEFAULT 'sip',
  PRIMARY KEY (id),
  UNIQUE KEY uriattrs_idx (username,did,name,value,scheme)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE uid_user_attrs (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  uid varchar(64) NOT NULL,
  name varchar(32) NOT NULL,
  value varchar(128) DEFAULT NULL,
  type int(11) NOT NULL DEFAULT '0',
  flags int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  UNIQUE KEY userattrs_idx (uid,name,value)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

SER Modules

SER modules that had no equivalent in Kamailio were moved to modules/ folder. Several of them were renamed:

  • auth_db => uid_auth_db
  • avp_db => uid_auth_db
  • domain => uid_domain
  • gflags => uid_gflags
  • uri_db => uid_uri_db