blob: b58ddb37afd6b87cf38e1e11f8042776837e114d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
"
(C) 2011 by Holger Hans Peter Freyther
All Rights Reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
Object subclass: MGCPTrunkBase [
| ip ports sem |
<comment: 'I represent a trunk for a Gateway'>
<category: 'MGCP-Callagent'>
MGCPTrunkBase class >> initialize [
<category: 'creation'>
^ self new
initialize;
yourself
]
initialize [
sem := RecursionLock new.
]
destIp [
<category: 'accessing'>
^ ip
]
destIP: aDest [
<category: 'private'>
ip := aDest
]
numbersPorts: nrPorts [
<category: 'private'>
ports := Array new: nrPorts.
1 to: nrPorts do: [:each |
ports at: each put: (MGCPEndpoint initWith: each trunk: self)].
]
endpointAt: aNr [
<category: 'private'>
^ ports at: aNr
]
endpointName: aNr [
^ self subclassResponsibility
]
critical: aBlock [
sem critical: aBlock.
]
]
MGCPTrunkBase subclass: MGCPVirtualTrunk [
<comment: 'I represent a @mgw virtual trunk'>
<category: 'MGCP-Callagent'>
MGCPVirtualTrunk class >> createWithDest: anIP numberPorts: nr [
<category: 'factory'>
^ self new
destIP: anIP;
numbersPorts: nr
yourself
]
endpointName: aNr [
^ '%1@mgw' % {(aNr radix: 16) copyFrom: 4}
]
]
MGCPTrunkBase subclass: MGCPDSTrunk [
| trunk |
<comment: 'I represent an E1 trunk with 32 endpoints'>
<category: 'MGCP-Callagent'>
MGCPDSTrunk class >> createWithDest: anIP trunkNr: aNr [
<category: 'factory'>
^ self new
destIP: anIP;
numbersPorts: 32;
trunkNr: aNr;
yourself
]
trunkNr: aNr [
trunk := aNr.
]
endpointName: aNr [
^ 'ds/e1-%1/%2@mgw' % {trunk. (aNr radix: 16) copyFrom: 4}
]
]
|