Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame^] | 1 | # -*- text -*- |
| 2 | # |
| 3 | # cui/postgresql/queries.conf -- Queries to update a PostgreSQL CUI table. |
| 4 | # |
| 5 | # $Id: 6c2215f0abbe5cb30658ea541d525fd7a274c547 $ |
| 6 | |
| 7 | post-auth { |
| 8 | query = "\ |
| 9 | INSERT INTO ${..cui_table} \ |
| 10 | (clientipaddress, callingstationid, username, cui) \ |
| 11 | VALUES \ |
| 12 | ('%{%{Packet-Src-IPv6-Address}:-%{Packet-Src-IP-Address}}', '%{Calling-Station-Id}', \ |
| 13 | '%{User-Name}', '%{reply:Chargeable-User-Identity}')" |
| 14 | |
| 15 | } |
| 16 | |
| 17 | accounting { |
| 18 | reference = "%{tolower:type.%{Acct-Status-Type}.query}" |
| 19 | type { |
| 20 | start { |
| 21 | query = "\ |
| 22 | UPDATE ${....cui_table} SET \ |
| 23 | lastaccounting = now() \ |
| 24 | WHERE clientipaddress = '%{%{Packet-Src-IPv6-Address}:-%{Packet-Src-IP-Address}}' \ |
| 25 | AND callingstationid = '%{Calling-Station-Id}' \ |
| 26 | AND username = '%{User-Name}' \ |
| 27 | AND cui = '%{Chargeable-User-Identity}'" |
| 28 | } |
| 29 | interim-update { |
| 30 | query ="\ |
| 31 | UPDATE ${....cui_table} SET \ |
| 32 | lastaccounting = now() \ |
| 33 | WHERE clientipaddress = '%{%{Packet-Src-IPv6-Address}:-%{Packet-Src-IP-Address}}' \ |
| 34 | AND callingstationid = '%{Calling-Station-Id}' \ |
| 35 | AND username = '%{User-Name}' \ |
| 36 | AND cui = '%{Chargeable-User-Identity}'" |
| 37 | } |
| 38 | stop { |
| 39 | query ="\ |
| 40 | DELETE FROM ${....cui_table} \ |
| 41 | WHERE clientipaddress = '%{%{Packet-Src-IPv6-Address}:-%{Packet-Src-IP-Address}}' \ |
| 42 | AND callingstationid = '%{Calling-Station-Id}' \ |
| 43 | AND username = '%{User-Name}' \ |
| 44 | AND cui = '%{Chargeable-User-Identity}'" |
| 45 | } |
| 46 | } |
| 47 | } |