Hello,

the cc_acc module has an internal database of credits (measured in seconds) for the different users (PINs, IDs, ...).

You can add or set credit to users (PINs, IDs, ...) with the DI functions, setCredit(user, credit) and addCredit(user, credit), e.g. by XMLRPC.

If the user is not found, you'll receive -1 as credit and the 500 response.

Below some scripts to manage that internal database, load xmlrpc2di module to access those functions.

--- sems-acc-set-credit ---
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from xmlrpclib import *

if len(sys.argv) != 3:
        print "usage: %s <user> <credit>" % sys.argv[0]
        sys.exit(1)

s = ServerProxy('http://localhost:8090')
print "Active calls: %d" % s.calls()
print s.di('cc_acc','setCredit', sys.argv[1], sys.argv[2])

--- sems-acc-add-credit ---
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from xmlrpclib import *

if len(sys.argv) != 3:
        print "usage: %s <user> <credit>" % sys.argv[0]
        sys.exit(1)

s = ServerProxy('http://localhost:8090')
print "Active calls: %d" % s.calls()
print s.di('cc_acc','addCredit', sys.argv[1], sys.argv[2])


--- sems-acc-subtract-credit ---
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from xmlrpclib import *

if len(sys.argv) != 3:
        print "usage: %s <user> <credit>" % sys.argv[0]
        sys.exit(1)

s = ServerProxy('http://localhost:8090')
print "Active calls: %d" % s.calls()
print s.di('cc_acc','subtractCredit', sys.argv[1], sys.argv[2])

--- sems-acc-get-credit ---
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from xmlrpclib import *

if len(sys.argv) != 2:
        print "usage: %s <user>" % sys.argv[0]
        sys.exit(1)

s = ServerProxy('http://localhost:8090')
print "Active calls: %d" % s.calls()
print s.di('cc_acc','getCredit', sys.argv[1])

Alternatively, e.g. if you want to fetch the credits from a server via XMLRPC, use the cc_acc_xmlrpc module.

hth
Stefan

o Skyler on 08/24/2011 10:23 PM:
Hi all,

  I'm stuck trying to figure out how the cc_acc module fetches credit. I
haven't found any docs or examples describing 'where' to tell the module
to look and see if credit is available. ngrep is below, the proper HF's
are being sent through but I still am not 100% sure I understand 'how'
the cc_acc module works when 'Fetching credit'.

500 response is what I get at the moment and sems.log shows:

[onInvite, SBC.cpp:691] ERROR: Failed to fetch credit from accounting
module
[onSipRequest, AmSession.cpp:855] ERROR: 500 Server Internal
Error

  Am I missing a piece to this puzzle?

  Any help is appreciated.

TIA,

Skyler


U 2011/08/24 16:05:06.497627 127.0.0.1:5062 ->  127.0.0.1:5080
INVITE sip:b2b-2725846431@ASTERISK_IP:5060 SIP/2.0.
Record-Route:
<sip:127.0.0.1:5062;lr=on;ftag=e1c985c366e55dbbo0;did=c73.0e87c5d2>.
Record-Route:<sip:127.0.0.1;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Record-Route:<sip:SPCE_IP;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Via: SIP/2.0/UDP
127.0.0.1:5062;branch=z9hG4bKb42e.c58ae3d490360d9c6df65422f13fd40c.0.
Via: SIP/2.0/UDP 127.0.0.1;rport=5060;branch=z9hG4bKb42e.fdc956c2.0.
Via: SIP/2.0/UDP NAT_DEVICE_IP:5060;rport=5060;branch=z9hG4bK-58a8b5af.
From: testy tester<sip:16048881212@SPCE_IP>;tag=e1c985c366e55dbbo0.
To:<sip:2725846431@SPCE_IP>.
Call-ID: 2f220c63-d635879b@REAL_DEVICE_IP.
CSeq: 102 INVITE.
Max-Forwards: 68.
Contact: testy tester<sip:14168881212@NAT_DEVICE_IP:5060>.
Expires: 240.
User-Agent: Linksys/PAP2-3.1.23(LS).
Content-Length: 467.
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER.
Supported: x-sipura, replaces.
Content-Type: application/sdp.
P-Asserted-Identity:<sip:16048881212@SPCE_IP>.
P-R-Uri: sip:2725846431@ASTERISK_IP:5060.
P-D-Uri: sip:127.0.0.1:5060
P-Caller-Uuid: 976dc5d0-f0ce-47fe-8501-72ca8dd5f0ae.
P-Acc-Dest: 2725846431@ASTERISK_IP.
.
v=0.
o=- 15674915 15674915 IN IP4 SPCE_IP.
s=-.
c=IN IP4 SPCE_IP.
t=0 0.
m=audio 30180 RTP/AVP 18 0 2 4 8 96 97 98 100 101.
a=rtpmap:18 G729/8000.
a=rtpmap:0 PCMU/8000.
a=rtpmap:2 G726-32/8000.
a=rtpmap:4 G723/8000.
a=rtpmap:8 PCMA/8000.
a=rtpmap:96 G726-40/8000.
a=rtpmap:97 G726-24/8000.
a=rtpmap:98 G726-16/8000.
a=rtpmap:100 NSE/8000.
a=fmtp:100 192-193.
a=rtpmap:101 telephone-event/8000.
a=fmtp:101 0-15.
a=ptime:20.
a=sendrecv.
a=nortpproxy:yes.

U 2011/08/24 16:05:06.497943 127.0.0.1:5080 ->  127.0.0.1:5062
SIP/2.0 100 Connecting.
Record-Route:
<sip:127.0.0.1:5062;lr=on;ftag=e1c985c366e55dbbo0;did=c73.0e87c5d2>.
Record-Route:<sip:127.0.0.1;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Record-Route:<sip:SPCE_IP;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Via: SIP/2.0/UDP
127.0.0.1:5062;branch=z9hG4bKb42e.c58ae3d490360d9c6df65422f13fd40c.0;received=127.0.0.1.
Via: SIP/2.0/UDP 127.0.0.1;rport=5060;branch=z9hG4bKb42e.fdc956c2.0.
Via: SIP/2.0/UDP NAT_DEVICE_IP:5060;rport=5060;branch=z9hG4bK-58a8b5af.
From: testy tester<sip:16048881212@SPCE_IP>;tag=e1c985c366e55dbbo0.
To:<sip:2725846431@SPCE_IP>;tag=5F950E62-4E55597200079895-AC7F1700.
Call-ID: 2f220c63-d635879b@REAL_DEVICE_IP.
CSeq: 102 INVITE.
Server: Sipwise NGCP Application Server.
Contact:<sip:[email protected]:5080>.
Content-Length: 0.
.

U 2011/08/24 16:05:06.498688 127.0.0.1:5080 ->  127.0.0.1:5062
SIP/2.0 500 Server Internal Error.
Record-Route:
<sip:127.0.0.1:5062;lr=on;ftag=e1c985c366e55dbbo0;did=c73.0e87c5d2>.
Record-Route:<sip:127.0.0.1;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Record-Route:<sip:SPCE_IP;r2=on;lr=on;ftag=e1c985c366e55dbbo0>.
Via: SIP/2.0/UDP
127.0.0.1:5062;branch=z9hG4bKb42e.c58ae3d490360d9c6df65422f13fd40c.0;received=127.0.0.1.
Via: SIP/2.0/UDP 127.0.0.1;rport=5060;branch=z9hG4bKb42e.fdc956c2.0.
Via: SIP/2.0/UDP NAT_DEVICE_IP:5060;rport=5060;branch=z9hG4bK-58a8b5af.
From: testy tester<sip:16048881212@SPCE_IP>;tag=e1c985c366e55dbbo0.
To:<sip:2725846431@SPCE_IP>;tag=5F950E62-4E55597200079895-AC7F1700.
Call-ID: 2f220c63-d635879b@REAL_DEVICE_IP.
CSeq: 102 INVITE.
Server: Sipwise NGCP Application Server.
Content-Length: 0.
.

U 2011/08/24 16:05:06.498886 127.0.0.1:5062 ->  127.0.0.1:5080
ACK sip:b2b-2725846431@ASTERISK_IP:5060 SIP/2.0.
Via: SIP/2.0/UDP
127.0.0.1:5062;branch=z9hG4bKb42e.c58ae3d490360d9c6df65422f13fd40c.0.
From: testy tester<sip:16048881212@SPCE_IP>;tag=e1c985c366e55dbbo0.
To:<sip:2725846431@SPCE_IP>;tag=5F950E62-4E55597200079895-AC7F1700.
Call-ID: 2f220c63-d635879b@REAL_DEVICE_IP.
CSeq: 102 ACK.
Max-Forwards: 68.
Content-Length: 0.
.

_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems



--
frafos.com
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

Reply via email to