Browse code

cnxcc: New improvement for the cnxcc module. With this changes it is possible to account the connect cost for the call. This is useful for calls to premium numbers that have connection charges

Jose Luis Verdeguer authored on 04/01/2019 10:59:02
Showing 6 changed files
... ...
@@ -67,8 +67,9 @@ void check_calls_by_money(unsigned int ticks, void *param)
67 67
 
68 68
 					if(consumed_time > call->money_based.initial_pulse) {
69 69
 						call->consumed_amount =
70
-								(call->money_based.cost_per_second
71
-										* call->money_based.initial_pulse)
70
+								call->money_based.connect_cost
71
+								+ (call->money_based.cost_per_second
72
+										  * call->money_based.initial_pulse)
72 73
 								+ call->money_based.cost_per_second
73 74
 										  * ((consumed_time
74 75
 													 - call->money_based
... ...
@@ -102,8 +102,8 @@ static int __pv_get_calls(
102 102
 /*
103 103
  * Billing management functions
104 104
  */
105
-static int __set_max_credit(sip_msg_t *msg, char *pclient,
106
-		char *pcredit, char *pcps, char *pinitp, char *pfinishp);
105
+static int __set_max_credit(sip_msg_t *msg, char *pclient, char *pcredit,
106
+		char *pconnect, char *pcps, char *pinitp, char *pfinishp);
107 107
 static int __set_max_time(sip_msg_t *msg, char *pclient, char *pmaxsecs);
108 108
 static int __update_max_time(sip_msg_t *msg, char *pclient, char *psecs);
109 109
 static int __set_max_channels(sip_msg_t *msg, char *pclient, char *pmaxchan);
... ...
@@ -119,8 +119,8 @@ static int __add_call_by_cid(str *cid, call_t *call, credit_type_t type);
119 119
 static call_t *__alloc_new_call_by_time(
120 120
 		credit_data_t *credit_data, struct sip_msg *msg, int max_secs);
121 121
 static call_t *__alloc_new_call_by_money(credit_data_t *credit_data,
122
-		struct sip_msg *msg, double credit, double cost_per_second,
123
-		int initial_pulse, int final_pulse);
122
+		struct sip_msg *msg, double credit, double connect_cost,
123
+		double cost_per_second, int initial_pulse, int final_pulse);
124 124
 static void __notify_call_termination(sip_msg_t *msg);
125 125
 static void __free_call(call_t *call);
126 126
 static int __has_to_tag(struct sip_msg *msg);
... ...
@@ -152,7 +152,7 @@ static pv_export_t mod_pvs[] = {
152 152
 };
153 153
 
154 154
 static cmd_export_t cmds[] = {
155
-	{"cnxcc_set_max_credit", (cmd_function) __set_max_credit, 5,
155
+	{"cnxcc_set_max_credit", (cmd_function) __set_max_credit, 6,
156 156
 		cnxcc_set_max_credit_fixup, NULL, ANY_ROUTE},
157 157
 	{"cnxcc_set_max_time", (cmd_function) __set_max_time, 2,
158 158
 		fixup_spve_igp, fixup_free_spve_igp, ANY_ROUTE},
... ...
@@ -229,7 +229,9 @@ static int cnxcc_set_max_credit_fixup(void **param, int param_no)
229 229
 		case 3:
230 230
 			return fixup_spve_all(param, param_no);
231 231
 		case 4:
232
+			return fixup_spve_all(param, param_no);
232 233
 		case 5:
234
+		case 6:
233 235
 			return fixup_igp_all(param, param_no);
234 236
 		default:
235 237
 			LM_ERR("unexpected parameter number: %d\n", param_no);
... ...
@@ -1261,8 +1263,8 @@ error:
1261 1263
 }
1262 1264
 
1263 1265
 static call_t *__alloc_new_call_by_money(credit_data_t *credit_data,
1264
-		struct sip_msg *msg, double credit, double cost_per_second,
1265
-		int initial_pulse, int final_pulse)
1266
+		struct sip_msg *msg, double credit, double connect_cost,
1267
+		double cost_per_second, int initial_pulse, int final_pulse)
1266 1268
 {
1267 1269
 	call_t *call = NULL;
1268 1270
 
... ...
@@ -1296,9 +1298,11 @@ static call_t *__alloc_new_call_by_money(credit_data_t *credit_data,
1296 1298
 	call->sip_data.from_tag.len = 0;
1297 1299
 
1298 1300
 	call->consumed_amount = initial_pulse * cost_per_second;
1301
+	call->connect_amount = connect_cost;
1299 1302
 	call->confirmed = FALSE;
1300 1303
 	call->max_amount = credit;
1301 1304
 
1305
+	call->money_based.connect_cost = connect_cost;
1302 1306
 	call->money_based.cost_per_second = cost_per_second;
1303 1307
 	call->money_based.initial_pulse = initial_pulse;
1304 1308
 	call->money_based.final_pulse = final_pulse;
... ...
@@ -1569,13 +1573,13 @@ static inline int get_pv_value(
1569 1573
 	return 0;
1570 1574
 }
1571 1575
 
1572
-static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1573
-		str *scredit, str *scps, int initp, int finishp)
1576
+static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
1577
+		str *sconnect, str *scps, int initp, int finishp)
1574 1578
 {
1575 1579
 	credit_data_t *credit_data = NULL;
1576 1580
 	call_t *call = NULL;
1577 1581
 
1578
-	double credit = 0, cost_per_second = 0;
1582
+	double credit = 0, connect_cost = 0, cost_per_second = 0;
1579 1583
 
1580 1584
 	if(msg->first_line.type != SIP_REQUEST
1581 1585
 			|| msg->first_line.u.request.method_value != METHOD_INVITE) {
... ...
@@ -1601,6 +1605,13 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1601 1605
 		return -1;
1602 1606
 	}
1603 1607
 
1608
+	connect_cost = str2double(sconnect);
1609
+
1610
+	if(connect_cost < 0) {
1611
+		LM_ERR("connect_cost value must be >= 0: %f\n", connect_cost);
1612
+		return -1;
1613
+	}
1614
+
1604 1615
 	cost_per_second = str2double(scps);
1605 1616
 
1606 1617
 	if(cost_per_second <= 0) {
... ...
@@ -1609,26 +1620,26 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1609 1620
 	}
1610 1621
 
1611 1622
 	LM_DBG("Setting up new call for client [%.*s], max-credit[%f], "
1612
-			"cost-per-sec[%f], initial-pulse [%d], "
1613
-			"final-pulse [%d], call-id[%.*s]\n",
1614
-			sclient->len, sclient->s, credit,
1615
-			cost_per_second, initp, finishp,
1616
-			msg->callid->body.len, msg->callid->body.s);
1623
+		   "connect-cost[%f], cost-per-sec[%f], initial-pulse [%d], "
1624
+		   "final-pulse [%d], call-id[%.*s]\n",
1625
+			sclient->len, sclient->s, credit, connect_cost, cost_per_second,
1626
+			initp, finishp, msg->callid->body.len, msg->callid->body.s);
1617 1627
 
1618 1628
 	set_ctrl_flag(msg);
1619 1629
 
1620 1630
 	if((credit_data = __get_or_create_credit_data_entry(sclient, CREDIT_MONEY))
1621 1631
 			== NULL) {
1622 1632
 		LM_ERR("Error retrieving credit data from shared memory for client "
1623
-				"[%.*s]\n", sclient->len, sclient->s);
1633
+			   "[%.*s]\n",
1634
+				sclient->len, sclient->s);
1624 1635
 		return -1;
1625 1636
 	}
1626 1637
 
1627
-	if((call = __alloc_new_call_by_money(credit_data, msg, credit,
1638
+	if((call = __alloc_new_call_by_money(credit_data, msg, credit, connect_cost,
1628 1639
 				cost_per_second, initp, finishp))
1629 1640
 			== NULL) {
1630
-		LM_ERR("Unable to allocate new call for client [%.*s]\n",
1631
-				sclient->len, sclient->s);
1641
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1642
+				sclient->s);
1632 1643
 		return -1;
1633 1644
 	}
1634 1645
 
... ...
@@ -1641,43 +1652,49 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1641 1652
 	return 1;
1642 1653
 }
1643 1654
 
1644
-static int __set_max_credit(sip_msg_t *msg, char *pclient,
1645
-		char *pcredit, char *pcps, char *pinitp, char *pfinishp)
1655
+static int __set_max_credit(sip_msg_t *msg, char *pclient, char *pcredit,
1656
+		char *pconnect, char *pcps, char *pinitp, char *pfinishp)
1646 1657
 {
1647 1658
 	str sclient;
1648 1659
 	str scredit;
1660
+	str sconnect;
1649 1661
 	str scps;
1650 1662
 	int initp;
1651 1663
 	int finishp;
1652 1664
 
1653
-	if(msg==NULL || pclient==NULL || pcredit==NULL || pcps==NULL
1654
-			|| pinitp==NULL || pfinishp==NULL) {
1665
+	if(msg == NULL || pclient == NULL || pcredit == NULL || pconnect == NULL
1666
+			|| pcps == NULL || pinitp == NULL || pfinishp == NULL) {
1655 1667
 		LM_ERR("invalid parameters\n");
1656 1668
 		return -1;
1657 1669
 	}
1658 1670
 
1659
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1671
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1660 1672
 		LM_ERR("failed to get client parameter\n");
1661 1673
 		return -1;
1662 1674
 	}
1663
-	if(fixup_get_svalue(msg, (gparam_t*)pcredit, &scredit)<0) {
1675
+	if(fixup_get_svalue(msg, (gparam_t *)pcredit, &scredit) < 0) {
1664 1676
 		LM_ERR("failed to get credit parameter\n");
1665 1677
 		return -1;
1666 1678
 	}
1667
-	if(fixup_get_svalue(msg, (gparam_t*)pcps, &scps)<0) {
1679
+	if(fixup_get_svalue(msg, (gparam_t *)pconnect, &sconnect) < 0) {
1680
+		LM_ERR("failed to get connect parameter\n");
1681
+		return -1;
1682
+	}
1683
+	if(fixup_get_svalue(msg, (gparam_t *)pcps, &scps) < 0) {
1668 1684
 		LM_ERR("failed to get cps parameter\n");
1669 1685
 		return -1;
1670 1686
 	}
1671
-	if(fixup_get_ivalue(msg, (gparam_t*)pinitp, &initp)<0) {
1687
+	if(fixup_get_ivalue(msg, (gparam_t *)pinitp, &initp) < 0) {
1672 1688
 		LM_ERR("failed to get init pulse parameter\n");
1673 1689
 		return -1;
1674 1690
 	}
1675
-	if(fixup_get_ivalue(msg, (gparam_t*)pfinishp, &finishp)<0) {
1691
+	if(fixup_get_ivalue(msg, (gparam_t *)pfinishp, &finishp) < 0) {
1676 1692
 		LM_ERR("failed to get finish pulse parameter\n");
1677 1693
 		return -1;
1678 1694
 	}
1679 1695
 
1680
-	return ki_set_max_credit(msg, &sclient, &scredit, &scps, initp, finishp);
1696
+	return ki_set_max_credit(
1697
+			msg, &sclient, &scredit, &sconnect, &scps, initp, finishp);
1681 1698
 }
1682 1699
 
1683 1700
 static int ki_terminate_all(sip_msg_t *msg, str *sclient)
... ...
@@ -1691,9 +1708,8 @@ static int ki_terminate_all(sip_msg_t *msg, str *sclient)
1691 1708
 	}
1692 1709
 
1693 1710
 	if(try_get_credit_data_entry(sclient, &credit_data) != 0) {
1694
-		LM_DBG("credit data for [%.*s] on [%.*s] not found\n",
1695
-				sclient->len, sclient->s,
1696
-				msg->callid->body.len, msg->callid->body.s);
1711
+		LM_DBG("credit data for [%.*s] on [%.*s] not found\n", sclient->len,
1712
+				sclient->s, msg->callid->body.len, msg->callid->body.s);
1697 1713
 		return -1;
1698 1714
 	}
1699 1715
 
... ...
@@ -1705,7 +1721,7 @@ static int __terminate_all(sip_msg_t *msg, char *pclient, char *p2)
1705 1721
 {
1706 1722
 	str sclient;
1707 1723
 
1708
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1724
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1709 1725
 		LM_ERR("failed to get client parameter\n");
1710 1726
 		return -1;
1711 1727
 	}
... ...
@@ -1713,8 +1729,8 @@ static int __terminate_all(sip_msg_t *msg, char *pclient, char *p2)
1713 1729
 	return ki_terminate_all(msg, &sclient);
1714 1730
 }
1715 1731
 
1716
-static int __get_channel_count_helper(sip_msg_t *msg, str *sclient,
1717
-		pv_spec_t *pvcount)
1732
+static int __get_channel_count_helper(
1733
+		sip_msg_t *msg, str *sclient, pv_spec_t *pvcount)
1718 1734
 {
1719 1735
 	credit_data_t *credit_data = NULL;
1720 1736
 	pv_value_t countval;
... ...
@@ -1755,7 +1771,7 @@ static int __get_channel_count(sip_msg_t *msg, char *pclient, char *pcount)
1755 1771
 {
1756 1772
 	str sclient;
1757 1773
 
1758
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1774
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1759 1775
 		LM_ERR("failed to get client parameter\n");
1760 1776
 		return -1;
1761 1777
 	}
... ...
@@ -1769,7 +1785,7 @@ static int ki_get_channel_count(sip_msg_t *msg, str *sclient, str *pvname)
1769 1785
 
1770 1786
 	pvcount = pv_cache_get(pvname);
1771 1787
 
1772
-	if(pvcount==NULL) {
1788
+	if(pvcount == NULL) {
1773 1789
 		LM_ERR("failed to get pv spec for [%.*s]\n", pvname->len, pvname->s);
1774 1790
 		return -1;
1775 1791
 	}
... ...
@@ -1811,14 +1827,16 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
1811 1827
 	}
1812 1828
 
1813 1829
 	LM_DBG("Setting up new call for client [%.*s], max-chan[%d], "
1814
-			"call-id[%.*s]\n",
1815
-			sclient->len, sclient->s, max_chan,
1816
-			msg->callid->body.len, msg->callid->body.s);
1830
+		   "call-id[%.*s]\n",
1831
+			sclient->len, sclient->s, max_chan, msg->callid->body.len,
1832
+			msg->callid->body.s);
1817 1833
 
1818
-	if((credit_data = __get_or_create_credit_data_entry(sclient,
1819
-				CREDIT_CHANNEL)) == NULL) {
1834
+	if((credit_data = __get_or_create_credit_data_entry(
1835
+				sclient, CREDIT_CHANNEL))
1836
+			== NULL) {
1820 1837
 		LM_ERR("Error retrieving credit data from shared memory for client "
1821
-				"[%.*s]\n", sclient->len, sclient->s);
1838
+			   "[%.*s]\n",
1839
+				sclient->len, sclient->s);
1822 1840
 		return -1;
1823 1841
 	}
1824 1842
 
... ...
@@ -1828,15 +1846,13 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
1828 1846
 	if(credit_data->concurrent_calls + 1 > max_chan)
1829 1847
 		return -3; // you have the max amount of established calls already
1830 1848
 
1831
-	if((call = alloc_new_call_by_channel(credit_data, msg, max_chan))
1832
-			== NULL) {
1833
-		LM_ERR("Unable to allocate new call for client [%.*s]\n",
1834
-				sclient->len, sclient->s);
1849
+	if((call = alloc_new_call_by_channel(credit_data, msg, max_chan)) == NULL) {
1850
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1851
+				sclient->s);
1835 1852
 		return -1;
1836 1853
 	}
1837 1854
 
1838
-	if(__add_call_by_cid(&call->sip_data.callid, call, CREDIT_CHANNEL)
1839
-			!= 0) {
1855
+	if(__add_call_by_cid(&call->sip_data.callid, call, CREDIT_CHANNEL) != 0) {
1840 1856
 		LM_ERR("Unable to allocate new cid_by_client for client [%.*s]\n",
1841 1857
 				sclient->len, sclient->s);
1842 1858
 		return -1;
... ...
@@ -1850,11 +1866,11 @@ static int __set_max_channels(sip_msg_t *msg, char *pclient, char *pmaxchan)
1850 1866
 	str sclient;
1851 1867
 	int max_chan = 0;
1852 1868
 
1853
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1869
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1854 1870
 		LM_ERR("failed to get client parameter\n");
1855 1871
 		return -1;
1856 1872
 	}
1857
-	if(fixup_get_ivalue(msg, (gparam_t*)pmaxchan, &max_chan)<0) {
1873
+	if(fixup_get_ivalue(msg, (gparam_t *)pmaxchan, &max_chan) < 0) {
1858 1874
 		LM_ERR("failed to get max chan parameter\n");
1859 1875
 		return -1;
1860 1876
 	}
... ...
@@ -1898,21 +1914,21 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
1898 1914
 	}
1899 1915
 
1900 1916
 	LM_DBG("Setting up new call for client [%.*s], max-secs[%d], "
1901
-			"call-id[%.*s]\n",
1902
-			sclient->len, sclient->s, max_secs,
1903
-			msg->callid->body.len, msg->callid->body.s);
1917
+		   "call-id[%.*s]\n",
1918
+			sclient->len, sclient->s, max_secs, msg->callid->body.len,
1919
+			msg->callid->body.s);
1904 1920
 
1905 1921
 	if((credit_data = __get_or_create_credit_data_entry(sclient, CREDIT_TIME))
1906 1922
 			== NULL) {
1907 1923
 		LM_ERR("Error retrieving credit data from shared memory for client "
1908
-				"[%.*s]\n", sclient->len, sclient->s);
1924
+			   "[%.*s]\n",
1925
+				sclient->len, sclient->s);
1909 1926
 		return -1;
1910 1927
 	}
1911 1928
 
1912
-	if((call = __alloc_new_call_by_time(credit_data, msg, max_secs))
1913
-			== NULL) {
1914
-		LM_ERR("Unable to allocate new call for client [%.*s]\n",
1915
-				sclient->len, sclient->s);
1929
+	if((call = __alloc_new_call_by_time(credit_data, msg, max_secs)) == NULL) {
1930
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1931
+				sclient->s);
1916 1932
 		return -1;
1917 1933
 	}
1918 1934
 
... ...
@@ -1930,11 +1946,11 @@ static int __set_max_time(sip_msg_t *msg, char *pclient, char *pmaxsecs)
1930 1946
 	str sclient;
1931 1947
 	int max_secs = 0;
1932 1948
 
1933
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1949
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1934 1950
 		LM_ERR("failed to get client parameter\n");
1935 1951
 		return -1;
1936 1952
 	}
1937
-	if(fixup_get_ivalue(msg, (gparam_t*)pmaxsecs, &max_secs)<0) {
1953
+	if(fixup_get_ivalue(msg, (gparam_t *)pmaxsecs, &max_secs) < 0) {
1938 1954
 		LM_ERR("failed to get max secs parameter\n");
1939 1955
 		return -1;
1940 1956
 	}
... ...
@@ -1966,8 +1982,8 @@ static int ki_update_max_time(sip_msg_t *msg, str *sclient, int secs)
1966 1982
 	}
1967 1983
 
1968 1984
 	LM_DBG("Updating call for client [%.*s], max-secs[%d], call-id[%.*s]\n",
1969
-			sclient->len, sclient->s, secs,
1970
-			msg->callid->body.len, msg->callid->body.s);
1985
+			sclient->len, sclient->s, secs, msg->callid->body.len,
1986
+			msg->callid->body.s);
1971 1987
 
1972 1988
 
1973 1989
 	struct str_hash_table *ht = NULL;
... ...
@@ -1981,8 +1997,7 @@ static int ki_update_max_time(sip_msg_t *msg, str *sclient, int secs)
1981 1997
 	cnxcc_unlock(_data.time.lock);
1982 1998
 
1983 1999
 	if(e == NULL) {
1984
-		LM_ERR("Client [%.*s] was not found\n", sclient->len,
1985
-				sclient->s);
2000
+		LM_ERR("Client [%.*s] was not found\n", sclient->len, sclient->s);
1986 2001
 		return -1;
1987 2002
 	}
1988 2003
 
... ...
@@ -2017,11 +2032,11 @@ static int __update_max_time(sip_msg_t *msg, char *pclient, char *psecs)
2017 2032
 	str sclient;
2018 2033
 	int secs = 0;
2019 2034
 
2020
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
2035
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
2021 2036
 		LM_ERR("failed to get client parameter\n");
2022 2037
 		return -1;
2023 2038
 	}
2024
-	if(fixup_get_ivalue(msg, (gparam_t*)psecs, &secs)<0) {
2039
+	if(fixup_get_ivalue(msg, (gparam_t *)psecs, &secs) < 0) {
2025 2040
 		LM_ERR("failed to get secs parameter\n");
2026 2041
 		return -1;
2027 2042
 	}
... ...
@@ -158,6 +158,7 @@ typedef struct sip_data
158 158
 
159 159
 typedef struct money_spec_data
160 160
 {
161
+	double connect_cost;
161 162
 	double cost_per_second;
162 163
 	int initial_pulse;
163 164
 	int final_pulse;
... ...
@@ -178,6 +179,7 @@ typedef struct call
178 179
 
179 180
 	unsigned int start_timestamp;
180 181
 	double consumed_amount;
182
+	double connect_amount;
181 183
 
182 184
 	unsigned int dlg_h_entry;
183 185
 	unsigned int dlg_h_id;
... ...
@@ -115,13 +115,14 @@ void rpc_check_client_stats(rpc_t *rpc, void *ctx)
115 115
 					"id:%d,confirmed:%s,local_consumed_amount:%f,global_"
116 116
 					"consumed_amount:%f,local_max_amount:%f,global_max_amount:%"
117 117
 					"f,call_id:%.*s,start_timestamp:%d"
118
-					",inip:%d,finp:%d,cps:%f;",
118
+					",inip:%d,finp:%d,connect:%f,cps:%f;",
119 119
 					index, call->confirmed ? "yes" : "no",
120 120
 					call->consumed_amount, credit_data->consumed_amount,
121 121
 					call->max_amount, credit_data->max_amount,
122 122
 					call->sip_data.callid.len, call->sip_data.callid.s,
123 123
 					call->start_timestamp, call->money_based.initial_pulse,
124 124
 					call->money_based.final_pulse,
125
+					call->money_based.connect_cost,
125 126
 					call->money_based.cost_per_second);
126 127
 		else
127 128
 			snprintf(row_buffer, sizeof(row_buffer),
... ...
@@ -23,6 +23,15 @@
23 23
 	    <email>carlos.ruizdiaz@gmail.com</email>
24 24
 	</address>
25 25
 	</author>
26
+        <editor>
27
+        <firstname>Jose Luis</firstname>
28
+        <surname>Verdeguer</surname>
29
+        <email>verdeguer@zoonsuite.com</email>
30
+        <affiliation><orgname>Zoon Suite</orgname></affiliation>
31
+        <address>
32
+                <email>verdeguer@zoonsuite.com</email>
33
+        </address>
34
+        </editor>
26 35
     </authorgroup>
27 36
     <copyright>
28 37
 	<year>2013</year>
... ...
@@ -32,6 +41,10 @@
32 41
 	<year>2014</year>
33 42
 	<holder>Carlos Ruiz Díaz, carlos@latamvoices.com</holder>
34 43
     </copyright>
44
+    <copyright>
45
+	<year>2018</year>
46
+	<holder>Jose Luis Verdeguer</holder>
47
+    </copyright>
35 48
 
36 49
     </bookinfo>
37 50
 
... ...
@@ -123,11 +123,11 @@ modparam("cnxcc", "credit_check_period", 1)
123 123
 		<title>Functions</title>
124 124
 		<section id="cnxcc.f.set_max_credit">
125 125
 			<title>
126
-				<function moreinfo="none">cnxcc_set_max_credit(customer, maxcredit, cps, ipulse, fpulse)</function>
126
+				<function moreinfo="none">cnxcc_set_max_credit(customer, maxcredit, connect, cps, ipulse, fpulse)</function>
127 127
 			</title>
128 128
 			<para>
129 129
 				Associates the call with a customer id and sets the max credit,
130
-				cost per second, initial pulse and final pulse. The discount
130
+				connect cost, cost per second, initial pulse and final pulse. The discount
131 131
 				is calculated in pulses (30/6, 1/1, etc) and subtracted from the pool
132 132
 				of credit.
133 133
 			</para>
... ...
@@ -136,7 +136,7 @@ modparam("cnxcc", "credit_check_period", 1)
136 136
 				a string.
137 137
 			</para>
138 138
 			<para>
139
-				The maxcredit and cps can be double (float) or integer values, they
139
+				The maxcredit, connect and cps can be double (float) or integer values, they
140 140
 				have to be provided as static string values of variables holding string
141 141
 				values.
142 142
 			</para>
... ...
@@ -171,15 +171,16 @@ modparam("cnxcc", "credit_check_period", 1)
171 171
 				<title>cnxcc_set_max_credit()</title>
172 172
 				<programlisting format="linespecific">
173 173
 ...
174
-cnxcc_set_max_credit("john-doe", "100.5", "0.5", "20", "10");
174
+cnxcc_set_max_credit("john-doe", "100", "3.0", "0.5", 60, 1);
175 175
 ...
176
-$var(customer) = "john-doe-premium"; # customer id
177
-$var(credit) = "100";       # max credit
178
-$var(cps)   = "2.00";       # cost per second
179
-$var(initial_p)   = 30;     # initial pulse
180
-$var(final_p)     = 6;      # final pulse
181
-cnxcc_set_max_credit("$var(customer)", "$var(credit)", "$var(cps)",
182
-        "$var(initial_p)", "$var(final_p)");
176
+$var(customer)  = "john-doe-premium"; # customer id
177
+$var(credit)    = "100";  # max credit
178
+$var(connect)   = "3.0";  # connect const
179
+$var(cps)       = "0.5";  # cost per second
180
+$var(initial_p) = 60;     # initial pulse
181
+$var(final_p)   = 1;      # final pulse
182
+cnxcc_set_max_credit("$var(customer)", "$var(credit)", "$var(connect)",
183
+        "$var(cps)", "$var(initial_p)", "$var(final_p)");
183 184
 ...
184 185
 </programlisting>
185 186
 			</example>