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 1261
 }
1262 1262
 
1263 1263
 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)
1264
+		struct sip_msg *msg, double credit, double connect_cost,
1265
+		double cost_per_second, int initial_pulse, int final_pulse)
1266 1266
 {
1267 1267
 	call_t *call = NULL;
1268 1268
 
... ...
@@ -1296,9 +1298,11 @@ static call_t *__alloc_new_call_by_money(credit_data_t *credit_data,
1296 1296
 	call->sip_data.from_tag.len = 0;
1297 1297
 
1298 1298
 	call->consumed_amount = initial_pulse * cost_per_second;
1299
+	call->connect_amount = connect_cost;
1299 1300
 	call->confirmed = FALSE;
1300 1301
 	call->max_amount = credit;
1301 1302
 
1303
+	call->money_based.connect_cost = connect_cost;
1302 1304
 	call->money_based.cost_per_second = cost_per_second;
1303 1305
 	call->money_based.initial_pulse = initial_pulse;
1304 1306
 	call->money_based.final_pulse = final_pulse;
... ...
@@ -1569,13 +1573,13 @@ static inline int get_pv_value(
1569 1569
 	return 0;
1570 1570
 }
1571 1571
 
1572
-static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1573
-		str *scredit, str *scps, int initp, int finishp)
1572
+static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
1573
+		str *sconnect, str *scps, int initp, int finishp)
1574 1574
 {
1575 1575
 	credit_data_t *credit_data = NULL;
1576 1576
 	call_t *call = NULL;
1577 1577
 
1578
-	double credit = 0, cost_per_second = 0;
1578
+	double credit = 0, connect_cost = 0, cost_per_second = 0;
1579 1579
 
1580 1580
 	if(msg->first_line.type != SIP_REQUEST
1581 1581
 			|| 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 1601
 		return -1;
1602 1602
 	}
1603 1603
 
1604
+	connect_cost = str2double(sconnect);
1605
+
1606
+	if(connect_cost < 0) {
1607
+		LM_ERR("connect_cost value must be >= 0: %f\n", connect_cost);
1608
+		return -1;
1609
+	}
1610
+
1604 1611
 	cost_per_second = str2double(scps);
1605 1612
 
1606 1613
 	if(cost_per_second <= 0) {
... ...
@@ -1609,26 +1620,26 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1609 1609
 	}
1610 1610
 
1611 1611
 	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);
1612
+		   "connect-cost[%f], cost-per-sec[%f], initial-pulse [%d], "
1613
+		   "final-pulse [%d], call-id[%.*s]\n",
1614
+			sclient->len, sclient->s, credit, connect_cost, cost_per_second,
1615
+			initp, finishp, msg->callid->body.len, msg->callid->body.s);
1617 1616
 
1618 1617
 	set_ctrl_flag(msg);
1619 1618
 
1620 1619
 	if((credit_data = __get_or_create_credit_data_entry(sclient, CREDIT_MONEY))
1621 1620
 			== NULL) {
1622 1621
 		LM_ERR("Error retrieving credit data from shared memory for client "
1623
-				"[%.*s]\n", sclient->len, sclient->s);
1622
+			   "[%.*s]\n",
1623
+				sclient->len, sclient->s);
1624 1624
 		return -1;
1625 1625
 	}
1626 1626
 
1627
-	if((call = __alloc_new_call_by_money(credit_data, msg, credit,
1627
+	if((call = __alloc_new_call_by_money(credit_data, msg, credit, connect_cost,
1628 1628
 				cost_per_second, initp, finishp))
1629 1629
 			== NULL) {
1630
-		LM_ERR("Unable to allocate new call for client [%.*s]\n",
1631
-				sclient->len, sclient->s);
1630
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1631
+				sclient->s);
1632 1632
 		return -1;
1633 1633
 	}
1634 1634
 
... ...
@@ -1641,43 +1652,49 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient,
1641 1641
 	return 1;
1642 1642
 }
1643 1643
 
1644
-static int __set_max_credit(sip_msg_t *msg, char *pclient,
1645
-		char *pcredit, char *pcps, char *pinitp, char *pfinishp)
1644
+static int __set_max_credit(sip_msg_t *msg, char *pclient, char *pcredit,
1645
+		char *pconnect, char *pcps, char *pinitp, char *pfinishp)
1646 1646
 {
1647 1647
 	str sclient;
1648 1648
 	str scredit;
1649
+	str sconnect;
1649 1650
 	str scps;
1650 1651
 	int initp;
1651 1652
 	int finishp;
1652 1653
 
1653
-	if(msg==NULL || pclient==NULL || pcredit==NULL || pcps==NULL
1654
-			|| pinitp==NULL || pfinishp==NULL) {
1654
+	if(msg == NULL || pclient == NULL || pcredit == NULL || pconnect == NULL
1655
+			|| pcps == NULL || pinitp == NULL || pfinishp == NULL) {
1655 1656
 		LM_ERR("invalid parameters\n");
1656 1657
 		return -1;
1657 1658
 	}
1658 1659
 
1659
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1660
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1660 1661
 		LM_ERR("failed to get client parameter\n");
1661 1662
 		return -1;
1662 1663
 	}
1663
-	if(fixup_get_svalue(msg, (gparam_t*)pcredit, &scredit)<0) {
1664
+	if(fixup_get_svalue(msg, (gparam_t *)pcredit, &scredit) < 0) {
1664 1665
 		LM_ERR("failed to get credit parameter\n");
1665 1666
 		return -1;
1666 1667
 	}
1667
-	if(fixup_get_svalue(msg, (gparam_t*)pcps, &scps)<0) {
1668
+	if(fixup_get_svalue(msg, (gparam_t *)pconnect, &sconnect) < 0) {
1669
+		LM_ERR("failed to get connect parameter\n");
1670
+		return -1;
1671
+	}
1672
+	if(fixup_get_svalue(msg, (gparam_t *)pcps, &scps) < 0) {
1668 1673
 		LM_ERR("failed to get cps parameter\n");
1669 1674
 		return -1;
1670 1675
 	}
1671
-	if(fixup_get_ivalue(msg, (gparam_t*)pinitp, &initp)<0) {
1676
+	if(fixup_get_ivalue(msg, (gparam_t *)pinitp, &initp) < 0) {
1672 1677
 		LM_ERR("failed to get init pulse parameter\n");
1673 1678
 		return -1;
1674 1679
 	}
1675
-	if(fixup_get_ivalue(msg, (gparam_t*)pfinishp, &finishp)<0) {
1680
+	if(fixup_get_ivalue(msg, (gparam_t *)pfinishp, &finishp) < 0) {
1676 1681
 		LM_ERR("failed to get finish pulse parameter\n");
1677 1682
 		return -1;
1678 1683
 	}
1679 1684
 
1680
-	return ki_set_max_credit(msg, &sclient, &scredit, &scps, initp, finishp);
1685
+	return ki_set_max_credit(
1686
+			msg, &sclient, &scredit, &sconnect, &scps, initp, finishp);
1681 1687
 }
1682 1688
 
1683 1689
 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 1691
 	}
1692 1692
 
1693 1693
 	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);
1694
+		LM_DBG("credit data for [%.*s] on [%.*s] not found\n", sclient->len,
1695
+				sclient->s, msg->callid->body.len, msg->callid->body.s);
1697 1696
 		return -1;
1698 1697
 	}
1699 1698
 
... ...
@@ -1705,7 +1721,7 @@ static int __terminate_all(sip_msg_t *msg, char *pclient, char *p2)
1705 1705
 {
1706 1706
 	str sclient;
1707 1707
 
1708
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1708
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1709 1709
 		LM_ERR("failed to get client parameter\n");
1710 1710
 		return -1;
1711 1711
 	}
... ...
@@ -1713,8 +1729,8 @@ static int __terminate_all(sip_msg_t *msg, char *pclient, char *p2)
1713 1713
 	return ki_terminate_all(msg, &sclient);
1714 1714
 }
1715 1715
 
1716
-static int __get_channel_count_helper(sip_msg_t *msg, str *sclient,
1717
-		pv_spec_t *pvcount)
1716
+static int __get_channel_count_helper(
1717
+		sip_msg_t *msg, str *sclient, pv_spec_t *pvcount)
1718 1718
 {
1719 1719
 	credit_data_t *credit_data = NULL;
1720 1720
 	pv_value_t countval;
... ...
@@ -1755,7 +1771,7 @@ static int __get_channel_count(sip_msg_t *msg, char *pclient, char *pcount)
1755 1755
 {
1756 1756
 	str sclient;
1757 1757
 
1758
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1758
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1759 1759
 		LM_ERR("failed to get client parameter\n");
1760 1760
 		return -1;
1761 1761
 	}
... ...
@@ -1769,7 +1785,7 @@ static int ki_get_channel_count(sip_msg_t *msg, str *sclient, str *pvname)
1769 1769
 
1770 1770
 	pvcount = pv_cache_get(pvname);
1771 1771
 
1772
-	if(pvcount==NULL) {
1772
+	if(pvcount == NULL) {
1773 1773
 		LM_ERR("failed to get pv spec for [%.*s]\n", pvname->len, pvname->s);
1774 1774
 		return -1;
1775 1775
 	}
... ...
@@ -1811,14 +1827,16 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
1811 1811
 	}
1812 1812
 
1813 1813
 	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);
1814
+		   "call-id[%.*s]\n",
1815
+			sclient->len, sclient->s, max_chan, msg->callid->body.len,
1816
+			msg->callid->body.s);
1817 1817
 
1818
-	if((credit_data = __get_or_create_credit_data_entry(sclient,
1819
-				CREDIT_CHANNEL)) == NULL) {
1818
+	if((credit_data = __get_or_create_credit_data_entry(
1819
+				sclient, CREDIT_CHANNEL))
1820
+			== NULL) {
1820 1821
 		LM_ERR("Error retrieving credit data from shared memory for client "
1821
-				"[%.*s]\n", sclient->len, sclient->s);
1822
+			   "[%.*s]\n",
1823
+				sclient->len, sclient->s);
1822 1824
 		return -1;
1823 1825
 	}
1824 1826
 
... ...
@@ -1828,15 +1846,13 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
1828 1828
 	if(credit_data->concurrent_calls + 1 > max_chan)
1829 1829
 		return -3; // you have the max amount of established calls already
1830 1830
 
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);
1831
+	if((call = alloc_new_call_by_channel(credit_data, msg, max_chan)) == NULL) {
1832
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1833
+				sclient->s);
1835 1834
 		return -1;
1836 1835
 	}
1837 1836
 
1838
-	if(__add_call_by_cid(&call->sip_data.callid, call, CREDIT_CHANNEL)
1839
-			!= 0) {
1837
+	if(__add_call_by_cid(&call->sip_data.callid, call, CREDIT_CHANNEL) != 0) {
1840 1838
 		LM_ERR("Unable to allocate new cid_by_client for client [%.*s]\n",
1841 1839
 				sclient->len, sclient->s);
1842 1840
 		return -1;
... ...
@@ -1850,11 +1866,11 @@ static int __set_max_channels(sip_msg_t *msg, char *pclient, char *pmaxchan)
1850 1850
 	str sclient;
1851 1851
 	int max_chan = 0;
1852 1852
 
1853
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1853
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1854 1854
 		LM_ERR("failed to get client parameter\n");
1855 1855
 		return -1;
1856 1856
 	}
1857
-	if(fixup_get_ivalue(msg, (gparam_t*)pmaxchan, &max_chan)<0) {
1857
+	if(fixup_get_ivalue(msg, (gparam_t *)pmaxchan, &max_chan) < 0) {
1858 1858
 		LM_ERR("failed to get max chan parameter\n");
1859 1859
 		return -1;
1860 1860
 	}
... ...
@@ -1898,21 +1914,21 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
1898 1898
 	}
1899 1899
 
1900 1900
 	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);
1901
+		   "call-id[%.*s]\n",
1902
+			sclient->len, sclient->s, max_secs, msg->callid->body.len,
1903
+			msg->callid->body.s);
1904 1904
 
1905 1905
 	if((credit_data = __get_or_create_credit_data_entry(sclient, CREDIT_TIME))
1906 1906
 			== NULL) {
1907 1907
 		LM_ERR("Error retrieving credit data from shared memory for client "
1908
-				"[%.*s]\n", sclient->len, sclient->s);
1908
+			   "[%.*s]\n",
1909
+				sclient->len, sclient->s);
1909 1910
 		return -1;
1910 1911
 	}
1911 1912
 
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);
1913
+	if((call = __alloc_new_call_by_time(credit_data, msg, max_secs)) == NULL) {
1914
+		LM_ERR("Unable to allocate new call for client [%.*s]\n", sclient->len,
1915
+				sclient->s);
1916 1916
 		return -1;
1917 1917
 	}
1918 1918
 
... ...
@@ -1930,11 +1946,11 @@ static int __set_max_time(sip_msg_t *msg, char *pclient, char *pmaxsecs)
1930 1930
 	str sclient;
1931 1931
 	int max_secs = 0;
1932 1932
 
1933
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
1933
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
1934 1934
 		LM_ERR("failed to get client parameter\n");
1935 1935
 		return -1;
1936 1936
 	}
1937
-	if(fixup_get_ivalue(msg, (gparam_t*)pmaxsecs, &max_secs)<0) {
1937
+	if(fixup_get_ivalue(msg, (gparam_t *)pmaxsecs, &max_secs) < 0) {
1938 1938
 		LM_ERR("failed to get max secs parameter\n");
1939 1939
 		return -1;
1940 1940
 	}
... ...
@@ -1966,8 +1982,8 @@ static int ki_update_max_time(sip_msg_t *msg, str *sclient, int secs)
1966 1966
 	}
1967 1967
 
1968 1968
 	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);
1969
+			sclient->len, sclient->s, secs, msg->callid->body.len,
1970
+			msg->callid->body.s);
1971 1971
 
1972 1972
 
1973 1973
 	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 1981
 	cnxcc_unlock(_data.time.lock);
1982 1982
 
1983 1983
 	if(e == NULL) {
1984
-		LM_ERR("Client [%.*s] was not found\n", sclient->len,
1985
-				sclient->s);
1984
+		LM_ERR("Client [%.*s] was not found\n", sclient->len, sclient->s);
1986 1985
 		return -1;
1987 1986
 	}
1988 1987
 
... ...
@@ -2017,11 +2032,11 @@ static int __update_max_time(sip_msg_t *msg, char *pclient, char *psecs)
2017 2017
 	str sclient;
2018 2018
 	int secs = 0;
2019 2019
 
2020
-	if(fixup_get_svalue(msg, (gparam_t*)pclient, &sclient)<0) {
2020
+	if(fixup_get_svalue(msg, (gparam_t *)pclient, &sclient) < 0) {
2021 2021
 		LM_ERR("failed to get client parameter\n");
2022 2022
 		return -1;
2023 2023
 	}
2024
-	if(fixup_get_ivalue(msg, (gparam_t*)psecs, &secs)<0) {
2024
+	if(fixup_get_ivalue(msg, (gparam_t *)psecs, &secs) < 0) {
2025 2025
 		LM_ERR("failed to get secs parameter\n");
2026 2026
 		return -1;
2027 2027
 	}
... ...
@@ -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 178
 
179 179
 	unsigned int start_timestamp;
180 180
 	double consumed_amount;
181
+	double connect_amount;
181 182
 
182 183
 	unsigned int dlg_h_entry;
183 184
 	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 32
 	<year>2014</year>
33 33
 	<holder>Carlos Ruiz Díaz, carlos@latamvoices.com</holder>
34 34
     </copyright>
35
+    <copyright>
36
+	<year>2018</year>
37
+	<holder>Jose Luis Verdeguer</holder>
38
+    </copyright>
35 39
 
36 40
     </bookinfo>
37 41
 
... ...
@@ -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>