mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 13:03:33 +00:00
Compare commits
697 Commits
1.12.0
...
on-waves/0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2537b2f836 | ||
|
|
1168d13e0c | ||
|
|
588c423f12 | ||
|
|
088601004c | ||
|
|
55982ca9a7 | ||
|
|
91a035d2fb | ||
|
|
5ed2e3004b | ||
|
|
00460d3bc5 | ||
|
|
dcb7ad3f2c | ||
|
|
74e7cc4c4a | ||
|
|
667cba9d28 | ||
|
|
6f926f0197 | ||
|
|
c98d67d592 | ||
|
|
43dbcfe2cf | ||
|
|
98d949b02f | ||
|
|
4f5421a482 | ||
|
|
c8fdf0c4b6 | ||
|
|
45473477f6 | ||
|
|
cd7bed5327 | ||
|
|
83594c1f2c | ||
|
|
7e1524644b | ||
|
|
3ec13ed3a8 | ||
|
|
11557ecd8c | ||
|
|
c737fbd4af | ||
|
|
24963554a8 | ||
|
|
c7bd29e6d7 | ||
|
|
137523ef7c | ||
|
|
0457b4b6da | ||
|
|
c372b1eb75 | ||
|
|
55228e31be | ||
|
|
db544db73a | ||
|
|
f49d616427 | ||
|
|
1eecb1689b | ||
|
|
f55fc02e87 | ||
|
|
6bb3065e6d | ||
|
|
3c30a4bb1f | ||
|
|
636c1cadd8 | ||
|
|
20f3d21665 | ||
|
|
889fd79511 | ||
|
|
7e25253b71 | ||
|
|
f90c8c9d75 | ||
|
|
08a366f11f | ||
|
|
c12bfa45a5 | ||
|
|
e320fc115a | ||
|
|
5bf8f95701 | ||
|
|
6989b57350 | ||
|
|
edd980619c | ||
|
|
2c362abfb4 | ||
|
|
f8e0838f7a | ||
|
|
ec2886d1bd | ||
|
|
865ba8b572 | ||
|
|
9be1b5495f | ||
|
|
7cf7d27d10 | ||
|
|
9002169dcd | ||
|
|
43242f8947 | ||
|
|
83961de565 | ||
|
|
19776f70a2 | ||
|
|
6233ab9859 | ||
|
|
0037badb02 | ||
|
|
054efe1ef2 | ||
|
|
68fc12d89b | ||
|
|
7eccf5b0a5 | ||
|
|
6d346d8931 | ||
|
|
71e90b8eea | ||
|
|
72bd2c247c | ||
|
|
f45ee6371f | ||
|
|
d585586d7b | ||
|
|
0b3ffb1513 | ||
|
|
0577dc1372 | ||
|
|
dab98fb15a | ||
|
|
d8ba591c49 | ||
|
|
87c8f182cc | ||
|
|
c4fe5ac43a | ||
|
|
00d1f0d7a9 | ||
|
|
caecc9ad80 | ||
|
|
c00bf8f930 | ||
|
|
d657c67c9c | ||
|
|
9ad1f2404f | ||
|
|
0dcacda194 | ||
|
|
1a9ffe85eb | ||
|
|
c94b9c4eb4 | ||
|
|
b5fa05ff41 | ||
|
|
83f94497ce | ||
|
|
1230b3c02e | ||
|
|
6d2d523e77 | ||
|
|
dbd957c872 | ||
|
|
bfc3688024 | ||
|
|
c50510b67e | ||
|
|
980891cdf4 | ||
|
|
c43a0ab856 | ||
|
|
c882a0560d | ||
|
|
1c5d12009e | ||
|
|
b6dd348df2 | ||
|
|
b43e2afb3e | ||
|
|
d506107d1c | ||
|
|
7947b6be88 | ||
|
|
175a7b42af | ||
|
|
38a2653801 | ||
|
|
f1bb05fbef | ||
|
|
0c4f7ecabc | ||
|
|
5822be4690 | ||
|
|
acda6908ad | ||
|
|
83f46278dd | ||
|
|
e1c37bc4fe | ||
|
|
0f87be341d | ||
|
|
f15e647cba | ||
|
|
e2c1a6a33d | ||
|
|
9626783494 | ||
|
|
a68f139820 | ||
|
|
539b8ed99f | ||
|
|
d7cb8aa275 | ||
|
|
38454904cb | ||
|
|
c60465359b | ||
|
|
e9eb4d1ab8 | ||
|
|
c2b9bd202e | ||
|
|
0d147d47b9 | ||
|
|
ce701d7c5f | ||
|
|
f3759a4934 | ||
|
|
5bfb9102af | ||
|
|
2300d69df6 | ||
|
|
c67cd2e11a | ||
|
|
2afb915758 | ||
|
|
dbac9295e7 | ||
|
|
9f972a5fb0 | ||
|
|
33f3dcbbca | ||
|
|
2ad760fe5f | ||
|
|
fea0aebd36 | ||
|
|
c9b7d74a08 | ||
|
|
42a4e9a52d | ||
|
|
d4f7a81992 | ||
|
|
cd4afce470 | ||
|
|
299d5aa2a4 | ||
|
|
f85e93cd4d | ||
|
|
fdfaf9c519 | ||
|
|
4d4e6714cd | ||
|
|
3806b070bb | ||
|
|
3dd069cfd7 | ||
|
|
e1dcbc7622 | ||
|
|
6be75737c4 | ||
|
|
290a11d0ad | ||
|
|
67505f46b7 | ||
|
|
8b4898360a | ||
|
|
6e495eee4b | ||
|
|
e6a8a9359d | ||
|
|
1d55fd9e2b | ||
|
|
df342ea82b | ||
|
|
049eb23b73 | ||
|
|
95eb9dd339 | ||
|
|
ca660ac9ca | ||
|
|
96d6ed2552 | ||
|
|
170619fef6 | ||
|
|
09f28ea6b3 | ||
|
|
1884f89d9b | ||
|
|
0777fb2d32 | ||
|
|
35e56453d2 | ||
|
|
4fcf80a59a | ||
|
|
31e0bafa10 | ||
|
|
01ffc204f3 | ||
|
|
466c40bec2 | ||
|
|
60a2f4a7e6 | ||
|
|
797b9f0af0 | ||
|
|
677f0e7f90 | ||
|
|
ddbb5a4e1e | ||
|
|
75042b80be | ||
|
|
c32589f395 | ||
|
|
abd0719f23 | ||
|
|
5bac62216e | ||
|
|
c93c523872 | ||
|
|
ed1c872352 | ||
|
|
e21bdea501 | ||
|
|
11c17233fe | ||
|
|
fceee8779e | ||
|
|
e27740a0e2 | ||
|
|
95defd542d | ||
|
|
2d2a43f3d6 | ||
|
|
a9aab6a9ca | ||
|
|
775b3dc566 | ||
|
|
45bb8bfc1a | ||
|
|
57900f0008 | ||
|
|
66ac860f62 | ||
|
|
ec82426c5e | ||
|
|
60fa0efcc8 | ||
|
|
3dfcd4636a | ||
|
|
50818d0c20 | ||
|
|
317934a2ba | ||
|
|
565b355c82 | ||
|
|
be9201a272 | ||
|
|
a43c56637d | ||
|
|
980c84f0a3 | ||
|
|
1ae7b7c372 | ||
|
|
e265db68b0 | ||
|
|
fdc4a9386f | ||
|
|
023ac93377 | ||
|
|
fa53aba62c | ||
|
|
34c0b245fb | ||
|
|
4c4d2d48ec | ||
|
|
13441a1c50 | ||
|
|
8ff74e8c24 | ||
|
|
a202342d64 | ||
|
|
d275cf6407 | ||
|
|
c00e9ce09f | ||
|
|
5d645bf984 | ||
|
|
723fb87a6c | ||
|
|
9da4492655 | ||
|
|
1927e93ce5 | ||
|
|
7bbd416a52 | ||
|
|
efd38dd015 | ||
|
|
e8d8811b12 | ||
|
|
39cb9f2a3c | ||
|
|
0558a5a0dd | ||
|
|
fcb4468de4 | ||
|
|
9e96b2df12 | ||
|
|
72952d854c | ||
|
|
637dce99ba | ||
|
|
641b07ab73 | ||
|
|
6eae31e39f | ||
|
|
4647015f69 | ||
|
|
239f95467c | ||
|
|
cd80c73f37 | ||
|
|
d6f1c4afbb | ||
|
|
0c8af75c94 | ||
|
|
e4b33be6fc | ||
|
|
cc7461cefc | ||
|
|
e174061d17 | ||
|
|
6e1c3412ae | ||
|
|
bff54b3e00 | ||
|
|
e75eb4ca25 | ||
|
|
566737a4b8 | ||
|
|
2b7350240d | ||
|
|
d76b53c00e | ||
|
|
9c9ef7796a | ||
|
|
49fcc8fc90 | ||
|
|
51a4bcc96a | ||
|
|
d6238120dd | ||
|
|
7407aec921 | ||
|
|
e575ce69ce | ||
|
|
c1ca0ff091 | ||
|
|
661e68b78f | ||
|
|
376e146cfb | ||
|
|
eb3ab2f85b | ||
|
|
ebc38e4f26 | ||
|
|
e2ab44a439 | ||
|
|
8b3cced773 | ||
|
|
3d1b0770f4 | ||
|
|
99743fb7ec | ||
|
|
a2a42a7561 | ||
|
|
ebd57da87d | ||
|
|
b0ee082bb0 | ||
|
|
81f6a4c0bf | ||
|
|
3978de52c1 | ||
|
|
7faf692cb7 | ||
|
|
0cf25d5154 | ||
|
|
08db178271 | ||
|
|
936d8c1b64 | ||
|
|
3170305e56 | ||
|
|
0f3490dd03 | ||
|
|
61e5e7bd8b | ||
|
|
f7b06fbe0c | ||
|
|
45403b1804 | ||
|
|
6782cea4bf | ||
|
|
ec7ecab66f | ||
|
|
d1287e379b | ||
|
|
3fb44f3e61 | ||
|
|
d48bfe0e93 | ||
|
|
41cdaf520d | ||
|
|
f94418a129 | ||
|
|
88b299ca24 | ||
|
|
58a2758e78 | ||
|
|
be3fdc2c6e | ||
|
|
6a8d765334 | ||
|
|
adebbfdfa7 | ||
|
|
afccfb9380 | ||
|
|
0f7a8258f0 | ||
|
|
2aa7f10939 | ||
|
|
37ba5b3e35 | ||
|
|
9f63d2b4ad | ||
|
|
d21b5de8c0 | ||
|
|
12b63716e2 | ||
|
|
184961ea3e | ||
|
|
a9ec86029f | ||
|
|
d1b19f3308 | ||
|
|
33f531fd12 | ||
|
|
b051b3b161 | ||
|
|
479a3aa707 | ||
|
|
fd2a877e25 | ||
|
|
53f797305f | ||
|
|
691b40e834 | ||
|
|
e511d54dd0 | ||
|
|
6edf7b9a51 | ||
|
|
e4045679a8 | ||
|
|
52ae9a461b | ||
|
|
5bd9493257 | ||
|
|
c92fd5d9d3 | ||
|
|
01cf14d679 | ||
|
|
840447e2bf | ||
|
|
3f7586d571 | ||
|
|
b74a9f13e5 | ||
|
|
bbc2c6e765 | ||
|
|
7e3724ad18 | ||
|
|
569dccf947 | ||
|
|
89a378e9aa | ||
|
|
4a78c7b250 | ||
|
|
c71013091a | ||
|
|
4b1cde10fe | ||
|
|
0f5a2345d1 | ||
|
|
ae81ff95ea | ||
|
|
e5981edf6a | ||
|
|
93cc16ae4f | ||
|
|
119a1976f5 | ||
|
|
c53c2ab524 | ||
|
|
32423500f6 | ||
|
|
c3a6a1dbe5 | ||
|
|
f4f090ee36 | ||
|
|
2a554bfcc4 | ||
|
|
a12dea66ca | ||
|
|
ec59bb04df | ||
|
|
4417f7f477 | ||
|
|
39563af27c | ||
|
|
242faaafd1 | ||
|
|
f77c0cd428 | ||
|
|
4103a3e5b9 | ||
|
|
4aca7f621f | ||
|
|
507d536ce8 | ||
|
|
cb618c7980 | ||
|
|
3c0702d3c5 | ||
|
|
caf24567d1 | ||
|
|
1d34c6ac5a | ||
|
|
1506f8e465 | ||
|
|
f044c585e2 | ||
|
|
6d17dd1314 | ||
|
|
7cb6867ea3 | ||
|
|
d8138c43a1 | ||
|
|
46d9b94477 | ||
|
|
4f705b9f99 | ||
|
|
c592e697ce | ||
|
|
ebb6b99c63 | ||
|
|
e08253a3f7 | ||
|
|
5e86095364 | ||
|
|
a7c144888d | ||
|
|
7897c4446b | ||
|
|
ff9e09b2bc | ||
|
|
ecf5cc294d | ||
|
|
82126763a7 | ||
|
|
a380c89a9c | ||
|
|
bedaf5da64 | ||
|
|
2b08aa35a6 | ||
|
|
c24632930a | ||
|
|
f140348eff | ||
|
|
b5de1b0781 | ||
|
|
b022cc3b8e | ||
|
|
e8396c9663 | ||
|
|
941839b300 | ||
|
|
23a0e46f11 | ||
|
|
cb8fd6e99e | ||
|
|
e66bea8ad7 | ||
|
|
e8a9f471ef | ||
|
|
c2d66bdf5a | ||
|
|
80b584bbe7 | ||
|
|
15c21e8eec | ||
|
|
c0a1fff064 | ||
|
|
77fa4d2386 | ||
|
|
9be8752541 | ||
|
|
2b57b3cea4 | ||
|
|
00c531709a | ||
|
|
a094108f84 | ||
|
|
61e73eec3f | ||
|
|
1aa2798919 | ||
|
|
b829eac9bc | ||
|
|
7b1719327d | ||
|
|
493645eda9 | ||
|
|
8614cd0be7 | ||
|
|
19bd74d093 | ||
|
|
4821b5a847 | ||
|
|
84df56d577 | ||
|
|
4e23d5f87f | ||
|
|
4346424987 | ||
|
|
520656e004 | ||
|
|
9dac231fe4 | ||
|
|
2bb518a3bd | ||
|
|
476940f747 | ||
|
|
8deab8cdee | ||
|
|
a54f9e81c8 | ||
|
|
ed4390747f | ||
|
|
242d098d32 | ||
|
|
f795164f04 | ||
|
|
b6c6d43daa | ||
|
|
82df124c8e | ||
|
|
189587f428 | ||
|
|
45ab581f37 | ||
|
|
f48776ea6a | ||
|
|
7fc17cff64 | ||
|
|
a5a7075fe5 | ||
|
|
2b4e366083 | ||
|
|
bf1eb64b02 | ||
|
|
f0fbae94ea | ||
|
|
8fe4df503c | ||
|
|
8da7103070 | ||
|
|
f73f6fad8c | ||
|
|
25cb84be12 | ||
|
|
d9ae25c1bf | ||
|
|
5c011366c9 | ||
|
|
79e2d4230d | ||
|
|
8ecd029b12 | ||
|
|
3c0508e94a | ||
|
|
f535aad612 | ||
|
|
d0ac8866f1 | ||
|
|
73f9a65f12 | ||
|
|
b2c55c49a8 | ||
|
|
8dc241959c | ||
|
|
f99709430a | ||
|
|
b9bc45b1b0 | ||
|
|
65d10c1320 | ||
|
|
414ba77f75 | ||
|
|
59f2470650 | ||
|
|
339dfdb624 | ||
|
|
9e2e2e04d1 | ||
|
|
2ab6db0153 | ||
|
|
6cb97bdebe | ||
|
|
8c3694a282 | ||
|
|
191d23a889 | ||
|
|
a5963097ac | ||
|
|
221fb37518 | ||
|
|
4ec8a390cc | ||
|
|
cf3f1c8b3d | ||
|
|
984f3b8047 | ||
|
|
ec1f15d513 | ||
|
|
b76cd5ed7e | ||
|
|
1592550d98 | ||
|
|
5cdf42b1a4 | ||
|
|
3a6b1a41fb | ||
|
|
1b5b3bbfdb | ||
|
|
3a67035411 | ||
|
|
cb1937a4c5 | ||
|
|
3cfd5d6a02 | ||
|
|
6cc4dbfd46 | ||
|
|
9960d59fff | ||
|
|
161bd6d253 | ||
|
|
add3472e9f | ||
|
|
33b0bee457 | ||
|
|
6949db1bd8 | ||
|
|
8ae0080e21 | ||
|
|
546c296c4a | ||
|
|
86f42eb6a5 | ||
|
|
494c086dca | ||
|
|
6b18c8f3b6 | ||
|
|
87f6d26c2e | ||
|
|
fab2ff34c4 | ||
|
|
06d353e02e | ||
|
|
dfe47549c6 | ||
|
|
c70e8c2103 | ||
|
|
b462a03c35 | ||
|
|
6e0ec5b6fa | ||
|
|
6768387f16 | ||
|
|
5ef1234dd3 | ||
|
|
581e58d166 | ||
|
|
e308bb466a | ||
|
|
e4be5394ef | ||
|
|
81e1edd3e6 | ||
|
|
cfd1c28604 | ||
|
|
3ba8963a1d | ||
|
|
238d156481 | ||
|
|
516c4f073a | ||
|
|
fa22aa6bbd | ||
|
|
4072ceed32 | ||
|
|
cf6bf63a0d | ||
|
|
88b614110f | ||
|
|
d9b825a5f5 | ||
|
|
b91e5f1da4 | ||
|
|
07bb509434 | ||
|
|
08db6ca509 | ||
|
|
6446ded81c | ||
|
|
7b8f6064d6 | ||
|
|
c6a1fe773d | ||
|
|
729d468fdf | ||
|
|
b37ce4c5a4 | ||
|
|
5cd62c0ba5 | ||
|
|
1e1acafafd | ||
|
|
fb83b7a86d | ||
|
|
ef0b641f63 | ||
|
|
27e0bfd3c7 | ||
|
|
bbfff6ec39 | ||
|
|
dc0914df09 | ||
|
|
0db691dcf6 | ||
|
|
bb45b73b20 | ||
|
|
5f5c1b6bcb | ||
|
|
e51cf4f946 | ||
|
|
749ba7f5ad | ||
|
|
860c8955c3 | ||
|
|
c33701c4e5 | ||
|
|
44d92b4728 | ||
|
|
8aaec620da | ||
|
|
a5a4014d67 | ||
|
|
9d519189ae | ||
|
|
f0fc618782 | ||
|
|
c57575bea8 | ||
|
|
8cdfe9fc37 | ||
|
|
0959f8cbe6 | ||
|
|
f21028985e | ||
|
|
483b768ab2 | ||
|
|
82cb311c4f | ||
|
|
2980442e33 | ||
|
|
fa7afb31e9 | ||
|
|
7513b3a1c2 | ||
|
|
135d99b36e | ||
|
|
5aaf7c164c | ||
|
|
790db1e01b | ||
|
|
81a8975662 | ||
|
|
fd876b7488 | ||
|
|
2ffe7aa340 | ||
|
|
538ea6d5c6 | ||
|
|
e14ec0dab4 | ||
|
|
8252b9b947 | ||
|
|
9fb88021dd | ||
|
|
b031d6ecae | ||
|
|
fcfdde5390 | ||
|
|
571ba8e4da | ||
|
|
bed6234e26 | ||
|
|
9d24578812 | ||
|
|
a087c4e75d | ||
|
|
6b64b26d8b | ||
|
|
22252a98e3 | ||
|
|
957bc93244 | ||
|
|
18bbe2e8a0 | ||
|
|
1b17913cbc | ||
|
|
ce2a36840d | ||
|
|
0e09feccb0 | ||
|
|
40a1de699a | ||
|
|
d906a366c8 | ||
|
|
d44d4c8c8b | ||
|
|
af0e1d7a85 | ||
|
|
d21b4d7f98 | ||
|
|
3bdaa69fb2 | ||
|
|
5c0132882a | ||
|
|
ed443e949e | ||
|
|
1df69f3c64 | ||
|
|
d7cafafeee | ||
|
|
e09348d366 | ||
|
|
5f1b7c14f5 | ||
|
|
5b3e9198f0 | ||
|
|
f0b21dfd25 | ||
|
|
e165d1aaa4 | ||
|
|
649496eb57 | ||
|
|
135a45c833 | ||
|
|
1a3d9dbabf | ||
|
|
a91d15df7e | ||
|
|
3368e2a3d1 | ||
|
|
929d788e21 | ||
|
|
6958065f85 | ||
|
|
097c82b2bc | ||
|
|
abaeb3f55f | ||
|
|
f42e29c79c | ||
|
|
3177580cc1 | ||
|
|
cbe77e1657 | ||
|
|
3cedc4738f | ||
|
|
0834fd9b85 | ||
|
|
7b65c986eb | ||
|
|
17d751531e | ||
|
|
facb5cdfc2 | ||
|
|
aebea482f5 | ||
|
|
12f20d369c | ||
|
|
2008d3f54c | ||
|
|
a26ebe40f5 | ||
|
|
a52f1cacb3 | ||
|
|
f5e71415a2 | ||
|
|
82a8d6e393 | ||
|
|
1226c93937 | ||
|
|
b9c520f9b3 | ||
|
|
8a7ca57d3e | ||
|
|
29f9f9fc79 | ||
|
|
d512e454b3 | ||
|
|
22481bf76d | ||
|
|
b973955295 | ||
|
|
9d51a36528 | ||
|
|
ba3bbe55c1 | ||
|
|
0619478073 | ||
|
|
f8f184edab | ||
|
|
d838951302 | ||
|
|
f8e1b45a78 | ||
|
|
dd2c9fdbcf | ||
|
|
9991421cfb | ||
|
|
e30f0e1c75 | ||
|
|
18598ff66d | ||
|
|
8882c9e3a8 | ||
|
|
fdc64f6806 | ||
|
|
16b331d14f | ||
|
|
ab46372e2a | ||
|
|
be807e4250 | ||
|
|
71ddbf5c4f | ||
|
|
63bb29fac0 | ||
|
|
04b4f915a7 | ||
|
|
4d95ab2231 | ||
|
|
17944f7285 | ||
|
|
d2964b6cd1 | ||
|
|
1ce5d7c8b7 | ||
|
|
846457b10a | ||
|
|
e7b9771c4d | ||
|
|
d709900efa | ||
|
|
55b4f5cc2e | ||
|
|
1ac5ac75a9 | ||
|
|
5cf38ed1ab | ||
|
|
35d1531089 | ||
|
|
47e3777caa | ||
|
|
710f3c615c | ||
|
|
3111560e8a | ||
|
|
7396afbba4 | ||
|
|
52a72e217e | ||
|
|
ff0a562f9a | ||
|
|
556008d724 | ||
|
|
0094f84f30 | ||
|
|
86069143ff | ||
|
|
44f0be88a3 | ||
|
|
5d88b372d7 | ||
|
|
71c7bf5907 | ||
|
|
869033148c | ||
|
|
bc0f7c0988 | ||
|
|
7d06063cfb | ||
|
|
4e42b637fd | ||
|
|
f44de9942b | ||
|
|
3a110ae60b | ||
|
|
bb84adc465 | ||
|
|
8d123ea3c0 | ||
|
|
88ca894df7 | ||
|
|
42b0d6b494 | ||
|
|
82d8b0457b | ||
|
|
433d6ee1a2 | ||
|
|
203a6eddf8 | ||
|
|
56ef6249e3 | ||
|
|
b2a96b1be7 | ||
|
|
d4c29c1574 | ||
|
|
3d947e6d67 | ||
|
|
b62c9a19cf | ||
|
|
ff5957568f | ||
|
|
7d2e1ca4be | ||
|
|
7ce2e0c8b0 | ||
|
|
78d442420b | ||
|
|
8cd2709ebf | ||
|
|
41a1780102 | ||
|
|
2f84715984 | ||
|
|
7253154fc5 | ||
|
|
6c1c76683f | ||
|
|
a92fe9a4ca | ||
|
|
e83a3f584e | ||
|
|
118ddebc36 | ||
|
|
bb53004d47 | ||
|
|
6af20842cb | ||
|
|
cc41cb07e7 | ||
|
|
d6fb23523a | ||
|
|
2aa0b45cc0 | ||
|
|
619df61ad2 | ||
|
|
893ea65f38 | ||
|
|
64b811f113 | ||
|
|
91fc9bf862 | ||
|
|
111a58dd37 | ||
|
|
d1a2563a74 | ||
|
|
7d3ef919ce | ||
|
|
cba98d87d6 | ||
|
|
5c18ad0829 | ||
|
|
0d9ed87d5c | ||
|
|
ec7be0c969 | ||
|
|
9be3347601 | ||
|
|
3eef7b7d81 | ||
|
|
9de4a6daa9 | ||
|
|
851ace9f33 | ||
|
|
d1dd069b48 | ||
|
|
401db32ca2 | ||
|
|
17e03d21d2 | ||
|
|
26a9bff201 | ||
|
|
80fb260a60 | ||
|
|
55a0716da7 | ||
|
|
c88fb75616 | ||
|
|
d55a4dc326 | ||
|
|
a4e6f2e6e1 | ||
|
|
7f71d99cc3 | ||
|
|
b92167cf80 | ||
|
|
4b6a6dbe7e | ||
|
|
763e8c7766 | ||
|
|
823ff16088 | ||
|
|
6f93c6a1e0 | ||
|
|
f97e48b0de | ||
|
|
761600b0fd | ||
|
|
8549462bc6 | ||
|
|
436e5c6308 | ||
|
|
f8b9d844c1 | ||
|
|
58ec07d580 | ||
|
|
71465c21f4 | ||
|
|
16d0a833f8 | ||
|
|
ea72b62cac | ||
|
|
49a84ec6e9 | ||
|
|
42c636b6c8 | ||
|
|
a0a55f555e | ||
|
|
23ed00e410 | ||
|
|
3fe910b9f1 | ||
|
|
097bdeb77d | ||
|
|
1b85de02e0 | ||
|
|
2281d1835f | ||
|
|
fb4433a129 | ||
|
|
d954dcf9e1 |
@@ -4,7 +4,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
|
||||
SUBDIRS = include src tests
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = openbsc.pc libsccp.pc
|
||||
pkgconfig_DATA = openbsc.pc
|
||||
|
||||
BUILT_SOURCES = $(top_srcdir)/.version
|
||||
$(top_srcdir)/.version:
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script
|
||||
AC_INIT([openbsc],
|
||||
m4_esyscmd([./git-version-gen .tarball-version]),
|
||||
[openbsc-devel@lists.openbsc.org])
|
||||
|
||||
AM_INIT_AUTOMAKE([dist-bzip2])
|
||||
AC_INIT(openbsc, 0.3.99.20onwaves)
|
||||
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
|
||||
|
||||
dnl kernel style compile messages
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
@@ -18,7 +15,8 @@ dnl checks for libraries
|
||||
AC_SEARCH_LIBS(crypt, crypt,
|
||||
[LIBCRYPT="-lcrypt"; AC_DEFINE([VTY_CRYPT_PW], [], [Use crypt functionality of vty.])])
|
||||
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.3)
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.22)
|
||||
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.3)
|
||||
|
||||
dnl checks for header files
|
||||
AC_HEADER_STDC
|
||||
@@ -42,10 +40,8 @@ AM_CONFIG_HEADER(bscconfig.h)
|
||||
|
||||
AC_OUTPUT(
|
||||
openbsc.pc
|
||||
libsccp.pc
|
||||
include/openbsc/Makefile
|
||||
include/vty/Makefile
|
||||
include/sccp/Makefile
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
@@ -53,5 +49,4 @@ AC_OUTPUT(
|
||||
tests/gsm0408/Makefile
|
||||
tests/db/Makefile
|
||||
tests/channel/Makefile
|
||||
tests/sccp/Makefile
|
||||
Makefile)
|
||||
|
||||
2
openbsc/contrib/README
Normal file
2
openbsc/contrib/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This contains a set of scripts used for the development of the
|
||||
MSC functionality.
|
||||
30
openbsc/contrib/send_handshake.py
Executable file
30
openbsc/contrib/send_handshake.py
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
# packages
|
||||
ACK ="\x00\x01\xfe\x06"
|
||||
RESET_ACK = "\x00\x13\xfd\x09\x00\x03\x07\x0b\x04\x43\x01\x00\xfe\x04\x43\x5c\x00\xfe\x03\x00\x01\x31"
|
||||
PAGE = "\x00\x20\xfd\x09\x00\x03\x07\x0b\x04\x43\x01\x00\xfe\x04\x43\x5c\x00\xfe\x10\x00\x0e\x52\x08\x08\x29\x42\x08\x05\x03\x12\x23\x42\x1a\x01\x06"
|
||||
|
||||
|
||||
# simple handshake...
|
||||
sys.stdout.write(ACK)
|
||||
sys.stdout.flush()
|
||||
sys.stdin.read(4)
|
||||
|
||||
# wait for some data and send reset ack
|
||||
sys.stdin.read(21)
|
||||
sys.stdout.write(RESET_ACK)
|
||||
sys.stdout.flush()
|
||||
|
||||
sys.stdout.write(RESET_ACK)
|
||||
sys.stdout.flush()
|
||||
|
||||
# page a subscriber
|
||||
sys.stdout.write(PAGE)
|
||||
sys.stdout.flush()
|
||||
|
||||
while True:
|
||||
sys.stdin.read(1)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
SUBDIRS = openbsc vty sccp
|
||||
SUBDIRS = openbsc vty
|
||||
|
||||
noinst_HEADERS = mISDNif.h compat_af_isdn.h
|
||||
|
||||
@@ -6,7 +6,8 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \
|
||||
bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \
|
||||
silent_call.h mgcp.h meas_rep.h rest_octets.h \
|
||||
system_information.h handover.h mgcp_internal.h \
|
||||
vty.h
|
||||
vty.h bssap.h bsc_msc.h bsc_nat.h osmo_bsc_rf.h \
|
||||
osmo_bsc_grace.h
|
||||
|
||||
openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h
|
||||
openbscdir = $(includedir)/openbsc
|
||||
|
||||
@@ -55,6 +55,8 @@ struct ipac_bcch_info {
|
||||
u_int8_t ca_list_si1[16];
|
||||
};
|
||||
|
||||
extern const struct value_string abis_nm_adm_state_names[];
|
||||
extern const struct value_string abis_nm_obj_class_names[];
|
||||
extern const struct tlv_definition nm_att_tlvdef;
|
||||
|
||||
/* PUBLIC */
|
||||
@@ -92,7 +94,7 @@ int abis_nm_sw_act_req_ack(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i1,
|
||||
int abis_nm_raw_msg(struct gsm_bts *bts, int len, u_int8_t *msg);
|
||||
int abis_nm_event_reports(struct gsm_bts *bts, int on);
|
||||
int abis_nm_reset_resource(struct gsm_bts *bts);
|
||||
int abis_nm_software_load(struct gsm_bts *bts, const char *fname,
|
||||
int abis_nm_software_load(struct gsm_bts *bts, int trx_nr, const char *fname,
|
||||
u_int8_t win_size, int forced,
|
||||
gsm_cbfn *cbfn, void *cb_data);
|
||||
int abis_nm_software_load_status(struct gsm_bts *bts);
|
||||
@@ -148,7 +150,7 @@ int abis_nm_ipaccess_msg(struct gsm_bts *bts, u_int8_t msg_type,
|
||||
u_int8_t *attr, int attr_len);
|
||||
int abis_nm_ipaccess_set_nvattr(struct gsm_bts_trx *trx, u_int8_t *attr,
|
||||
int attr_len);
|
||||
int abis_nm_ipaccess_restart(struct gsm_bts *bts);
|
||||
int abis_nm_ipaccess_restart(struct gsm_bts_trx *trx);
|
||||
int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, u_int8_t obj_class,
|
||||
u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr,
|
||||
u_int8_t *attr, u_int8_t attr_len);
|
||||
@@ -164,9 +166,15 @@ enum nm_evt {
|
||||
EVT_STATECHG_ADM,
|
||||
};
|
||||
int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state);
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state,
|
||||
struct abis_om_obj_inst *obj_inst);
|
||||
|
||||
const char *nm_opstate_name(u_int8_t os);
|
||||
const char *nm_avail_name(u_int8_t avail);
|
||||
int nm_is_running(struct gsm_nm_state *s);
|
||||
void abis_nm_clear_queue(struct gsm_bts *bts);
|
||||
|
||||
|
||||
int abis_nm_vty_init(void);
|
||||
|
||||
#endif /* _NM_H */
|
||||
|
||||
@@ -68,13 +68,16 @@ unsigned int get_paging_group(u_int64_t imsi, unsigned int bs_cc_chans,
|
||||
unsigned int n_pag_blocks(int bs_ccch_sdcch_comb, unsigned int bs_ag_blks_res);
|
||||
u_int64_t str_to_imsi(const char *imsi_str);
|
||||
u_int8_t lchan2chan_nr(const struct gsm_lchan *lchan);
|
||||
int rsl_release_request(struct gsm_lchan *lchan, u_int8_t link_id);
|
||||
int rsl_release_request(struct gsm_lchan *lchan, u_int8_t link_id, u_int8_t release_reason);
|
||||
|
||||
int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
|
||||
|
||||
int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
|
||||
|
||||
/* to be provided by external code */
|
||||
int abis_rsl_sendmsg(struct msgb *msg);
|
||||
int rsl_deact_sacch(struct gsm_lchan *lchan);
|
||||
int rsl_lchan_rll_release(struct gsm_lchan *lchan, u_int8_t link_id);
|
||||
|
||||
/* BCCH related code */
|
||||
int rsl_ccch_conf_to_bs_cc_chans(int ccch_conf);
|
||||
|
||||
51
openbsc/include/openbsc/bsc_msc.h
Normal file
51
openbsc/include/openbsc/bsc_msc.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Routines to talk to the MSC using the IPA Protocol */
|
||||
/*
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BSC_MSC_H
|
||||
#define BSC_MSC_H
|
||||
|
||||
#include <osmocore/write_queue.h>
|
||||
#include <osmocore/timer.h>
|
||||
|
||||
struct bsc_msc_connection {
|
||||
struct write_queue write_queue;
|
||||
int is_connected;
|
||||
int is_authenticated;
|
||||
const char *ip;
|
||||
int port;
|
||||
int prio;
|
||||
|
||||
void (*connection_loss) (struct bsc_msc_connection *);
|
||||
void (*connected) (struct bsc_msc_connection *);
|
||||
struct timer_list reconnect_timer;
|
||||
struct timer_list timeout_timer;
|
||||
};
|
||||
|
||||
struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio);
|
||||
int bsc_msc_connect(struct bsc_msc_connection *);
|
||||
void bsc_msc_schedule_connect(struct bsc_msc_connection *);
|
||||
|
||||
void bsc_msc_lost(struct bsc_msc_connection *);
|
||||
|
||||
struct msgb *bsc_msc_id_get_resp(const char *token);
|
||||
|
||||
#endif
|
||||
338
openbsc/include/openbsc/bsc_nat.h
Normal file
338
openbsc/include/openbsc/bsc_nat.h
Normal file
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BSC_NAT_H
|
||||
#define BSC_NAT_H
|
||||
|
||||
#include "mgcp.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <osmocom/sccp/sccp_types.h>
|
||||
|
||||
#include <osmocore/select.h>
|
||||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/timer.h>
|
||||
#include <osmocore/write_queue.h>
|
||||
#include <osmocore/statistics.h>
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define DIR_BSC 1
|
||||
#define DIR_MSC 2
|
||||
|
||||
#define NAT_IPAC_PROTO_MGCP 0xfc
|
||||
|
||||
struct bsc_nat;
|
||||
|
||||
enum {
|
||||
NAT_CON_TYPE_NONE,
|
||||
NAT_CON_TYPE_LU,
|
||||
NAT_CON_TYPE_CM_SERV_REQ,
|
||||
NAT_CON_TYPE_PAG_RESP,
|
||||
NAT_CON_TYPE_LOCAL_REJECT,
|
||||
NAT_CON_TYPE_OTHER,
|
||||
};
|
||||
|
||||
/*
|
||||
* For the NAT we will need to analyze and later patch
|
||||
* the received message. This would require us to parse
|
||||
* the IPA and SCCP header twice. Instead of doing this
|
||||
* we will have one analyze structure and have the patching
|
||||
* and filter operate on the same structure.
|
||||
*/
|
||||
struct bsc_nat_parsed {
|
||||
/* ip access prototype */
|
||||
int ipa_proto;
|
||||
|
||||
/* source local reference */
|
||||
struct sccp_source_reference *src_local_ref;
|
||||
|
||||
/* destination local reference */
|
||||
struct sccp_source_reference *dest_local_ref;
|
||||
|
||||
/* called ssn number */
|
||||
int called_ssn;
|
||||
|
||||
/* calling ssn number */
|
||||
int calling_ssn;
|
||||
|
||||
/* sccp message type */
|
||||
int sccp_type;
|
||||
|
||||
/* bssap type, e.g. 0 for BSS Management */
|
||||
int bssap;
|
||||
|
||||
/* the gsm0808 message type */
|
||||
int gsm_type;
|
||||
};
|
||||
|
||||
/*
|
||||
* Per BSC data structure
|
||||
*/
|
||||
struct bsc_connection {
|
||||
struct llist_head list_entry;
|
||||
|
||||
/* do we know anything about this BSC? */
|
||||
int authenticated;
|
||||
|
||||
/* the fd we use to communicate */
|
||||
struct write_queue write_queue;
|
||||
|
||||
/* the BSS associated */
|
||||
struct bsc_config *cfg;
|
||||
|
||||
/* a timeout node */
|
||||
struct timer_list id_timeout;
|
||||
|
||||
/* pong timeout */
|
||||
struct timer_list ping_timeout;
|
||||
struct timer_list pong_timeout;
|
||||
|
||||
/* a back pointer */
|
||||
struct bsc_nat *nat;
|
||||
};
|
||||
|
||||
/*
|
||||
* Per SCCP source local reference patch table. It needs to
|
||||
* be updated on new SCCP connections, connection confirm and reject,
|
||||
* and on the loss of the BSC connection.
|
||||
*/
|
||||
struct sccp_connections {
|
||||
struct llist_head list_entry;
|
||||
|
||||
struct bsc_connection *bsc;
|
||||
|
||||
struct sccp_source_reference real_ref;
|
||||
struct sccp_source_reference patched_ref;
|
||||
struct sccp_source_reference remote_ref;
|
||||
int has_remote_ref;
|
||||
|
||||
/* status */
|
||||
int con_type;
|
||||
int con_local;
|
||||
|
||||
/* GSM audio handling. That is 32 * multiplex + ts */
|
||||
int crcx;
|
||||
int msc_timeslot;
|
||||
int bsc_timeslot;
|
||||
|
||||
/* timeout handling */
|
||||
struct timespec creation_time;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stats per BSC
|
||||
*/
|
||||
struct bsc_config_stats {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} net;
|
||||
};
|
||||
|
||||
/**
|
||||
* One BSC entry in the config
|
||||
*/
|
||||
struct bsc_config {
|
||||
struct llist_head entry;
|
||||
|
||||
char *token;
|
||||
unsigned int lac;
|
||||
int nr;
|
||||
|
||||
char *description;
|
||||
|
||||
/* imsi white and blacklist */
|
||||
char *acc_lst_name;
|
||||
|
||||
int forbid_paging;
|
||||
|
||||
/* backpointer */
|
||||
struct bsc_nat *nat;
|
||||
|
||||
struct bsc_config_stats stats;
|
||||
};
|
||||
|
||||
/**
|
||||
* BSCs point of view of endpoints
|
||||
*/
|
||||
struct bsc_endpoint {
|
||||
/* the pending transaction id */
|
||||
char *transaction_id;
|
||||
/* the bsc we are talking to */
|
||||
struct bsc_connection *bsc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Statistic for the nat.
|
||||
*/
|
||||
struct bsc_nat_statistics {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
struct counter *auth_fail;
|
||||
} bsc;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} msc;
|
||||
};
|
||||
|
||||
struct bsc_nat_acc_lst {
|
||||
struct llist_head list;
|
||||
|
||||
/* the name of the list */
|
||||
const char *name;
|
||||
struct llist_head fltr_list;
|
||||
};
|
||||
|
||||
struct bsc_nat_acc_lst_entry {
|
||||
struct llist_head list;
|
||||
|
||||
/* the filter */
|
||||
char *imsi_allow;
|
||||
regex_t imsi_allow_re;
|
||||
char *imsi_deny;
|
||||
regex_t imsi_deny_re;
|
||||
};
|
||||
|
||||
/**
|
||||
* the structure of the "nat" network
|
||||
*/
|
||||
struct bsc_nat {
|
||||
/* active SCCP connections that need patching */
|
||||
struct llist_head sccp_connections;
|
||||
|
||||
/* active BSC connections that need patching */
|
||||
struct llist_head bsc_connections;
|
||||
|
||||
/* access lists */
|
||||
struct llist_head access_lists;
|
||||
|
||||
/* known BSC's */
|
||||
struct llist_head bsc_configs;
|
||||
int num_bsc;
|
||||
int bsc_ip_tos;
|
||||
|
||||
/* MGCP config */
|
||||
struct mgcp_config *mgcp_cfg;
|
||||
struct write_queue mgcp_queue;
|
||||
u_int8_t mgcp_msg[4096];
|
||||
int mgcp_length;
|
||||
|
||||
/* msc things */
|
||||
char *msc_ip;
|
||||
int msc_port;
|
||||
int first_contact;
|
||||
struct bsc_msc_connection *msc_con;
|
||||
char *token;
|
||||
|
||||
/* timeouts */
|
||||
int auth_timeout;
|
||||
int ping_timeout;
|
||||
int pong_timeout;
|
||||
|
||||
struct bsc_endpoint *bsc_endpoints;
|
||||
|
||||
/* filter */
|
||||
char *acc_lst_name;
|
||||
|
||||
/* statistics */
|
||||
struct bsc_nat_statistics stats;
|
||||
};
|
||||
|
||||
/* create and init the structures */
|
||||
struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsigned int lac);
|
||||
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num);
|
||||
struct bsc_nat *bsc_nat_alloc(void);
|
||||
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat);
|
||||
void bsc_nat_set_msc_ip(struct bsc_nat *bsc, const char *ip);
|
||||
|
||||
void sccp_connection_destroy(struct sccp_connections *);
|
||||
void bsc_close_connection(struct bsc_connection *);
|
||||
|
||||
const char *bsc_con_type_to_string(int type);
|
||||
|
||||
/**
|
||||
* parse the given message into the above structure
|
||||
*/
|
||||
struct bsc_nat_parsed *bsc_nat_parse(struct msgb *msg);
|
||||
|
||||
/**
|
||||
* filter based on IP Access header in both directions
|
||||
*/
|
||||
int bsc_nat_filter_ipa(int direction, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
||||
int bsc_nat_vty_init(struct bsc_nat *nat);
|
||||
struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg, int *_lac);
|
||||
|
||||
/**
|
||||
* Content filtering.
|
||||
*/
|
||||
int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
|
||||
struct bsc_nat_parsed *, int *con_type);
|
||||
|
||||
/**
|
||||
* SCCP patching and handling
|
||||
*/
|
||||
struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed);
|
||||
int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *parsed);
|
||||
void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
||||
struct sccp_connections *patch_sccp_src_ref_to_bsc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *);
|
||||
struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat_parsed *, struct bsc_connection *);
|
||||
|
||||
/**
|
||||
* MGCP/Audio handling
|
||||
*/
|
||||
int bsc_write_mgcp(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length);
|
||||
int bsc_mgcp_assign(struct sccp_connections *, struct msgb *msg);
|
||||
void bsc_mgcp_init(struct sccp_connections *);
|
||||
void bsc_mgcp_dlcx(struct sccp_connections *);
|
||||
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
|
||||
int bsc_mgcp_nat_init(struct bsc_nat *nat);
|
||||
|
||||
struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
||||
struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port);
|
||||
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
|
||||
|
||||
void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc);
|
||||
int bsc_mgcp_parse_response(const char *str, int *code, char transaction[60]);
|
||||
uint32_t bsc_mgcp_extract_ci(const char *resp);
|
||||
|
||||
|
||||
int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id);
|
||||
|
||||
/* IMSI allow/deny handling */
|
||||
void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv);
|
||||
struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct bsc_nat *nat, const char *name);
|
||||
struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(struct bsc_nat *nat, const char *name);
|
||||
void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst);
|
||||
|
||||
struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *);
|
||||
|
||||
#endif
|
||||
333
openbsc/include/openbsc/bssap.h
Normal file
333
openbsc/include/openbsc/bssap.h
Normal file
@@ -0,0 +1,333 @@
|
||||
/* From GSM08.08 */
|
||||
|
||||
#ifndef BSSAP_H
|
||||
#define BSSAP_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <osmocore/msgb.h>
|
||||
#include <openbsc/gsm_data.h>
|
||||
|
||||
/*
|
||||
* this is from GSM 03.03 CGI but is copied in GSM 08.08
|
||||
* in § 3.2.2.27 for Cell Identifier List
|
||||
*/
|
||||
enum CELL_IDENT {
|
||||
CELL_IDENT_WHOLE_GLOBAL = 0,
|
||||
CELL_IDENT_LAC_AND_CI = 1,
|
||||
CELL_IDENT_CI = 2,
|
||||
CELL_IDENT_NO_CELL = 3,
|
||||
CELL_IDENT_LAI_AND_LAC = 4,
|
||||
CELL_IDENT_LAC = 5,
|
||||
CELL_IDENT_BSS = 6,
|
||||
CELL_IDENT_UTRAN_PLMN_LAC_RNC = 8,
|
||||
CELL_IDENT_UTRAN_RNC = 9,
|
||||
CELL_IDENT_UTRAN_LAC_RNC = 10,
|
||||
};
|
||||
|
||||
|
||||
/* GSM 08.06 § 6.3 */
|
||||
enum BSSAP_MSG_TYPE {
|
||||
BSSAP_MSG_BSS_MANAGEMENT = 0x0,
|
||||
BSSAP_MSG_DTAP = 0x1,
|
||||
};
|
||||
|
||||
struct bssmap_header {
|
||||
u_int8_t type;
|
||||
u_int8_t length;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct dtap_header {
|
||||
u_int8_t type;
|
||||
u_int8_t link_id;
|
||||
u_int8_t length;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
enum BSS_MAP_MSG_TYPE {
|
||||
BSS_MAP_MSG_RESERVED_0 = 0,
|
||||
|
||||
/* ASSIGNMENT MESSAGES */
|
||||
BSS_MAP_MSG_ASSIGMENT_RQST = 1,
|
||||
BSS_MAP_MSG_ASSIGMENT_COMPLETE = 2,
|
||||
BSS_MAP_MSG_ASSIGMENT_FAILURE = 3,
|
||||
|
||||
/* HANDOVER MESSAGES */
|
||||
BSS_MAP_MSG_HANDOVER_RQST = 16,
|
||||
BSS_MAP_MSG_HANDOVER_REQUIRED = 17,
|
||||
BSS_MAP_MSG_HANDOVER_RQST_ACKNOWLEDGE= 18,
|
||||
BSS_MAP_MSG_HANDOVER_CMD = 19,
|
||||
BSS_MAP_MSG_HANDOVER_COMPLETE = 20,
|
||||
BSS_MAP_MSG_HANDOVER_SUCCEEDED = 21,
|
||||
BSS_MAP_MSG_HANDOVER_FAILURE = 22,
|
||||
BSS_MAP_MSG_HANDOVER_PERFORMED = 23,
|
||||
BSS_MAP_MSG_HANDOVER_CANDIDATE_ENQUIRE = 24,
|
||||
BSS_MAP_MSG_HANDOVER_CANDIDATE_RESPONSE = 25,
|
||||
BSS_MAP_MSG_HANDOVER_REQUIRED_REJECT = 26,
|
||||
BSS_MAP_MSG_HANDOVER_DETECT = 27,
|
||||
|
||||
/* RELEASE MESSAGES */
|
||||
BSS_MAP_MSG_CLEAR_CMD = 32,
|
||||
BSS_MAP_MSG_CLEAR_COMPLETE = 33,
|
||||
BSS_MAP_MSG_CLEAR_RQST = 34,
|
||||
BSS_MAP_MSG_RESERVED_1 = 35,
|
||||
BSS_MAP_MSG_RESERVED_2 = 36,
|
||||
BSS_MAP_MSG_SAPI_N_REJECT = 37,
|
||||
BSS_MAP_MSG_CONFUSION = 38,
|
||||
|
||||
/* OTHER CONNECTION RELATED MESSAGES */
|
||||
BSS_MAP_MSG_SUSPEND = 40,
|
||||
BSS_MAP_MSG_RESUME = 41,
|
||||
BSS_MAP_MSG_CONNECTION_ORIENTED_INFORMATION = 42,
|
||||
BSS_MAP_MSG_PERFORM_LOCATION_RQST = 43,
|
||||
BSS_MAP_MSG_LSA_INFORMATION = 44,
|
||||
BSS_MAP_MSG_PERFORM_LOCATION_RESPONSE = 45,
|
||||
BSS_MAP_MSG_PERFORM_LOCATION_ABORT = 46,
|
||||
BSS_MAP_MSG_COMMON_ID = 47,
|
||||
|
||||
/* GENERAL MESSAGES */
|
||||
BSS_MAP_MSG_RESET = 48,
|
||||
BSS_MAP_MSG_RESET_ACKNOWLEDGE = 49,
|
||||
BSS_MAP_MSG_OVERLOAD = 50,
|
||||
BSS_MAP_MSG_RESERVED_3 = 51,
|
||||
BSS_MAP_MSG_RESET_CIRCUIT = 52,
|
||||
BSS_MAP_MSG_RESET_CIRCUIT_ACKNOWLEDGE = 53,
|
||||
BSS_MAP_MSG_MSC_INVOKE_TRACE = 54,
|
||||
BSS_MAP_MSG_BSS_INVOKE_TRACE = 55,
|
||||
BSS_MAP_MSG_CONNECTIONLESS_INFORMATION = 58,
|
||||
|
||||
/* TERRESTRIAL RESOURCE MESSAGES */
|
||||
BSS_MAP_MSG_BLOCK = 64,
|
||||
BSS_MAP_MSG_BLOCKING_ACKNOWLEDGE = 65,
|
||||
BSS_MAP_MSG_UNBLOCK = 66,
|
||||
BSS_MAP_MSG_UNBLOCKING_ACKNOWLEDGE = 67,
|
||||
BSS_MAP_MSG_CIRCUIT_GROUP_BLOCK = 68,
|
||||
BSS_MAP_MSG_CIRCUIT_GROUP_BLOCKING_ACKNOWLEDGE = 69,
|
||||
BSS_MAP_MSG_CIRCUIT_GROUP_UNBLOCK = 70,
|
||||
BSS_MAP_MSG_CIRCUIT_GROUP_UNBLOCKING_ACKNOWLEDGE = 71,
|
||||
BSS_MAP_MSG_UNEQUIPPED_CIRCUIT = 72,
|
||||
BSS_MAP_MSG_CHANGE_CIRCUIT = 78,
|
||||
BSS_MAP_MSG_CHANGE_CIRCUIT_ACKNOWLEDGE = 79,
|
||||
|
||||
/* RADIO RESOURCE MESSAGES */
|
||||
BSS_MAP_MSG_RESOURCE_RQST = 80,
|
||||
BSS_MAP_MSG_RESOURCE_INDICATION = 81,
|
||||
BSS_MAP_MSG_PAGING = 82,
|
||||
BSS_MAP_MSG_CIPHER_MODE_CMD = 83,
|
||||
BSS_MAP_MSG_CLASSMARK_UPDATE = 84,
|
||||
BSS_MAP_MSG_CIPHER_MODE_COMPLETE = 85,
|
||||
BSS_MAP_MSG_QUEUING_INDICATION = 86,
|
||||
BSS_MAP_MSG_COMPLETE_LAYER_3 = 87,
|
||||
BSS_MAP_MSG_CLASSMARK_RQST = 88,
|
||||
BSS_MAP_MSG_CIPHER_MODE_REJECT = 89,
|
||||
BSS_MAP_MSG_LOAD_INDICATION = 90,
|
||||
|
||||
/* VGCS/VBS */
|
||||
BSS_MAP_MSG_VGCS_VBS_SETUP = 4,
|
||||
BSS_MAP_MSG_VGCS_VBS_SETUP_ACK = 5,
|
||||
BSS_MAP_MSG_VGCS_VBS_SETUP_REFUSE = 6,
|
||||
BSS_MAP_MSG_VGCS_VBS_ASSIGNMENT_RQST = 7,
|
||||
BSS_MAP_MSG_VGCS_VBS_ASSIGNMENT_RESULT = 28,
|
||||
BSS_MAP_MSG_VGCS_VBS_ASSIGNMENT_FAILURE = 29,
|
||||
BSS_MAP_MSG_VGCS_VBS_QUEUING_INDICATION = 30,
|
||||
BSS_MAP_MSG_UPLINK_RQST = 31,
|
||||
BSS_MAP_MSG_UPLINK_RQST_ACKNOWLEDGE = 39,
|
||||
BSS_MAP_MSG_UPLINK_RQST_CONFIRMATION = 73,
|
||||
BSS_MAP_MSG_UPLINK_RELEASE_INDICATION = 74,
|
||||
BSS_MAP_MSG_UPLINK_REJECT_CMD = 75,
|
||||
BSS_MAP_MSG_UPLINK_RELEASE_CMD = 76,
|
||||
BSS_MAP_MSG_UPLINK_SEIZED_CMD = 77,
|
||||
};
|
||||
|
||||
enum GSM0808_IE_CODING {
|
||||
GSM0808_IE_CIRCUIT_IDENTITY_CODE = 1,
|
||||
GSM0808_IE_RESERVED_0 = 2,
|
||||
GSM0808_IE_RESOURCE_AVAILABLE = 3,
|
||||
GSM0808_IE_CAUSE = 4,
|
||||
GSM0808_IE_CELL_IDENTIFIER = 5,
|
||||
GSM0808_IE_PRIORITY = 6,
|
||||
GSM0808_IE_LAYER_3_HEADER_INFORMATION = 7,
|
||||
GSM0808_IE_IMSI = 8,
|
||||
GSM0808_IE_TMSI = 9,
|
||||
GSM0808_IE_ENCRYPTION_INFORMATION = 10,
|
||||
GSM0808_IE_CHANNEL_TYPE = 11,
|
||||
GSM0808_IE_PERIODICITY = 12,
|
||||
GSM0808_IE_EXTENDED_RESOURCE_INDICATOR = 13,
|
||||
GSM0808_IE_NUMBER_OF_MSS = 14,
|
||||
GSM0808_IE_RESERVED_1 = 15,
|
||||
GSM0808_IE_RESERVED_2 = 16,
|
||||
GSM0808_IE_RESERVED_3 = 17,
|
||||
GSM0808_IE_CLASSMARK_INFORMATION_T2 = 18,
|
||||
GSM0808_IE_CLASSMARK_INFORMATION_T3 = 19,
|
||||
GSM0808_IE_INTERFERENCE_BAND_TO_USE = 20,
|
||||
GSM0808_IE_RR_CAUSE = 21,
|
||||
GSM0808_IE_RESERVED_4 = 22,
|
||||
GSM0808_IE_LAYER_3_INFORMATION = 23,
|
||||
GSM0808_IE_DLCI = 24,
|
||||
GSM0808_IE_DOWNLINK_DTX_FLAG = 25,
|
||||
GSM0808_IE_CELL_IDENTIFIER_LIST = 26,
|
||||
GSM0808_IE_RESPONSE_RQST = 27,
|
||||
GSM0808_IE_RESOURCE_INDICATION_METHOD = 28,
|
||||
GSM0808_IE_CLASSMARK_INFORMATION_TYPE_1 = 29,
|
||||
GSM0808_IE_CIRCUIT_IDENTITY_CODE_LIST = 30,
|
||||
GSM0808_IE_DIAGNOSTIC = 31,
|
||||
GSM0808_IE_LAYER_3_MESSAGE_CONTENTS = 32,
|
||||
GSM0808_IE_CHOSEN_CHANNEL = 33,
|
||||
GSM0808_IE_TOTAL_RESOURCE_ACCESSIBLE = 34,
|
||||
GSM0808_IE_CIPHER_RESPONSE_MODE = 35,
|
||||
GSM0808_IE_CHANNEL_NEEDED = 36,
|
||||
GSM0808_IE_TRACE_TYPE = 37,
|
||||
GSM0808_IE_TRIGGERID = 38,
|
||||
GSM0808_IE_TRACE_REFERENCE = 39,
|
||||
GSM0808_IE_TRANSACTIONID = 40,
|
||||
GSM0808_IE_MOBILE_IDENTITY = 41,
|
||||
GSM0808_IE_OMCID = 42,
|
||||
GSM0808_IE_FORWARD_INDICATOR = 43,
|
||||
GSM0808_IE_CHOSEN_ENCR_ALG = 44,
|
||||
GSM0808_IE_CIRCUIT_POOL = 45,
|
||||
GSM0808_IE_CIRCUIT_POOL_LIST = 46,
|
||||
GSM0808_IE_TIME_INDICATION = 47,
|
||||
GSM0808_IE_RESOURCE_SITUATION = 48,
|
||||
GSM0808_IE_CURRENT_CHANNEL_TYPE_1 = 49,
|
||||
GSM0808_IE_QUEUEING_INDICATOR = 50,
|
||||
GSM0808_IE_SPEECH_VERSION = 64,
|
||||
GSM0808_IE_ASSIGNMENT_REQUIREMENT = 51,
|
||||
GSM0808_IE_TALKER_FLAG = 53,
|
||||
GSM0808_IE_CONNECTION_RELEASE_RQSTED = 54,
|
||||
GSM0808_IE_GROUP_CALL_REFERENCE = 55,
|
||||
GSM0808_IE_EMLPP_PRIORITY = 56,
|
||||
GSM0808_IE_CONFIG_EVO_INDI = 57,
|
||||
GSM0808_IE_OLD_BSS_TO_NEW_BSS_INFORMATION = 58,
|
||||
GSM0808_IE_LSA_IDENTIFIER = 59,
|
||||
GSM0808_IE_LSA_IDENTIFIER_LIST = 60,
|
||||
GSM0808_IE_LSA_INFORMATION = 61,
|
||||
GSM0808_IE_LCS_QOS = 62,
|
||||
GSM0808_IE_LSA_ACCESS_CTRL_SUPPR = 63,
|
||||
GSM0808_IE_LCS_PRIORITY = 67,
|
||||
GSM0808_IE_LOCATION_TYPE = 68,
|
||||
GSM0808_IE_LOCATION_ESTIMATE = 69,
|
||||
GSM0808_IE_POSITIONING_DATA = 70,
|
||||
GSM0808_IE_LCS_CAUSE = 71,
|
||||
GSM0808_IE_LCS_CLIENT_TYPE = 72,
|
||||
GSM0808_IE_APDU = 73,
|
||||
GSM0808_IE_NETWORK_ELEMENT_IDENTITY = 74,
|
||||
GSM0808_IE_GPS_ASSISTANCE_DATA = 75,
|
||||
GSM0808_IE_DECIPHERING_KEYS = 76,
|
||||
GSM0808_IE_RETURN_ERROR_RQST = 77,
|
||||
GSM0808_IE_RETURN_ERROR_CAUSE = 78,
|
||||
GSM0808_IE_SEGMENTATION = 79,
|
||||
GSM0808_IE_SERVICE_HANDOVER = 80,
|
||||
GSM0808_IE_SOURCE_RNC_TO_TARGET_RNC_TRANSPARENT_UMTS = 81,
|
||||
GSM0808_IE_SOURCE_RNC_TO_TARGET_RNC_TRANSPARENT_CDMA2000= 82,
|
||||
GSM0808_IE_RESERVED_5 = 65,
|
||||
GSM0808_IE_RESERVED_6 = 66,
|
||||
};
|
||||
|
||||
enum gsm0808_cause {
|
||||
GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE = 0,
|
||||
GSM0808_CAUSE_RADIO_INTERFACE_FAILURE = 1,
|
||||
GSM0808_CAUSE_UPLINK_QUALITY = 2,
|
||||
GSM0808_CAUSE_UPLINK_STRENGTH = 3,
|
||||
GSM0808_CAUSE_DOWNLINK_QUALITY = 4,
|
||||
GSM0808_CAUSE_DOWNLINK_STRENGTH = 5,
|
||||
GSM0808_CAUSE_DISTANCE = 6,
|
||||
GSM0808_CAUSE_O_AND_M_INTERVENTION = 7,
|
||||
GSM0808_CAUSE_RESPONSE_TO_MSC_INVOCATION = 8,
|
||||
GSM0808_CAUSE_CALL_CONTROL = 9,
|
||||
GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION = 10,
|
||||
GSM0808_CAUSE_HANDOVER_SUCCESSFUL = 11,
|
||||
GSM0808_CAUSE_BETTER_CELL = 12,
|
||||
GSM0808_CAUSE_DIRECTED_RETRY = 13,
|
||||
GSM0808_CAUSE_JOINED_GROUP_CALL_CHANNEL = 14,
|
||||
GSM0808_CAUSE_TRAFFIC = 15,
|
||||
GSM0808_CAUSE_EQUIPMENT_FAILURE = 32,
|
||||
GSM0808_CAUSE_NO_RADIO_RESOURCE_AVAILABLE = 33,
|
||||
GSM0808_CAUSE_RQSTED_TERRESTRIAL_RESOURCE_UNAVAILABLE = 34,
|
||||
GSM0808_CAUSE_CCCH_OVERLOAD = 35,
|
||||
GSM0808_CAUSE_PROCESSOR_OVERLOAD = 36,
|
||||
GSM0808_CAUSE_BSS_NOT_EQUIPPED = 37,
|
||||
GSM0808_CAUSE_MS_NOT_EQUIPPED = 38,
|
||||
GSM0808_CAUSE_INVALID_CELL = 39,
|
||||
GSM0808_CAUSE_TRAFFIC_LOAD = 40,
|
||||
GSM0808_CAUSE_PREEMPTION = 41,
|
||||
GSM0808_CAUSE_RQSTED_TRANSCODING_RATE_ADAPTION_UNAVAILABLE = 48,
|
||||
GSM0808_CAUSE_CIRCUIT_POOL_MISMATCH = 49,
|
||||
GSM0808_CAUSE_SWITCH_CIRCUIT_POOL = 50,
|
||||
GSM0808_CAUSE_RQSTED_SPEECH_VERSION_UNAVAILABLE = 51,
|
||||
GSM0808_CAUSE_LSA_NOT_ALLOWED = 52,
|
||||
GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED = 64,
|
||||
GSM0808_CAUSE_TERRESTRIAL_CIRCUIT_ALREADY_ALLOCATED = 80,
|
||||
GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS = 81,
|
||||
GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING = 82,
|
||||
GSM0808_CAUSE_INCORRECT_VALUE = 83,
|
||||
GSM0808_CAUSE_UNKNOWN_MESSAGE_TYPE = 84,
|
||||
GSM0808_CAUSE_UNKNOWN_INFORMATION_ELEMENT = 85,
|
||||
GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC = 96,
|
||||
};
|
||||
|
||||
/* GSM 08.08 3.2.2.11 Channel Type */
|
||||
enum gsm0808_chan_indicator {
|
||||
GSM0808_CHAN_SPEECH = 1,
|
||||
GSM0808_CHAN_DATA = 2,
|
||||
GSM0808_CHAN_SIGN = 3,
|
||||
};
|
||||
|
||||
enum gsm0808_chan_rate_type_data {
|
||||
GSM0808_DATA_FULL_BM = 0x8,
|
||||
GSM0808_DATA_HALF_LM = 0x9,
|
||||
GSM0808_DATA_FULL_RPREF = 0xa,
|
||||
GSM0808_DATA_HALF_PREF = 0xb,
|
||||
GSM0808_DATA_FULL_PREF_NO_CHANGE = 0x1a,
|
||||
GSM0808_DATA_HALF_PREF_NO_CHANGE = 0x1b,
|
||||
GSM0808_DATA_MULTI_MASK = 0x20,
|
||||
GSM0808_DATA_MULTI_MASK_NO_CHANGE = 0x30,
|
||||
};
|
||||
|
||||
enum gsm0808_chan_rate_type_speech {
|
||||
GSM0808_SPEECH_FULL_BM = 0x8,
|
||||
GSM0808_SPEECH_HALF_LM = 0x9,
|
||||
GSM0808_SPEECH_FULL_PREF= 0xa,
|
||||
GSM0808_SPEECH_HALF_PREF= 0xb,
|
||||
GSM0808_SPEECH_FULL_PREF_NO_CHANGE = 0x1a,
|
||||
GSM0808_SPEECH_HALF_PREF_NO_CHANGE = 0x1b,
|
||||
GSM0808_SPEECH_PERM = 0xf,
|
||||
GSM0808_SPEECH_PERM_NO_CHANGE = 0x1f,
|
||||
};
|
||||
|
||||
enum gsm0808_permitted_speech {
|
||||
GSM0808_PERM_FR1 = 0x01,
|
||||
GSM0808_PERM_FR2 = 0x11,
|
||||
GSM0808_PERM_FR3 = 0x21,
|
||||
GSM0808_PERM_HR1 = GSM0808_PERM_FR1 | 0x4,
|
||||
GSM0808_PERM_HR2 = GSM0808_PERM_FR2 | 0x4,
|
||||
GSM0808_PERM_HR3 = GSM0808_PERM_FR3 | 0x4,
|
||||
};
|
||||
|
||||
int bssmap_rcvmsg_dt1(struct sccp_connection *conn, struct msgb *msg, unsigned int length);
|
||||
int bssmap_rcvmsg_udt(struct gsm_network *net, struct msgb *msg, unsigned int length);
|
||||
|
||||
struct msgb *bssmap_create_layer3(struct msgb *msg);
|
||||
struct msgb *bssmap_create_reset(void);
|
||||
struct msgb *bssmap_create_clear_complete(void);
|
||||
struct msgb *bssmap_create_cipher_complete(struct msgb *layer3);
|
||||
struct msgb *bssmap_create_cipher_reject(u_int8_t cause);
|
||||
struct msgb *bssmap_create_sapi_reject(u_int8_t link_id);
|
||||
struct msgb *bssmap_create_assignment_completed(struct gsm_lchan *lchan, u_int8_t rr_cause);
|
||||
struct msgb *bssmap_create_assignment_failure(u_int8_t cause, u_int8_t *rr_cause);
|
||||
struct msgb *bssmap_create_classmark_update(const u_int8_t *classmark, u_int8_t length);
|
||||
|
||||
void gsm0808_send_assignment_failure(struct gsm_lchan *l, u_int8_t cause, u_int8_t *rr_value);
|
||||
void gsm0808_send_assignment_compl(struct gsm_lchan *l, u_int8_t rr_value);
|
||||
|
||||
int dtap_rcvmsg(struct gsm_lchan *lchan, struct msgb *msg, unsigned int length);
|
||||
struct msgb *dtap_create_msg(struct msgb *msg_l3, u_int8_t link_id);
|
||||
|
||||
void bsc_queue_connection_write(struct sccp_connection *conn, struct msgb *msg);
|
||||
void bsc_free_queued(struct sccp_connection *conn);
|
||||
void bsc_send_queued(struct sccp_connection *conn);
|
||||
|
||||
void bts_send_queued(struct bss_sccp_connection_data*);
|
||||
void bts_free_queued(struct bss_sccp_connection_data*);
|
||||
void bts_unblock_queue(struct bss_sccp_connection_data*);
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,28 @@
|
||||
|
||||
#include "gsm_subscriber.h"
|
||||
|
||||
/*
|
||||
* Refcounting for the lchan. If the refcount drops to zero
|
||||
* the channel will send a RSL release request.
|
||||
*/
|
||||
#define use_subscr_con(con) \
|
||||
do { (con)->use_count++; \
|
||||
DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \
|
||||
(con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \
|
||||
(con)->lchan->nr, (con)->use_count); \
|
||||
} while(0);
|
||||
|
||||
#define put_subscr_con(con, reason) \
|
||||
do { (con)->use_count--; \
|
||||
DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \
|
||||
(con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \
|
||||
(con)->lchan->nr, (con)->use_count); \
|
||||
if ((con)->use_count <= 0) \
|
||||
_lchan_release((con)->lchan, reason); \
|
||||
} while(0);
|
||||
|
||||
|
||||
|
||||
/* Special allocator for C0 of BTS */
|
||||
struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts,
|
||||
enum gsm_phys_chan_config pchan);
|
||||
@@ -41,14 +63,14 @@ struct gsm_lchan *lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr)
|
||||
struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr);
|
||||
|
||||
/* Allocate a logical channel (SDCCH, TCH, ...) */
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type);
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, int allow_bigger);
|
||||
|
||||
/* Free a logical channel (SDCCH, TCH, ...) */
|
||||
void lchan_free(struct gsm_lchan *lchan);
|
||||
void lchan_reset(struct gsm_lchan *lchan);
|
||||
|
||||
/* Consider releasing the channel */
|
||||
int lchan_auto_release(struct gsm_lchan *lchan);
|
||||
/* internal.. do not use */
|
||||
int _lchan_release(struct gsm_lchan *lchan, u_int8_t release_reason);
|
||||
|
||||
struct load_counter {
|
||||
unsigned int total;
|
||||
|
||||
@@ -29,6 +29,7 @@ enum {
|
||||
DHO,
|
||||
DDB,
|
||||
DREF,
|
||||
DNAT,
|
||||
Debug_LastEntry,
|
||||
};
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ struct e1inp_ts {
|
||||
struct {
|
||||
/* list of all signalling links on this TS */
|
||||
struct llist_head sign_links;
|
||||
/* delay for the queue */
|
||||
int delay;
|
||||
/* timer when to dequeue next frame */
|
||||
struct timer_list tx_timer;
|
||||
} sign;
|
||||
@@ -93,6 +95,7 @@ struct e1inp_driver {
|
||||
struct llist_head list;
|
||||
const char *name;
|
||||
int (*want_write)(struct e1inp_ts *ts);
|
||||
int default_delay;
|
||||
};
|
||||
|
||||
struct e1inp_line {
|
||||
|
||||
@@ -16,8 +16,9 @@ struct gsm_trans;
|
||||
void gsm0408_allow_everyone(int allow);
|
||||
|
||||
int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id);
|
||||
enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci);
|
||||
enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci);
|
||||
enum gsm_chan_t get_ctype_by_chreq(struct gsm_network *bts, u_int8_t ra);
|
||||
enum gsm_chreq_reason_t get_reason_by_chreq(u_int8_t ra, int neci);
|
||||
void gsm_net_update_ctype(struct gsm_network *net);
|
||||
|
||||
int gsm48_tx_mm_info(struct gsm_lchan *lchan);
|
||||
int gsm48_tx_mm_auth_req(struct gsm_lchan *lchan, u_int8_t *rand, int key_seq);
|
||||
@@ -44,12 +45,15 @@ int decode_bcd_number(char *output, int output_len, const u_int8_t *bcd_lv,
|
||||
int h_len);
|
||||
|
||||
int send_siemens_mrpci(struct gsm_lchan *lchan, u_int8_t *classmark2_lv);
|
||||
int gsm48_paging_extract_mi(struct msgb *msg, char *mi_string, u_int8_t *mi_type);
|
||||
int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type);
|
||||
int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, u_int8_t *mi_type);
|
||||
int gsm48_handle_paging_resp(struct msgb *msg, struct gsm_subscriber *subscr);
|
||||
|
||||
int gsm48_lchan_modify(struct gsm_lchan *lchan, u_int8_t lchan_mode);
|
||||
int gsm48_rx_rr_modif_ack(struct msgb *msg);
|
||||
int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg);
|
||||
|
||||
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
|
||||
struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,4 +19,7 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char* response_t
|
||||
int gsm0480_send_ussd_reject(const struct msgb *msg,
|
||||
const struct ussd_request *request);
|
||||
|
||||
int gsm0480_send_ussdNotify(struct gsm_lchan *lchan, int level, const char *text);
|
||||
int gsm0480_send_releaseComplete(struct gsm_lchan *lchan);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct bsc_msc_connection;
|
||||
|
||||
enum gsm_phys_chan_config {
|
||||
GSM_PCHAN_NONE,
|
||||
GSM_PCHAN_CCCH,
|
||||
@@ -79,36 +81,15 @@ enum bts_gprs_mode {
|
||||
BTS_GPRS_EGPRS = 2,
|
||||
};
|
||||
|
||||
#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
|
||||
struct msgb;
|
||||
typedef int gsm_cbfn(unsigned int hooknum,
|
||||
unsigned int event,
|
||||
struct msgb *msg,
|
||||
void *data, void *param);
|
||||
|
||||
/*
|
||||
* Use the channel. As side effect the lchannel recycle timer
|
||||
* will be started.
|
||||
*/
|
||||
#define LCHAN_RELEASE_TIMEOUT 20, 0
|
||||
#define use_subscr_con(con) \
|
||||
do { (con)->use_count++; \
|
||||
DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \
|
||||
(con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \
|
||||
(con)->lchan->nr, (con)->use_count); \
|
||||
bsc_schedule_timer(&(con)->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
|
||||
|
||||
#define put_subscr_con(con) \
|
||||
do { (con)->use_count--; \
|
||||
DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \
|
||||
(con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \
|
||||
(con)->lchan->nr, (con)->use_count); \
|
||||
} while(0);
|
||||
|
||||
|
||||
/* communications link with a BTS */
|
||||
struct gsm_bts_link {
|
||||
struct gsm_bts *bts;
|
||||
};
|
||||
struct osmo_bsc_rf;
|
||||
struct sccp_connection;
|
||||
|
||||
/* Real authentication information containing Ki */
|
||||
enum gsm_auth_algo {
|
||||
@@ -137,6 +118,49 @@ struct gsm_subscriber;
|
||||
struct gsm_mncc;
|
||||
struct rtp_socket;
|
||||
|
||||
/* BSC/MSC data holding them together */
|
||||
struct bss_sccp_connection_data {
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_lchan *secondary_lchan;
|
||||
struct sccp_connection *sccp;
|
||||
int ciphering_handled : 1;
|
||||
|
||||
int new_subscriber;
|
||||
|
||||
/* Timers... */
|
||||
|
||||
/* for assginment command */
|
||||
struct timer_list T10;
|
||||
|
||||
/* for SCCP ... */
|
||||
struct timer_list sccp_cc_timeout;
|
||||
struct timer_list sccp_it;
|
||||
|
||||
/* audio handling */
|
||||
int rtp_port;
|
||||
|
||||
/* Queue SCCP and GSM0408 messages */
|
||||
int block_gsm;
|
||||
struct llist_head gsm_queue;
|
||||
unsigned int gsm_queue_size;
|
||||
|
||||
struct llist_head sccp_queue;
|
||||
unsigned int sccp_queue_size;
|
||||
|
||||
/* which msc connection to use? */
|
||||
struct bsc_msc_connection *msc_con;
|
||||
|
||||
/* Active connections */
|
||||
struct llist_head active_connections;
|
||||
};
|
||||
|
||||
#define GSM0808_T10_VALUE 6, 0
|
||||
#define sccp_get_lchan(data_ctx) ((struct bss_sccp_connection_data *)data_ctx)->lchan
|
||||
#define lchan_get_sccp(lchan) lchan->msc_data->sccp
|
||||
struct bss_sccp_connection_data *bss_sccp_create_data();
|
||||
void bss_sccp_free_data(struct bss_sccp_connection_data *);
|
||||
|
||||
|
||||
/* Network Management State */
|
||||
struct gsm_nm_state {
|
||||
u_int8_t operational;
|
||||
@@ -185,6 +209,7 @@ enum gsm_lchan_state {
|
||||
LCHAN_S_ACT_REQ, /* channel activatin requested */
|
||||
LCHAN_S_ACTIVE, /* channel is active and operational */
|
||||
LCHAN_S_REL_REQ, /* channel release has been requested */
|
||||
LCHAN_S_REL_ERR, /* channel is in an error state */
|
||||
LCHAN_S_INACTIVE, /* channel is set inactive */
|
||||
};
|
||||
|
||||
@@ -193,9 +218,6 @@ struct gsm_subscriber_connection {
|
||||
/* To whom we are allocated at the moment */
|
||||
struct gsm_subscriber *subscr;
|
||||
|
||||
/* Timer started to release the channel */
|
||||
struct timer_list release_timer;
|
||||
|
||||
/*
|
||||
* Operations that have a state and might be pending
|
||||
*/
|
||||
@@ -203,6 +225,7 @@ struct gsm_subscriber_connection {
|
||||
|
||||
/* use count. how many users use this channel */
|
||||
unsigned int use_count;
|
||||
int hand_off;
|
||||
|
||||
/* Are we part of a special "silent" call */
|
||||
int silent_call;
|
||||
@@ -236,6 +259,8 @@ struct gsm_lchan {
|
||||
} encr;
|
||||
|
||||
struct timer_list T3101;
|
||||
struct timer_list T3111;
|
||||
struct timer_list error_timer;
|
||||
|
||||
/* AMR bits */
|
||||
struct gsm48_multi_rate_conf mr_conf;
|
||||
@@ -243,6 +268,15 @@ struct gsm_lchan {
|
||||
/* Established data link layer services */
|
||||
u_int8_t sapis[8];
|
||||
|
||||
/*
|
||||
* MSC handling...
|
||||
*/
|
||||
struct bss_sccp_connection_data *msc_data;
|
||||
|
||||
/* GSM Random Access data */
|
||||
struct gsm48_req_ref *rqd_ref;
|
||||
uint8_t rqd_ta;
|
||||
|
||||
/* cache of last measurement reports on this lchan */
|
||||
struct gsm_meas_rep meas_rep[6];
|
||||
int meas_rep_idx;
|
||||
@@ -256,13 +290,18 @@ struct gsm_lchan {
|
||||
u_int16_t bound_port;
|
||||
u_int16_t connect_port;
|
||||
u_int16_t conn_id;
|
||||
u_int8_t rtp_payload;
|
||||
u_int8_t rtp_payload2;
|
||||
u_int8_t speech_mode;
|
||||
struct rtp_socket *rtp_socket;
|
||||
} abis_ip;
|
||||
|
||||
struct gsm_subscriber_connection conn;
|
||||
|
||||
/* release reason */
|
||||
u_int8_t release_reason;
|
||||
|
||||
/* timestamp */
|
||||
struct timeval alloc_time;
|
||||
};
|
||||
|
||||
struct gsm_e1_subslot {
|
||||
@@ -378,6 +417,10 @@ struct gsm_bts_paging_state {
|
||||
struct gsm_bts *bts;
|
||||
|
||||
struct timer_list work_timer;
|
||||
struct timer_list credit_timer;
|
||||
|
||||
/* free chans needed */
|
||||
int free_chans_need;
|
||||
|
||||
/* load */
|
||||
u_int16_t available_slots;
|
||||
@@ -486,18 +529,28 @@ struct gsm_bts {
|
||||
struct {
|
||||
struct gsm_nm_state nm_state;
|
||||
u_int16_t nsei;
|
||||
uint8_t timer[7];
|
||||
} nse;
|
||||
struct {
|
||||
struct gsm_nm_state nm_state;
|
||||
u_int16_t bvci;
|
||||
uint8_t timer[11];
|
||||
} cell;
|
||||
struct gsm_bts_gprs_nsvc nsvc[2];
|
||||
u_int8_t rac;
|
||||
} gprs;
|
||||
|
||||
/* RACH NM values */
|
||||
int rach_b_thresh;
|
||||
int rach_ldavg_slots;
|
||||
|
||||
/* transceivers */
|
||||
int num_trx;
|
||||
struct llist_head trx_list;
|
||||
|
||||
/* Abis NM queue */
|
||||
struct llist_head abis_queue;
|
||||
int abis_nm_pend;
|
||||
};
|
||||
|
||||
/* Some statistics of our network */
|
||||
@@ -560,6 +613,14 @@ enum gsm_auth_policy {
|
||||
#define GSM_T3101_DEFAULT 10
|
||||
#define GSM_T3113_DEFAULT 60
|
||||
|
||||
/*
|
||||
* internal data for audio management
|
||||
*/
|
||||
struct gsm_audio_support {
|
||||
u_int8_t hr : 1,
|
||||
ver : 7;
|
||||
};
|
||||
|
||||
struct gsm_network {
|
||||
/* global parameters */
|
||||
u_int16_t country_code;
|
||||
@@ -590,6 +651,11 @@ struct gsm_network {
|
||||
|
||||
struct gsmnet_stats stats;
|
||||
|
||||
struct gsm_audio_support **audio_support;
|
||||
int audio_length;
|
||||
int rtp_payload;
|
||||
int rtp_base_port;
|
||||
|
||||
/* layer 4 */
|
||||
int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg);
|
||||
struct llist_head upqueue;
|
||||
@@ -615,6 +681,30 @@ struct gsm_network {
|
||||
struct {
|
||||
enum rrlp_mode mode;
|
||||
} rrlp;
|
||||
|
||||
enum gsm_chan_t ctype_by_chreq[16];
|
||||
|
||||
/* enable the DTXu and DTXd for this network */
|
||||
int dtx_enabled;
|
||||
|
||||
/* Use a TCH for handling requests of type paging any */
|
||||
int pag_any_tch;
|
||||
|
||||
/* a hack for On Waves. It must be signed */
|
||||
int32_t core_country_code;
|
||||
int32_t core_network_code;
|
||||
|
||||
/* a simple token for this network... */
|
||||
char *bsc_token;
|
||||
char *msc_ip;
|
||||
int msc_port;
|
||||
int msc_ip_dscp;
|
||||
struct bsc_msc_connection *msc_con;
|
||||
int ping_timeout;
|
||||
int pong_timeout;
|
||||
struct osmo_bsc_rf *rf;
|
||||
char *ussd_grace_txt;
|
||||
char *ussd_welcome_txt;
|
||||
};
|
||||
|
||||
#define SMS_HDR_SIZE 128
|
||||
@@ -716,14 +806,6 @@ const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
|
||||
|
||||
void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
|
||||
|
||||
/* A parsed GPRS routing area */
|
||||
struct gprs_ra_id {
|
||||
u_int16_t mnc;
|
||||
u_int16_t mcc;
|
||||
u_int16_t lac;
|
||||
u_int8_t rac;
|
||||
};
|
||||
|
||||
int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts);
|
||||
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
|
||||
struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan);
|
||||
|
||||
@@ -81,6 +81,8 @@ struct gsm_subscriber *subscr_get_by_extension(struct gsm_network *net,
|
||||
const char *ext);
|
||||
struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
|
||||
unsigned long long id);
|
||||
struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
|
||||
const char *imsi);
|
||||
int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason);
|
||||
void subscr_put_channel(struct gsm_lchan *lchan);
|
||||
void subscr_get_channel(struct gsm_subscriber *subscr,
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define RTP_PORT_DEFAULT 4000
|
||||
|
||||
#define RTP_PORT_NET_DEFAULT 16000
|
||||
/**
|
||||
* Calculate the RTP audio port for the given multiplex
|
||||
* and the direction. This allows a semi static endpoint
|
||||
@@ -75,38 +75,62 @@ struct mgcp_config;
|
||||
#define MGCP_POLICY_REJECT 5
|
||||
#define MGCP_POLICY_DEFER 6
|
||||
|
||||
typedef int (*mgcp_change)(struct mgcp_config *cfg, int endpoint, int state, int local_rtp);
|
||||
typedef int (*mgcp_realloc)(struct mgcp_config *cfg, int endpoint);
|
||||
typedef int (*mgcp_change)(struct mgcp_config *cfg, int endpoint, int state);
|
||||
typedef int (*mgcp_policy)(struct mgcp_config *cfg, int endpoint, int state, const char *transactio_id);
|
||||
typedef int (*mgcp_reset)(struct mgcp_config *cfg);
|
||||
|
||||
#define PORT_ALLOC_STATIC 0
|
||||
#define PORT_ALLOC_DYNAMIC 1
|
||||
|
||||
/**
|
||||
* This holds information on how to allocate ports
|
||||
*/
|
||||
struct mgcp_port_range {
|
||||
int mode;
|
||||
|
||||
/* pre-allocated from a base? */
|
||||
int base_port;
|
||||
|
||||
/* dynamically allocated */
|
||||
int range_start;
|
||||
int range_end;
|
||||
int last_port;
|
||||
};
|
||||
|
||||
struct mgcp_config {
|
||||
/* common configuration */
|
||||
int source_port;
|
||||
char *local_ip;
|
||||
char *source_addr;
|
||||
unsigned int number_endpoints;
|
||||
char *bts_ip;
|
||||
char *call_agent_addr;
|
||||
|
||||
/* default endpoint data */
|
||||
struct in_addr bts_in;
|
||||
char *audio_name;
|
||||
int audio_payload;
|
||||
int audio_loop;
|
||||
int early_bind;
|
||||
int rtp_base_port;
|
||||
|
||||
char *forward_ip;
|
||||
int forward_port;
|
||||
struct mgcp_port_range bts_ports;
|
||||
struct mgcp_port_range net_ports;
|
||||
int endp_dscp;
|
||||
|
||||
/* endpoint configuration */
|
||||
unsigned int number_endpoints;
|
||||
struct mgcp_endpoint *endpoints;
|
||||
|
||||
/* spec handling */
|
||||
int force_realloc;
|
||||
|
||||
/* callback functionality */
|
||||
mgcp_change change_cb;
|
||||
mgcp_policy policy_cb;
|
||||
mgcp_reset reset_cb;
|
||||
mgcp_realloc realloc_cb;
|
||||
void *data;
|
||||
|
||||
struct mgcp_endpoint *endpoints;
|
||||
unsigned int last_call_id;
|
||||
uint32_t last_call_id;
|
||||
};
|
||||
|
||||
/* config management */
|
||||
@@ -114,7 +138,6 @@ struct mgcp_config *mgcp_config_alloc(void);
|
||||
int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg);
|
||||
int mgcp_vty_init(void);
|
||||
int mgcp_endpoints_allocate(struct mgcp_config *cfg);
|
||||
int mgcp_bind_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
|
||||
void mgcp_free_endp(struct mgcp_endpoint *endp);
|
||||
|
||||
/*
|
||||
@@ -128,7 +151,7 @@ static inline int mgcp_timeslot_to_endpoint(int multiplex, int timeslot)
|
||||
{
|
||||
if (timeslot == 0)
|
||||
timeslot = 1;
|
||||
return timeslot + (31 * multiplex);
|
||||
return timeslot + (32 * multiplex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,39 +28,86 @@
|
||||
|
||||
#define CI_UNUSED 0
|
||||
|
||||
enum mgcp_connection_mode {
|
||||
MGCP_CONN_NONE = 0,
|
||||
MGCP_CONN_RECV_ONLY = 1,
|
||||
MGCP_CONN_SEND_ONLY = 2,
|
||||
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
|
||||
MGCP_CONN_LOOPBACK = 4,
|
||||
};
|
||||
|
||||
struct mgcp_rtp_state {
|
||||
int initialized;
|
||||
int patch;
|
||||
|
||||
uint32_t orig_ssrc;
|
||||
uint32_t ssrc;
|
||||
uint16_t seq_no;
|
||||
int lost_no;
|
||||
int seq_offset;
|
||||
uint32_t last_timestamp;
|
||||
int32_t timestamp_offset;
|
||||
};
|
||||
|
||||
struct mgcp_rtp_end {
|
||||
/* statistics */
|
||||
unsigned int packets;
|
||||
struct in_addr addr;
|
||||
|
||||
/* in network byte order */
|
||||
int rtp_port, rtcp_port;
|
||||
|
||||
int payload_type;
|
||||
|
||||
/*
|
||||
* Each end has a socket...
|
||||
*/
|
||||
struct bsc_fd rtp;
|
||||
struct bsc_fd rtcp;
|
||||
|
||||
int local_port;
|
||||
int local_alloc;
|
||||
};
|
||||
|
||||
enum {
|
||||
MGCP_TAP_BTS_IN,
|
||||
MGCP_TAP_BTS_OUT,
|
||||
MGCP_TAP_NET_IN,
|
||||
MGCP_TAP_NET_OUT,
|
||||
|
||||
/* last element */
|
||||
MGCP_TAP_COUNT
|
||||
};
|
||||
|
||||
struct mgcp_rtp_tap {
|
||||
int enabled;
|
||||
struct sockaddr_in forward;
|
||||
};
|
||||
|
||||
struct mgcp_endpoint {
|
||||
int ci;
|
||||
int allocated;
|
||||
uint32_t ci;
|
||||
char *callid;
|
||||
char *local_options;
|
||||
int conn_mode;
|
||||
|
||||
int bts_payload_type;
|
||||
int net_payload_type;
|
||||
|
||||
/* the local rtp port we are binding to */
|
||||
int rtp_port;
|
||||
|
||||
/*
|
||||
* RTP mangling:
|
||||
* - we get RTP and RTCP to us and need to forward to the BTS
|
||||
* - we get RTP and RTCP from the BTS and forward to the network
|
||||
*/
|
||||
struct bsc_fd local_rtp;
|
||||
struct bsc_fd local_rtcp;
|
||||
|
||||
struct in_addr remote;
|
||||
struct in_addr bts;
|
||||
|
||||
/* in network byte order */
|
||||
int net_rtp, net_rtcp;
|
||||
int bts_rtp, bts_rtcp;
|
||||
int orig_mode;
|
||||
|
||||
/* backpointer */
|
||||
struct mgcp_config *cfg;
|
||||
|
||||
/* statistics */
|
||||
unsigned int in_bts;
|
||||
unsigned int in_remote;
|
||||
/* port status for bts/net */
|
||||
struct mgcp_rtp_end bts_end;
|
||||
struct mgcp_rtp_end net_end;
|
||||
|
||||
/* sequence bits */
|
||||
struct mgcp_rtp_state net_state;
|
||||
struct mgcp_rtp_state bts_state;
|
||||
|
||||
/* SSRC/seq/ts patching for loop */
|
||||
int allow_patch;
|
||||
|
||||
/* tap for the endpoint */
|
||||
struct mgcp_rtp_tap taps[MGCP_TAP_COUNT];
|
||||
};
|
||||
|
||||
#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
|
||||
@@ -73,5 +120,9 @@ struct mgcp_msg_ptr {
|
||||
int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
|
||||
struct mgcp_msg_ptr *ptr, int size,
|
||||
const char **transaction_id, struct mgcp_endpoint **endp);
|
||||
int mgcp_send_dummy(struct mgcp_endpoint *endp);
|
||||
int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
|
||||
int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port);
|
||||
int mgcp_free_rtp_port(struct mgcp_rtp_end *end);
|
||||
|
||||
#endif
|
||||
|
||||
29
openbsc/include/openbsc/osmo_bsc_grace.h
Normal file
29
openbsc/include/openbsc/osmo_bsc_grace.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OSMO_BSC_GRACE_H
|
||||
#define OSMO_BSC_GRACE_H
|
||||
|
||||
#include "gsm_data.h"
|
||||
|
||||
int bsc_grace_allow_new_connection(struct gsm_network *network);
|
||||
|
||||
#endif
|
||||
22
openbsc/include/openbsc/osmo_bsc_rf.h
Normal file
22
openbsc/include/openbsc/osmo_bsc_rf.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef BSC_MSC_RF
|
||||
#define BSC_MSC_RF
|
||||
|
||||
#include <osmocore/write_queue.h>
|
||||
|
||||
struct gsm_network;
|
||||
|
||||
struct osmo_bsc_rf {
|
||||
/* the value of signal.h */
|
||||
int policy;
|
||||
struct bsc_fd listen;
|
||||
struct gsm_network *gsm_network;
|
||||
};
|
||||
|
||||
struct osmo_bsc_rf_conn {
|
||||
struct write_queue queue;
|
||||
struct osmo_bsc_rf *rf;
|
||||
};
|
||||
|
||||
struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net);
|
||||
|
||||
#endif
|
||||
@@ -43,4 +43,7 @@ void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
||||
/* update paging load */
|
||||
void paging_update_buffer_space(struct gsm_bts *bts, u_int16_t);
|
||||
|
||||
/* pending paging requests */
|
||||
unsigned int paging_pending_requests_nr(struct gsm_bts *bts);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,12 +28,6 @@
|
||||
#include <osmocore/linuxlist.h>
|
||||
#include <osmocore/select.h>
|
||||
|
||||
#define RTP_PT_GSM_FULL 3
|
||||
#define RTP_PT_GSM_HALF 96
|
||||
#define RTP_PT_GSM_EFR 97
|
||||
#define RTP_PT_AMR_FULL 98
|
||||
#define RTP_PT_AMR_HALF 99
|
||||
|
||||
enum rtp_rx_action {
|
||||
RTP_NONE,
|
||||
RTP_PROXY,
|
||||
|
||||
@@ -43,6 +43,7 @@ enum signal_subsystems {
|
||||
SS_SCALL,
|
||||
SS_GLOBAL,
|
||||
SS_CHALLOC,
|
||||
SS_RF,
|
||||
};
|
||||
|
||||
/* SS_PAGING signals */
|
||||
@@ -118,6 +119,13 @@ enum signal_global {
|
||||
S_GLOBAL_SHUTDOWN,
|
||||
};
|
||||
|
||||
/* SS_RF signals */
|
||||
enum signal_rf {
|
||||
S_RF_OFF,
|
||||
S_RF_ON,
|
||||
S_RF_GRACE,
|
||||
};
|
||||
|
||||
struct paging_signal_data {
|
||||
struct gsm_subscriber *subscr;
|
||||
struct gsm_bts *bts;
|
||||
@@ -133,7 +141,7 @@ struct scall_signal_data {
|
||||
};
|
||||
|
||||
struct ipacc_ack_signal_data {
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_bts_trx *trx;
|
||||
u_int8_t msg_type;
|
||||
};
|
||||
|
||||
@@ -143,4 +151,8 @@ struct challoc_signal_data {
|
||||
enum gsm_chan_t type;
|
||||
};
|
||||
|
||||
struct rf_signal_data {
|
||||
struct gsm_network *net;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
sccp_HEADERS = sccp_types.h sccp.h
|
||||
sccpdir = $(includedir)/sccp
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* SCCP management code
|
||||
*
|
||||
* (C) 2009, 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SCCP_H
|
||||
#define SCCP_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "sccp_types.h"
|
||||
|
||||
struct msgb;
|
||||
struct sccp_system;
|
||||
|
||||
enum {
|
||||
SCCP_CONNECTION_STATE_NONE,
|
||||
SCCP_CONNECTION_STATE_REQUEST,
|
||||
SCCP_CONNECTION_STATE_CONFIRM,
|
||||
SCCP_CONNECTION_STATE_ESTABLISHED,
|
||||
SCCP_CONNECTION_STATE_RELEASE,
|
||||
SCCP_CONNECTION_STATE_RELEASE_COMPLETE,
|
||||
SCCP_CONNECTION_STATE_REFUSED,
|
||||
SCCP_CONNECTION_STATE_SETUP_ERROR,
|
||||
};
|
||||
|
||||
struct sockaddr_sccp {
|
||||
sa_family_t sccp_family; /* AF_SCCP in the future??? */
|
||||
u_int8_t sccp_ssn; /* subssystem number for routing */
|
||||
|
||||
/* TODO fill in address indicator... if that is ever needed */
|
||||
|
||||
/* not sure about these */
|
||||
/* u_int8_t sccp_class; */
|
||||
};
|
||||
|
||||
/*
|
||||
* parsed structure of an address
|
||||
*/
|
||||
struct sccp_address {
|
||||
struct sccp_called_party_address address;
|
||||
u_int8_t ssn;
|
||||
u_int8_t poi[2];
|
||||
};
|
||||
|
||||
struct sccp_optional_data {
|
||||
u_int8_t data_len;
|
||||
u_int8_t data_start;
|
||||
};
|
||||
|
||||
struct sccp_connection {
|
||||
/* public */
|
||||
void *data_ctx;
|
||||
void (*data_cb)(struct sccp_connection *conn, struct msgb *msg, unsigned int len);
|
||||
|
||||
void *state_ctx;
|
||||
void (*state_cb)(struct sccp_connection *, int old_state);
|
||||
|
||||
struct sccp_source_reference source_local_reference;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
|
||||
int connection_state;
|
||||
|
||||
/* private */
|
||||
/* list of active connections */
|
||||
struct llist_head list;
|
||||
struct sccp_system *system;
|
||||
int incoming;
|
||||
};
|
||||
|
||||
/**
|
||||
* system functionality to implement on top of any other transport layer:
|
||||
* call sccp_system_incoming for incoming data (from the network)
|
||||
* sccp will call outgoing whenever outgoing data exists
|
||||
*/
|
||||
int sccp_system_init(void (*outgoing)(struct msgb *data, void *ctx), void *context);
|
||||
int sccp_system_incoming(struct msgb *data);
|
||||
|
||||
/**
|
||||
* Send data on an existing connection
|
||||
*/
|
||||
int sccp_connection_write(struct sccp_connection *connection, struct msgb *data);
|
||||
int sccp_connection_send_it(struct sccp_connection *connection);
|
||||
int sccp_connection_close(struct sccp_connection *connection, int cause);
|
||||
int sccp_connection_free(struct sccp_connection *connection);
|
||||
|
||||
/**
|
||||
* internal..
|
||||
*/
|
||||
int sccp_connection_force_free(struct sccp_connection *conn);
|
||||
|
||||
/**
|
||||
* Create a new socket. Set your callbacks and then call bind to open
|
||||
* the connection.
|
||||
*/
|
||||
struct sccp_connection *sccp_connection_socket(void);
|
||||
|
||||
/**
|
||||
* Open the connection and send additional data
|
||||
*/
|
||||
int sccp_connection_connect(struct sccp_connection *conn,
|
||||
const struct sockaddr_sccp *sccp_called,
|
||||
struct msgb *data);
|
||||
|
||||
/**
|
||||
* mostly for testing purposes only. Set the accept callback.
|
||||
* TODO: add true routing information... in analogy to socket, bind, accept
|
||||
*/
|
||||
int sccp_connection_set_incoming(const struct sockaddr_sccp *sock,
|
||||
int (*accept_cb)(struct sccp_connection *connection, void *data),
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* Send data in terms of unit data. A fixed address indicator will be used.
|
||||
*/
|
||||
int sccp_write(struct msgb *data,
|
||||
const struct sockaddr_sccp *sock_sender,
|
||||
const struct sockaddr_sccp *sock_target, int class);
|
||||
int sccp_set_read(const struct sockaddr_sccp *sock,
|
||||
int (*read_cb)(struct msgb *msgb, unsigned int, void *user_data),
|
||||
void *user_data);
|
||||
|
||||
/* generic sock addresses */
|
||||
extern const struct sockaddr_sccp sccp_ssn_bssap;
|
||||
|
||||
/* helpers */
|
||||
u_int32_t sccp_src_ref_to_int(struct sccp_source_reference *ref);
|
||||
struct sccp_source_reference sccp_src_ref_from_int(u_int32_t);
|
||||
|
||||
/**
|
||||
* Below this are helper functions and structs for parsing SCCP messages
|
||||
*/
|
||||
struct sccp_parse_result {
|
||||
struct sccp_address called;
|
||||
struct sccp_address calling;
|
||||
|
||||
/* point to the msg packet */
|
||||
struct sccp_source_reference *source_local_reference;
|
||||
struct sccp_source_reference *destination_local_reference;
|
||||
|
||||
/* data pointer */
|
||||
int data_len;
|
||||
};
|
||||
|
||||
/*
|
||||
* helper functions for the nat code
|
||||
*/
|
||||
int sccp_determine_msg_type(struct msgb *msg);
|
||||
int sccp_parse_header(struct msgb *msg, struct sccp_parse_result *result);
|
||||
|
||||
#endif
|
||||
@@ -1,414 +0,0 @@
|
||||
/*
|
||||
* ITU Q.713 defined types for SCCP
|
||||
*
|
||||
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SCCP_TYPES_H
|
||||
#define SCCP_TYPES_H
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
/* Table 1/Q.713 - SCCP message types */
|
||||
enum sccp_message_types {
|
||||
SCCP_MSG_TYPE_CR = 1,
|
||||
SCCP_MSG_TYPE_CC = 2,
|
||||
SCCP_MSG_TYPE_CREF = 3,
|
||||
SCCP_MSG_TYPE_RLSD = 4,
|
||||
SCCP_MSG_TYPE_RLC = 5,
|
||||
SCCP_MSG_TYPE_DT1 = 6,
|
||||
SCCP_MSG_TYPE_DT2 = 7,
|
||||
SCCP_MSG_TYPE_AK = 8,
|
||||
SCCP_MSG_TYPE_UDT = 9,
|
||||
SCCP_MSG_TYPE_UDTS = 10,
|
||||
SCCP_MSG_TYPE_ED = 11,
|
||||
SCCP_MSG_TYPE_EA = 12,
|
||||
SCCP_MSG_TYPE_RSR = 13,
|
||||
SCCP_MSG_TYPE_RSC = 14,
|
||||
SCCP_MSG_TYPE_ERR = 15,
|
||||
SCCP_MSG_TYPE_IT = 16,
|
||||
SCCP_MSG_TYPE_XUDT = 17,
|
||||
SCCP_MSG_TYPE_XUDTS = 18,
|
||||
SCCP_MSG_TYPE_LUDT = 19,
|
||||
SCCP_MSG_TYPE_LUDTS = 20
|
||||
};
|
||||
|
||||
/* Table 2/Q.713 - SCCP parameter name codes */
|
||||
enum sccp_parameter_name_codes {
|
||||
SCCP_PNC_END_OF_OPTIONAL = 0,
|
||||
SCCP_PNC_DESTINATION_LOCAL_REFERENCE = 1,
|
||||
SCCP_PNC_SOURCE_LOCAL_REFERENCE = 2,
|
||||
SCCP_PNC_CALLED_PARTY_ADDRESS = 3,
|
||||
SCCP_PNC_CALLING_PARTY_ADDRESS = 4,
|
||||
SCCP_PNC_PROTOCOL_CLASS = 5,
|
||||
SCCP_PNC_SEGMENTING = 6,
|
||||
SCCP_PNC_RECEIVE_SEQ_NUMBER = 7,
|
||||
SCCP_PNC_SEQUENCING = 8,
|
||||
SCCP_PNC_CREDIT = 9,
|
||||
SCCP_PNC_RELEASE_CAUSE = 10,
|
||||
SCCP_PNC_RETURN_CAUSE = 11,
|
||||
SCCP_PNC_RESET_CAUSE = 12,
|
||||
SCCP_PNC_ERROR_CAUSE = 13,
|
||||
SCCP_PNC_REFUSAL_CAUSE = 14,
|
||||
SCCP_PNC_DATA = 15,
|
||||
SCCP_PNC_SEGMENTATION = 16,
|
||||
SCCP_PNC_HOP_COUNTER = 17,
|
||||
SCCP_PNC_IMPORTANCE = 18,
|
||||
SCCP_PNC_LONG_DATA = 19,
|
||||
};
|
||||
|
||||
/* Figure 3/Q.713 Called/calling party address */
|
||||
enum {
|
||||
SCCP_TITLE_IND_NONE = 0,
|
||||
SCCP_TITLE_IND_NATURE_ONLY = 1,
|
||||
SCCP_TITLE_IND_TRANSLATION_ONLY = 2,
|
||||
SCCP_TITLE_IND_TRANS_NUM_ENC = 3,
|
||||
SCCP_TITLE_IND_TRANS_NUM_ENC_NATURE = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
SCCP_CALL_ROUTE_ON_SSN = 1,
|
||||
SCCP_CALL_ROUTE_ON_GT = 0,
|
||||
};
|
||||
|
||||
struct sccp_called_party_address {
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
u_int8_t point_code_indicator : 1,
|
||||
ssn_indicator : 1,
|
||||
global_title_indicator : 4,
|
||||
routing_indicator : 1,
|
||||
reserved : 1;
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
u_int8_t reserved : 1,
|
||||
routing_indicator : 1,
|
||||
global_title_indicator : 4,
|
||||
ssn_indicator : 1,
|
||||
point_code_indicator : 1;
|
||||
#endif
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/* indicator indicates presence in the above order */
|
||||
|
||||
/* Figure 6/Q.713 */
|
||||
struct sccp_signalling_point_code {
|
||||
u_int8_t lsb;
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
u_int8_t msb : 6,
|
||||
reserved : 2;
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
u_int8_t reserved : 2,
|
||||
msb : 6;
|
||||
#endif
|
||||
} __attribute__((packed));
|
||||
|
||||
/* SSN == subsystem number */
|
||||
enum sccp_subsystem_number {
|
||||
SCCP_SSN_NOT_KNOWN_OR_USED = 0,
|
||||
SCCP_SSN_MANAGEMENT = 1,
|
||||
SCCP_SSN_RESERVED_ITU = 2,
|
||||
SCCP_SSN_ISDN_USER_PART = 3,
|
||||
SCCP_SSN_OMAP = 4, /* operation, maint and administration part */
|
||||
SCCP_SSN_MAP = 5, /* mobile application part */
|
||||
SCCP_SSN_HLR = 6,
|
||||
SCCP_SSN_VLR = 7,
|
||||
SCCP_SSN_MSC = 8,
|
||||
SCCP_SSN_EIC = 9, /* equipent identifier centre */
|
||||
SCCP_SSN_AUC = 10, /* authentication centre */
|
||||
SCCP_SSN_ISDN_SUPPL_SERVICES = 11,
|
||||
SCCP_SSN_RESERVED_INTL = 12,
|
||||
SCCP_SSN_ISDN_EDGE_TO_EDGE = 13,
|
||||
SCCP_SSN_TC_TEST_RESPONDER = 14,
|
||||
|
||||
/* From GSM 03.03 8.2 */
|
||||
SCCP_SSN_BSSAP = 254,
|
||||
SCCP_SSN_BSSOM = 253,
|
||||
};
|
||||
|
||||
/* Q.713, 3.4.2.3 */
|
||||
enum {
|
||||
SCCP_NAI_UNKNOWN = 0,
|
||||
SCCP_NAI_SUBSCRIBER_NUMBER = 1,
|
||||
SCCP_NAI_RESERVED_NATIONAL = 2,
|
||||
SCCP_NAI_NATIONAL_SIGNIFICANT = 3,
|
||||
SCCP_NAI_INTERNATIONAL = 4,
|
||||
};
|
||||
|
||||
struct sccp_global_title {
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
u_int8_t nature_of_addr_ind : 7,
|
||||
odd_even : 1;
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
u_int8_t odd_even : 1,
|
||||
nature_of_addr_ind : 7;
|
||||
#endif
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/* Q.713, 3.3 */
|
||||
struct sccp_source_reference {
|
||||
u_int8_t octet1;
|
||||
u_int8_t octet2;
|
||||
u_int8_t octet3;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* Q.714, 3.6 */
|
||||
enum sccp_protocol_class {
|
||||
SCCP_PROTOCOL_CLASS_0 = 0,
|
||||
SCCP_PROTOCOL_CLASS_1 = 1,
|
||||
SCCP_PROTOCOL_CLASS_2 = 2,
|
||||
SCCP_PROTOCOL_CLASS_3 = 3,
|
||||
};
|
||||
|
||||
/* bits 5-8 when class0, class1 is used */
|
||||
enum sccp_protocol_options {
|
||||
SCCP_PROTOCOL_NO_SPECIAL = 0,
|
||||
SCCP_PROTOCOL_RETURN_MESSAGE = 8,
|
||||
};
|
||||
|
||||
enum sccp_release_cause {
|
||||
SCCP_RELEASE_CAUSE_END_USER_ORIGINATED = 0,
|
||||
SCCP_RELEASE_CAUSE_END_USER_CONGESTION = 1,
|
||||
SCCP_RELEASE_CAUSE_END_USER_FAILURE = 2,
|
||||
SCCP_RELEASE_CAUSE_SCCP_USER_ORIGINATED = 3,
|
||||
SCCP_RELEASE_CAUSE_REMOTE_PROCEDURE_ERROR = 4,
|
||||
SCCP_RELEASE_CAUSE_INCONSISTENT_CONN_DATA = 5,
|
||||
SCCP_RELEASE_CAUSE_ACCESS_FAILURE = 6,
|
||||
SCCP_RELEASE_CAUSE_ACCESS_CONGESTION = 7,
|
||||
SCCP_RELEASE_CAUSE_SUBSYSTEM_FAILURE = 8,
|
||||
SCCP_RELEASE_CAUSE_SUBSYSTEM_CONGESTION = 9,
|
||||
SCCP_RELEASE_CAUSE_MTP_FAILURE = 10,
|
||||
SCCP_RELEASE_CAUSE_NETWORK_CONGESTION = 11,
|
||||
SCCP_RELEASE_CAUSE_EXPIRATION_RESET = 12,
|
||||
SCCP_RELEASE_CAUSE_EXPIRATION_INACTIVE = 13,
|
||||
SCCP_RELEASE_CAUSE_RESERVED = 14,
|
||||
SCCP_RELEASE_CAUSE_UNQUALIFIED = 15,
|
||||
SCCP_RELEASE_CAUSE_SCCP_FAILURE = 16,
|
||||
};
|
||||
|
||||
enum sccp_return_cause {
|
||||
SCCP_RETURN_CAUSE_NO_TRANSLATION_NATURE = 0,
|
||||
SCCP_RETURN_CAUSE_NO_TRANSLATION = 1,
|
||||
SCCP_RETURN_CAUSE_SUBSYSTEM_CONGESTION = 2,
|
||||
SCCP_RETURN_CAUSE_SUBSYSTEM_FAILURE = 3,
|
||||
SCCP_RETURN_CAUSE_UNEQUIPPED_USER = 4,
|
||||
SCCP_RETURN_CAUSE_MTP_FAILURE = 5,
|
||||
SCCP_RETURN_CAUSE_NETWORK_CONGESTION = 6,
|
||||
SCCP_RETURN_CAUSE_UNQUALIFIED = 7,
|
||||
SCCP_RETURN_CAUSE_ERROR_IN_MSG_TRANSPORT = 8,
|
||||
SCCP_RETURN_CAUSE_ERROR_IN_LOCAL_PROCESSING = 9,
|
||||
SCCP_RETURN_CAUSE_DEST_CANNOT_PERFORM_REASSEMBLY = 10,
|
||||
SCCP_RETURN_CAUSE_SCCP_FAILURE = 11,
|
||||
SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION = 12,
|
||||
SCCP_RETURN_CAUSE_SEGMENTATION_NOT_SUPPORTED= 13,
|
||||
SCCP_RETURN_CAUSE_SEGMENTATION_FAOLURE = 14
|
||||
};
|
||||
|
||||
enum sccp_reset_cause {
|
||||
SCCP_RESET_CAUSE_END_USER_ORIGINATED = 0,
|
||||
SCCP_RESET_CAUSE_SCCP_USER_ORIGINATED = 1,
|
||||
SCCP_RESET_CAUSE_MSG_OUT_OF_ORDER_PS = 2,
|
||||
SCCP_RESET_CAUSE_MSG_OUT_OF_ORDER_PR = 3,
|
||||
SCCP_RESET_CAUSE_RPC_OUT_OF_WINDOW = 4,
|
||||
SCCP_RESET_CAUSE_RPC_INCORRECT_PS = 5,
|
||||
SCCP_RESET_CAUSE_RPC_GENERAL = 6,
|
||||
SCCP_RESET_CAUSE_REMOTE_END_USER_OPERATIONAL= 7,
|
||||
SCCP_RESET_CAUSE_NETWORK_OPERATIONAL = 8,
|
||||
SCCP_RESET_CAUSE_ACCESS_OPERATIONAL = 9,
|
||||
SCCP_RESET_CAUSE_NETWORK_CONGESTION = 10,
|
||||
SCCP_RESET_CAUSE_RESERVED = 11,
|
||||
};
|
||||
|
||||
enum sccp_error_cause {
|
||||
SCCP_ERROR_LRN_MISMATCH_UNASSIGNED = 0, /* local reference number */
|
||||
SCCP_ERROR_LRN_MISMATCH_INCONSISTENT = 1,
|
||||
SCCP_ERROR_POINT_CODE_MISMATCH = 2,
|
||||
SCCP_ERROR_SERVICE_CLASS_MISMATCH = 3,
|
||||
SCCP_ERROR_UNQUALIFIED = 4,
|
||||
};
|
||||
|
||||
enum sccp_refusal_cause {
|
||||
SCCP_REFUSAL_END_USER_ORIGINATED = 0,
|
||||
SCCP_REFUSAL_END_USER_CONGESTION = 1,
|
||||
SCCP_REFUSAL_END_USER_FAILURE = 2,
|
||||
SCCP_REFUSAL_SCCP_USER_ORIGINATED = 3,
|
||||
SCCP_REFUSAL_DESTINATION_ADDRESS_UKNOWN = 4,
|
||||
SCCP_REFUSAL_DESTINATION_INACCESSIBLE = 5,
|
||||
SCCP_REFUSAL_NET_QOS_NON_TRANSIENT = 6,
|
||||
SCCP_REFUSAL_NET_QOS_TRANSIENT = 7,
|
||||
SCCP_REFUSAL_ACCESS_FAILURE = 8,
|
||||
SCCP_REFUSAL_ACCESS_CONGESTION = 9,
|
||||
SCCP_REFUSAL_SUBSYSTEM_FAILURE = 10,
|
||||
SCCP_REFUSAL_SUBSYTEM_CONGESTION = 11,
|
||||
SCCP_REFUSAL_EXPIRATION = 12,
|
||||
SCCP_REFUSAL_INCOMPATIBLE_USER_DATA = 13,
|
||||
SCCP_REFUSAL_RESERVED = 14,
|
||||
SCCP_REFUSAL_UNQUALIFIED = 15,
|
||||
SCCP_REFUSAL_HOP_COUNTER_VIOLATION = 16,
|
||||
SCCP_REFUSAL_SCCP_FAILURE = 17,
|
||||
SCCP_REFUSAL_UNEQUIPPED_USER = 18,
|
||||
};
|
||||
|
||||
/*
|
||||
* messages... as of Q.713 Chapter 4
|
||||
*/
|
||||
struct sccp_connection_request {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference source_local_reference;
|
||||
u_int8_t proto_class;
|
||||
|
||||
|
||||
/* variable */
|
||||
u_int8_t variable_called;
|
||||
#if VARIABLE
|
||||
called_party_address
|
||||
#endif
|
||||
|
||||
/* optional */
|
||||
u_int8_t optional_start;
|
||||
|
||||
#if OPTIONAL
|
||||
credit 3
|
||||
callingparty var 4-n
|
||||
data 3-130
|
||||
hop_counter 3
|
||||
importance 3
|
||||
end_of_optional 1
|
||||
#endif
|
||||
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_connection_confirm {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
struct sccp_source_reference source_local_reference;
|
||||
u_int8_t proto_class;
|
||||
|
||||
/* optional */
|
||||
u_int8_t optional_start;
|
||||
|
||||
/* optional */
|
||||
#if OPTIONAL
|
||||
credit 3
|
||||
called party 4
|
||||
data 3-130
|
||||
importance 3
|
||||
end_of_optional 1
|
||||
#endif
|
||||
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_connection_refused {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
u_int8_t cause;
|
||||
|
||||
/* optional */
|
||||
u_int8_t optional_start;
|
||||
|
||||
/* optional */
|
||||
#if OPTIONAL
|
||||
called party 4
|
||||
data 3-130
|
||||
importance 3
|
||||
end_of_optional 1
|
||||
#endif
|
||||
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_connection_released {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
struct sccp_source_reference source_local_reference;
|
||||
u_int8_t release_cause;
|
||||
|
||||
|
||||
/* optional */
|
||||
u_int8_t optional_start;
|
||||
|
||||
#if OPTIONAL
|
||||
data 3-130
|
||||
importance 3
|
||||
end_of_optional 1
|
||||
#endif
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_connection_release_complete {
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
struct sccp_source_reference source_local_reference;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_data_form1 {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
u_int8_t segmenting;
|
||||
|
||||
/* variable */
|
||||
u_int8_t variable_start;
|
||||
|
||||
#if VARIABLE
|
||||
data 2-256;
|
||||
#endif
|
||||
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
struct sccp_data_unitdata {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
u_int8_t proto_class;
|
||||
|
||||
|
||||
/* variable */
|
||||
u_int8_t variable_called;
|
||||
u_int8_t variable_calling;
|
||||
u_int8_t variable_data;
|
||||
|
||||
#if VARIABLE
|
||||
called party address
|
||||
calling party address
|
||||
#endif
|
||||
|
||||
u_int8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_data_it {
|
||||
/* mandantory */
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
struct sccp_source_reference source_local_reference;
|
||||
u_int8_t proto_class;
|
||||
|
||||
u_int8_t sequencing[2];
|
||||
u_int8_t credit;
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@
|
||||
/* Create a new buffer. Memory will be allocated in chunks of the given
|
||||
size. If the argument is 0, the library will supply a reasonable
|
||||
default size suitable for buffering socket I/O. */
|
||||
struct buffer *buffer_new(size_t);
|
||||
struct buffer *buffer_new(void *ctx, size_t);
|
||||
|
||||
/* Free all data in the buffer. */
|
||||
void buffer_reset(struct buffer *);
|
||||
|
||||
@@ -65,6 +65,7 @@ enum node_type {
|
||||
VIEW_NODE, /* View node. Default mode of vty interface. */
|
||||
AUTH_ENABLE_NODE, /* Authentication mode for change enable. */
|
||||
ENABLE_NODE, /* Enable node. */
|
||||
OML_NODE,
|
||||
CONFIG_NODE, /* Config node. Default mode of config file. */
|
||||
SERVICE_NODE, /* Service node. */
|
||||
DEBUG_NODE, /* Debug node. */
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: OpenBSC SCCP Lib
|
||||
Description: OpenBSC SCCP Lib
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lsccp
|
||||
Cflags: -I${includedir}/
|
||||
@@ -1,38 +1,38 @@
|
||||
INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
|
||||
AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
|
||||
AM_LDFLAGS = $(LIBOSMOCORE_LIBS)
|
||||
AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOSCCP_CFLAGS)
|
||||
AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS)
|
||||
|
||||
sbin_PROGRAMS = bsc_hack bs11_config ipaccess-find ipaccess-config \
|
||||
isdnsync bsc_mgcp ipaccess-proxy
|
||||
isdnsync bsc_mgcp ipaccess-proxy \
|
||||
bsc_msc_ip
|
||||
noinst_LIBRARIES = libbsc.a libmsc.a libvty.a
|
||||
noinst_HEADERS = vty/cardshell.h
|
||||
|
||||
bscdir = $(libdir)
|
||||
bsc_LIBRARIES = libsccp.a
|
||||
|
||||
libbsc_a_SOURCES = abis_rsl.c abis_nm.c gsm_data.c gsm_04_08_utils.c \
|
||||
chan_alloc.c debug.c \
|
||||
chan_alloc.c debug.c abis_nm_vty.c \
|
||||
gsm_subscriber_base.c subchan_demux.c bsc_rll.c transaction.c \
|
||||
trau_frame.c trau_mux.c paging.c e1_config.c e1_input.c \
|
||||
input/misdn.c input/ipaccess.c \
|
||||
talloc_ctx.c system_information.c rest_octets.c \
|
||||
rtp_proxy.c bts_siemens_bs11.c bts_ipaccess_nanobts.c \
|
||||
bts_unknown.c bsc_version.c bsc_api.c vty_interface_cmds.c
|
||||
bts_unknown.c meas_rep.c telnet_interface.c bsc_version.c bsc_api.c vty_interface_cmds.c
|
||||
|
||||
libmsc_a_SOURCES = gsm_subscriber.c db.c telnet_interface.c \
|
||||
libmsc_a_SOURCES = gsm_subscriber.c db.c \
|
||||
mncc.c gsm_04_08.c gsm_04_11.c transaction.c \
|
||||
token_auth.c rrlp.c gsm_04_80.c ussd.c silent_call.c \
|
||||
handover_logic.c handover_decision.c meas_rep.c
|
||||
handover_logic.c handover_decision.c
|
||||
|
||||
libvty_a_SOURCES = vty/buffer.c vty/command.c vty/vector.c vty/vty.c
|
||||
|
||||
libsccp_a_SOURCES = sccp/sccp.c
|
||||
|
||||
bsc_hack_SOURCES = bsc_hack.c bsc_init.c vty_interface.c vty_interface_layer3.c
|
||||
bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -ldl -ldbi $(LIBCRYPT)
|
||||
|
||||
bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c debug.c \
|
||||
rs232.c bts_siemens_bs11.c
|
||||
bsc_msc_ip_SOURCES = bssap.c bsc_msc_ip.c bsc_init.c vty_interface.c vty_interface_bsc.c \
|
||||
bsc_msc.c osmo_bsc_rf.c osmo_bsc_grace.c gsm_04_80.c
|
||||
bsc_msc_ip_LDADD = libbsc.a libvty.a $(LIBOSMOSCCP_LIBS)
|
||||
|
||||
|
||||
ipaccess_find_SOURCES = ipaccess/ipaccess-find.c
|
||||
|
||||
@@ -46,3 +46,4 @@ bsc_mgcp_SOURCES = mgcp/mgcp_main.c mgcp/mgcp_protocol.c mgcp/mgcp_network.c mgc
|
||||
bsc_mgcp_LDADD = libvty.a
|
||||
|
||||
ipaccess_proxy_SOURCES = ipaccess/ipaccess-proxy.c debug.c
|
||||
|
||||
|
||||
@@ -410,39 +410,59 @@ static struct msgb *nm_msgb_alloc(void)
|
||||
}
|
||||
|
||||
/* Send a OML NM Message from BSC to BTS */
|
||||
int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg)
|
||||
static int abis_nm_queue_msg(struct gsm_bts *bts, struct msgb *msg)
|
||||
{
|
||||
msg->trx = bts->c0;
|
||||
|
||||
return _abis_nm_sendmsg(msg);
|
||||
/* queue OML messages */
|
||||
if (llist_empty(&bts->abis_queue) && !bts->abis_nm_pend) {
|
||||
bts->abis_nm_pend = OBSC_NM_W_ACK_CB(msg);
|
||||
return _abis_nm_sendmsg(msg);
|
||||
} else {
|
||||
msgb_enqueue(&bts->abis_queue, msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg)
|
||||
{
|
||||
OBSC_NM_W_ACK_CB(msg) = 1;
|
||||
return abis_nm_queue_msg(bts, msg);
|
||||
}
|
||||
|
||||
static int abis_nm_sendmsg_direct(struct gsm_bts *bts, struct msgb *msg)
|
||||
{
|
||||
OBSC_NM_W_ACK_CB(msg) = 0;
|
||||
return abis_nm_queue_msg(bts, msg);
|
||||
}
|
||||
|
||||
static int abis_nm_rcvmsg_sw(struct msgb *mb);
|
||||
|
||||
static struct value_string obj_class_names[] = {
|
||||
{ NM_OC_SITE_MANAGER, "SITE MANAGER" },
|
||||
const struct value_string abis_nm_obj_class_names[] = {
|
||||
{ NM_OC_SITE_MANAGER, "SITE-MANAGER" },
|
||||
{ NM_OC_BTS, "BTS" },
|
||||
{ NM_OC_RADIO_CARRIER, "RADIO CARRIER" },
|
||||
{ NM_OC_BASEB_TRANSC, "BASEBAND TRANSCEIVER" },
|
||||
{ NM_OC_RADIO_CARRIER, "RADIO-CARRIER" },
|
||||
{ NM_OC_BASEB_TRANSC, "BASEBAND-TRANSCEIVER" },
|
||||
{ NM_OC_CHANNEL, "CHANNEL" },
|
||||
{ NM_OC_BS11_ADJC, "ADJC" },
|
||||
{ NM_OC_BS11_HANDOVER, "HANDOVER" },
|
||||
{ NM_OC_BS11_PWR_CTRL, "POWER CONTROL" },
|
||||
{ NM_OC_BS11_PWR_CTRL, "POWER-CONTROL" },
|
||||
{ NM_OC_BS11_BTSE, "BTSE" },
|
||||
{ NM_OC_BS11_RACK, "RACK" },
|
||||
{ NM_OC_BS11_TEST, "TEST" },
|
||||
{ NM_OC_BS11_ENVABTSE, "ENVABTSE" },
|
||||
{ NM_OC_BS11_BPORT, "BPORT" },
|
||||
{ NM_OC_GPRS_NSE, "GPRS NSE" },
|
||||
{ NM_OC_GPRS_CELL, "GPRS CELL" },
|
||||
{ NM_OC_GPRS_NSVC, "GPRS NSVC" },
|
||||
{ NM_OC_GPRS_NSE, "GPRS-NSE" },
|
||||
{ NM_OC_GPRS_CELL, "GPRS-CELL" },
|
||||
{ NM_OC_GPRS_NSVC, "GPRS-NSVC" },
|
||||
{ NM_OC_BS11, "SIEMENSHW" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const char *obj_class_name(u_int8_t oc)
|
||||
{
|
||||
return get_value_string(obj_class_names, oc);
|
||||
return get_value_string(abis_nm_obj_class_names, oc);
|
||||
}
|
||||
|
||||
const char *nm_opstate_name(u_int8_t os)
|
||||
@@ -490,18 +510,17 @@ static struct value_string test_names[] = {
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const struct value_string abis_nm_adm_state_names[] = {
|
||||
{ NM_STATE_LOCKED, "Locked" },
|
||||
{ NM_STATE_UNLOCKED, "Unlocked" },
|
||||
{ NM_STATE_SHUTDOWN, "Shutdown" },
|
||||
{ NM_STATE_NULL, "NULL" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *nm_adm_name(u_int8_t adm)
|
||||
{
|
||||
switch (adm) {
|
||||
case 1:
|
||||
return "Locked";
|
||||
case 2:
|
||||
return "Unlocked";
|
||||
case 3:
|
||||
return "Shutdown";
|
||||
default:
|
||||
return "<not used>";
|
||||
}
|
||||
return get_value_string(abis_nm_adm_state_names, adm);
|
||||
}
|
||||
|
||||
int nm_is_running(struct gsm_nm_state *s) {
|
||||
@@ -678,7 +697,7 @@ static int update_admstate(struct gsm_bts *bts, u_int8_t obj_class,
|
||||
new_state = *nm_state;
|
||||
new_state.administrative = adm_state;
|
||||
|
||||
rc = nm_state_event(EVT_STATECHG_ADM, obj_class, obj, nm_state, &new_state);
|
||||
rc = nm_state_event(EVT_STATECHG_ADM, obj_class, obj, nm_state, &new_state, obj_inst);
|
||||
|
||||
nm_state->administrative = adm_state;
|
||||
|
||||
@@ -732,7 +751,7 @@ static int abis_nm_rx_statechg_rep(struct msgb *mb)
|
||||
/* Update the operational state of a given object in our in-memory data
|
||||
* structures and send an event to the higher layer */
|
||||
void *obj = objclass2obj(bts, foh->obj_class, &foh->obj_inst);
|
||||
rc = nm_state_event(EVT_STATECHG_OPER, foh->obj_class, obj, nm_state, &new_state);
|
||||
rc = nm_state_event(EVT_STATECHG_OPER, foh->obj_class, obj, nm_state, &new_state, &foh->obj_inst);
|
||||
nm_state->operational = new_state.operational;
|
||||
nm_state->availability = new_state.availability;
|
||||
if (nm_state->administrative == 0)
|
||||
@@ -952,12 +971,30 @@ static int abis_nm_rx_lmt_event(struct msgb *mb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void abis_nm_queue_send_next(struct gsm_bts *bts)
|
||||
{
|
||||
int wait = 0;
|
||||
struct msgb *msg;
|
||||
/* the queue is empty */
|
||||
while (!llist_empty(&bts->abis_queue)) {
|
||||
msg = msgb_dequeue(&bts->abis_queue);
|
||||
wait = OBSC_NM_W_ACK_CB(msg);
|
||||
_abis_nm_sendmsg(msg);
|
||||
|
||||
if (wait)
|
||||
break;
|
||||
}
|
||||
|
||||
bts->abis_nm_pend = wait;
|
||||
}
|
||||
|
||||
/* Receive a OML NM Message from BTS */
|
||||
static int abis_nm_rcvmsg_fom(struct msgb *mb)
|
||||
{
|
||||
struct abis_om_hdr *oh = msgb_l2(mb);
|
||||
struct abis_om_fom_hdr *foh = msgb_l3(mb);
|
||||
u_int8_t mt = foh->msg_type;
|
||||
int ret = 0;
|
||||
|
||||
/* check for unsolicited message */
|
||||
if (is_report(mt))
|
||||
@@ -971,16 +1008,17 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb)
|
||||
|
||||
debugp_foh(foh);
|
||||
|
||||
DEBUGPC(DNM, "%s NACK ", get_value_string(nack_names, mt));
|
||||
LOGPC(DNM, LOGL_ERROR, "%s NACK ", get_value_string(nack_names, mt));
|
||||
|
||||
abis_nm_tlv_parse(&tp, mb->trx->bts, foh->data, oh->length-sizeof(*foh));
|
||||
if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES))
|
||||
DEBUGPC(DNM, "CAUSE=%s\n",
|
||||
LOGPC(DNM, LOGL_ERROR, "CAUSE=%s\n",
|
||||
nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES)));
|
||||
else
|
||||
DEBUGPC(DNM, "\n");
|
||||
LOGPC(DNM, LOGL_ERROR, "\n");
|
||||
|
||||
dispatch_signal(SS_NM, S_NM_NACK, (void*) &mt);
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
@@ -1002,13 +1040,13 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb)
|
||||
|
||||
switch (mt) {
|
||||
case NM_MT_CHG_ADM_STATE_ACK:
|
||||
return abis_nm_rx_chg_adm_state_ack(mb);
|
||||
ret = abis_nm_rx_chg_adm_state_ack(mb);
|
||||
break;
|
||||
case NM_MT_SW_ACT_REQ:
|
||||
return abis_nm_rx_sw_act_req(mb);
|
||||
ret = abis_nm_rx_sw_act_req(mb);
|
||||
break;
|
||||
case NM_MT_BS11_LMT_SESSION:
|
||||
return abis_nm_rx_lmt_event(mb);
|
||||
ret = abis_nm_rx_lmt_event(mb);
|
||||
break;
|
||||
case NM_MT_CONN_MDROP_LINK_ACK:
|
||||
DEBUGP(DNM, "CONN MDROP LINK ACK\n");
|
||||
@@ -1021,7 +1059,8 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int abis_nm_rx_ipacc(struct msgb *mb);
|
||||
@@ -1034,6 +1073,7 @@ static int abis_nm_rcvmsg_manuf(struct msgb *mb)
|
||||
switch (bts_type) {
|
||||
case GSM_BTS_TYPE_NANOBTS:
|
||||
rc = abis_nm_rx_ipacc(mb);
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
default:
|
||||
LOGP(DNM, LOGL_ERROR, "don't know how to parse OML for this "
|
||||
@@ -1139,6 +1179,7 @@ enum sw_state {
|
||||
|
||||
struct abis_nm_sw {
|
||||
struct gsm_bts *bts;
|
||||
int trx_nr;
|
||||
gsm_cbfn *cbfn;
|
||||
void *cb_data;
|
||||
int forced;
|
||||
@@ -1276,7 +1317,7 @@ static int sw_load_segment(struct abis_nm_sw *sw)
|
||||
sw->obj_instance[0], sw->obj_instance[1],
|
||||
sw->obj_instance[2]);
|
||||
|
||||
return abis_nm_sendmsg(sw->bts, msg);
|
||||
return abis_nm_sendmsg_direct(sw->bts, msg);
|
||||
}
|
||||
|
||||
/* 6.2.4 / 8.3.4 Load Data End */
|
||||
@@ -1469,6 +1510,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
sw->cb_data, NULL);
|
||||
rc = sw_fill_window(sw);
|
||||
sw->state = SW_STATE_WAIT_SEGACK;
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
case NM_MT_LOAD_INIT_NACK:
|
||||
if (sw->forced) {
|
||||
@@ -1489,6 +1531,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
sw->cb_data, NULL);
|
||||
sw->state = SW_STATE_ERROR;
|
||||
}
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1509,6 +1552,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
sw->state = SW_STATE_WAIT_ENDACK;
|
||||
rc = sw_load_end(sw);
|
||||
}
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
case NM_MT_LOAD_ABORT:
|
||||
if (sw->cbfn)
|
||||
@@ -1530,6 +1574,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
NM_MT_LOAD_END_ACK, mb,
|
||||
sw->cb_data, NULL);
|
||||
rc = 0;
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
case NM_MT_LOAD_END_NACK:
|
||||
if (sw->forced) {
|
||||
@@ -1549,6 +1594,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
NM_MT_LOAD_END_NACK, mb,
|
||||
sw->cb_data, NULL);
|
||||
}
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
}
|
||||
case SW_STATE_WAIT_ACTACK:
|
||||
@@ -1562,6 +1608,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
sw->cbfn(GSM_HOOK_NM_SWLOAD,
|
||||
NM_MT_ACTIVATE_SW_ACK, mb,
|
||||
sw->cb_data, NULL);
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
case NM_MT_ACTIVATE_SW_NACK:
|
||||
DEBUGP(DNM, "Activate Software NACK\n");
|
||||
@@ -1571,6 +1618,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
sw->cbfn(GSM_HOOK_NM_SWLOAD,
|
||||
NM_MT_ACTIVATE_SW_NACK, mb,
|
||||
sw->cb_data, NULL);
|
||||
abis_nm_queue_send_next(mb->trx->bts);
|
||||
break;
|
||||
}
|
||||
case SW_STATE_NONE:
|
||||
@@ -1592,7 +1640,7 @@ static int abis_nm_rcvmsg_sw(struct msgb *mb)
|
||||
}
|
||||
|
||||
/* Load the specified software into the BTS */
|
||||
int abis_nm_software_load(struct gsm_bts *bts, const char *fname,
|
||||
int abis_nm_software_load(struct gsm_bts *bts, int trx_nr, const char *fname,
|
||||
u_int8_t win_size, int forced,
|
||||
gsm_cbfn *cbfn, void *cb_data)
|
||||
{
|
||||
@@ -1606,6 +1654,7 @@ int abis_nm_software_load(struct gsm_bts *bts, const char *fname,
|
||||
return -EBUSY;
|
||||
|
||||
sw->bts = bts;
|
||||
sw->trx_nr = trx_nr;
|
||||
|
||||
switch (bts->type) {
|
||||
case GSM_BTS_TYPE_BS11:
|
||||
@@ -1616,8 +1665,8 @@ int abis_nm_software_load(struct gsm_bts *bts, const char *fname,
|
||||
break;
|
||||
case GSM_BTS_TYPE_NANOBTS:
|
||||
sw->obj_class = NM_OC_BASEB_TRANSC;
|
||||
sw->obj_instance[0] = 0x00;
|
||||
sw->obj_instance[1] = 0x00;
|
||||
sw->obj_instance[0] = sw->bts->nr;
|
||||
sw->obj_instance[1] = sw->trx_nr;
|
||||
sw->obj_instance[2] = 0xff;
|
||||
break;
|
||||
case GSM_BTS_TYPE_UNKNOWN:
|
||||
@@ -2012,7 +2061,7 @@ int abis_nm_sw_act_req_ack(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i1,
|
||||
if (nack)
|
||||
msgb_tv_put(msg, NM_ATT_NACK_CAUSES, NM_NACK_OBJCLASS_NOTSUPP);
|
||||
|
||||
return abis_nm_sendmsg(bts, msg);
|
||||
return abis_nm_sendmsg_direct(bts, msg);
|
||||
}
|
||||
|
||||
int abis_nm_raw_msg(struct gsm_bts *bts, int len, u_int8_t *rawmsg)
|
||||
@@ -2551,7 +2600,7 @@ static int bs11_swload_cbfn(unsigned int hook, unsigned int event,
|
||||
fle = fl_dequeue(&bs11_sw->file_list);
|
||||
if (fle) {
|
||||
/* start download the next file of our file list */
|
||||
rc = abis_nm_software_load(bs11_sw->bts, fle->fname,
|
||||
rc = abis_nm_software_load(bs11_sw->bts, 0xff, fle->fname,
|
||||
bs11_sw->win_size,
|
||||
bs11_sw->forced,
|
||||
&bs11_swload_cbfn, bs11_sw);
|
||||
@@ -2607,7 +2656,7 @@ int abis_nm_bs11_load_swl(struct gsm_bts *bts, const char *fname,
|
||||
return -EINVAL;
|
||||
|
||||
/* start download the next file of our file list */
|
||||
rc = abis_nm_software_load(bts, fle->fname, win_size, forced,
|
||||
rc = abis_nm_software_load(bts, 0xff, fle->fname, win_size, forced,
|
||||
bs11_swload_cbfn, bs11_sw);
|
||||
talloc_free(fle);
|
||||
return rc;
|
||||
@@ -2688,6 +2737,7 @@ static const char ipaccess_magic[] = "com.ipaccess";
|
||||
|
||||
static int abis_nm_rx_ipacc(struct msgb *msg)
|
||||
{
|
||||
struct in_addr addr;
|
||||
struct abis_om_hdr *oh = msgb_l2(msg);
|
||||
struct abis_om_fom_hdr *foh;
|
||||
u_int8_t idstrlen = oh->data[0];
|
||||
@@ -2709,10 +2759,12 @@ static int abis_nm_rx_ipacc(struct msgb *msg)
|
||||
switch (foh->msg_type) {
|
||||
case NM_MT_IPACC_RSL_CONNECT_ACK:
|
||||
DEBUGPC(DNM, "RSL CONNECT ACK ");
|
||||
if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP))
|
||||
DEBUGPC(DNM, "IP=%s ",
|
||||
inet_ntoa(*((struct in_addr *)
|
||||
TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP))));
|
||||
if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP)) {
|
||||
memcpy(&addr,
|
||||
TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP), sizeof(addr));
|
||||
|
||||
DEBUGPC(DNM, "IP=%s ", inet_ntoa(addr));
|
||||
}
|
||||
if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP_PORT))
|
||||
DEBUGPC(DNM, "PORT=%u ",
|
||||
ntohs(*((u_int16_t *)
|
||||
@@ -2775,12 +2827,12 @@ static int abis_nm_rx_ipacc(struct msgb *msg)
|
||||
case NM_MT_IPACC_RSL_CONNECT_NACK:
|
||||
case NM_MT_IPACC_SET_NVATTR_NACK:
|
||||
case NM_MT_IPACC_GET_NVATTR_NACK:
|
||||
signal.bts = msg->trx->bts;
|
||||
signal.trx = gsm_bts_trx_by_nr(msg->trx->bts, foh->obj_inst.trx_nr);
|
||||
signal.msg_type = foh->msg_type;
|
||||
dispatch_signal(SS_NM, S_NM_IPACC_NACK, &signal);
|
||||
break;
|
||||
case NM_MT_IPACC_SET_NVATTR_ACK:
|
||||
signal.bts = msg->trx->bts;
|
||||
signal.trx = gsm_bts_trx_by_nr(msg->trx->bts, foh->obj_inst.trx_nr);
|
||||
signal.msg_type = foh->msg_type;
|
||||
dispatch_signal(SS_NM, S_NM_IPACC_ACK, &signal);
|
||||
break;
|
||||
@@ -2866,9 +2918,16 @@ int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx,
|
||||
}
|
||||
|
||||
/* restart / reboot an ip.access nanoBTS */
|
||||
int abis_nm_ipaccess_restart(struct gsm_bts *bts)
|
||||
int abis_nm_ipaccess_restart(struct gsm_bts_trx *trx)
|
||||
{
|
||||
return __simple_cmd(bts, NM_MT_IPACC_RESTART);
|
||||
struct abis_om_hdr *oh;
|
||||
struct msgb *msg = nm_msgb_alloc();
|
||||
|
||||
oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
|
||||
fill_om_fom_hdr(oh, 0, NM_MT_IPACC_RESTART, NM_OC_BASEB_TRANSC,
|
||||
trx->bts->nr, trx->nr, 0xff);
|
||||
|
||||
return abis_nm_sendmsg(trx->bts, msg);
|
||||
}
|
||||
|
||||
int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, u_int8_t obj_class,
|
||||
@@ -3004,3 +3063,15 @@ int ipac_parse_bcch_info(struct ipac_bcch_info *binf, u_int8_t *buf)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void abis_nm_clear_queue(struct gsm_bts *bts)
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
||||
while (!llist_empty(&bts->abis_queue)) {
|
||||
msg = msgb_dequeue(&bts->abis_queue);
|
||||
msgb_free(msg);
|
||||
}
|
||||
|
||||
bts->abis_nm_pend = 0;
|
||||
}
|
||||
|
||||
194
openbsc/src/abis_nm_vty.c
Normal file
194
openbsc/src/abis_nm_vty.c
Normal file
@@ -0,0 +1,194 @@
|
||||
/* VTY interface for A-bis OML (Netowrk Management) */
|
||||
|
||||
/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/tlv.h>
|
||||
#include <osmocore/talloc.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/signal.h>
|
||||
#include <openbsc/abis_nm.h>
|
||||
#include <openbsc/vty.h>
|
||||
|
||||
#include <vty/command.h>
|
||||
|
||||
extern struct gsm_network *bsc_gsmnet;
|
||||
|
||||
static struct cmd_node oml_node = {
|
||||
OML_NODE,
|
||||
"%s(oml)# ",
|
||||
1,
|
||||
};
|
||||
|
||||
struct oml_node_state {
|
||||
struct gsm_bts *bts;
|
||||
uint8_t obj_class;
|
||||
uint8_t obj_inst[3];
|
||||
};
|
||||
|
||||
static int dummy_config_write(struct vty *v)
|
||||
{
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* FIXME: auto-generate those strings from the value_string lists */
|
||||
#define NM_OBJCLASS_VTY "(site-manager|bts|radio-carrier|baseband-transceiver|channel|adjc|handover|power-contorl|btse|rack|test|envabtse|bport|gprs-nse|gprs-cell|gprs-nsvc|siemenshw)"
|
||||
#define NM_OBJCLASS_VTY_HELP "FIXME"
|
||||
|
||||
DEFUN(oml_class_inst, oml_class_inst_cmd,
|
||||
"bts <0-255> oml class " NM_OBJCLASS_VTY
|
||||
" instance <0-255> <0-255> <0-255>",
|
||||
"BTS related commands\n" "BTS Number\n"
|
||||
"Manipulate the OML managed objects\n"
|
||||
"Object Class\n" NM_OBJCLASS_VTY_HELP
|
||||
"Object Instance\n" "BTS Number\n" "TRX Number\n" "TS Number\n")
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
struct oml_node_state *oms;
|
||||
int bts_nr = atoi(argv[0]);
|
||||
|
||||
bts = gsm_bts_num(bsc_gsmnet, bts_nr);
|
||||
if (!bts) {
|
||||
vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
oms = talloc_zero(tall_bsc_ctx, struct oml_node_state);
|
||||
if (!oms)
|
||||
return CMD_WARNING;
|
||||
|
||||
oms->bts = bts;
|
||||
oms->obj_class = get_string_value(abis_nm_obj_class_names, argv[1]);
|
||||
oms->obj_inst[0] = atoi(argv[2]);
|
||||
oms->obj_inst[1] = atoi(argv[3]);
|
||||
oms->obj_inst[2] = atoi(argv[4]);
|
||||
|
||||
vty->index = oms;
|
||||
vty->node = OML_NODE;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
DEFUN(oml_classnum_inst, oml_classnum_inst_cmd,
|
||||
"bts <0-255> oml class <0-255> instance <0-255> <0-255> <0-255>",
|
||||
"BTS related commands\n" "BTS Number\n"
|
||||
"Manipulate the OML managed objects\n"
|
||||
"Object Class\n" "Object Class\n"
|
||||
"Object Instance\n" "BTS Number\n" "TRX Number\n" "TS Number\n")
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
struct oml_node_state *oms;
|
||||
int bts_nr = atoi(argv[0]);
|
||||
|
||||
bts = gsm_bts_num(bsc_gsmnet, bts_nr);
|
||||
if (!bts) {
|
||||
vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
oms = talloc_zero(tall_bsc_ctx, struct oml_node_state);
|
||||
if (!oms)
|
||||
return CMD_WARNING;
|
||||
|
||||
oms->bts = bts;
|
||||
oms->obj_class = atoi(argv[1]);
|
||||
oms->obj_inst[0] = atoi(argv[2]);
|
||||
oms->obj_inst[1] = atoi(argv[3]);
|
||||
oms->obj_inst[2] = atoi(argv[4]);
|
||||
|
||||
vty->index = oms;
|
||||
vty->node = OML_NODE;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(oml_attrib_get, oml_attrib_get_cmd,
|
||||
"attribute get <0-255>",
|
||||
"OML Attribute Actions\n" "Get a single OML Attribute\n"
|
||||
"OML Attribute Number\n")
|
||||
{
|
||||
struct oml_node_state *oms = vty->index;
|
||||
|
||||
/* FIXME */
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(oml_attrib_set, oml_attrib_set_cmd,
|
||||
"attribute set <0-255> .HEX",
|
||||
"OML Attribute Actions\n" "Set a single OML Attribute\n"
|
||||
"OML Attribute Number\n")
|
||||
{
|
||||
struct oml_node_state *oms = vty->index;
|
||||
|
||||
/* FIXME */
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(oml_chg_adm_state, oml_chg_adm_state_cmd,
|
||||
"change-adm-state (locked|unlocked|shutdown|null)",
|
||||
"Change the Administrative State\n"
|
||||
"Locked\n" "Unlocked\n" "Shutdown\n" "NULL\n")
|
||||
{
|
||||
struct oml_node_state *oms = vty->index;
|
||||
enum abis_nm_adm_state state;
|
||||
|
||||
state = get_string_value(abis_nm_adm_state_names, argv[0]);
|
||||
|
||||
abis_nm_chg_adm_state(oms->bts, oms->obj_class, oms->obj_inst[0],
|
||||
oms->obj_inst[1], oms->obj_inst[2], state);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(oml_opstart, oml_opstart_cmd,
|
||||
"opstart", "Send an OPSTART message to the object")
|
||||
{
|
||||
struct oml_node_state *oms = vty->index;
|
||||
|
||||
abis_nm_opstart(oms->bts, oms->obj_class, oms->obj_inst[0],
|
||||
oms->obj_inst[1], oms->obj_inst[2]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int abis_nm_vty_init(void)
|
||||
{
|
||||
install_element(ENABLE_NODE, &oml_class_inst_cmd);
|
||||
install_element(ENABLE_NODE, &oml_classnum_inst_cmd);
|
||||
install_node(&oml_node, dummy_config_write);
|
||||
|
||||
install_default(OML_NODE);
|
||||
install_element(OML_NODE, &oml_attrib_get_cmd);
|
||||
install_element(OML_NODE, &oml_attrib_set_cmd);
|
||||
install_element(OML_NODE, &oml_chg_adm_state_cmd);
|
||||
install_element(OML_NODE, &oml_opstart_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -42,11 +42,15 @@
|
||||
#include <openbsc/rtp_proxy.h>
|
||||
#include <osmocore/rsl.h>
|
||||
|
||||
#include <osmocore/talloc.h>
|
||||
|
||||
#define RSL_ALLOC_SIZE 1024
|
||||
#define RSL_ALLOC_HEADROOM 128
|
||||
|
||||
#define MAX(a, b) (a) >= (b) ? (a) : (b)
|
||||
|
||||
static int rsl_send_imm_assignment(struct gsm_lchan *lchan);
|
||||
|
||||
static u_int8_t mdisc_by_msgtype(u_int8_t msg_type)
|
||||
{
|
||||
/* mask off the transparent bit ? */
|
||||
@@ -325,7 +329,10 @@ static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm,
|
||||
memset(cm, 0, sizeof(cm));
|
||||
|
||||
/* FIXME: what to do with data calls ? */
|
||||
cm->dtx_dtu = 0x00;
|
||||
if (lchan->ts->trx->bts->network->dtx_enabled)
|
||||
cm->dtx_dtu = 0x03;
|
||||
else
|
||||
cm->dtx_dtu = 0x00;
|
||||
|
||||
/* set TCH Speech/Data */
|
||||
cm->spd_ind = lchan->rsl_cmode;
|
||||
@@ -568,12 +575,33 @@ int rsl_deact_sacch(struct gsm_lchan *lchan)
|
||||
return abis_rsl_sendmsg(msg);
|
||||
}
|
||||
|
||||
static void error_timeout_cb(void *data)
|
||||
{
|
||||
struct gsm_lchan *lchan = data;
|
||||
if (lchan->state != LCHAN_S_REL_ERR) {
|
||||
LOGP(DRSL, LOGL_ERROR, "%s error timeout but not in error state: %d\n",
|
||||
gsm_lchan_name(lchan), lchan->state);
|
||||
return;
|
||||
}
|
||||
|
||||
/* go back to the none state */
|
||||
LOGP(DRSL, LOGL_NOTICE, "%s is back in operation.\n", gsm_lchan_name(lchan));
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_NONE);
|
||||
}
|
||||
|
||||
/* Chapter 8.4.14 / 4.7: Tell BTS to release the radio channel */
|
||||
int rsl_rf_chan_release(struct gsm_lchan *lchan)
|
||||
static int rsl_rf_chan_release(struct gsm_lchan *lchan, int error)
|
||||
{
|
||||
struct abis_rsl_dchan_hdr *dh;
|
||||
struct msgb *msg = rsl_msgb_alloc();
|
||||
struct msgb *msg;
|
||||
|
||||
if (lchan->state == LCHAN_S_REL_ERR) {
|
||||
LOGP(DRSL, LOGL_NOTICE, "%s is in error state not sending release.\n",
|
||||
gsm_lchan_name(lchan));
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = rsl_msgb_alloc();
|
||||
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
||||
init_dchan_hdr(dh, RSL_MT_RF_CHAN_REL);
|
||||
dh->chan_nr = lchan2chan_nr(lchan);
|
||||
@@ -581,7 +609,20 @@ int rsl_rf_chan_release(struct gsm_lchan *lchan)
|
||||
msg->lchan = lchan;
|
||||
msg->trx = lchan->ts->trx;
|
||||
|
||||
DEBUGP(DRSL, "%s RF Channel Release CMD\n", gsm_lchan_name(lchan));
|
||||
DEBUGP(DRSL, "%s RF Channel Release CMD due error %d\n", gsm_lchan_name(lchan), error);
|
||||
|
||||
if (error) {
|
||||
/*
|
||||
* the nanoBTS sends RLL release indications after the channel release. This can
|
||||
* be a problem when we have reassigned the channel to someone else and then can
|
||||
* not figure out who used this channel.
|
||||
*/
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR);
|
||||
lchan->error_timer.data = lchan;
|
||||
lchan->error_timer.cb = error_timeout_cb;
|
||||
bsc_schedule_timer(&lchan->error_timer,
|
||||
msg->trx->bts->network->T3111 + 2, 0);
|
||||
}
|
||||
|
||||
/* BTS will respond by RF CHAN REL ACK */
|
||||
return abis_rsl_sendmsg(msg);
|
||||
@@ -718,14 +759,15 @@ int rsl_establish_request(struct gsm_lchan *lchan, u_int8_t link_id)
|
||||
RELEASE CONFIRM, which we in turn use to trigger RSL CHANNEL RELEASE,
|
||||
which in turn is acknowledged by RSL CHANNEL RELEASE ACK, which calls
|
||||
lchan_free() */
|
||||
int rsl_release_request(struct gsm_lchan *lchan, u_int8_t link_id)
|
||||
int rsl_release_request(struct gsm_lchan *lchan, u_int8_t link_id, u_int8_t reason)
|
||||
{
|
||||
|
||||
struct msgb *msg;
|
||||
|
||||
msg = rsl_rll_simple(RSL_MT_REL_REQ, lchan2chan_nr(lchan),
|
||||
link_id, 0);
|
||||
msgb_tv_put(msg, RSL_IE_RELEASE_MODE, 0); /* normal release */
|
||||
/* 0 is normal release, 1 is local end */
|
||||
msgb_tv_put(msg, RSL_IE_RELEASE_MODE, reason);
|
||||
|
||||
/* FIXME: start some timer in case we don't receive a REL ACK ? */
|
||||
|
||||
@@ -756,6 +798,13 @@ static int rsl_rx_chan_act_ack(struct msgb *msg)
|
||||
gsm_lchans_name(msg->lchan->state));
|
||||
rsl_lchan_set_state(msg->lchan, LCHAN_S_ACTIVE);
|
||||
|
||||
if (msg->lchan->rqd_ref) {
|
||||
rsl_send_imm_assignment(msg->lchan);
|
||||
talloc_free(msg->lchan->rqd_ref);
|
||||
msg->lchan->rqd_ref = NULL;
|
||||
msg->lchan->rqd_ta = 0;
|
||||
}
|
||||
|
||||
dispatch_signal(SS_LCHAN, S_LCHAN_ACTIVATE_ACK, msg->lchan);
|
||||
|
||||
return 0;
|
||||
@@ -811,7 +860,7 @@ static int rsl_rx_conn_fail(struct msgb *msg)
|
||||
LOGPC(DRSL, LOGL_NOTICE, "\n");
|
||||
/* FIXME: only free it after channel release ACK */
|
||||
counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rf_fail);
|
||||
return rsl_rf_chan_release(msg->lchan);
|
||||
return rsl_rf_chan_release(msg->lchan, 1);
|
||||
}
|
||||
|
||||
static void print_meas_rep_uni(struct gsm_meas_rep_unidir *mru,
|
||||
@@ -876,7 +925,7 @@ static int rsl_rx_meas_res(struct msgb *msg)
|
||||
/* check if this channel is actually active */
|
||||
/* FIXME: maybe this check should be way more generic/centralized */
|
||||
if (msg->lchan->state != LCHAN_S_ACTIVE) {
|
||||
LOGP(DRSL, LOGL_NOTICE, "%s: MEAS RES for inactive channel\n",
|
||||
LOGP(DRSL, LOGL_DEBUG, "%s: MEAS RES for inactive channel\n",
|
||||
gsm_lchan_name(msg->lchan));
|
||||
return 0;
|
||||
}
|
||||
@@ -983,11 +1032,14 @@ static int abis_rsl_rx_dchan(struct msgb *msg)
|
||||
break;
|
||||
case RSL_MT_RF_CHAN_REL_ACK:
|
||||
DEBUGP(DRSL, "%s RF CHANNEL RELEASE ACK\n", ts_name);
|
||||
if (msg->lchan->state != LCHAN_S_REL_REQ)
|
||||
if (msg->lchan->state != LCHAN_S_REL_REQ && msg->lchan->state != LCHAN_S_REL_ERR)
|
||||
LOGP(DRSL, LOGL_NOTICE, "%s CHAN REL ACK but state %s\n",
|
||||
gsm_lchan_name(msg->lchan),
|
||||
gsm_lchans_name(msg->lchan->state));
|
||||
rsl_lchan_set_state(msg->lchan, LCHAN_S_NONE);
|
||||
bsc_del_timer(&msg->lchan->T3111);
|
||||
/* we have an error timer pending to release that */
|
||||
if (msg->lchan->state != LCHAN_S_REL_ERR)
|
||||
rsl_lchan_set_state(msg->lchan, LCHAN_S_NONE);
|
||||
lchan_free(msg->lchan);
|
||||
break;
|
||||
case RSL_MT_MODE_MODIFY_ACK:
|
||||
@@ -1079,7 +1131,15 @@ static void t3101_expired(void *data)
|
||||
{
|
||||
struct gsm_lchan *lchan = data;
|
||||
|
||||
rsl_rf_chan_release(lchan);
|
||||
rsl_rf_chan_release(lchan, 1);
|
||||
}
|
||||
|
||||
/* If T3111 expires, we will send the RF Channel Request */
|
||||
static void t3111_expired(void *data)
|
||||
{
|
||||
struct gsm_lchan *lchan = data;
|
||||
|
||||
rsl_rf_chan_release(lchan, 0);
|
||||
}
|
||||
|
||||
/* MS has requested a channel on the RACH */
|
||||
@@ -1088,12 +1148,11 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
struct gsm_bts *bts = msg->trx->bts;
|
||||
struct abis_rsl_dchan_hdr *rqd_hdr = msgb_l2(msg);
|
||||
struct gsm48_req_ref *rqd_ref;
|
||||
struct gsm48_imm_ass ia;
|
||||
enum gsm_chan_t lctype;
|
||||
enum gsm_chreq_reason_t chreq_reason;
|
||||
struct gsm_lchan *lchan;
|
||||
u_int8_t rqd_ta;
|
||||
int ret;
|
||||
int is_lu;
|
||||
|
||||
u_int16_t arfcn;
|
||||
u_int8_t ts_number, subch;
|
||||
@@ -1111,13 +1170,19 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
|
||||
/* determine channel type (SDCCH/TCH_F/TCH_H) based on
|
||||
* request reference RA */
|
||||
lctype = get_ctype_by_chreq(bts, rqd_ref->ra, bts->network->neci);
|
||||
chreq_reason = get_reason_by_chreq(bts, rqd_ref->ra, bts->network->neci);
|
||||
lctype = get_ctype_by_chreq(bts->network, rqd_ref->ra);
|
||||
chreq_reason = get_reason_by_chreq(rqd_ref->ra, bts->network->neci);
|
||||
|
||||
counter_inc(bts->network->stats.chreq.total);
|
||||
|
||||
/*
|
||||
* We want LOCATION UPDATES to succeed and will assign a TCH
|
||||
* if we have no SDCCH available.
|
||||
*/
|
||||
is_lu = !!(chreq_reason == GSM_CHREQ_REASON_LOCATION_UPD);
|
||||
|
||||
/* check availability / allocate channel */
|
||||
lchan = lchan_alloc(bts, lctype);
|
||||
lchan = lchan_alloc(bts, lctype, is_lu);
|
||||
if (!lchan) {
|
||||
LOGP(DRSL, LOGL_NOTICE, "BTS %d CHAN RQD: no resources for %s 0x%x\n",
|
||||
msg->lchan->ts->trx->bts->nr, gsm_lchant_name(lctype), rqd_ref->ra);
|
||||
@@ -1132,6 +1197,17 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
gsm_lchans_name(lchan->state));
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_ACT_REQ);
|
||||
|
||||
/* save the RACH data as we need it after the CHAN ACT ACK */
|
||||
lchan->rqd_ref = talloc_zero(bts, struct gsm48_req_ref);
|
||||
if (!lchan->rqd_ref) {
|
||||
LOGP(DRSL, LOGL_ERROR, "Failed to allocate gsm48_req_ref.\n");
|
||||
lchan_free(lchan);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(lchan->rqd_ref, rqd_ref, sizeof(*rqd_ref));
|
||||
lchan->rqd_ta = rqd_ta;
|
||||
|
||||
ts_number = lchan->ts->nr;
|
||||
arfcn = lchan->ts->trx->arfcn;
|
||||
subch = lchan->nr;
|
||||
@@ -1141,8 +1217,25 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
lchan->bs_power = 0; /* 0dB reduction, output power = Pn */
|
||||
lchan->rsl_cmode = RSL_CMOD_SPD_SIGN;
|
||||
lchan->tch_mode = GSM48_CMODE_SIGN;
|
||||
|
||||
/* FIXME: Start another timer or assume the BTS sends a ACK/NACK? */
|
||||
rsl_chan_activate_lchan(lchan, 0x00, rqd_ta, 0);
|
||||
|
||||
DEBUGP(DRSL, "%s Activating ARFCN(%u) SS(%u) lctype %s "
|
||||
"r=%s ra=0x%02x\n", gsm_lchan_name(lchan), arfcn, subch,
|
||||
gsm_lchant_name(lchan->type), gsm_chreq_name(chreq_reason),
|
||||
rqd_ref->ra);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsl_send_imm_assignment(struct gsm_lchan *lchan)
|
||||
{
|
||||
struct gsm_bts *bts = lchan->ts->trx->bts;
|
||||
struct gsm48_imm_ass ia;
|
||||
u_int16_t arfcn;
|
||||
|
||||
arfcn = lchan->ts->trx->arfcn;
|
||||
|
||||
/* create IMMEDIATE ASSIGN 04.08 messge */
|
||||
memset(&ia, 0, sizeof(ia));
|
||||
ia.l2_plen = 0x2d;
|
||||
@@ -1155,24 +1248,17 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
ia.chan_desc.h0.arfcn_low = arfcn & 0xff;
|
||||
ia.chan_desc.h0.tsc = bts->tsc;
|
||||
/* use request reference extracted from CHAN_RQD */
|
||||
memcpy(&ia.req_ref, rqd_ref, sizeof(ia.req_ref));
|
||||
ia.timing_advance = rqd_ta;
|
||||
memcpy(&ia.req_ref, lchan->rqd_ref, sizeof(ia.req_ref));
|
||||
ia.timing_advance = lchan->rqd_ta;
|
||||
ia.mob_alloc_len = 0;
|
||||
|
||||
DEBUGP(DRSL, "%s Activating ARFCN(%u) SS(%u) lctype %s "
|
||||
"r=%s ra=0x%02x\n", gsm_lchan_name(lchan), arfcn, subch,
|
||||
gsm_lchant_name(lchan->type), gsm_chreq_name(chreq_reason),
|
||||
rqd_ref->ra);
|
||||
|
||||
/* Start timer T3101 to wait for GSM48_MT_RR_PAG_RESP */
|
||||
lchan->T3101.cb = t3101_expired;
|
||||
lchan->T3101.data = lchan;
|
||||
bsc_schedule_timer(&lchan->T3101, bts->network->T3101, 0);
|
||||
|
||||
/* send IMMEDIATE ASSIGN CMD on RSL to BTS (to send on CCCH to MS) */
|
||||
ret = rsl_imm_assign_cmd(bts, sizeof(ia), (u_int8_t *) &ia);
|
||||
|
||||
return ret;
|
||||
return rsl_imm_assign_cmd(bts, sizeof(ia), (u_int8_t *) &ia);
|
||||
}
|
||||
|
||||
/* MS has requested a channel on the RACH */
|
||||
@@ -1252,12 +1338,38 @@ static int rsl_rx_rll_err_ind(struct msgb *msg)
|
||||
|
||||
if (rlm_cause[1] == RLL_CAUSE_T200_EXPIRED) {
|
||||
counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rll_err);
|
||||
return rsl_rf_chan_release(msg->lchan);
|
||||
return rsl_rf_chan_release(msg->lchan, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rsl_handle_release(struct gsm_lchan *lchan)
|
||||
{
|
||||
int sapi;
|
||||
struct gsm_bts *bts;
|
||||
|
||||
/* maybe we have only brought down one RLL */
|
||||
if (lchan->state != LCHAN_S_REL_REQ)
|
||||
return;
|
||||
|
||||
for (sapi = 0; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) {
|
||||
if (lchan->sapis[sapi] == LCHAN_SAPI_UNUSED)
|
||||
continue;
|
||||
LOGP(DRSL, LOGL_NOTICE, "%s waiting for SAPI=%d to be released.\n",
|
||||
gsm_lchan_name(lchan), sapi);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* wait a bit to send the RF Channel Release */
|
||||
lchan->T3111.cb = t3111_expired;
|
||||
lchan->T3111.data = lchan;
|
||||
bts = lchan->ts->trx->bts;
|
||||
bsc_schedule_timer(&lchan->T3111, bts->network->T3111, 0);
|
||||
}
|
||||
|
||||
/* ESTABLISH INDICATION, LOCATION AREA UPDATE REQUEST
|
||||
0x02, 0x06,
|
||||
0x01, 0x20,
|
||||
@@ -1309,20 +1421,16 @@ static int abis_rsl_rx_rll(struct msgb *msg)
|
||||
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_UNUSED;
|
||||
rll_indication(msg->lchan, rllh->link_id,
|
||||
BSC_RLLR_IND_REL_IND);
|
||||
/* we can now releae the channel on the BTS/Abis side */
|
||||
/* FIXME: officially we need to start T3111 and wait for
|
||||
* some grace period */
|
||||
rsl_rf_chan_release(msg->lchan);
|
||||
rsl_handle_release(msg->lchan);
|
||||
rsl_lchan_rll_release(msg->lchan, rllh->link_id);
|
||||
break;
|
||||
case RSL_MT_REL_CONF:
|
||||
/* BTS informs us of having received UA from MS,
|
||||
* in response to DISC that we've sent earlier */
|
||||
DEBUGPC(DRLL, "RELEASE CONFIRMATION\n");
|
||||
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_UNUSED;
|
||||
/* we can now releae the channel on the BTS/Abis side */
|
||||
/* FIXME: officially we need to start T3111 and wait for
|
||||
* some grace period */
|
||||
rsl_rf_chan_release(msg->lchan);
|
||||
rsl_handle_release(msg->lchan);
|
||||
rsl_lchan_rll_release(msg->lchan, rllh->link_id);
|
||||
break;
|
||||
case RSL_MT_ERROR_IND:
|
||||
rc = rsl_rx_rll_err_ind(msg);
|
||||
@@ -1342,31 +1450,11 @@ static u_int8_t ipa_smod_s_for_lchan(struct gsm_lchan *lchan)
|
||||
{
|
||||
switch (lchan->tch_mode) {
|
||||
case GSM48_CMODE_SPEECH_V1:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return 0x00;
|
||||
case GSM_LCHAN_TCH_H:
|
||||
return 0x03;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0x00;
|
||||
case GSM48_CMODE_SPEECH_EFR:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return 0x01;
|
||||
/* there's no half-rate EFR */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0x01;
|
||||
case GSM48_CMODE_SPEECH_AMR:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return 0x02;
|
||||
case GSM_LCHAN_TCH_H:
|
||||
return 0x05;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0x02;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1375,44 +1463,6 @@ static u_int8_t ipa_smod_s_for_lchan(struct gsm_lchan *lchan)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u_int8_t ipa_rtp_pt_for_lchan(struct gsm_lchan *lchan)
|
||||
{
|
||||
switch (lchan->tch_mode) {
|
||||
case GSM48_CMODE_SPEECH_V1:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return RTP_PT_GSM_FULL;
|
||||
case GSM_LCHAN_TCH_H:
|
||||
return RTP_PT_GSM_HALF;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case GSM48_CMODE_SPEECH_EFR:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return RTP_PT_GSM_EFR;
|
||||
/* there's no half-rate EFR */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case GSM48_CMODE_SPEECH_AMR:
|
||||
switch (lchan->type) {
|
||||
case GSM_LCHAN_TCH_F:
|
||||
return RTP_PT_AMR_FULL;
|
||||
case GSM_LCHAN_TCH_H:
|
||||
return RTP_PT_AMR_HALF;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOGP(DRSL, LOGL_ERROR, "Cannot determine ip.access rtp payload type for "
|
||||
"tch_mode == 0x%02x\n & lchan_type == %d",
|
||||
lchan->tch_mode, lchan->type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ip.access specific RSL extensions */
|
||||
static void ipac_parse_rtp(struct gsm_lchan *lchan, struct tlv_parsed *tv)
|
||||
{
|
||||
@@ -1479,13 +1529,10 @@ int rsl_ipacc_crcx(struct gsm_lchan *lchan)
|
||||
|
||||
/* 0x1- == receive-only, 0x-1 == EFR codec */
|
||||
lchan->abis_ip.speech_mode = 0x10 | ipa_smod_s_for_lchan(lchan);
|
||||
lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
|
||||
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
|
||||
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
|
||||
|
||||
DEBUGP(DRSL, "%s IPAC_BIND speech_mode=0x%02x RTP_PAYLOAD=%d\n",
|
||||
gsm_lchan_name(lchan), lchan->abis_ip.speech_mode,
|
||||
lchan->abis_ip.rtp_payload);
|
||||
DEBUGP(DRSL, "%s IPAC_BIND speech_mode=0x%02x\n",
|
||||
gsm_lchan_name(lchan), lchan->abis_ip.speech_mode);
|
||||
|
||||
msg->trx = lchan->ts->trx;
|
||||
|
||||
@@ -1512,13 +1559,11 @@ int rsl_ipacc_mdcx(struct gsm_lchan *lchan, u_int32_t ip, u_int16_t port,
|
||||
|
||||
/* 0x0- == both directions, 0x-1 == EFR codec */
|
||||
lchan->abis_ip.speech_mode = 0x00 | ipa_smod_s_for_lchan(lchan);
|
||||
lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
|
||||
|
||||
ia.s_addr = htonl(ip);
|
||||
DEBUGP(DRSL, "%s IPAC_MDCX IP=%s PORT=%d RTP_PAYLOAD=%d RTP_PAYLOAD2=%d "
|
||||
"CONN_ID=%d speech_mode=0x%02x\n", gsm_lchan_name(lchan),
|
||||
inet_ntoa(ia), port, lchan->abis_ip.rtp_payload, rtp_payload2,
|
||||
lchan->abis_ip.conn_id, lchan->abis_ip.speech_mode);
|
||||
DEBUGP(DRSL, "%s IPAC_MDCX IP=%s PORT=%d RTP_PAYLOAD2=%d CONN_ID=%d "
|
||||
"speech_mode=0x%02x\n", gsm_lchan_name(lchan), inet_ntoa(ia), port,
|
||||
rtp_payload2, lchan->abis_ip.conn_id, lchan->abis_ip.speech_mode);
|
||||
|
||||
msgb_tv16_put(msg, RSL_IE_IPAC_CONN_ID, lchan->abis_ip.conn_id);
|
||||
msgb_v_put(msg, RSL_IE_IPAC_REMOTE_IP);
|
||||
@@ -1526,7 +1571,6 @@ int rsl_ipacc_mdcx(struct gsm_lchan *lchan, u_int32_t ip, u_int16_t port,
|
||||
*att_ip = ia.s_addr;
|
||||
msgb_tv16_put(msg, RSL_IE_IPAC_REMOTE_PORT, port);
|
||||
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
|
||||
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
|
||||
if (rtp_payload2)
|
||||
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD2, rtp_payload2);
|
||||
|
||||
|
||||
@@ -481,7 +481,7 @@ static int handle_state_resp(enum abis_bs11_phase state)
|
||||
* argument, so our swload_cbfn can distinguish
|
||||
* a safety load from a regular software */
|
||||
if (file_is_readable(fname_safety))
|
||||
rc = abis_nm_software_load(g_bts, fname_safety,
|
||||
rc = abis_nm_software_load(g_bts, 0xff, fname_safety,
|
||||
win_size, param_forced,
|
||||
swload_cbfn, g_bts);
|
||||
else
|
||||
@@ -697,7 +697,8 @@ int handle_serial_msg(struct msgb *rx_msg)
|
||||
}
|
||||
|
||||
int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state)
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state,
|
||||
struct abis_om_obj_inst *obj_ins)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -870,3 +871,8 @@ int main(int argc, char **argv)
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* dummy to be able to compile */
|
||||
void gsm_net_update_ctype(struct gsm_network *net)
|
||||
{
|
||||
}
|
||||
|
||||
25
openbsc/src/bsc-nat.cfg
Normal file
25
openbsc/src/bsc-nat.cfg
Normal file
@@ -0,0 +1,25 @@
|
||||
!
|
||||
! BSC NAT configuration hand edited
|
||||
! !
|
||||
password foo
|
||||
!
|
||||
line vty
|
||||
no login
|
||||
!
|
||||
nat
|
||||
msc ip 10.0.0.23
|
||||
bsc 0
|
||||
token zecke
|
||||
location_area_code 3
|
||||
bsc 1
|
||||
token roch
|
||||
location_area_code 4
|
||||
mgcp
|
||||
local ip 10.0.0.23
|
||||
! bts ip 0.0.0.0
|
||||
bind ip 127.0.0.1
|
||||
bind port 2427
|
||||
bind early 1
|
||||
rtp base 4000
|
||||
number endpoints 31
|
||||
call agent ip 127.0.0.1
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <openbsc/signal.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
#include <osmocore/talloc.h>
|
||||
#include <openbsc/ipaccess.h>
|
||||
|
||||
/* global pointer to the gsm network data structure */
|
||||
extern struct gsm_network *bsc_gsmnet;
|
||||
@@ -317,14 +318,14 @@ static unsigned char bs11_attr_radio[] =
|
||||
static unsigned char nanobts_attr_bts[] = {
|
||||
NM_ATT_INTERF_BOUND, 0x55, 0x5b, 0x61, 0x67, 0x6d, 0x73,
|
||||
/* interference avg. period in numbers of SACCH multifr */
|
||||
NM_ATT_INTAVE_PARAM, 0x06,
|
||||
NM_ATT_INTAVE_PARAM, 0x1f,
|
||||
/* conn fail based on SACCH error rate */
|
||||
NM_ATT_CONN_FAIL_CRIT, 0x00, 0x02, 0x01, 0x10,
|
||||
NM_ATT_T200, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21, 0xa8,
|
||||
NM_ATT_MAX_TA, 0x3f,
|
||||
NM_ATT_OVERL_PERIOD, 0x00, 0x01, 10, /* seconds */
|
||||
NM_ATT_CCCH_L_T, 10, /* percent */
|
||||
NM_ATT_CCCH_L_I_P, 1, /* seconds */
|
||||
NM_ATT_CONN_FAIL_CRIT, 0x00, 0x02, 0x01, 0x20,
|
||||
NM_ATT_T200, 0x1e, 0x1e, 0x24, 0xa8, 0x34, 0x21, 0xa8,
|
||||
NM_ATT_MAX_TA, 0x00,
|
||||
NM_ATT_OVERL_PERIOD, 0x00, 0x01, 5, /* seconds */
|
||||
NM_ATT_CCCH_L_T, 32, /* percent */
|
||||
NM_ATT_CCCH_L_I_P, 5, /* seconds */
|
||||
NM_ATT_RACH_B_THRESH, 10, /* busy threshold in - dBm */
|
||||
NM_ATT_LDAVG_SLOTS, 0x03, 0xe8, /* rach load averaging 1000 slots */
|
||||
NM_ATT_BTS_AIR_TIMER, 128, /* miliseconds */
|
||||
@@ -345,7 +346,7 @@ static unsigned char nanobts_attr_nse[] = {
|
||||
3, /* (un)blocking retries */
|
||||
3, /* reset timer (Tns-reset) */
|
||||
3, /* reset retries */
|
||||
30, /* test timer (Tns-test) */
|
||||
3, /* test timer (Tns-test) */
|
||||
3, /* alive timer (Tns-alive) */
|
||||
10, /* alive retrires */
|
||||
NM_ATT_IPACC_BSSGP_CFG, 0, 11,
|
||||
@@ -366,29 +367,27 @@ static unsigned char nanobts_attr_cell[] = {
|
||||
NM_ATT_IPACC_RAC, 0, 1, 1, /* routing area code */
|
||||
NM_ATT_IPACC_GPRS_PAGING_CFG, 0, 2,
|
||||
5, /* repeat time (50ms) */
|
||||
3, /* repeat count */
|
||||
1, /* repeat count */
|
||||
NM_ATT_IPACC_BVCI, 0, 2, 0x03, 0x9d, /* BVCI 925 */
|
||||
NM_ATT_IPACC_RLC_CFG, 0, 9,
|
||||
20, /* T3142 */
|
||||
5, /* T3169 */
|
||||
5, /* T3191 */
|
||||
200, /* T3193 */
|
||||
5, /* T3195 */
|
||||
10, /* N3101 */
|
||||
4, /* N3103 */
|
||||
8, /* N3105 */
|
||||
15, /* RLC CV countdown */
|
||||
NM_ATT_IPACC_CODING_SCHEMES, 0, 2, 0x0f, 0x00, /* CS1..CS4 */
|
||||
0x14, /* T3142 */
|
||||
0x05, /* T3169 */
|
||||
0x05, /* T3191 */
|
||||
0x14, /* T3193 */
|
||||
0x05, /* T3195 */
|
||||
0x0a, /* N3101 */
|
||||
0x04, /* N3103 */
|
||||
0x08, /* N3105 */
|
||||
0x0f, /* RLC CV countdown */
|
||||
NM_ATT_IPACC_CODING_SCHEMES, 0, 2, 0x8f, 0xff, /* CS1..CS4 */
|
||||
NM_ATT_IPACC_RLC_CFG_2, 0, 5,
|
||||
0x00, 250, /* T downlink TBF extension (0..500) */
|
||||
0x00, 250, /* T uplink TBF extension (0..500) */
|
||||
0x00, 0x96, /* T downlink TBF extension (0..500) */
|
||||
0x00, 0x32, /* T uplink TBF extension (0..500) */
|
||||
2, /* CS2 */
|
||||
#if 0
|
||||
/* EDGE model only, breaks older models.
|
||||
* Should inquire the BTS capabilities */
|
||||
NM_ATT_IPACC_RLC_CFG_3, 0, 1,
|
||||
2, /* MCS2 */
|
||||
#endif
|
||||
};
|
||||
|
||||
static unsigned char nanobts_attr_nsvc0[] = {
|
||||
@@ -401,7 +400,8 @@ static unsigned char nanobts_attr_nsvc0[] = {
|
||||
|
||||
/* Callback function to be called whenever we get a GSM 12.21 state change event */
|
||||
int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state)
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state,
|
||||
struct abis_om_obj_inst *obj_inst)
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_bts_trx *trx;
|
||||
@@ -418,9 +418,9 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
switch (obj_class) {
|
||||
case NM_OC_SITE_MANAGER:
|
||||
bts = container_of(obj, struct gsm_bts, site_mgr);
|
||||
if ((new_state->operational == 2 &&
|
||||
if ((new_state->operational == NM_OPSTATE_ENABLED &&
|
||||
new_state->availability == NM_AVSTATE_OK) ||
|
||||
(new_state->operational == 1 &&
|
||||
(new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_OFF_LINE))
|
||||
abis_nm_opstart(bts, obj_class, 0xff, 0xff, 0xff);
|
||||
break;
|
||||
@@ -440,7 +440,7 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
case NM_OC_CHANNEL:
|
||||
ts = obj;
|
||||
trx = ts->trx;
|
||||
if (new_state->operational == 1 &&
|
||||
if (new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
patch_nm_tables(trx->bts);
|
||||
enum abis_nm_chan_comb ccomb =
|
||||
@@ -455,7 +455,7 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
break;
|
||||
case NM_OC_RADIO_CARRIER:
|
||||
trx = obj;
|
||||
if (new_state->operational == 1 &&
|
||||
if (new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_OK)
|
||||
abis_nm_opstart(trx->bts, obj_class, trx->bts->bts_nr,
|
||||
trx->nr, 0xff);
|
||||
@@ -464,21 +464,19 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
bts = container_of(obj, struct gsm_bts, gprs.nse);
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
if (new_state->availability == 5) {
|
||||
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr,
|
||||
0xff, 0xff, nanobts_attr_nse,
|
||||
sizeof(nanobts_attr_nse));
|
||||
abis_nm_opstart(bts, obj_class, bts->bts_nr,
|
||||
0xff, 0xff);
|
||||
abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr,
|
||||
0xff, 0xff, NM_STATE_UNLOCKED);
|
||||
}
|
||||
break;
|
||||
case NM_OC_GPRS_CELL:
|
||||
bts = container_of(obj, struct gsm_bts, gprs.cell);
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
if (new_state->availability == 5) {
|
||||
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr,
|
||||
0, 0xff, nanobts_attr_cell,
|
||||
sizeof(nanobts_attr_cell));
|
||||
@@ -486,6 +484,8 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
0, 0xff);
|
||||
abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr,
|
||||
0, 0xff, NM_STATE_UNLOCKED);
|
||||
abis_nm_chg_adm_state(bts, NM_OC_GPRS_NSE, bts->bts_nr,
|
||||
0xff, 0xff, NM_STATE_UNLOCKED);
|
||||
}
|
||||
break;
|
||||
case NM_OC_GPRS_NSVC:
|
||||
@@ -493,7 +493,7 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
bts = nsvc->bts;
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
/* We skip NSVC1 since we only use NSVC0 */
|
||||
/* We skip NSVC1 since we only use NSVC0 */
|
||||
if (nsvc->id == 1)
|
||||
break;
|
||||
if (new_state->availability == NM_AVSTATE_OFF_LINE) {
|
||||
@@ -564,10 +564,19 @@ static int sw_activ_rep(struct msgb *mb)
|
||||
/* Callback function for NACK on the OML NM */
|
||||
static int oml_msg_nack(u_int8_t mt)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mt == NM_MT_SET_BTS_ATTR_NACK) {
|
||||
LOGP(DNM, LOGL_FATAL, "Failed to set BTS attributes. That is fatal. "
|
||||
"Was the bts type and frequency properly specified?\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
LOGP(DNM, LOGL_ERROR, "Got a NACK going to drop the OML links.\n");
|
||||
for (i = 0; i < bsc_gsmnet->num_bts; ++i) {
|
||||
struct gsm_bts *bts = gsm_bts_num(bsc_gsmnet, i);
|
||||
if (is_ipaccess_bts(bts))
|
||||
ipaccess_drop_oml(bts);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -831,6 +840,16 @@ err_out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void patch_16(uint8_t *data, const uint16_t val)
|
||||
{
|
||||
memcpy(data, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static void patch_32(uint8_t *data, const uint32_t val)
|
||||
{
|
||||
memcpy(data, &val, sizeof(val));
|
||||
}
|
||||
|
||||
/*
|
||||
* Patch the various SYSTEM INFORMATION tables to update
|
||||
* the LAI
|
||||
@@ -853,6 +872,22 @@ static void patch_nm_tables(struct gsm_bts *bts)
|
||||
bs11_attr_radio[2] |= arfcn_high;
|
||||
bs11_attr_radio[3] = arfcn_low;
|
||||
|
||||
/* patch the RACH attributes */
|
||||
if (bts->rach_b_thresh != -1) {
|
||||
nanobts_attr_bts[33] = bts->rach_b_thresh & 0xff;
|
||||
bs11_attr_bts[33] = bts->rach_b_thresh & 0xff;
|
||||
}
|
||||
|
||||
if (bts->rach_ldavg_slots != -1) {
|
||||
u_int8_t avg_high = bts->rach_ldavg_slots & 0xff;
|
||||
u_int8_t avg_low = (bts->rach_ldavg_slots >> 8) & 0x0f;
|
||||
|
||||
nanobts_attr_bts[35] = avg_high;
|
||||
nanobts_attr_bts[36] = avg_low;
|
||||
bs11_attr_bts[35] = avg_high;
|
||||
bs11_attr_bts[36] = avg_low;
|
||||
}
|
||||
|
||||
/* patch BSIC */
|
||||
bs11_attr_bts[1] = bts->bsic;
|
||||
nanobts_attr_bts[sizeof(nanobts_attr_bts)-11] = bts->bsic;
|
||||
@@ -867,18 +902,22 @@ static void patch_nm_tables(struct gsm_bts *bts)
|
||||
/* patch NSEI */
|
||||
nanobts_attr_nse[3] = bts->gprs.nse.nsei >> 8;
|
||||
nanobts_attr_nse[4] = bts->gprs.nse.nsei & 0xff;
|
||||
memcpy(nanobts_attr_nse+8, bts->gprs.nse.timer,
|
||||
ARRAY_SIZE(bts->gprs.nse.timer));
|
||||
memcpy(nanobts_attr_nse+18, bts->gprs.cell.timer,
|
||||
ARRAY_SIZE(bts->gprs.cell.timer));
|
||||
|
||||
/* patch NSVCI */
|
||||
nanobts_attr_nsvc0[3] = bts->gprs.nsvc[0].nsvci >> 8;
|
||||
nanobts_attr_nsvc0[4] = bts->gprs.nsvc[0].nsvci & 0xff;
|
||||
|
||||
/* patch IP address as SGSN IP */
|
||||
*(u_int16_t *)(nanobts_attr_nsvc0+8) =
|
||||
htons(bts->gprs.nsvc[0].remote_port);
|
||||
*(u_int32_t *)(nanobts_attr_nsvc0+10) =
|
||||
htonl(bts->gprs.nsvc[0].remote_ip);
|
||||
*(u_int16_t *)(nanobts_attr_nsvc0+14) =
|
||||
htons(bts->gprs.nsvc[0].local_port);
|
||||
patch_16(nanobts_attr_nsvc0 + 8,
|
||||
htons(bts->gprs.nsvc[0].remote_port));
|
||||
patch_32(nanobts_attr_nsvc0 + 10,
|
||||
htonl(bts->gprs.nsvc[0].remote_ip));
|
||||
patch_16(nanobts_attr_nsvc0 + 14,
|
||||
htons(bts->gprs.nsvc[0].local_port));
|
||||
|
||||
/* patch BVCI */
|
||||
nanobts_attr_cell[12] = bts->gprs.cell.bvci >> 8;
|
||||
@@ -950,6 +989,8 @@ void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
||||
trx->nm_state.availability = 0;
|
||||
trx->bb_transc.nm_state.operational = 0;
|
||||
trx->bb_transc.nm_state.availability = 0;
|
||||
|
||||
abis_nm_clear_queue(trx->bts);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -958,6 +999,8 @@ void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
||||
|
||||
static int bootstrap_bts(struct gsm_bts *bts)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
switch (bts->band) {
|
||||
case GSM_BAND_1800:
|
||||
if (bts->c0->arfcn < 512 || bts->c0->arfcn > 885) {
|
||||
@@ -994,13 +1037,43 @@ static int bootstrap_bts(struct gsm_bts *bts)
|
||||
|
||||
/* Control Channel Description */
|
||||
bts->si_common.chan_desc.att = 1;
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C;
|
||||
bts->si_common.chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5;
|
||||
/* T3212 is set from vty/config */
|
||||
|
||||
/* Set ccch config by looking at ts config */
|
||||
for (n=0, i=0; i<8; i++)
|
||||
n += bts->c0->ts[i].pchan == GSM_PCHAN_CCCH ? 1 : 0;
|
||||
|
||||
switch (n) {
|
||||
case 0:
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C;
|
||||
break;
|
||||
case 1:
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_NC;
|
||||
break;
|
||||
case 2:
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_2_NC;
|
||||
break;
|
||||
case 3:
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_3_NC;
|
||||
break;
|
||||
case 4:
|
||||
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_4_NC;
|
||||
break;
|
||||
default:
|
||||
LOGP(DNM, LOGL_ERROR, "Unsupported CCCH timeslot configuration\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* some defaults for our system information */
|
||||
bts->si_common.cell_options.radio_link_timeout = 2; /* 12 */
|
||||
bts->si_common.cell_options.dtx = 2; /* MS shall not use upplink DTX */
|
||||
bts->si_common.cell_options.radio_link_timeout = 7; /* 12 */
|
||||
|
||||
/* allow/disallow DTXu */
|
||||
if (bts->network->dtx_enabled)
|
||||
bts->si_common.cell_options.dtx = 0;
|
||||
else
|
||||
bts->si_common.cell_options.dtx = 2;
|
||||
|
||||
bts->si_common.cell_options.pwrc = 0; /* PWRC not set */
|
||||
|
||||
bts->si_common.cell_sel_par.acs = 0;
|
||||
|
||||
261
openbsc/src/bsc_msc.c
Normal file
261
openbsc/src/bsc_msc.c
Normal file
@@ -0,0 +1,261 @@
|
||||
/* Routines to talk to the MSC using the IPA Protocol */
|
||||
/*
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openbsc/bsc_msc.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/ipaccess.h>
|
||||
|
||||
#include <osmocore/write_queue.h>
|
||||
#include <osmocore/talloc.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void connection_loss(struct bsc_msc_connection *con)
|
||||
{
|
||||
struct bsc_fd *fd;
|
||||
|
||||
fd = &con->write_queue.bfd;
|
||||
|
||||
close(fd->fd);
|
||||
fd->fd = -1;
|
||||
fd->cb = write_queue_bfd_cb;
|
||||
fd->when = 0;
|
||||
|
||||
con->is_connected = 0;
|
||||
con->connection_loss(con);
|
||||
}
|
||||
|
||||
static void msc_con_timeout(void *_con)
|
||||
{
|
||||
struct bsc_msc_connection *con = _con;
|
||||
|
||||
LOGP(DMSC, LOGL_ERROR, "MSC Connection timeout.\n");
|
||||
bsc_msc_lost(con);
|
||||
}
|
||||
|
||||
/* called in the case of a non blocking connect */
|
||||
static int msc_connection_connect(struct bsc_fd *fd, unsigned int what)
|
||||
{
|
||||
int rc;
|
||||
int val;
|
||||
struct bsc_msc_connection *con;
|
||||
struct write_queue *queue;
|
||||
|
||||
socklen_t len = sizeof(val);
|
||||
|
||||
if ((what & BSC_FD_WRITE) == 0) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Callback but not writable.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
queue = container_of(fd, struct write_queue, bfd);
|
||||
con = container_of(queue, struct bsc_msc_connection, write_queue);
|
||||
|
||||
/* From here on we will either be connected or reconnect */
|
||||
bsc_del_timer(&con->timeout_timer);
|
||||
|
||||
/* check the socket state */
|
||||
rc = getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &val, &len);
|
||||
if (rc != 0) {
|
||||
LOGP(DMSC, LOGL_ERROR, "getsockopt for the MSC socket failed.\n");
|
||||
goto error;
|
||||
}
|
||||
if (val != 0) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Not connected to the MSC: %d\n", val);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* go to full operation */
|
||||
fd->cb = write_queue_bfd_cb;
|
||||
fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
|
||||
|
||||
con->is_connected = 1;
|
||||
LOGP(DMSC, LOGL_NOTICE, "(Re)Connected to the MSC.\n");
|
||||
if (con->connected)
|
||||
con->connected(con);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
bsc_unregister_fd(fd);
|
||||
connection_loss(con);
|
||||
return -1;
|
||||
}
|
||||
static void setnonblocking(struct bsc_fd *fd)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = fcntl(fd->fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl get failed");
|
||||
close(fd->fd);
|
||||
fd->fd = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
flags |= O_NONBLOCK;
|
||||
flags = fcntl(fd->fd, F_SETFL, flags);
|
||||
if (flags < 0) {
|
||||
perror("fcntl get failed");
|
||||
close(fd->fd);
|
||||
fd->fd = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int bsc_msc_connect(struct bsc_msc_connection *con)
|
||||
{
|
||||
struct bsc_fd *fd;
|
||||
struct sockaddr_in sin;
|
||||
int on = 1, ret;
|
||||
|
||||
LOGP(DMSC, LOGL_NOTICE, "Attempting to connect MSC at %s:%d\n", con->ip, con->port);
|
||||
|
||||
con->is_connected = 0;
|
||||
|
||||
fd = &con->write_queue.bfd;
|
||||
fd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
fd->data = NULL;
|
||||
fd->priv_nr = 1;
|
||||
|
||||
if (fd->fd < 0) {
|
||||
perror("Creating TCP socket failed");
|
||||
return fd->fd;
|
||||
}
|
||||
|
||||
/* make it non blocking */
|
||||
setnonblocking(fd);
|
||||
|
||||
/* set the socket priority */
|
||||
ret = setsockopt(fd->fd, IPPROTO_IP, IP_TOS,
|
||||
&con->prio, sizeof(con->prio));
|
||||
if (ret != 0)
|
||||
LOGP(DMSC, LOGL_ERROR, "Failed to set prio to %d. %s\n",
|
||||
con->prio, strerror(errno));
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(con->port);
|
||||
inet_aton(con->ip, &sin.sin_addr);
|
||||
|
||||
setsockopt(fd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
ret = connect(fd->fd, (struct sockaddr *) &sin, sizeof(sin));
|
||||
|
||||
if (ret == -1 && errno == EINPROGRESS) {
|
||||
LOGP(DMSC, LOGL_ERROR, "MSC Connection in progress\n");
|
||||
fd->when = BSC_FD_WRITE;
|
||||
fd->cb = msc_connection_connect;
|
||||
con->timeout_timer.cb = msc_con_timeout;
|
||||
con->timeout_timer.data = con;
|
||||
bsc_schedule_timer(&con->timeout_timer, 20, 0);
|
||||
} else if (ret < 0) {
|
||||
perror("Connection failed");
|
||||
connection_loss(con);
|
||||
return ret;
|
||||
} else {
|
||||
fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
|
||||
fd->cb = write_queue_bfd_cb;
|
||||
con->is_connected = 1;
|
||||
if (con->connected)
|
||||
con->connected(con);
|
||||
}
|
||||
|
||||
ret = bsc_register_fd(fd);
|
||||
if (ret < 0) {
|
||||
perror("Registering the fd failed");
|
||||
close(fd->fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio)
|
||||
{
|
||||
struct bsc_msc_connection *con;
|
||||
|
||||
con = talloc_zero(NULL, struct bsc_msc_connection);
|
||||
if (!con) {
|
||||
LOGP(DMSC, LOGL_FATAL, "Failed to create the MSC connection.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
con->ip = ip;
|
||||
con->port = port;
|
||||
con->prio = prio;
|
||||
write_queue_init(&con->write_queue, 100);
|
||||
return con;
|
||||
}
|
||||
|
||||
void bsc_msc_lost(struct bsc_msc_connection *con)
|
||||
{
|
||||
write_queue_clear(&con->write_queue);
|
||||
bsc_del_timer(&con->timeout_timer);
|
||||
|
||||
if (con->write_queue.bfd.fd >= 0)
|
||||
bsc_unregister_fd(&con->write_queue.bfd);
|
||||
connection_loss(con);
|
||||
}
|
||||
|
||||
static void reconnect_msc(void *_msc)
|
||||
{
|
||||
struct bsc_msc_connection *con = _msc;
|
||||
|
||||
LOGP(DMSC, LOGL_NOTICE, "Attempting to reconnect to the MSC.\n");
|
||||
bsc_msc_connect(con);
|
||||
}
|
||||
|
||||
void bsc_msc_schedule_connect(struct bsc_msc_connection *con)
|
||||
{
|
||||
LOGP(DMSC, LOGL_NOTICE, "Attempting to reconnect to the MSC.\n");
|
||||
con->reconnect_timer.cb = reconnect_msc;
|
||||
con->reconnect_timer.data = con;
|
||||
bsc_schedule_timer(&con->reconnect_timer, 5, 0);
|
||||
}
|
||||
|
||||
struct msgb *bsc_msc_id_get_resp(const char *token)
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
||||
if (!token) {
|
||||
LOGP(DMSC, LOGL_ERROR, "No token specified.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg = msgb_alloc_headroom(4096, 128, "id resp");
|
||||
if (!msg) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Failed to create the message.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg->l2h = msgb_v_put(msg, IPAC_MSGT_ID_RESP);
|
||||
msgb_l16tv_put(msg, strlen(token) + 1,
|
||||
IPAC_IDTAG_UNITNAME, (u_int8_t *) token);
|
||||
return msg;
|
||||
}
|
||||
1321
openbsc/src/bsc_msc_ip.c
Normal file
1321
openbsc/src/bsc_msc_ip.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ static void complete_rllr(struct bsc_rll_req *rllr, enum bsc_rllr_ind type)
|
||||
|
||||
conn = &rllr->lchan->conn;
|
||||
llist_del(&rllr->list);
|
||||
put_subscr_con(conn);
|
||||
put_subscr_con(conn, 0);
|
||||
rllr->cb(rllr->lchan, rllr->link_id, rllr->data, type);
|
||||
talloc_free(rllr);
|
||||
}
|
||||
|
||||
1169
openbsc/src/bssap.c
Normal file
1169
openbsc/src/bssap.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
@@ -33,7 +34,7 @@
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/signal.h>
|
||||
|
||||
static void auto_release_channel(void *_lchan);
|
||||
#include <osmocore/talloc.h>
|
||||
|
||||
static int ts_is_usable(struct gsm_bts_trx_ts *ts)
|
||||
{
|
||||
@@ -225,7 +226,8 @@ _lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
|
||||
}
|
||||
|
||||
/* Allocate a logical channel */
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
|
||||
int allow_bigger)
|
||||
{
|
||||
struct gsm_lchan *lchan = NULL;
|
||||
enum gsm_phys_chan_config first, second;
|
||||
@@ -243,6 +245,19 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
|
||||
lchan = _lc_find_bts(bts, first);
|
||||
if (lchan == NULL)
|
||||
lchan = _lc_find_bts(bts, second);
|
||||
|
||||
/* allow to assign bigger channels */
|
||||
if (allow_bigger) {
|
||||
if (lchan == NULL) {
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H);
|
||||
type = GSM_LCHAN_TCH_H;
|
||||
}
|
||||
|
||||
if (lchan == NULL) {
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
|
||||
type = GSM_LCHAN_TCH_F;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GSM_LCHAN_TCH_F:
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
|
||||
@@ -268,16 +283,16 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
|
||||
/* clear multi rate config */
|
||||
memset(&lchan->mr_conf, 0, sizeof(lchan->mr_conf));
|
||||
|
||||
/* clear any msc reference */
|
||||
lchan->msc_data = NULL;
|
||||
|
||||
/* clear per MSC/BSC data */
|
||||
memset(&lchan->conn, 0, sizeof(lchan->conn));
|
||||
|
||||
/* Configure the time and start it so it will be closed */
|
||||
lchan->conn.lchan = lchan;
|
||||
lchan->conn.bts = lchan->ts->trx->bts;
|
||||
lchan->conn.release_timer.cb = auto_release_channel;
|
||||
lchan->conn.release_timer.data = lchan;
|
||||
bsc_schedule_timer(&lchan->conn.release_timer, LCHAN_RELEASE_TIMEOUT);
|
||||
|
||||
/* set the alloc time */
|
||||
gettimeofday(&lchan->alloc_time, NULL);
|
||||
} else {
|
||||
struct challoc_signal_data sig;
|
||||
sig.bts = bts;
|
||||
@@ -307,8 +322,6 @@ void lchan_free(struct gsm_lchan *lchan)
|
||||
lchan->conn.use_count = 0;
|
||||
}
|
||||
|
||||
/* stop the timer */
|
||||
bsc_del_timer(&lchan->conn.release_timer);
|
||||
bsc_del_timer(&lchan->T3101);
|
||||
|
||||
/* clear cached measuement reports */
|
||||
@@ -320,6 +333,11 @@ void lchan_free(struct gsm_lchan *lchan)
|
||||
for (i = 0; i < ARRAY_SIZE(lchan->neigh_meas); i++)
|
||||
lchan->neigh_meas[i].arfcn = 0;
|
||||
|
||||
if (lchan->rqd_ref) {
|
||||
talloc_free(lchan->rqd_ref);
|
||||
lchan->rqd_ref = NULL;
|
||||
lchan->rqd_ta = 0;
|
||||
}
|
||||
lchan->conn.silent_call = 0;
|
||||
|
||||
sig.lchan = lchan;
|
||||
@@ -338,22 +356,48 @@ void lchan_free(struct gsm_lchan *lchan)
|
||||
void lchan_reset(struct gsm_lchan *lchan)
|
||||
{
|
||||
bsc_del_timer(&lchan->T3101);
|
||||
bsc_del_timer(&lchan->T3111);
|
||||
bsc_del_timer(&lchan->error_timer);
|
||||
|
||||
lchan->type = GSM_LCHAN_NONE;
|
||||
lchan->state = LCHAN_S_NONE;
|
||||
}
|
||||
|
||||
|
||||
/* Consider releasing the channel now */
|
||||
int lchan_auto_release(struct gsm_lchan *lchan)
|
||||
static int _lchan_release_next_sapi(struct gsm_lchan *lchan)
|
||||
{
|
||||
if (lchan->conn.use_count > 0) {
|
||||
int sapi;
|
||||
|
||||
for (sapi = 1; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) {
|
||||
u_int8_t link_id;
|
||||
if (lchan->sapis[sapi] == LCHAN_SAPI_UNUSED)
|
||||
continue;
|
||||
|
||||
link_id = sapi;
|
||||
if (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H)
|
||||
link_id |= 0x40;
|
||||
rsl_release_request(lchan, link_id, lchan->release_reason);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _lchan_handle_release(struct gsm_lchan *lchan)
|
||||
{
|
||||
/* Ask for SAPI != 0 to be freed first and stop if we need to wait */
|
||||
if (_lchan_release_next_sapi(lchan) == 0)
|
||||
return;
|
||||
|
||||
/* Assume we have GSM04.08 running and send a release */
|
||||
if (lchan->conn.subscr) {
|
||||
++lchan->conn.use_count;
|
||||
gsm48_send_rr_release(lchan);
|
||||
--lchan->conn.use_count;
|
||||
|
||||
/* avoid reentrancy */
|
||||
subscr_put(lchan->conn.subscr);
|
||||
lchan->conn.subscr = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* spoofed? message */
|
||||
@@ -361,19 +405,44 @@ int lchan_auto_release(struct gsm_lchan *lchan)
|
||||
LOGP(DRLL, LOGL_ERROR, "Channel count is negative: %d\n",
|
||||
lchan->conn.use_count);
|
||||
|
||||
DEBUGP(DRLL, "%s Recycling Channel\n", gsm_lchan_name(lchan));
|
||||
rsl_release_request(lchan, 0, lchan->release_reason);
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ);
|
||||
rsl_release_request(lchan, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Auto release the channel when the use count is zero */
|
||||
static void auto_release_channel(void *_lchan)
|
||||
/* called from abis rsl */
|
||||
int rsl_lchan_rll_release(struct gsm_lchan *lchan, u_int8_t link_id)
|
||||
{
|
||||
struct gsm_lchan *lchan = _lchan;
|
||||
if (lchan->state != LCHAN_S_REL_REQ)
|
||||
return -1;
|
||||
|
||||
if (!lchan_auto_release(lchan))
|
||||
bsc_schedule_timer(&lchan->conn.release_timer, LCHAN_RELEASE_TIMEOUT);
|
||||
if ((link_id & 0x7) != 0)
|
||||
_lchan_handle_release(lchan);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start the channel release procedure now. We will start by shutting
|
||||
* down SAPI!=0, then we will deactivate the SACCH and finish by releasing
|
||||
* the last SAPI at which point the RSL code will send the channel release
|
||||
* for us. We should guard the whole shutdown by T3109 or similiar and then
|
||||
* update the fixme inside gsm_04_08_utils.c
|
||||
* When we request to release the RLL and we don't get an answer within T200
|
||||
* the BTS will send us an Error indication which we will handle by closing
|
||||
* the channel and be done.
|
||||
*/
|
||||
int _lchan_release(struct gsm_lchan *lchan, u_int8_t release_reason)
|
||||
{
|
||||
if (lchan->conn.use_count > 0) {
|
||||
LOGP(DRLL, LOGL_ERROR, "BUG: _lchan_release called without zero use_count.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOGP(DRLL, LOGL_NOTICE, "%s Recycling Channel.\n", gsm_lchan_name(lchan));
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ);
|
||||
lchan->release_reason = release_reason;
|
||||
_lchan_handle_release(lchan);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) {
|
||||
|
||||
@@ -146,6 +146,11 @@ static const struct log_info_cat default_categories[] = {
|
||||
.description = "Reference Counting",
|
||||
.enabled = 0, .loglevel = LOGL_NOTICE,
|
||||
},
|
||||
[DNAT] = {
|
||||
.name = "DNAT",
|
||||
.description = "BSC MUX/NAT",
|
||||
.enabled = 1, .loglevel = LOGL_NOTICE,
|
||||
},
|
||||
};
|
||||
|
||||
enum log_ctxt {
|
||||
|
||||
@@ -303,6 +303,10 @@ int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
|
||||
|
||||
switch (type) {
|
||||
case E1INP_TS_TYPE_SIGN:
|
||||
if (line->driver)
|
||||
ts->sign.delay = line->driver->default_delay;
|
||||
else
|
||||
ts->sign.delay = 100000;
|
||||
INIT_LLIST_HEAD(&ts->sign.sign_links);
|
||||
break;
|
||||
case E1INP_TS_TYPE_TRAU:
|
||||
@@ -420,7 +424,17 @@ e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
|
||||
|
||||
void e1inp_sign_link_destroy(struct e1inp_sign_link *link)
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
||||
llist_del(&link->list);
|
||||
while (!llist_empty(&link->tx_list)) {
|
||||
msg = msgb_dequeue(&link->tx_list);
|
||||
msgb_free(msg);
|
||||
}
|
||||
|
||||
if (link->ts->type == E1INP_TS_TYPE_SIGN)
|
||||
bsc_del_timer(&link->ts->sign.tx_timer);
|
||||
|
||||
talloc_free(link);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <openbsc/transaction.h>
|
||||
#include <openbsc/ussd.h>
|
||||
#include <openbsc/silent_call.h>
|
||||
#include <osmocore/gsm0480.h>
|
||||
|
||||
void *tall_locop_ctx;
|
||||
|
||||
@@ -104,12 +105,12 @@ static void release_loc_updating_req(struct gsm_subscriber_connection *conn)
|
||||
bsc_del_timer(&conn->loc_operation->updating_timer);
|
||||
talloc_free(conn->loc_operation);
|
||||
conn->loc_operation = 0;
|
||||
put_subscr_con(conn);
|
||||
put_subscr_con(conn, 0);
|
||||
}
|
||||
|
||||
static void allocate_loc_updating_req(struct gsm_subscriber_connection *conn)
|
||||
{
|
||||
use_subscr_con(conn)
|
||||
use_subscr_con(conn);
|
||||
release_loc_updating_req(conn);
|
||||
|
||||
conn->loc_operation = talloc_zero(tall_locop_ctx,
|
||||
@@ -122,7 +123,6 @@ static int gsm0408_authorize(struct gsm_subscriber_connection *conn, struct msgb
|
||||
int rc;
|
||||
|
||||
db_subscriber_alloc_tmsi(conn->subscr);
|
||||
release_loc_updating_req(conn);
|
||||
rc = gsm0408_loc_upd_acc(msg->lchan, conn->subscr->tmsi);
|
||||
if (msg->lchan->ts->trx->bts->network->send_mm_info) {
|
||||
/* send MM INFO with network name */
|
||||
@@ -134,9 +134,7 @@ static int gsm0408_authorize(struct gsm_subscriber_connection *conn, struct msgb
|
||||
* trigger further action like SMS delivery */
|
||||
subscr_update(conn->subscr, msg->trx->bts,
|
||||
GSM_SUBSCRIBER_UPDATE_ATTACHED);
|
||||
|
||||
/* try to close channel ASAP */
|
||||
lchan_auto_release(conn->lchan);
|
||||
release_loc_updating_req(conn);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -178,24 +176,24 @@ int gsm0408_loc_upd_rej(struct gsm_lchan *lchan, u_int8_t cause)
|
||||
{
|
||||
struct gsm_subscriber_connection *conn;
|
||||
struct gsm_bts *bts = lchan->ts->trx->bts;
|
||||
struct msgb *msg = gsm48_msgb_alloc();
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
counter_inc(bts->network->stats.loc_upd_resp.reject);
|
||||
|
||||
msg = gsm48_create_loc_upd_rej(cause);
|
||||
if (!msg) {
|
||||
LOGP(DMM, LOGL_ERROR, "Failed to create msg for LOCATION UPDATING REJECT.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg->lchan = lchan;
|
||||
conn = &lchan->conn;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
|
||||
gh->proto_discr = GSM48_PDISC_MM;
|
||||
gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
|
||||
gh->data[0] = cause;
|
||||
|
||||
LOGP(DMM, LOGL_INFO, "Subscriber %s: LOCATION UPDATING REJECT "
|
||||
"LAC=%u BTS=%u\n", conn->subscr ?
|
||||
subscr_name(conn->subscr) : "unknown",
|
||||
lchan->ts->trx->bts->location_area_code, lchan->ts->trx->bts->nr);
|
||||
|
||||
counter_inc(bts->network->stats.loc_upd_resp.reject);
|
||||
|
||||
return gsm48_sendmsg(msg, NULL);
|
||||
}
|
||||
|
||||
@@ -298,9 +296,8 @@ static void loc_upd_rej_cb(void *data)
|
||||
struct gsm_lchan *lchan = conn->lchan;
|
||||
struct gsm_bts *bts = lchan->ts->trx->bts;
|
||||
|
||||
release_loc_updating_req(conn);
|
||||
gsm0408_loc_upd_rej(lchan, bts->network->reject_cause);
|
||||
lchan_auto_release(lchan);
|
||||
release_loc_updating_req(conn);
|
||||
}
|
||||
|
||||
static void schedule_reject(struct gsm_subscriber_connection *conn)
|
||||
@@ -578,19 +575,17 @@ static int gsm48_tx_mm_serv_ack(struct gsm_lchan *lchan)
|
||||
static int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
|
||||
enum gsm48_reject_value value)
|
||||
{
|
||||
struct msgb *msg = gsm48_msgb_alloc();
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
|
||||
msg = gsm48_create_mm_serv_rej(value);
|
||||
if (!msg) {
|
||||
LOGP(DMM, LOGL_ERROR, "Failed to allocate CM Service Reject.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
DEBUGP(DMM, "-> CM SERVICE Reject cause: %d\n", value);
|
||||
msg->lchan = conn->lchan;
|
||||
use_subscr_con(conn);
|
||||
|
||||
gh->proto_discr = GSM48_PDISC_MM;
|
||||
gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
|
||||
gh->data[0] = value;
|
||||
DEBUGP(DMM, "-> CM SERVICE Reject cause: %d\n", value);
|
||||
|
||||
return gsm48_sendmsg(msg, NULL);
|
||||
}
|
||||
|
||||
@@ -613,7 +608,7 @@ static int gsm48_rx_mm_serv_req(struct msgb *msg)
|
||||
struct gsm48_hdr *gh = msgb_l3(msg);
|
||||
struct gsm48_service_request *req =
|
||||
(struct gsm48_service_request *)gh->data;
|
||||
/* unfortunately in Phase1 the classmar2 length is variable */
|
||||
/* unfortunately in Phase1 the classmark2 length is variable */
|
||||
u_int8_t classmark2_len = gh->data[1];
|
||||
u_int8_t *classmark2 = gh->data+2;
|
||||
u_int8_t mi_len = *(classmark2 + classmark2_len);
|
||||
@@ -722,8 +717,6 @@ static int gsm48_rx_mm_imsi_detach_ind(struct msgb *msg)
|
||||
* imagine an IMSI DETACH happening during an active call! */
|
||||
|
||||
/* subscriber is detached: should we release lchan? */
|
||||
lchan_auto_release(msg->lchan);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -785,13 +778,16 @@ static int gsm48_rx_rr_pag_resp(struct msgb *msg)
|
||||
{
|
||||
struct gsm_bts *bts = msg->lchan->ts->trx->bts;
|
||||
struct gsm48_hdr *gh = msgb_l3(msg);
|
||||
struct gsm48_pag_resp *resp;
|
||||
u_int8_t *classmark2_lv = gh->data + 1;
|
||||
u_int8_t mi_type;
|
||||
char mi_string[GSM48_MI_SIZE];
|
||||
struct gsm_subscriber *subscr = NULL;
|
||||
int rc = 0;
|
||||
|
||||
gsm48_paging_extract_mi(msg, mi_string, &mi_type);
|
||||
resp = (struct gsm48_pag_resp *) &gh->data[0];
|
||||
gsm48_paging_extract_mi(resp, msgb_l3len(msg) - sizeof(*gh),
|
||||
mi_string, &mi_type);
|
||||
DEBUGP(DRR, "PAGING RESPONSE: mi_type=0x%02x MI(%s)\n",
|
||||
mi_type, mi_string);
|
||||
|
||||
@@ -2070,7 +2066,6 @@ static int gsm48_cc_rx_release_compl(struct gsm_trans *trans, struct msgb *msg)
|
||||
MNCC_REL_CNF, &rel);
|
||||
/* FIXME: in case of multiple calls, we can't simply
|
||||
* hang up here ! */
|
||||
lchan_auto_release(msg->lchan);
|
||||
break;
|
||||
default:
|
||||
rc = mncc_recvmsg(trans->subscr->net, trans,
|
||||
|
||||
@@ -164,13 +164,46 @@ static const enum gsm_chreq_reason_t reason_by_chreq[] = {
|
||||
[CHREQ_T_RESERVED_IGNORE] = GSM_CHREQ_REASON_OTHER,
|
||||
};
|
||||
|
||||
enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci)
|
||||
/* verify that the two tables match */
|
||||
static_assert(sizeof(ctype_by_chreq) ==
|
||||
sizeof(((struct gsm_network *) NULL)->ctype_by_chreq), assert_size);
|
||||
|
||||
/*
|
||||
* Update channel types for request based on policy. E.g. in the
|
||||
* case of a TCH/H network/bsc use TCH/H for the emergency calls,
|
||||
* for early assignment assign a SDCCH and some other options.
|
||||
*/
|
||||
void gsm_net_update_ctype(struct gsm_network *network)
|
||||
{
|
||||
/* copy over the data */
|
||||
memcpy(network->ctype_by_chreq, ctype_by_chreq, sizeof(ctype_by_chreq));
|
||||
|
||||
/*
|
||||
* Use TCH/H for emergency calls when this cell allows TCH/H. Maybe it
|
||||
* is better to iterate over the BTS/TRX and check if no TCH/F is available
|
||||
* and then set it to TCH/H.
|
||||
*/
|
||||
if (network->neci)
|
||||
network->ctype_by_chreq[CHREQ_T_EMERG_CALL] = GSM_LCHAN_TCH_H;
|
||||
|
||||
if (network->pag_any_tch) {
|
||||
if (network->neci) {
|
||||
network->ctype_by_chreq[CHREQ_T_PAG_R_ANY_NECI0] = GSM_LCHAN_TCH_H;
|
||||
network->ctype_by_chreq[CHREQ_T_PAG_R_ANY_NECI1] = GSM_LCHAN_TCH_H;
|
||||
} else {
|
||||
network->ctype_by_chreq[CHREQ_T_PAG_R_ANY_NECI0] = GSM_LCHAN_TCH_F;
|
||||
network->ctype_by_chreq[CHREQ_T_PAG_R_ANY_NECI1] = GSM_LCHAN_TCH_F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum gsm_chan_t get_ctype_by_chreq(struct gsm_network *network, u_int8_t ra)
|
||||
{
|
||||
int i;
|
||||
int length;
|
||||
const struct chreq *chreq;
|
||||
|
||||
if (neci) {
|
||||
if (network->neci) {
|
||||
chreq = chreq_type_neci1;
|
||||
length = ARRAY_SIZE(chreq_type_neci1);
|
||||
} else {
|
||||
@@ -182,13 +215,13 @@ enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci)
|
||||
for (i = 0; i < length; i++) {
|
||||
const struct chreq *chr = &chreq[i];
|
||||
if ((ra & chr->mask) == chr->val)
|
||||
return ctype_by_chreq[chr->type];
|
||||
return network->ctype_by_chreq[chr->type];
|
||||
}
|
||||
LOGP(DRR, LOGL_ERROR, "Unknown CHANNEL REQUEST RQD 0x%02x\n", ra);
|
||||
return GSM_LCHAN_SDCCH;
|
||||
}
|
||||
|
||||
enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci)
|
||||
enum gsm_chreq_reason_t get_reason_by_chreq(u_int8_t ra, int neci)
|
||||
{
|
||||
int i;
|
||||
int length;
|
||||
@@ -252,16 +285,30 @@ int send_siemens_mrpci(struct gsm_lchan *lchan,
|
||||
return rsl_siemens_mrpci(lchan, &mrpci);
|
||||
}
|
||||
|
||||
int gsm48_paging_extract_mi(struct msgb *msg, char *mi_string, u_int8_t *mi_type)
|
||||
int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type)
|
||||
{
|
||||
struct gsm48_hdr *gh = msgb_l3(msg);
|
||||
u_int8_t *classmark2_lv = gh->data + 1;
|
||||
u_int8_t *mi_lv = gh->data + 2 + *classmark2_lv;
|
||||
*mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
|
||||
/* Check the size for the classmark */
|
||||
if (length < 1 + *classmark2_lv)
|
||||
return -1;
|
||||
|
||||
u_int8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
|
||||
if (length < 2 + *classmark2_lv + mi_lv[0])
|
||||
return -2;
|
||||
|
||||
*mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
|
||||
return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
|
||||
}
|
||||
|
||||
int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
|
||||
char *mi_string, u_int8_t *mi_type)
|
||||
{
|
||||
static const uint32_t classmark_offset =
|
||||
offsetof(struct gsm48_pag_resp, classmark2);
|
||||
u_int8_t *classmark2_lv = (uint8_t *) &resp->classmark2;
|
||||
return gsm48_extract_mi(classmark2_lv, length - classmark_offset,
|
||||
mi_string, mi_type);
|
||||
}
|
||||
|
||||
int gsm48_handle_paging_resp(struct msgb *msg, struct gsm_subscriber *subscr)
|
||||
{
|
||||
struct gsm_bts *bts = msg->lchan->ts->trx->bts;
|
||||
@@ -288,7 +335,7 @@ int gsm48_handle_paging_resp(struct msgb *msg, struct gsm_subscriber *subscr)
|
||||
sig_data.bts = msg->lchan->ts->trx->bts;
|
||||
sig_data.lchan = msg->lchan;
|
||||
|
||||
bts->network->stats.paging.completed++;
|
||||
counter_inc(bts->network->stats.paging.completed);
|
||||
|
||||
dispatch_signal(SS_PAGING, S_PAGING_SUCCEEDED, &sig_data);
|
||||
|
||||
@@ -582,3 +629,36 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct gsm48_hdr *gh;
|
||||
|
||||
msg = gsm48_msgb_alloc();
|
||||
if (!msg)
|
||||
return NULL;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
|
||||
gh->proto_discr = GSM48_PDISC_MM;
|
||||
gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
|
||||
gh->data[0] = value;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
|
||||
{
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
msg = gsm48_msgb_alloc();
|
||||
if (!msg)
|
||||
return NULL;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
|
||||
gh->proto_discr = GSM48_PDISC_MM;
|
||||
gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
|
||||
gh->data[0] = cause;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
|
||||
GSM411_RP_CAUSE_INV_MAND_INF);
|
||||
return -EIO;
|
||||
}
|
||||
msg->smsh = tpdu;
|
||||
msg->l4h = tpdu;
|
||||
|
||||
DEBUGP(DSMS, "DST(%u,%s)\n", dst_len, hexdump(dst, dst_len));
|
||||
|
||||
@@ -757,7 +757,7 @@ static int gsm411_rx_rp_ack(struct msgb *msg, struct gsm_trans *trans,
|
||||
/* release channel if done */
|
||||
#warning "BROKEN. The SAPI will be released automatically by the BSC"
|
||||
if (!sms)
|
||||
rsl_release_request(msg->lchan, trans->sms.link_id);
|
||||
rsl_release_request(msg->lchan, trans->sms.link_id, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -833,7 +833,7 @@ static int gsm411_rx_rp_smma(struct msgb *msg, struct gsm_trans *trans,
|
||||
if (sms)
|
||||
gsm411_send_sms_lchan(trans->conn, sms);
|
||||
else
|
||||
rsl_release_request(msg->lchan, trans->sms.link_id);
|
||||
rsl_release_request(msg->lchan, trans->sms.link_id, 0);
|
||||
#warning "BROKEN: The SAPI=3 will be released automatically by the BSC"
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
|
||||
|
||||
/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
|
||||
* (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2008, 2009, 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2009 by Mike Haben <michael.haben@btinternet.com>
|
||||
*
|
||||
* All Rights Reserved
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <osmocore/gsm_utils.h>
|
||||
#include <openbsc/gsm_04_08.h>
|
||||
#include <openbsc/gsm_04_80.h>
|
||||
#include <osmocore/gsm0480.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static int parse_ussd(u_int8_t *ussd, struct ussd_request *req);
|
||||
@@ -50,22 +51,22 @@ static int parse_process_uss_req(u_int8_t *uss_req_data, u_int8_t length,
|
||||
|
||||
static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, u_int8_t tag)
|
||||
{
|
||||
msgb->data -= 2;
|
||||
msgb->data[0] = tag;
|
||||
msgb->data[1] = msgb->len;
|
||||
msgb->len += 2;
|
||||
return msgb->data;
|
||||
uint8_t *data = msgb_push(msgb, 2);
|
||||
|
||||
data[0] = tag;
|
||||
data[1] = msgb->len - 2;
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, u_int8_t tag,
|
||||
u_int8_t value)
|
||||
{
|
||||
msgb->data -= 3;
|
||||
msgb->len += 3;
|
||||
msgb->data[0] = tag;
|
||||
msgb->data[1] = 1;
|
||||
msgb->data[2] = value;
|
||||
return msgb->data;
|
||||
uint8_t *data = msgb_push(msgb, 3);
|
||||
|
||||
data[0] = tag;
|
||||
data[1] = 1;
|
||||
data[2] = value;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +258,6 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_t
|
||||
if (((strlen(response_text) * 7) % 8) != 0)
|
||||
response_len += 1;
|
||||
|
||||
msg->bts_link = in_msg->bts_link;
|
||||
msg->lchan = in_msg->lchan;
|
||||
|
||||
/* First put the payload text into the message */
|
||||
@@ -299,12 +299,11 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_t
|
||||
}
|
||||
|
||||
int gsm0480_send_ussd_reject(const struct msgb *in_msg,
|
||||
const struct ussd_request *req)
|
||||
const struct ussd_request *req)
|
||||
{
|
||||
struct msgb *msg = gsm48_msgb_alloc();
|
||||
struct gsm48_hdr *gh;
|
||||
|
||||
msg->bts_link = in_msg->bts_link;
|
||||
msg->lchan = in_msg->lchan;
|
||||
|
||||
/* First insert the problem code */
|
||||
@@ -328,3 +327,43 @@ int gsm0480_send_ussd_reject(const struct msgb *in_msg,
|
||||
|
||||
return gsm48_sendmsg(msg, NULL);
|
||||
}
|
||||
|
||||
int gsm0480_send_ussdNotify(struct gsm_lchan *lchan, int level, const char *text)
|
||||
{
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
msg = gsm0480_create_unstructuredSS_Notify(level, text);
|
||||
if (!msg)
|
||||
return -1;
|
||||
|
||||
gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
|
||||
gsm0480_wrap_facility(msg);
|
||||
|
||||
msg->lchan = lchan;
|
||||
|
||||
/* And finally pre-pend the L3 header */
|
||||
gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
|
||||
gh->proto_discr = GSM48_PDISC_NC_SS;
|
||||
gh->msg_type = GSM0480_MTYPE_REGISTER;
|
||||
|
||||
return gsm48_sendmsg(msg, NULL);
|
||||
}
|
||||
|
||||
int gsm0480_send_releaseComplete(struct gsm_lchan *lchan)
|
||||
{
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
msg = gsm48_msgb_alloc();
|
||||
if (!msg)
|
||||
return -1;
|
||||
|
||||
msg->lchan = lchan;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
|
||||
gh->proto_discr = GSM48_PDISC_NC_SS;
|
||||
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
||||
|
||||
return gsm48_sendmsg(msg, NULL);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ static const struct value_string lchan_s_names[] = {
|
||||
{ LCHAN_S_ACTIVE, "ACTIVE" },
|
||||
{ LCHAN_S_INACTIVE, "INACTIVE" },
|
||||
{ LCHAN_S_REL_REQ, "RELEASE REQUESTED" },
|
||||
{ LCHAN_S_REL_ERR, "RELEASE DUE ERROR" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
@@ -171,6 +172,10 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
|
||||
return trx;
|
||||
}
|
||||
|
||||
static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 3, 3, 10 };
|
||||
static const uint8_t bts_cell_timer_default[] =
|
||||
{ 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 };
|
||||
|
||||
struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
|
||||
u_int8_t tsc, u_int8_t bsic)
|
||||
{
|
||||
@@ -212,6 +217,10 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
|
||||
bts->gprs.nsvc[i].bts = bts;
|
||||
bts->gprs.nsvc[i].id = i;
|
||||
}
|
||||
memcpy(&bts->gprs.nse.timer, bts_nse_timer_default,
|
||||
sizeof(bts->gprs.nse.timer));
|
||||
memcpy(&bts->gprs.cell.timer, bts_cell_timer_default,
|
||||
sizeof(bts->gprs.cell.timer));
|
||||
|
||||
/* create our primary TRX */
|
||||
bts->c0 = gsm_bts_trx_alloc(bts);
|
||||
@@ -221,6 +230,12 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
|
||||
}
|
||||
bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4;
|
||||
|
||||
bts->paging.free_chans_need = -1;
|
||||
bts->rach_b_thresh = -1;
|
||||
bts->rach_ldavg_slots = -1;
|
||||
|
||||
INIT_LLIST_HEAD(&bts->abis_queue);
|
||||
|
||||
llist_add_tail(&bts->list, &net->bts_list);
|
||||
|
||||
return bts;
|
||||
@@ -287,6 +302,17 @@ struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_c
|
||||
|
||||
net->mncc_recv = mncc_recv;
|
||||
|
||||
gsm_net_update_ctype(net);
|
||||
|
||||
net->core_country_code = -1;
|
||||
net->core_network_code = -1;
|
||||
net->rtp_base_port = 4000;
|
||||
|
||||
net->msc_ip = talloc_strdup(net, "127.0.0.1");
|
||||
net->msc_port = 5000;
|
||||
net->ping_timeout = 20;
|
||||
net->pong_timeout = 5;
|
||||
|
||||
return net;
|
||||
}
|
||||
|
||||
@@ -440,33 +466,6 @@ const char *gsm_auth_policy_name(enum gsm_auth_policy policy)
|
||||
return get_value_string(auth_policy_names, policy);
|
||||
}
|
||||
|
||||
/* this should not be here but in gsm_04_08... but that creates
|
||||
in turn a dependency nightmare (abis_nm depending on 04_08, ...) */
|
||||
static int gsm48_construct_ra(u_int8_t *buf, const struct gprs_ra_id *raid)
|
||||
{
|
||||
u_int16_t mcc = raid->mcc;
|
||||
u_int16_t mnc = raid->mnc;
|
||||
|
||||
buf[0] = ((mcc / 100) % 10) | (((mcc / 10) % 10) << 4);
|
||||
buf[1] = (mcc % 10);
|
||||
|
||||
/* I wonder who came up with the stupidity of encoding the MNC
|
||||
* differently depending on how many digits its decimal number has! */
|
||||
if (mnc < 100) {
|
||||
buf[1] |= 0xf0;
|
||||
buf[2] = ((mnc / 10) % 10) | ((mnc % 10) << 4);
|
||||
} else {
|
||||
buf[1] |= (mnc % 10) << 4;
|
||||
buf[2] = ((mnc / 100) % 10) | (((mcc / 10) % 10) << 4);
|
||||
}
|
||||
|
||||
*(u_int16_t *)(buf+3) = htons(raid->lac);
|
||||
|
||||
buf[5] = raid->rac;
|
||||
|
||||
return 6;
|
||||
}
|
||||
|
||||
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
|
||||
{
|
||||
raid->mcc = bts->network->country_code;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <openbsc/gsm_subscriber.h>
|
||||
#include <openbsc/paging.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
|
||||
LLIST_HEAD(active_subscribers);
|
||||
void *tall_subscr_ctx;
|
||||
@@ -88,6 +89,7 @@ static int subscr_paging_cb(unsigned int hooknum, unsigned int event,
|
||||
request->cbfn(hooknum, event, msg, data, request->param);
|
||||
subscr->in_callback = 0;
|
||||
|
||||
subscr_put(request->subscr);
|
||||
talloc_free(request);
|
||||
return 0;
|
||||
}
|
||||
@@ -165,7 +167,7 @@ void subscr_get_channel(struct gsm_subscriber *subscr,
|
||||
}
|
||||
|
||||
memset(request, 0, sizeof(*request));
|
||||
request->subscr = subscr;
|
||||
request->subscr = subscr_get(subscr);
|
||||
request->channel_type = type;
|
||||
request->cbfn = cbfn;
|
||||
request->param = param;
|
||||
@@ -206,9 +208,28 @@ void subscr_put_channel(struct gsm_lchan *lchan)
|
||||
* will listen to the paging requests before we timeout
|
||||
*/
|
||||
|
||||
put_subscr_con(conn);
|
||||
put_subscr_con(conn, 0);
|
||||
|
||||
if (lchan->conn.subscr && !llist_empty(&lchan->conn.subscr->requests))
|
||||
subscr_send_paging_request(lchan->conn.subscr);
|
||||
}
|
||||
|
||||
struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
|
||||
const char *imsi)
|
||||
{
|
||||
struct gsm_subscriber *subscr;
|
||||
|
||||
llist_for_each_entry(subscr, subscr_bsc_active_subscriber(), entry) {
|
||||
if (strcmp(subscr->imsi, imsi) == 0 && subscr->net == net)
|
||||
return subscr_get(subscr);
|
||||
}
|
||||
|
||||
subscr = subscr_alloc();
|
||||
if (!subscr)
|
||||
return NULL;
|
||||
|
||||
strcpy(subscr->imsi, imsi);
|
||||
subscr->net = net;
|
||||
return subscr;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts)
|
||||
|
||||
counter_inc(bts->network->stats.handover.attempted);
|
||||
|
||||
new_lchan = lchan_alloc(bts, old_lchan->type);
|
||||
new_lchan = lchan_alloc(bts, old_lchan->type, 0);
|
||||
if (!new_lchan) {
|
||||
LOGP(DHO, LOGL_NOTICE, "No free channel\n");
|
||||
counter_inc(bts->network->stats.handover.no_channel);
|
||||
@@ -231,7 +231,6 @@ static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan)
|
||||
trans_lchan_change(&ho->old_lchan->conn, &new_lchan->conn);
|
||||
|
||||
rsl_lchan_set_state(ho->old_lchan, LCHAN_S_INACTIVE);
|
||||
lchan_auto_release(ho->old_lchan);
|
||||
|
||||
/* do something to re-route the actual speech frames ! */
|
||||
|
||||
@@ -259,7 +258,7 @@ static int ho_gsm48_ho_fail(struct gsm_lchan *old_lchan)
|
||||
bsc_del_timer(&ho->T3103);
|
||||
llist_del(&ho->list);
|
||||
conn = &ho->new_lchan->conn;
|
||||
put_subscr_con(conn);
|
||||
put_subscr_con(conn, 0);
|
||||
talloc_free(ho);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -265,6 +265,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
|
||||
trx->rsl_link = e1inp_sign_link_create(e1i_ts,
|
||||
E1INP_SIGN_RSL, trx,
|
||||
trx->rsl_tei, 0);
|
||||
trx->rsl_link->ts->sign.delay = 0;
|
||||
|
||||
/* get rid of our old temporary bfd */
|
||||
memcpy(newbfd, bfd, sizeof(*newbfd));
|
||||
@@ -572,7 +573,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
|
||||
e1i_ts->sign.tx_timer.data = e1i_ts;
|
||||
|
||||
/* Reducing this might break the nanoBTS 900 init. */
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 100000);
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -606,6 +607,7 @@ static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
struct e1inp_driver ipaccess_driver = {
|
||||
.name = "ip.access",
|
||||
.want_write = ts_want_write,
|
||||
.default_delay = 0,
|
||||
};
|
||||
|
||||
/* callback of the OML listening filedescriptor */
|
||||
|
||||
@@ -235,7 +235,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
|
||||
/* set tx delay timer for next event */
|
||||
e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
|
||||
e1i_ts->sign.tx_timer.data = e1i_ts;
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 50000);
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -375,6 +375,7 @@ static int activate_bchan(struct e1inp_line *line, int ts, int act)
|
||||
struct e1inp_driver misdn_driver = {
|
||||
.name = "mISDNuser",
|
||||
.want_write = ts_want_write,
|
||||
.default_delay = 50000,
|
||||
};
|
||||
|
||||
static int mi_e1_setup(struct e1inp_line *line, int release_l2)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* ip.access nanoBTS configuration tool */
|
||||
|
||||
/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
|
||||
* (C) 2009 by Holger Hans Peter Freyther
|
||||
* (C) 2009 by On Waves
|
||||
* (C) 2009,2010 by Holger Hans Peter Freyther
|
||||
* (C) 2009,2010 by On Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -59,6 +59,7 @@ static int sw_load_state = 0;
|
||||
static int oml_state = 0;
|
||||
static int dump_files = 0;
|
||||
static char *firmware_analysis = NULL;
|
||||
static int found_trx = 0;
|
||||
|
||||
struct sw_load {
|
||||
u_int8_t file_id[255];
|
||||
@@ -91,23 +92,23 @@ static int ipacc_msg_nack(u_int8_t mt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ipacc_msg_ack(u_int8_t mt, struct gsm_bts *bts)
|
||||
static void check_restart_or_exit(struct gsm_bts_trx *trx)
|
||||
{
|
||||
if (restart) {
|
||||
abis_nm_ipaccess_restart(trx);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
static int ipacc_msg_ack(u_int8_t mt, struct gsm_bts_trx *trx)
|
||||
{
|
||||
if (sw_load_state == 1) {
|
||||
fprintf(stderr, "The new software is activaed.\n");
|
||||
|
||||
if (restart) {
|
||||
abis_nm_ipaccess_restart(bts);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
check_restart_or_exit(trx);
|
||||
} else if (oml_state == 1) {
|
||||
fprintf(stderr, "Set the primary OML IP.\n");
|
||||
if (restart) {
|
||||
abis_nm_ipaccess_restart(bts);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
check_restart_or_exit(trx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -202,7 +203,7 @@ static int nm_sig_cb(unsigned int subsys, unsigned int signal,
|
||||
return ipacc_msg_nack(ipacc_data->msg_type);
|
||||
case S_NM_IPACC_ACK:
|
||||
ipacc_data = signal_data;
|
||||
return ipacc_msg_ack(ipacc_data->msg_type, ipacc_data->bts);
|
||||
return ipacc_msg_ack(ipacc_data->msg_type, ipacc_data->trx);
|
||||
case S_NM_TEST_REP:
|
||||
return test_rep(signal_data);
|
||||
case S_NM_IPACC_RESTART_ACK:
|
||||
@@ -227,12 +228,12 @@ static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
|
||||
void *data, void *param)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_bts_trx *trx;
|
||||
|
||||
if (hook != GSM_HOOK_NM_SWLOAD)
|
||||
return 0;
|
||||
|
||||
bts = (struct gsm_bts *) data;
|
||||
trx = (struct gsm_bts_trx *) data;
|
||||
|
||||
switch (event) {
|
||||
case NM_MT_LOAD_INIT_ACK:
|
||||
@@ -271,7 +272,7 @@ static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
|
||||
msg->l2h[1] = msgb_l3len(msg) >> 8;
|
||||
msg->l2h[2] = msgb_l3len(msg) & 0xff;
|
||||
printf("Foo l2h: %p l3h: %p... length l2: %u l3: %u\n", msg->l2h, msg->l3h, msgb_l2len(msg), msgb_l3len(msg));
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, msg->l2h, msgb_l2len(msg));
|
||||
abis_nm_ipaccess_set_nvattr(trx, msg->l2h, msgb_l2len(msg));
|
||||
msgb_free(msg);
|
||||
break;
|
||||
case NM_MT_LOAD_END_NACK:
|
||||
@@ -285,7 +286,7 @@ static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
|
||||
case NM_MT_ACTIVATE_SW_ACK:
|
||||
break;
|
||||
case NM_MT_LOAD_SEG_ACK:
|
||||
percent = abis_nm_software_load_status(bts);
|
||||
percent = abis_nm_software_load_status(trx->bts);
|
||||
if (percent > percent_old)
|
||||
printf("Software Download Progress: %d%%\n", percent);
|
||||
percent_old = percent;
|
||||
@@ -298,13 +299,13 @@ static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bootstrap_om(struct gsm_bts *bts)
|
||||
static void bootstrap_om(struct gsm_bts_trx *trx)
|
||||
{
|
||||
int len;
|
||||
static u_int8_t buf[1024];
|
||||
u_int8_t *cur = buf;
|
||||
|
||||
printf("OML link established\n");
|
||||
printf("OML link established using TRX %d\n", trx->nr);
|
||||
|
||||
if (unit_id) {
|
||||
len = strlen(unit_id);
|
||||
@@ -316,7 +317,7 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||
memcpy(buf+3, unit_id, len);
|
||||
buf[3+len] = 0;
|
||||
printf("setting Unit ID to '%s'\n", unit_id);
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, buf, 3+len+1);
|
||||
abis_nm_ipaccess_set_nvattr(trx, buf, 3+len+1);
|
||||
}
|
||||
if (prim_oml_ip) {
|
||||
struct in_addr ia;
|
||||
@@ -340,7 +341,7 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||
*cur++ = 0;
|
||||
printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia));
|
||||
oml_state = 1;
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, buf, 3+len);
|
||||
abis_nm_ipaccess_set_nvattr(trx, buf, 3+len);
|
||||
}
|
||||
if (nv_mask) {
|
||||
len = 4;
|
||||
@@ -354,12 +355,12 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||
*cur++ = nv_mask >> 8;
|
||||
printf("setting NV Flags/Mask to 0x%04x/0x%04x\n",
|
||||
nv_flags, nv_mask);
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, buf, 3+len);
|
||||
abis_nm_ipaccess_set_nvattr(trx, buf, 3+len);
|
||||
}
|
||||
|
||||
if (restart && !prim_oml_ip && !software) {
|
||||
printf("restarting BTS\n");
|
||||
abis_nm_ipaccess_restart(bts);
|
||||
abis_nm_ipaccess_restart(trx);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -370,7 +371,6 @@ void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
||||
case EVT_E1_TEI_UP:
|
||||
switch (type) {
|
||||
case E1INP_SIGN_OML:
|
||||
bootstrap_om(trx->bts);
|
||||
break;
|
||||
case E1INP_SIGN_RSL:
|
||||
/* FIXME */
|
||||
@@ -389,22 +389,29 @@ void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
||||
}
|
||||
|
||||
int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state)
|
||||
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state,
|
||||
struct abis_om_obj_inst *obj_inst)
|
||||
{
|
||||
if (evt == EVT_STATECHG_OPER &&
|
||||
if (obj_class == NM_OC_BASEB_TRANSC) {
|
||||
if (!found_trx && obj_inst->trx_nr != 0xff) {
|
||||
struct gsm_bts_trx *trx = container_of(obj, struct gsm_bts_trx, bb_transc);
|
||||
bootstrap_om(trx);
|
||||
found_trx = 1;
|
||||
}
|
||||
} else if (evt == EVT_STATECHG_OPER &&
|
||||
obj_class == NM_OC_RADIO_CARRIER &&
|
||||
new_state->availability == 3) {
|
||||
struct gsm_bts_trx *trx = obj;
|
||||
|
||||
if (net_listen_testnr) {
|
||||
u_int8_t phys_config[] = { 0x02, 0x0a, 0x00, 0x01, 0x02 };
|
||||
abis_nm_perform_test(trx->bts, 2, 0, 0, 0xff,
|
||||
abis_nm_perform_test(trx->bts, 2, 0, trx->nr, 0xff,
|
||||
net_listen_testnr, 1,
|
||||
phys_config, sizeof(phys_config));
|
||||
} else if (software) {
|
||||
int rc;
|
||||
printf("Attempting software upload with '%s'\n", software);
|
||||
rc = abis_nm_software_load(trx->bts, software, 19, 0, swload_cbfn, trx->bts);
|
||||
rc = abis_nm_software_load(trx->bts, trx->nr, software, 19, 0, swload_cbfn, trx);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to start software load\n");
|
||||
exit(-3);
|
||||
@@ -639,6 +646,7 @@ int main(int argc, char **argv)
|
||||
{ "software", 1, 0, 'd' },
|
||||
{ "firmware", 1, 0, 'f' },
|
||||
{ "write-firmware", 0, 0, 'w' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "u:o:rn:l:hs:d:f:w", long_options,
|
||||
@@ -724,6 +732,8 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bts->oml_link->ts->sign.delay = 10;
|
||||
bts->c0->rsl_link->ts->sign.delay = 10;
|
||||
while (1) {
|
||||
rc = bsc_select_main(0);
|
||||
if (rc < 0)
|
||||
|
||||
@@ -128,6 +128,15 @@ static int mgcp_rsip_cb(struct mgcp_config *cfg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mgcp_change_cb(struct mgcp_config *cfg, int endpoint, int state)
|
||||
{
|
||||
if (state != MGCP_ENDP_MDCX)
|
||||
return 0;
|
||||
|
||||
mgcp_send_dummy(&cfg->endpoints[endpoint]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_call_agent(struct bsc_fd *fd, unsigned int what)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
@@ -200,6 +209,7 @@ int main(int argc, char** argv)
|
||||
|
||||
/* set some callbacks */
|
||||
cfg->reset_cb = mgcp_rsip_cb;
|
||||
cfg->change_cb = mgcp_change_cb;
|
||||
|
||||
/* we need to bind a socket */
|
||||
if (rc == 0) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <endian.h>
|
||||
#include <errno.h>
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/select.h>
|
||||
|
||||
#include <openbsc/debug.h>
|
||||
@@ -73,6 +73,8 @@ enum {
|
||||
PROTO_RTCP,
|
||||
};
|
||||
|
||||
#define DUMMY_LOAD 0x23
|
||||
|
||||
|
||||
static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
|
||||
{
|
||||
@@ -84,44 +86,128 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
|
||||
return sendto(fd, buf, len, 0, (struct sockaddr *)&out, sizeof(out));
|
||||
}
|
||||
|
||||
static void patch_payload(int payload, char *data, int len)
|
||||
int mgcp_send_dummy(struct mgcp_endpoint *endp)
|
||||
{
|
||||
static char buf[] = { DUMMY_LOAD };
|
||||
|
||||
return udp_send(endp->net_end.rtp.fd, &endp->net_end.addr,
|
||||
endp->net_end.rtp_port, buf, 1);
|
||||
}
|
||||
|
||||
static void patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *state,
|
||||
int payload, struct sockaddr_in *addr, char *data, int len)
|
||||
{
|
||||
uint16_t seq;
|
||||
uint32_t timestamp;
|
||||
struct rtp_hdr *rtp_hdr;
|
||||
|
||||
if (len < sizeof(*rtp_hdr))
|
||||
return;
|
||||
|
||||
rtp_hdr = (struct rtp_hdr *) data;
|
||||
seq = ntohs(rtp_hdr->sequence);
|
||||
timestamp = ntohl(rtp_hdr->timestamp);
|
||||
|
||||
if (!state->initialized) {
|
||||
state->seq_no = seq - 1;
|
||||
state->ssrc = state->orig_ssrc = rtp_hdr->ssrc;
|
||||
state->initialized = 1;
|
||||
state->last_timestamp = timestamp;
|
||||
} else if (state->ssrc != rtp_hdr->ssrc) {
|
||||
state->ssrc = rtp_hdr->ssrc;
|
||||
state->seq_offset = (state->seq_no + 1) - seq;
|
||||
state->timestamp_offset = state->last_timestamp - timestamp;
|
||||
state->patch = endp->allow_patch;
|
||||
LOGP(DMGCP, LOGL_NOTICE,
|
||||
"The SSRC changed on 0x%x SSRC: %u offset: %d from %s:%d in %d\n",
|
||||
ENDPOINT_NUMBER(endp), state->ssrc, state->seq_offset,
|
||||
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port), endp->conn_mode);
|
||||
}
|
||||
|
||||
/* apply the offset and store it back to the packet */
|
||||
if (state->patch) {
|
||||
seq += state->seq_offset;
|
||||
rtp_hdr->sequence = htons(seq);
|
||||
rtp_hdr->ssrc = state->orig_ssrc;
|
||||
|
||||
timestamp += state->timestamp_offset;
|
||||
rtp_hdr->timestamp = htonl(timestamp);
|
||||
}
|
||||
|
||||
/* seq changed, now compare if we have lost something */
|
||||
if (state->seq_no + 1u != seq)
|
||||
state->lost_no = abs(seq - (state->seq_no + 1));
|
||||
state->seq_no = seq;
|
||||
|
||||
state->last_timestamp = timestamp;
|
||||
|
||||
if (payload < 0)
|
||||
return;
|
||||
|
||||
rtp_hdr = (struct rtp_hdr *) data;
|
||||
rtp_hdr->payload_type = payload;
|
||||
}
|
||||
|
||||
/*
|
||||
* There is data coming. We will have to figure out if it
|
||||
* came from the BTS or the MediaGateway of the MSC. On top
|
||||
* of that we need to figure out if it was RTP or RTCP.
|
||||
*
|
||||
* Currently we do not communicate with the BSC so we have
|
||||
* no idea where the BTS is listening for RTP and need to
|
||||
* do the classic routing trick. Wait for the first packet
|
||||
* from the BTS and then go ahead.
|
||||
* The below code is for dispatching. We have a dedicated port for
|
||||
* the data coming from the net and one to discover the BTS.
|
||||
*/
|
||||
static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
|
||||
static int forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf, int len)
|
||||
{
|
||||
char buf[4096];
|
||||
struct sockaddr_in addr;
|
||||
socklen_t slen = sizeof(addr);
|
||||
struct mgcp_endpoint *endp;
|
||||
struct mgcp_config *cfg;
|
||||
int rc, dest, proto;
|
||||
if (!tap->enabled)
|
||||
return 0;
|
||||
|
||||
endp = (struct mgcp_endpoint *) fd->data;
|
||||
cfg = endp->cfg;
|
||||
return sendto(fd, buf, len, 0,
|
||||
(struct sockaddr *)&tap->forward, sizeof(tap->forward));
|
||||
}
|
||||
static int send_to(struct mgcp_endpoint *endp, int dest, int is_rtp,
|
||||
struct sockaddr_in *addr, char *buf, int rc)
|
||||
{
|
||||
struct mgcp_config *cfg = endp->cfg;
|
||||
/* For loop toggle the destination and then dispatch. */
|
||||
if (cfg->audio_loop)
|
||||
dest = !dest;
|
||||
|
||||
rc = recvfrom(fd->fd, &buf, sizeof(buf), 0,
|
||||
(struct sockaddr *) &addr, &slen);
|
||||
/* Loop based on the conn_mode, maybe undoing the above */
|
||||
if (endp->conn_mode == MGCP_CONN_LOOPBACK)
|
||||
dest = !dest;
|
||||
|
||||
if (dest == DEST_NETWORK) {
|
||||
if (is_rtp) {
|
||||
patch_and_count(endp, &endp->bts_state,
|
||||
endp->net_end.payload_type,
|
||||
addr, buf, rc);
|
||||
forward_data(endp->net_end.rtp.fd,
|
||||
&endp->taps[MGCP_TAP_NET_OUT], buf, rc);
|
||||
return udp_send(endp->net_end.rtp.fd, &endp->net_end.addr,
|
||||
endp->net_end.rtp_port, buf, rc);
|
||||
} else {
|
||||
return udp_send(endp->net_end.rtcp.fd, &endp->net_end.addr,
|
||||
endp->net_end.rtcp_port, buf, rc);
|
||||
}
|
||||
} else {
|
||||
if (is_rtp) {
|
||||
patch_and_count(endp, &endp->net_state,
|
||||
endp->bts_end.payload_type,
|
||||
addr, buf, rc);
|
||||
forward_data(endp->bts_end.rtp.fd,
|
||||
&endp->taps[MGCP_TAP_BTS_OUT], buf, rc);
|
||||
return udp_send(endp->bts_end.rtp.fd, &endp->bts_end.addr,
|
||||
endp->bts_end.rtp_port, buf, rc);
|
||||
} else {
|
||||
return udp_send(endp->bts_end.rtcp.fd, &endp->bts_end.addr,
|
||||
endp->bts_end.rtcp_port, buf, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int recevice_from(struct mgcp_endpoint *endp, int fd, struct sockaddr_in *addr,
|
||||
char *buf, int bufsize)
|
||||
{
|
||||
int rc;
|
||||
socklen_t slen = sizeof(*addr);
|
||||
|
||||
rc = recvfrom(fd, buf, bufsize, 0,
|
||||
(struct sockaddr *) addr, &slen);
|
||||
if (rc < 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to receive message on: 0x%x errno: %d/%s\n",
|
||||
ENDPOINT_NUMBER(endp), errno, strerror(errno));
|
||||
@@ -129,62 +215,131 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
|
||||
}
|
||||
|
||||
/* do not forward aynthing... maybe there is a packet from the bts */
|
||||
if (endp->ci == CI_UNUSED)
|
||||
if (!endp->allocated)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Figure out where to forward it to. This code assumes that we
|
||||
* have received the Connection Modify and know who is a legitimate
|
||||
* partner. According to the spec we could attempt to forward even
|
||||
* after the Create Connection but we will not as we are not really
|
||||
* able to tell if this is legitimate.
|
||||
*/
|
||||
#warning "Slight spec violation. With connection mode recvonly we should attempt to forward."
|
||||
dest = memcmp(&addr.sin_addr, &endp->remote, sizeof(addr.sin_addr)) == 0 &&
|
||||
(endp->net_rtp == addr.sin_port || endp->net_rtcp == addr.sin_port)
|
||||
? DEST_BTS : DEST_NETWORK;
|
||||
proto = fd == &endp->local_rtp ? PROTO_RTP : PROTO_RTCP;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int rtp_data_net(struct bsc_fd *fd, unsigned int what)
|
||||
{
|
||||
char buf[4096];
|
||||
struct sockaddr_in addr;
|
||||
struct mgcp_endpoint *endp;
|
||||
int rc, proto;
|
||||
|
||||
endp = (struct mgcp_endpoint *) fd->data;
|
||||
|
||||
rc = recevice_from(endp, fd->fd, &addr, buf, sizeof(buf));
|
||||
if (rc <= 0)
|
||||
return -1;
|
||||
|
||||
if (memcmp(&addr.sin_addr, &endp->net_end.addr, sizeof(addr.sin_addr)) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR,
|
||||
"Data from wrong address %s on 0x%x\n",
|
||||
inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(endp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (endp->net_end.rtp_port != addr.sin_port &&
|
||||
endp->net_end.rtcp_port != addr.sin_port) {
|
||||
LOGP(DMGCP, LOGL_ERROR,
|
||||
"Data from wrong source port %d on 0x%x\n",
|
||||
ntohs(addr.sin_port), ENDPOINT_NUMBER(endp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* throw away the dummy message */
|
||||
if (rc == 1 && buf[0] == DUMMY_LOAD) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from network on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
proto = fd == &endp->net_end.rtp ? PROTO_RTP : PROTO_RTCP;
|
||||
endp->net_end.packets += 1;
|
||||
|
||||
forward_data(fd->fd, &endp->taps[MGCP_TAP_NET_IN], buf, rc);
|
||||
return send_to(endp, DEST_BTS, proto == PROTO_RTP, &addr, &buf[0], rc);
|
||||
}
|
||||
|
||||
static void discover_bts(struct mgcp_endpoint *endp, int proto, struct sockaddr_in *addr)
|
||||
{
|
||||
struct mgcp_config *cfg = endp->cfg;
|
||||
|
||||
if (proto == PROTO_RTP && endp->bts_end.rtp_port == 0) {
|
||||
if (!cfg->bts_ip ||
|
||||
memcmp(&addr->sin_addr,
|
||||
&cfg->bts_in, sizeof(cfg->bts_in)) == 0 ||
|
||||
memcmp(&addr->sin_addr,
|
||||
&endp->bts_end.addr, sizeof(endp->bts_end.addr)) == 0) {
|
||||
|
||||
endp->bts_end.rtp_port = addr->sin_port;
|
||||
endp->bts_end.addr = addr->sin_addr;
|
||||
|
||||
LOGP(DMGCP, LOGL_NOTICE,
|
||||
"Found BTS for endpoint: 0x%x on port: %d/%d of %s\n",
|
||||
ENDPOINT_NUMBER(endp), ntohs(endp->bts_end.rtp_port),
|
||||
ntohs(endp->bts_end.rtcp_port), inet_ntoa(addr->sin_addr));
|
||||
}
|
||||
} else if (proto == PROTO_RTCP && endp->bts_end.rtcp_port == 0) {
|
||||
if (memcmp(&endp->bts_end.addr, &addr->sin_addr,
|
||||
sizeof(endp->bts_end.addr)) == 0) {
|
||||
endp->bts_end.rtcp_port = addr->sin_port;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int rtp_data_bts(struct bsc_fd *fd, unsigned int what)
|
||||
{
|
||||
char buf[4096];
|
||||
struct sockaddr_in addr;
|
||||
struct mgcp_endpoint *endp;
|
||||
struct mgcp_config *cfg;
|
||||
int rc, proto;
|
||||
|
||||
endp = (struct mgcp_endpoint *) fd->data;
|
||||
cfg = endp->cfg;
|
||||
|
||||
rc = recevice_from(endp, fd->fd, &addr, buf, sizeof(buf));
|
||||
if (rc <= 0)
|
||||
return -1;
|
||||
|
||||
proto = fd == &endp->bts_end.rtp ? PROTO_RTP : PROTO_RTCP;
|
||||
|
||||
/* We have no idea who called us, maybe it is the BTS. */
|
||||
if (dest == DEST_NETWORK && (endp->bts_rtp == 0 || cfg->forward_ip)) {
|
||||
/* it was the BTS... */
|
||||
if (!cfg->bts_ip
|
||||
|| memcmp(&addr.sin_addr, &cfg->bts_in, sizeof(cfg->bts_in)) == 0
|
||||
|| memcmp(&addr.sin_addr, &endp->bts, sizeof(endp->bts)) == 0) {
|
||||
if (fd == &endp->local_rtp) {
|
||||
endp->bts_rtp = addr.sin_port;
|
||||
} else {
|
||||
endp->bts_rtcp = addr.sin_port;
|
||||
}
|
||||
/* it was the BTS... */
|
||||
discover_bts(endp, proto, &addr);
|
||||
|
||||
endp->bts = addr.sin_addr;
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Found BTS for endpoint: 0x%x on port: %d/%d of %s\n",
|
||||
ENDPOINT_NUMBER(endp), ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
|
||||
inet_ntoa(addr.sin_addr));
|
||||
}
|
||||
if (memcmp(&endp->bts_end.addr, &addr.sin_addr, sizeof(addr.sin_addr)) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR,
|
||||
"Data from wrong bts %s on 0x%x\n",
|
||||
inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(endp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (endp->bts_end.rtp_port != addr.sin_port &&
|
||||
endp->bts_end.rtcp_port != addr.sin_port) {
|
||||
LOGP(DMGCP, LOGL_ERROR,
|
||||
"Data from wrong bts source port %d on 0x%x\n",
|
||||
ntohs(addr.sin_port), ENDPOINT_NUMBER(endp));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* throw away the dummy message */
|
||||
if (rc == 1 && buf[0] == DUMMY_LOAD) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from bts on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* do this before the loop handling */
|
||||
if (dest == DEST_NETWORK)
|
||||
++endp->in_bts;
|
||||
else
|
||||
++endp->in_remote;
|
||||
endp->bts_end.packets += 1;
|
||||
|
||||
/* dispatch */
|
||||
if (cfg->audio_loop)
|
||||
dest = !dest;
|
||||
|
||||
if (dest == DEST_NETWORK) {
|
||||
patch_payload(endp->net_payload_type, buf, rc);
|
||||
return udp_send(fd->fd, &endp->remote,
|
||||
proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp,
|
||||
buf, rc);
|
||||
} else {
|
||||
patch_payload(endp->bts_payload_type, buf, rc);
|
||||
return udp_send(fd->fd, &endp->bts,
|
||||
proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp,
|
||||
buf, rc);
|
||||
}
|
||||
forward_data(fd->fd, &endp->taps[MGCP_TAP_BTS_IN], buf, rc);
|
||||
return send_to(endp, DEST_NETWORK, proto == PROTO_RTP, &addr, &buf[0], rc);
|
||||
}
|
||||
|
||||
static int create_bind(const char *source_addr, struct bsc_fd *fd, int port)
|
||||
@@ -205,62 +360,112 @@ static int create_bind(const char *source_addr, struct bsc_fd *fd, int port)
|
||||
inet_aton(source_addr, &addr.sin_addr);
|
||||
|
||||
if (bind(fd->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||
close(fd->fd);
|
||||
fd->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_rtp(struct mgcp_endpoint *endp)
|
||||
static int set_ip_tos(int fd, int tos)
|
||||
{
|
||||
struct mgcp_config *cfg = endp->cfg;
|
||||
int ret;
|
||||
ret = setsockopt(fd, IPPROTO_IP, IP_TOS,
|
||||
&tos, sizeof(tos));
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
if (create_bind(cfg->source_addr, &endp->local_rtp, endp->rtp_port) != 0) {
|
||||
static int bind_rtp(struct mgcp_config *cfg, struct mgcp_rtp_end *rtp_end, int endpno)
|
||||
{
|
||||
if (create_bind(cfg->source_addr, &rtp_end->rtp, rtp_end->local_port) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTP port: %s:%d on 0x%x\n",
|
||||
cfg->source_addr, endp->rtp_port, ENDPOINT_NUMBER(endp));
|
||||
cfg->source_addr, rtp_end->local_port, endpno);
|
||||
goto cleanup0;
|
||||
}
|
||||
|
||||
if (create_bind(cfg->source_addr, &endp->local_rtcp, endp->rtp_port + 1) != 0) {
|
||||
if (create_bind(cfg->source_addr, &rtp_end->rtcp, rtp_end->local_port + 1) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to create RTCP port: %s:%d on 0x%x\n",
|
||||
cfg->source_addr, endp->rtp_port + 1, ENDPOINT_NUMBER(endp));
|
||||
cfg->source_addr, rtp_end->local_port + 1, endpno);
|
||||
goto cleanup1;
|
||||
}
|
||||
|
||||
endp->local_rtp.cb = rtp_data_cb;
|
||||
endp->local_rtp.data = endp;
|
||||
endp->local_rtp.when = BSC_FD_READ;
|
||||
if (bsc_register_fd(&endp->local_rtp) != 0) {
|
||||
set_ip_tos(rtp_end->rtp.fd, cfg->endp_dscp);
|
||||
set_ip_tos(rtp_end->rtcp.fd, cfg->endp_dscp);
|
||||
|
||||
rtp_end->rtp.when = BSC_FD_READ;
|
||||
if (bsc_register_fd(&rtp_end->rtp) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to register RTP port %d on 0x%x\n",
|
||||
endp->rtp_port, ENDPOINT_NUMBER(endp));
|
||||
rtp_end->local_port, endpno);
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
endp->local_rtcp.cb = rtp_data_cb;
|
||||
endp->local_rtcp.data = endp;
|
||||
endp->local_rtcp.when = BSC_FD_READ;
|
||||
if (bsc_register_fd(&endp->local_rtcp) != 0) {
|
||||
rtp_end->rtcp.when = BSC_FD_READ;
|
||||
if (bsc_register_fd(&rtp_end->rtcp) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to register RTCP port %d on 0x%x\n",
|
||||
endp->rtp_port + 1, ENDPOINT_NUMBER(endp));
|
||||
rtp_end->local_port + 1, endpno);
|
||||
goto cleanup3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup3:
|
||||
bsc_unregister_fd(&endp->local_rtp);
|
||||
bsc_unregister_fd(&rtp_end->rtp);
|
||||
cleanup2:
|
||||
close(endp->local_rtcp.fd);
|
||||
endp->local_rtcp.fd = -1;
|
||||
close(rtp_end->rtcp.fd);
|
||||
rtp_end->rtcp.fd = -1;
|
||||
cleanup1:
|
||||
close(endp->local_rtp.fd);
|
||||
endp->local_rtp.fd = -1;
|
||||
close(rtp_end->rtp.fd);
|
||||
rtp_end->rtp.fd = -1;
|
||||
cleanup0:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mgcp_bind_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
|
||||
int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
|
||||
{
|
||||
endp->rtp_port = rtp_port;
|
||||
return bind_rtp(endp);
|
||||
if (endp->bts_end.rtp.fd != -1 || endp->bts_end.rtcp.fd != -1) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Previous bts-port was still bound on %d\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
mgcp_free_rtp_port(&endp->bts_end);
|
||||
}
|
||||
|
||||
endp->bts_end.local_port = rtp_port;
|
||||
endp->bts_end.rtp.cb = rtp_data_bts;
|
||||
endp->bts_end.rtp.data = endp;
|
||||
endp->bts_end.rtcp.data = endp;
|
||||
endp->bts_end.rtcp.cb = rtp_data_bts;
|
||||
return bind_rtp(endp->cfg, &endp->bts_end, ENDPOINT_NUMBER(endp));
|
||||
}
|
||||
|
||||
int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
|
||||
{
|
||||
if (endp->net_end.rtp.fd != -1 || endp->net_end.rtcp.fd != -1) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Previous net-port was still bound on %d\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
mgcp_free_rtp_port(&endp->net_end);
|
||||
}
|
||||
|
||||
endp->net_end.local_port = rtp_port;
|
||||
endp->net_end.rtp.cb = rtp_data_net;
|
||||
endp->net_end.rtp.data = endp;
|
||||
endp->net_end.rtcp.data = endp;
|
||||
endp->net_end.rtcp.cb = rtp_data_net;
|
||||
return bind_rtp(endp->cfg, &endp->net_end, ENDPOINT_NUMBER(endp));
|
||||
}
|
||||
|
||||
int mgcp_free_rtp_port(struct mgcp_rtp_end *end)
|
||||
{
|
||||
if (end->rtp.fd != -1) {
|
||||
close(end->rtp.fd);
|
||||
end->rtp.fd = -1;
|
||||
bsc_unregister_fd(&end->rtp);
|
||||
}
|
||||
|
||||
if (end->rtcp.fd != -1) {
|
||||
close(end->rtcp.fd);
|
||||
end->rtcp.fd = -1;
|
||||
bsc_unregister_fd(&end->rtcp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -38,13 +38,6 @@
|
||||
#include <openbsc/mgcp.h>
|
||||
#include <openbsc/mgcp_internal.h>
|
||||
|
||||
enum mgcp_connection_mode {
|
||||
MGCP_CONN_NONE = 0,
|
||||
MGCP_CONN_RECV_ONLY = 1,
|
||||
MGCP_CONN_SEND_ONLY = 2,
|
||||
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
|
||||
};
|
||||
|
||||
/**
|
||||
* Macro for tokenizing MGCP messages and SDP in one go.
|
||||
*
|
||||
@@ -79,6 +72,7 @@ enum mgcp_connection_mode {
|
||||
} \
|
||||
}
|
||||
|
||||
static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end);
|
||||
|
||||
struct mgcp_request {
|
||||
char *name;
|
||||
@@ -95,7 +89,7 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg);
|
||||
static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg);
|
||||
|
||||
static int generate_call_id(struct mgcp_config *cfg)
|
||||
static uint32_t generate_call_id(struct mgcp_config *cfg)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -135,7 +129,7 @@ static struct msgb *mgcp_msgb_alloc(void)
|
||||
struct msgb *msg;
|
||||
msg = msgb_alloc_headroom(4096, 128, "MGCP msg");
|
||||
if (!msg)
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to msgb for MGCP data.\n");
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to msgb for MGCP data.\n");
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -176,13 +170,13 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
|
||||
addr = endp->cfg->source_addr;
|
||||
|
||||
snprintf(sdp_record, sizeof(sdp_record) - 1,
|
||||
"I: %d\n\n"
|
||||
"I: %u\n\n"
|
||||
"v=0\r\n"
|
||||
"c=IN IP4 %s\r\n"
|
||||
"m=audio %d RTP/AVP %d\r\n"
|
||||
"a=rtpmap:%d %s\r\n",
|
||||
endp->ci, addr, endp->rtp_port,
|
||||
endp->bts_payload_type, endp->bts_payload_type,
|
||||
endp->ci, addr, endp->net_end.local_port,
|
||||
endp->bts_end.payload_type, endp->bts_end.payload_type,
|
||||
endp->cfg->audio_name);
|
||||
return mgcp_create_response_with_data(200, msg, trans_id, sdp_record);
|
||||
}
|
||||
@@ -330,11 +324,13 @@ static int verify_call_id(const struct mgcp_endpoint *endp,
|
||||
}
|
||||
|
||||
static int verify_ci(const struct mgcp_endpoint *endp,
|
||||
const char *ci)
|
||||
const char *_ci)
|
||||
{
|
||||
if (atoi(ci) != endp->ci) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 0x%x. %d != %s\n",
|
||||
ENDPOINT_NUMBER(endp), endp->ci, ci);
|
||||
uint32_t ci = strtoul(_ci, NULL, 10);
|
||||
|
||||
if (ci != endp->ci) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 0x%x. %u != %s\n",
|
||||
ENDPOINT_NUMBER(endp), endp->ci, _ci);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -364,6 +360,8 @@ static int parse_conn_mode(const char* msg, int *conn_mode)
|
||||
*conn_mode = MGCP_CONN_RECV_ONLY;
|
||||
else if (strcmp(msg, "sendrecv") == 0)
|
||||
*conn_mode = MGCP_CONN_RECV_SEND;
|
||||
else if (strcmp(msg, "loopback") == 0)
|
||||
*conn_mode = MGCP_CONN_LOOPBACK;
|
||||
else {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Unknown connection mode: '%s'\n", msg);
|
||||
ret = -1;
|
||||
@@ -372,6 +370,54 @@ static int parse_conn_mode(const char* msg, int *conn_mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int allocate_port(struct mgcp_endpoint *endp, struct mgcp_rtp_end *end,
|
||||
struct mgcp_port_range *range, int for_net)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (range->mode == PORT_ALLOC_STATIC) {
|
||||
end->local_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), range->base_port);
|
||||
end->local_alloc = PORT_ALLOC_STATIC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* attempt to find a port */
|
||||
for (i = 0; i < 200; ++i) {
|
||||
int rc;
|
||||
|
||||
if (range->last_port >= range->range_end)
|
||||
range->last_port = range->range_start;
|
||||
|
||||
rc = for_net ?
|
||||
mgcp_bind_net_rtp_port(endp, range->last_port) :
|
||||
mgcp_bind_bts_rtp_port(endp, range->last_port);
|
||||
|
||||
range->last_port += 2;
|
||||
if (rc == 0) {
|
||||
end->local_alloc = PORT_ALLOC_DYNAMIC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LOGP(DMGCP, LOGL_ERROR, "Allocating a RTP/RTCP port failed 200 times 0x%x net: %d\n",
|
||||
ENDPOINT_NUMBER(endp), for_net);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int allocate_ports(struct mgcp_endpoint *endp)
|
||||
{
|
||||
if (allocate_port(endp, &endp->net_end, &endp->cfg->net_ports, 1) != 0)
|
||||
return -1;
|
||||
|
||||
if (allocate_port(endp, &endp->bts_end, &endp->cfg->bts_ports, 0) != 0) {
|
||||
mgcp_rtp_end_reset(&endp->net_end);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
{
|
||||
struct mgcp_msg_ptr data_ptrs[6];
|
||||
@@ -379,16 +425,18 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *trans_id;
|
||||
struct mgcp_endpoint *endp;
|
||||
int error_code = 500;
|
||||
int port;
|
||||
|
||||
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
|
||||
if (found != 0)
|
||||
return create_response(500, "CRCX", trans_id);
|
||||
|
||||
if (endp->ci != CI_UNUSED) {
|
||||
if (endp->allocated) {
|
||||
if (cfg->force_realloc) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Endpoint 0x%x already allocated. Forcing realloc.\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
mgcp_free_endp(endp);
|
||||
if (cfg->realloc_cb)
|
||||
cfg->realloc_cb(cfg, ENDPOINT_NUMBER(endp));
|
||||
} else {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Endpoint is already used. 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
@@ -413,6 +461,8 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
error_code = 517;
|
||||
goto error2;
|
||||
}
|
||||
|
||||
endp->orig_mode = endp->conn_mode;
|
||||
break;
|
||||
default:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Unhandled option: '%c'/%d on 0x%x\n",
|
||||
@@ -423,16 +473,13 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
MSG_TOKENIZE_END
|
||||
|
||||
/* initialize */
|
||||
endp->net_rtp = endp->net_rtcp = endp->bts_rtp = endp->bts_rtcp = 0;
|
||||
endp->net_end.rtp_port = endp->net_end.rtcp_port = endp->bts_end.rtp_port = endp->bts_end.rtcp_port = 0;
|
||||
|
||||
/* set to zero until we get the info */
|
||||
memset(&endp->remote, 0, sizeof(endp->remote));
|
||||
memset(&endp->net_end.addr, 0, sizeof(endp->net_end.addr));
|
||||
|
||||
/* bind to the port now */
|
||||
port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->rtp_base_port);
|
||||
if (cfg->early_bind)
|
||||
endp->rtp_port = port;
|
||||
else if (mgcp_bind_rtp_port(endp, port) != 0)
|
||||
if (allocate_ports(endp) != 0)
|
||||
goto error2;
|
||||
|
||||
/* assign a local call identifier or fail */
|
||||
@@ -440,7 +487,8 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
if (endp->ci == CI_UNUSED)
|
||||
goto error2;
|
||||
|
||||
endp->bts_payload_type = cfg->audio_payload;
|
||||
endp->allocated = 1;
|
||||
endp->bts_end.payload_type = cfg->audio_payload;
|
||||
|
||||
/* policy CB */
|
||||
if (cfg->policy_cb) {
|
||||
@@ -461,10 +509,11 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
}
|
||||
}
|
||||
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Creating endpoint on: 0x%x CI: %u port: %u\n",
|
||||
ENDPOINT_NUMBER(endp), endp->ci, endp->rtp_port);
|
||||
LOGP(DMGCP, LOGL_DEBUG, "Creating endpoint on: 0x%x CI: %u port: %u/%u\n",
|
||||
ENDPOINT_NUMBER(endp), endp->ci,
|
||||
endp->net_end.local_port, endp->bts_end.local_port);
|
||||
if (cfg->change_cb)
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX, endp->rtp_port);
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
|
||||
|
||||
return create_response_with_sdp(endp, "CRCX", trans_id);
|
||||
error:
|
||||
@@ -474,6 +523,7 @@ error:
|
||||
return create_response(error_code, "CRCX", trans_id);
|
||||
|
||||
error2:
|
||||
mgcp_free_endp(endp);
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Resource error on 0x%x\n", ENDPOINT_NUMBER(endp));
|
||||
return create_response(error_code, "CRCX", trans_id);
|
||||
}
|
||||
@@ -485,6 +535,7 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *trans_id;
|
||||
struct mgcp_endpoint *endp;
|
||||
int error_code = 500;
|
||||
int silent = 0;
|
||||
|
||||
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
|
||||
if (found != 0)
|
||||
@@ -516,6 +567,10 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
error_code = 517;
|
||||
goto error3;
|
||||
}
|
||||
endp->orig_mode = endp->conn_mode;
|
||||
break;
|
||||
case 'Z':
|
||||
silent = strcmp("noanswer", (const char *)&msg->l3h[line_start + 3]) == 0;
|
||||
break;
|
||||
case '\0':
|
||||
/* SDP file begins */
|
||||
@@ -533,9 +588,9 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *param = (const char *)&msg->l3h[line_start];
|
||||
|
||||
if (sscanf(param, "m=audio %d RTP/AVP %d", &port, &payload) == 2) {
|
||||
endp->net_rtp = htons(port);
|
||||
endp->net_rtcp = htons(port + 1);
|
||||
endp->net_payload_type = payload;
|
||||
endp->net_end.rtp_port = htons(port);
|
||||
endp->net_end.rtcp_port = htons(port + 1);
|
||||
endp->net_end.payload_type = payload;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -544,7 +599,7 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *param = (const char *)&msg->l3h[line_start];
|
||||
|
||||
if (sscanf(param, "c=IN IP4 %15s", ipv4) == 1) {
|
||||
inet_aton(ipv4, &endp->remote);
|
||||
inet_aton(ipv4, &endp->net_end.addr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -562,6 +617,8 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
case MGCP_POLICY_REJECT:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "MDCX rejected by policy on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(500, "MDCX", trans_id);
|
||||
break;
|
||||
case MGCP_POLICY_DEFER:
|
||||
@@ -575,10 +632,13 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
}
|
||||
|
||||
/* modify */
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Modified endpoint on: 0x%x Server: %s:%u\n",
|
||||
ENDPOINT_NUMBER(endp), inet_ntoa(endp->remote), ntohs(endp->net_rtp));
|
||||
LOGP(DMGCP, LOGL_DEBUG, "Modified endpoint on: 0x%x Server: %s:%u\n",
|
||||
ENDPOINT_NUMBER(endp), inet_ntoa(endp->net_end.addr), ntohs(endp->net_end.rtp_port));
|
||||
if (cfg->change_cb)
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX, endp->rtp_port);
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX);
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
|
||||
return create_response_with_sdp(endp, "MDCX", trans_id);
|
||||
|
||||
error:
|
||||
@@ -589,6 +649,10 @@ error:
|
||||
|
||||
error3:
|
||||
return create_response(error_code, "MDCX", trans_id);
|
||||
|
||||
|
||||
out_silent:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
@@ -598,12 +662,13 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *trans_id;
|
||||
struct mgcp_endpoint *endp;
|
||||
int error_code = 500;
|
||||
int silent = 0;
|
||||
|
||||
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
|
||||
if (found != 0)
|
||||
return create_response(error_code, "DLCX", trans_id);
|
||||
|
||||
if (endp->ci == CI_UNUSED) {
|
||||
if (!endp->allocated) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Endpoint is not used. 0x%x\n", ENDPOINT_NUMBER(endp));
|
||||
return create_response(error_code, "DLCX", trans_id);
|
||||
}
|
||||
@@ -619,6 +684,9 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
if (verify_ci(endp, (const char *)&msg->l3h[line_start + 3]) != 0)
|
||||
goto error3;
|
||||
break;
|
||||
case 'Z':
|
||||
silent = strcmp("noanswer", (const char *)&msg->l3h[line_start + 3]) == 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Unhandled option: '%c'/%d on 0x%x\n",
|
||||
@@ -634,6 +702,8 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
case MGCP_POLICY_REJECT:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "DLCX rejected by policy on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(500, "DLCX", trans_id);
|
||||
break;
|
||||
case MGCP_POLICY_DEFER:
|
||||
@@ -647,10 +717,14 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
}
|
||||
|
||||
/* free the connection */
|
||||
LOGP(DMGCP, LOGL_DEBUG, "Deleted endpoint on: 0x%x Server: %s:%u\n",
|
||||
ENDPOINT_NUMBER(endp), inet_ntoa(endp->net_end.addr), ntohs(endp->net_end.rtp_port));
|
||||
mgcp_free_endp(endp);
|
||||
if (cfg->change_cb)
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX, endp->rtp_port);
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX);
|
||||
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(250, "DLCX", trans_id);
|
||||
|
||||
error:
|
||||
@@ -661,6 +735,9 @@ error:
|
||||
|
||||
error3:
|
||||
return create_response(error_code, "DLCX", trans_id);
|
||||
|
||||
out_silent:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg)
|
||||
@@ -684,11 +761,32 @@ struct mgcp_config *mgcp_config_alloc(void)
|
||||
cfg->source_addr = talloc_strdup(cfg, "0.0.0.0");
|
||||
cfg->audio_name = talloc_strdup(cfg, "GSM-EFR/8000");
|
||||
cfg->audio_payload = 97;
|
||||
cfg->rtp_base_port = RTP_PORT_DEFAULT;
|
||||
|
||||
cfg->bts_ports.base_port = RTP_PORT_DEFAULT;
|
||||
cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end)
|
||||
{
|
||||
if (end->local_alloc == PORT_ALLOC_DYNAMIC)
|
||||
mgcp_free_rtp_port(end);
|
||||
|
||||
end->packets = 0;
|
||||
memset(&end->addr, 0, sizeof(end->addr));
|
||||
end->rtp_port = end->rtcp_port = end->local_port = 0;
|
||||
end->payload_type = -1;
|
||||
end->local_alloc = -1;
|
||||
}
|
||||
|
||||
static void mgcp_rtp_end_init(struct mgcp_rtp_end *end)
|
||||
{
|
||||
mgcp_rtp_end_reset(end);
|
||||
end->rtp.fd = -1;
|
||||
end->rtcp.fd = -1;
|
||||
}
|
||||
|
||||
int mgcp_endpoints_allocate(struct mgcp_config *cfg)
|
||||
{
|
||||
int i;
|
||||
@@ -701,12 +799,10 @@ int mgcp_endpoints_allocate(struct mgcp_config *cfg)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < cfg->number_endpoints; ++i) {
|
||||
cfg->endpoints[i].local_rtp.fd = -1;
|
||||
cfg->endpoints[i].local_rtcp.fd = -1;
|
||||
cfg->endpoints[i].ci = CI_UNUSED;
|
||||
cfg->endpoints[i].cfg = cfg;
|
||||
cfg->endpoints[i].net_payload_type = -1;
|
||||
cfg->endpoints[i].bts_payload_type = -1;
|
||||
mgcp_rtp_end_init(&cfg->endpoints[i].net_end);
|
||||
mgcp_rtp_end_init(&cfg->endpoints[i].bts_end);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -715,7 +811,8 @@ int mgcp_endpoints_allocate(struct mgcp_config *cfg)
|
||||
void mgcp_free_endp(struct mgcp_endpoint *endp)
|
||||
{
|
||||
LOGP(DMGCP, LOGL_DEBUG, "Deleting endpoint on: 0x%x\n", ENDPOINT_NUMBER(endp));
|
||||
endp->ci= CI_UNUSED;
|
||||
endp->ci = CI_UNUSED;
|
||||
endp->allocated = 0;
|
||||
|
||||
if (endp->callid) {
|
||||
talloc_free(endp->callid);
|
||||
@@ -727,14 +824,14 @@ void mgcp_free_endp(struct mgcp_endpoint *endp)
|
||||
endp->local_options = NULL;
|
||||
}
|
||||
|
||||
if (!endp->cfg->early_bind) {
|
||||
bsc_unregister_fd(&endp->local_rtp);
|
||||
bsc_unregister_fd(&endp->local_rtcp);
|
||||
}
|
||||
mgcp_rtp_end_reset(&endp->bts_end);
|
||||
mgcp_rtp_end_reset(&endp->net_end);
|
||||
|
||||
endp->net_rtp = endp->net_rtcp = endp->bts_rtp = endp->bts_rtcp = 0;
|
||||
endp->net_payload_type = endp->bts_payload_type = -1;
|
||||
endp->in_bts = endp->in_remote = 0;
|
||||
memset(&endp->remote, 0, sizeof(endp->remote));
|
||||
memset(&endp->bts, 0, sizeof(endp->bts));
|
||||
memset(&endp->net_state, 0, sizeof(endp->net_state));
|
||||
memset(&endp->bts_state, 0, sizeof(endp->bts_state));
|
||||
|
||||
endp->conn_mode = endp->orig_mode = MGCP_CONN_NONE;
|
||||
endp->allow_patch = 0;
|
||||
|
||||
memset(&endp->taps, 0, sizeof(endp->taps));
|
||||
}
|
||||
|
||||
@@ -55,18 +55,26 @@ static int config_write_mgcp(struct vty *vty)
|
||||
vty_out(vty, " bts ip %s%s", g_cfg->bts_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE);
|
||||
vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE);
|
||||
vty_out(vty, " bind early %u%s", !!g_cfg->early_bind, VTY_NEWLINE);
|
||||
vty_out(vty, " rtp base %u%s", g_cfg->rtp_base_port, VTY_NEWLINE);
|
||||
|
||||
if (g_cfg->bts_ports.mode == PORT_ALLOC_STATIC)
|
||||
vty_out(vty, " rtp bts-base %u%s", g_cfg->bts_ports.base_port, VTY_NEWLINE);
|
||||
else
|
||||
vty_out(vty, " rtp bts-range %u %u%s",
|
||||
g_cfg->bts_ports.range_start, g_cfg->bts_ports.range_end, VTY_NEWLINE);
|
||||
|
||||
if (g_cfg->net_ports.mode == PORT_ALLOC_STATIC)
|
||||
vty_out(vty, " rtp net-base %u%s", g_cfg->net_ports.base_port, VTY_NEWLINE);
|
||||
else
|
||||
vty_out(vty, " rtp net-range %u %u%s",
|
||||
g_cfg->net_ports.range_start, g_cfg->net_ports.range_end, VTY_NEWLINE);
|
||||
|
||||
vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE);
|
||||
if (g_cfg->audio_payload != -1)
|
||||
vty_out(vty, " sdp audio payload number %d%s", g_cfg->audio_payload, VTY_NEWLINE);
|
||||
if (g_cfg->audio_name)
|
||||
vty_out(vty, " sdp audio payload name %s%s", g_cfg->audio_name, VTY_NEWLINE);
|
||||
vty_out(vty, " loop %u%s", !!g_cfg->audio_loop, VTY_NEWLINE);
|
||||
vty_out(vty, " number endpoints %u%s", g_cfg->number_endpoints - 1, VTY_NEWLINE);
|
||||
if (g_cfg->forward_ip)
|
||||
vty_out(vty, " forward audio ip %s%s", g_cfg->forward_ip, VTY_NEWLINE);
|
||||
if (g_cfg->forward_port != 0)
|
||||
vty_out(vty, " forward audio port %d%s", g_cfg->forward_port, VTY_NEWLINE);
|
||||
if (g_cfg->call_agent_addr)
|
||||
vty_out(vty, " call agent ip %s%s", g_cfg->call_agent_addr, VTY_NEWLINE);
|
||||
|
||||
@@ -81,11 +89,13 @@ DEFUN(show_mcgp, show_mgcp_cmd, "show mgcp",
|
||||
vty_out(vty, "MGCP is up and running with %u endpoints:%s", g_cfg->number_endpoints - 1, VTY_NEWLINE);
|
||||
for (i = 1; i < g_cfg->number_endpoints; ++i) {
|
||||
struct mgcp_endpoint *endp = &g_cfg->endpoints[i];
|
||||
vty_out(vty, " Endpoint 0x%.2x: CI: %d net: %u/%u bts: %u/%u on %s traffic received bts: %u remote: %u%s",
|
||||
vty_out(vty, " Endpoint 0x%.2x: CI: %d net: %u/%u bts: %u/%u on %s traffic received bts: %u/%u remote: %u/%u%s",
|
||||
i, endp->ci,
|
||||
ntohs(endp->net_rtp), ntohs(endp->net_rtcp),
|
||||
ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
|
||||
inet_ntoa(endp->bts), endp->in_bts, endp->in_remote,
|
||||
ntohs(endp->net_end.rtp_port), ntohs(endp->net_end.rtcp_port),
|
||||
ntohs(endp->bts_end.rtp_port), ntohs(endp->bts_end.rtcp_port),
|
||||
inet_ntoa(endp->bts_end.addr),
|
||||
endp->bts_end.packets, endp->bts_state.lost_no,
|
||||
endp->net_end.packets, endp->net_state.lost_no,
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
|
||||
@@ -103,7 +113,7 @@ DEFUN(cfg_mgcp,
|
||||
|
||||
DEFUN(cfg_mgcp_local_ip,
|
||||
cfg_mgcp_local_ip_cmd,
|
||||
"local ip IP",
|
||||
"local ip A.B.C.D",
|
||||
"Set the IP to be used in SDP records")
|
||||
{
|
||||
if (g_cfg->local_ip)
|
||||
@@ -114,7 +124,7 @@ DEFUN(cfg_mgcp_local_ip,
|
||||
|
||||
DEFUN(cfg_mgcp_bts_ip,
|
||||
cfg_mgcp_bts_ip_cmd,
|
||||
"bts ip IP",
|
||||
"bts ip A.B.C.D",
|
||||
"Set the IP of the BTS for RTP forwarding")
|
||||
{
|
||||
if (g_cfg->bts_ip)
|
||||
@@ -126,7 +136,7 @@ DEFUN(cfg_mgcp_bts_ip,
|
||||
|
||||
DEFUN(cfg_mgcp_bind_ip,
|
||||
cfg_mgcp_bind_ip_cmd,
|
||||
"bind ip IP",
|
||||
"bind ip A.B.C.D",
|
||||
"Bind the MGCP to this local addr")
|
||||
{
|
||||
if (g_cfg->source_addr)
|
||||
@@ -141,11 +151,6 @@ DEFUN(cfg_mgcp_bind_port,
|
||||
"Bind the MGCP to this port")
|
||||
{
|
||||
unsigned int port = atoi(argv[0]);
|
||||
if (port > 65534) {
|
||||
vty_out(vty, "%% wrong bind port '%s'%s", argv[0], VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
g_cfg->source_port = port;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -155,42 +160,82 @@ DEFUN(cfg_mgcp_bind_early,
|
||||
"bind early (0|1)",
|
||||
"Bind all RTP ports early")
|
||||
{
|
||||
unsigned int bind = atoi(argv[0]);
|
||||
if (bind != 0 && bind != 1) {
|
||||
vty_out(vty, "%% param must be 0 or 1.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
g_cfg->early_bind = bind == 1;
|
||||
return CMD_SUCCESS;
|
||||
vty_out(vty, "bind early is deprecated, remove it from the config.\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_rtp_base_port,
|
||||
cfg_mgcp_rtp_base_port_cmd,
|
||||
"rtp base <0-65534>",
|
||||
DEFUN(cfg_mgcp_rtp_bts_base_port,
|
||||
cfg_mgcp_rtp_bts_base_port_cmd,
|
||||
"rtp bts-base <0-65534>",
|
||||
"Base port to use")
|
||||
{
|
||||
unsigned int port = atoi(argv[0]);
|
||||
if (port > 65534) {
|
||||
vty_out(vty, "%% wrong base port '%s'%s", argv[0], VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
g_cfg->rtp_base_port = port;
|
||||
g_cfg->bts_ports.mode = PORT_ALLOC_STATIC;
|
||||
g_cfg->bts_ports.base_port = port;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_rtp_bts_range,
|
||||
cfg_mgcp_rtp_bts_range_cmd,
|
||||
"rtp bts-range <0-65534> <0-65534>",
|
||||
"Range of ports to allocate for endpoints\n"
|
||||
"Start of the range of ports\n" "End of the range of ports\n")
|
||||
{
|
||||
g_cfg->bts_ports.mode = PORT_ALLOC_DYNAMIC;
|
||||
g_cfg->bts_ports.range_start = atoi(argv[0]);
|
||||
g_cfg->bts_ports.range_end = atoi(argv[1]);
|
||||
g_cfg->bts_ports.last_port = g_cfg->bts_ports.range_start;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_rtp_net_range,
|
||||
cfg_mgcp_rtp_net_range_cmd,
|
||||
"rtp net-range <0-65534> <0-65534>",
|
||||
"Range of ports to allocate for endpoints\n"
|
||||
"Start of the range of ports\n" "End of the range of ports\n")
|
||||
{
|
||||
g_cfg->net_ports.mode = PORT_ALLOC_DYNAMIC;
|
||||
g_cfg->net_ports.range_start = atoi(argv[0]);
|
||||
g_cfg->net_ports.range_end = atoi(argv[1]);
|
||||
g_cfg->net_ports.last_port = g_cfg->net_ports.range_start;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_rtp_net_base_port,
|
||||
cfg_mgcp_rtp_net_base_port_cmd,
|
||||
"rtp net-base <0-65534>",
|
||||
"Base port to use for network port\n" "Port\n")
|
||||
{
|
||||
unsigned int port = atoi(argv[0]);
|
||||
g_cfg->net_ports.mode = PORT_ALLOC_STATIC;
|
||||
g_cfg->net_ports.base_port = port;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
ALIAS_DEPRECATED(cfg_mgcp_rtp_bts_base_port, cfg_mgcp_rtp_base_port_cmd,
|
||||
"rtp base <0-65534>", "Base port to use")
|
||||
|
||||
DEFUN(cfg_mgcp_rtp_ip_dscp,
|
||||
cfg_mgcp_rtp_ip_dscp_cmd,
|
||||
"rtp ip-dscp <0-255>",
|
||||
"Set the IP_TOS socket attribute on the RTP/RTCP sockets.\n" "The DSCP value.")
|
||||
{
|
||||
int dscp = atoi(argv[0]);
|
||||
g_cfg->endp_dscp = dscp;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
ALIAS_DEPRECATED(cfg_mgcp_rtp_ip_dscp, cfg_mgcp_rtp_ip_tos_cmd,
|
||||
"rtp ip-tos <0-255>",
|
||||
"Set the IP_TOS socket attribute on the RTP/RTCP sockets.\n" "The DSCP value.")
|
||||
|
||||
|
||||
DEFUN(cfg_mgcp_sdp_payload_number,
|
||||
cfg_mgcp_sdp_payload_number_cmd,
|
||||
"sdp audio payload number <1-255>",
|
||||
"Set the audio codec to use")
|
||||
{
|
||||
unsigned int payload = atoi(argv[0]);
|
||||
if (payload > 255) {
|
||||
vty_out(vty, "%% wrong payload number '%s'%s", argv[0], VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
g_cfg->audio_payload = payload;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -225,26 +270,6 @@ DEFUN(cfg_mgcp_number_endp,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_forward_ip,
|
||||
cfg_mgcp_forward_ip_cmd,
|
||||
"forward audio ip IP",
|
||||
"Forward packets from and to the IP. This disables most of the MGCP feature.")
|
||||
{
|
||||
if (g_cfg->forward_ip)
|
||||
talloc_free(g_cfg->forward_ip);
|
||||
g_cfg->forward_ip = talloc_strdup(g_cfg, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_forward_port,
|
||||
cfg_mgcp_forward_port_cmd,
|
||||
"forward audio port <1-15000>",
|
||||
"Forward packets from and to the port. This disables most of the MGCP feature.")
|
||||
{
|
||||
g_cfg->forward_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_mgcp_agent_addr,
|
||||
cfg_mgcp_agent_addr_cmd,
|
||||
"call agent ip IP",
|
||||
@@ -256,12 +281,88 @@ DEFUN(cfg_mgcp_agent_addr,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(loop_endp,
|
||||
loop_endp_cmd,
|
||||
"loop-endpoint NAME (0|1)",
|
||||
"Loop a given endpoint\n"
|
||||
"The name in hex of the endpoint\n" "Disable the loop\n" "Enable the loop\n")
|
||||
{
|
||||
struct mgcp_endpoint *endp;
|
||||
|
||||
int endp_no = strtoul(argv[0], NULL, 16);
|
||||
if (endp_no < 1 || endp_no >= g_cfg->number_endpoints) {
|
||||
vty_out(vty, "Loopback number %s/%d is invalid.%s",
|
||||
argv[0], endp_no, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
|
||||
endp = &g_cfg->endpoints[endp_no];
|
||||
int loop = atoi(argv[1]);
|
||||
|
||||
if (loop)
|
||||
endp->conn_mode = MGCP_CONN_LOOPBACK;
|
||||
else
|
||||
endp->conn_mode = endp->orig_mode;
|
||||
endp->allow_patch = 1;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(tap_call,
|
||||
tap_call_cmd,
|
||||
"tap-call ENDPOINT (bts-in|bts-out|net-in|net-out) A.B.C.D <0-65534>",
|
||||
"Forward data on endpoint to a different system\n"
|
||||
"The endpoint in hex\n"
|
||||
"Forward the data coming from the bts\n"
|
||||
"Forward the data coming from the bts leaving to the network\n"
|
||||
"Forward the data coming from the net\n"
|
||||
"Forward the data coming from the net leaving to the bts\n"
|
||||
"destination IP of the data\n" "destination port\n")
|
||||
{
|
||||
struct mgcp_rtp_tap *tap;
|
||||
struct mgcp_endpoint *endp;
|
||||
int port = 0;
|
||||
|
||||
int endp_no = strtoul(argv[0], NULL, 16);
|
||||
if (endp_no < 1 || endp_no >= g_cfg->number_endpoints) {
|
||||
vty_out(vty, "Endpoint number %s/%d is invalid.%s",
|
||||
argv[0], endp_no, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
endp = &g_cfg->endpoints[endp_no];
|
||||
|
||||
if (strcmp(argv[1], "bts-in") == 0) {
|
||||
port = MGCP_TAP_BTS_IN;
|
||||
} else if (strcmp(argv[1], "bts-out") == 0) {
|
||||
port = MGCP_TAP_BTS_OUT;
|
||||
} else if (strcmp(argv[1], "net-in") == 0) {
|
||||
port = MGCP_TAP_NET_IN;
|
||||
} else if (strcmp(argv[1], "net-out") == 0) {
|
||||
port = MGCP_TAP_NET_OUT;
|
||||
} else {
|
||||
vty_out(vty, "Unknown mode... tricked vty?%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
tap = &endp->taps[port];
|
||||
memset(&tap->forward, 0, sizeof(tap->forward));
|
||||
inet_aton(argv[2], &tap->forward.sin_addr);
|
||||
tap->forward.sin_port = htons(atoi(argv[3]));
|
||||
tap->enabled = 1;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int mgcp_vty_init(void)
|
||||
{
|
||||
install_element(VIEW_NODE, &show_mgcp_cmd);
|
||||
install_element(ENABLE_NODE, &loop_endp_cmd);
|
||||
install_element(ENABLE_NODE, &tap_call_cmd);
|
||||
|
||||
install_element(CONFIG_NODE, &cfg_mgcp_cmd);
|
||||
install_node(&mgcp_node, config_write_mgcp);
|
||||
|
||||
install_default(MGCP_NODE);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_bts_ip_cmd);
|
||||
@@ -269,12 +370,16 @@ int mgcp_vty_init(void)
|
||||
install_element(MGCP_NODE, &cfg_mgcp_bind_port_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_bind_early_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_base_port_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_bts_base_port_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_net_base_port_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_bts_range_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_net_range_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_name_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_loop_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_forward_ip_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_forward_port_cmd);
|
||||
install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd);
|
||||
return 0;
|
||||
}
|
||||
@@ -304,51 +409,32 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This application supports two modes.
|
||||
* 1.) a true MGCP gateway with support for AUEP, CRCX, MDCX, DLCX
|
||||
* 2.) plain forwarding of RTP packets on the endpoints.
|
||||
* both modes are mutual exclusive
|
||||
*/
|
||||
if (g_cfg->forward_ip) {
|
||||
int port = g_cfg->rtp_base_port;
|
||||
if (g_cfg->forward_port != 0)
|
||||
port = g_cfg->forward_port;
|
||||
|
||||
if (!g_cfg->early_bind) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Forwarding requires early bind.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store the forward IP and assign a ci. For early bind
|
||||
* the sockets will be created after this.
|
||||
*/
|
||||
for (i = 1; i < g_cfg->number_endpoints; ++i) {
|
||||
struct mgcp_endpoint *endp = &g_cfg->endpoints[i];
|
||||
inet_aton(g_cfg->forward_ip, &endp->remote);
|
||||
endp->ci = CI_UNUSED + 23;
|
||||
endp->net_rtp = htons(rtp_calculate_port(ENDPOINT_NUMBER(endp), port));
|
||||
endp->net_rtcp = htons(rtp_calculate_port(ENDPOINT_NUMBER(endp), port) + 1);
|
||||
}
|
||||
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Configured for Audio Forwarding.\n");
|
||||
}
|
||||
|
||||
/* early bind */
|
||||
if (g_cfg->early_bind) {
|
||||
for (i = 1; i < g_cfg->number_endpoints; ++i) {
|
||||
struct mgcp_endpoint *endp = &g_cfg->endpoints[i];
|
||||
int rtp_port;
|
||||
for (i = 1; i < g_cfg->number_endpoints; ++i) {
|
||||
struct mgcp_endpoint *endp = &g_cfg->endpoints[i];
|
||||
int rtp_port;
|
||||
|
||||
rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), g_cfg->rtp_base_port);
|
||||
if (mgcp_bind_rtp_port(endp, rtp_port) != 0) {
|
||||
if (g_cfg->bts_ports.mode == PORT_ALLOC_STATIC) {
|
||||
rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
|
||||
g_cfg->bts_ports.base_port);
|
||||
if (mgcp_bind_bts_rtp_port(endp, rtp_port) != 0) {
|
||||
LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
|
||||
return -1;
|
||||
}
|
||||
endp->bts_end.local_alloc = PORT_ALLOC_STATIC;
|
||||
}
|
||||
|
||||
if (g_cfg->net_ports.mode == PORT_ALLOC_STATIC) {
|
||||
rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
|
||||
g_cfg->net_ports.base_port);
|
||||
if (mgcp_bind_net_rtp_port(endp, rtp_port) != 0) {
|
||||
LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
|
||||
return -1;
|
||||
}
|
||||
endp->net_end.local_alloc = PORT_ALLOC_STATIC;
|
||||
}
|
||||
}
|
||||
|
||||
return !!g_cfg->forward_ip;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
97
openbsc/src/osmo_bsc_grace.c
Normal file
97
openbsc/src/osmo_bsc_grace.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openbsc/osmo_bsc_grace.h>
|
||||
#include <openbsc/osmo_bsc_rf.h>
|
||||
#include <openbsc/gsm_04_80.h>
|
||||
#include <openbsc/signal.h>
|
||||
|
||||
int bsc_grace_allow_new_connection(struct gsm_network *network)
|
||||
{
|
||||
if (!network->rf)
|
||||
return 1;
|
||||
return network->rf->policy == S_RF_ON;
|
||||
}
|
||||
|
||||
static int handle_sub(struct gsm_lchan *lchan, const char *text)
|
||||
{
|
||||
/* only send it to TCH */
|
||||
if (lchan->type != GSM_LCHAN_TCH_H && lchan->type != GSM_LCHAN_TCH_F)
|
||||
return -1;
|
||||
|
||||
/* only when active */
|
||||
if (lchan->state != LCHAN_S_ACTIVE)
|
||||
return -1;
|
||||
|
||||
gsm0480_send_ussdNotify(lchan, 0, text);
|
||||
gsm0480_send_releaseComplete(lchan);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The place to handle the grace mode. Right now we will send
|
||||
* USSD messages to the subscriber, in the future we might start
|
||||
* a timer to have different modes for the grace period.
|
||||
*/
|
||||
static int handle_grace(struct gsm_network *network)
|
||||
{
|
||||
int ts_nr, lchan_nr;
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_bts_trx *trx;
|
||||
|
||||
if (!network->ussd_grace_txt)
|
||||
return 0;
|
||||
|
||||
llist_for_each_entry(bts, &network->bts_list, list) {
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
for (ts_nr = 0; ts_nr < TRX_NR_TS; ++ts_nr) {
|
||||
struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
|
||||
for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; ++lchan_nr) {
|
||||
handle_sub(&ts->lchan[lchan_nr],
|
||||
network->ussd_grace_txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handle_rf_signal(unsigned int subsys, unsigned int signal,
|
||||
void *handler_data, void *signal_data)
|
||||
{
|
||||
struct rf_signal_data *sig;
|
||||
|
||||
if (subsys != SS_RF)
|
||||
return -1;
|
||||
|
||||
sig = signal_data;
|
||||
|
||||
if (signal == S_RF_GRACE)
|
||||
handle_grace(sig->net);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __attribute__((constructor)) void on_dso_load_grace(void)
|
||||
{
|
||||
register_signal_handler(SS_RF, handle_rf_signal, NULL);
|
||||
}
|
||||
266
openbsc/src/osmo_bsc_rf.c
Normal file
266
openbsc/src/osmo_bsc_rf.c
Normal file
@@ -0,0 +1,266 @@
|
||||
/* RF Ctl handling socket */
|
||||
|
||||
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openbsc/osmo_bsc_rf.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/signal.h>
|
||||
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/protocol/gsm_12_21.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define RF_CMD_QUERY '?'
|
||||
#define RF_CMD_OFF '0'
|
||||
#define RF_CMD_ON '1'
|
||||
#define RF_CMD_GRACE 'g'
|
||||
|
||||
static int lock_each_trx(struct gsm_network *net, int lock)
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
|
||||
llist_for_each_entry(bts, &net->bts_list, list) {
|
||||
struct gsm_bts_trx *trx;
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
gsm_trx_lock_rf(trx, lock);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a '1' when one TRX is online, otherwise send 0
|
||||
*/
|
||||
static void handle_query(struct osmo_bsc_rf_conn *conn)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct gsm_bts *bts;
|
||||
char send = RF_CMD_OFF;
|
||||
|
||||
llist_for_each_entry(bts, &conn->rf->gsm_network->bts_list, list) {
|
||||
struct gsm_bts_trx *trx;
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
if (trx->nm_state.availability == NM_AVSTATE_OK &&
|
||||
trx->nm_state.operational != NM_STATE_LOCKED) {
|
||||
send = RF_CMD_ON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = msgb_alloc(10, "RF Query");
|
||||
if (!msg) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate response msg.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
msg->l2h = msgb_put(msg, 1);
|
||||
msg->l2h[0] = send;
|
||||
|
||||
if (write_queue_enqueue(&conn->queue, msg) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue the answer.\n");
|
||||
msgb_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_signal(struct osmo_bsc_rf_conn *conn, int val)
|
||||
{
|
||||
struct rf_signal_data sig;
|
||||
sig.net = conn->rf->gsm_network;
|
||||
|
||||
conn->rf->policy = val;
|
||||
dispatch_signal(SS_RF, val, &sig);
|
||||
}
|
||||
|
||||
static int rf_read_cmd(struct bsc_fd *fd)
|
||||
{
|
||||
struct osmo_bsc_rf_conn *conn = fd->data;
|
||||
char buf[1];
|
||||
int rc;
|
||||
|
||||
rc = read(fd->fd, buf, sizeof(buf));
|
||||
if (rc != sizeof(buf)) {
|
||||
LOGP(DINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno));
|
||||
bsc_unregister_fd(fd);
|
||||
close(fd->fd);
|
||||
write_queue_clear(&conn->queue);
|
||||
talloc_free(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (buf[0]) {
|
||||
case RF_CMD_QUERY:
|
||||
handle_query(conn);
|
||||
break;
|
||||
case RF_CMD_OFF:
|
||||
lock_each_trx(conn->rf->gsm_network, 1);
|
||||
send_signal(conn, S_RF_OFF);
|
||||
break;
|
||||
case RF_CMD_ON:
|
||||
lock_each_trx(conn->rf->gsm_network, 0);
|
||||
send_signal(conn, S_RF_ON);
|
||||
break;
|
||||
case RF_CMD_GRACE:
|
||||
send_signal(conn, S_RF_GRACE);
|
||||
break;
|
||||
default:
|
||||
LOGP(DINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rf_write_cmd(struct bsc_fd *fd, struct msgb *msg)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = write(fd->fd, msg->data, msg->len);
|
||||
if (rc != msg->len) {
|
||||
LOGP(DINP, LOGL_ERROR, "Short write %d/%s\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rf_ctl_accept(struct bsc_fd *bfd, unsigned int what)
|
||||
{
|
||||
struct osmo_bsc_rf_conn *conn;
|
||||
struct osmo_bsc_rf *rf = bfd->data;
|
||||
struct sockaddr_un addr;
|
||||
socklen_t len = sizeof(addr);
|
||||
int fd;
|
||||
|
||||
fd = accept(bfd->fd, (struct sockaddr *) &addr, &len);
|
||||
if (fd < 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to accept. errno: %d/%s\n",
|
||||
errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
conn = talloc_zero(rf, struct osmo_bsc_rf_conn);
|
||||
if (!conn) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate mem.\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
write_queue_init(&conn->queue, 10);
|
||||
conn->queue.bfd.data = conn;
|
||||
conn->queue.bfd.fd = fd;
|
||||
conn->queue.bfd.when = BSC_FD_READ | BSC_FD_WRITE;
|
||||
conn->queue.read_cb = rf_read_cmd;
|
||||
conn->queue.write_cb = rf_write_cmd;
|
||||
conn->rf = rf;
|
||||
|
||||
if (bsc_register_fd(&conn->queue.bfd) != 0) {
|
||||
close(fd);
|
||||
talloc_free(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net)
|
||||
{
|
||||
unsigned int namelen;
|
||||
struct sockaddr_un local;
|
||||
struct bsc_fd *bfd;
|
||||
struct osmo_bsc_rf *rf;
|
||||
int rc;
|
||||
|
||||
rf = talloc_zero(NULL, struct osmo_bsc_rf);
|
||||
if (!rf) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to create osmo_bsc_rf.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd = &rf->listen;
|
||||
bfd->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (bfd->fd < 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Can not create socket. %d/%s\n",
|
||||
errno, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
local.sun_family = AF_UNIX;
|
||||
strncpy(local.sun_path, path, sizeof(local.sun_path));
|
||||
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
|
||||
unlink(local.sun_path);
|
||||
|
||||
/* we use the same magic that X11 uses in Xtranssock.c for
|
||||
* calculating the proper length of the sockaddr */
|
||||
#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
|
||||
local.sun_len = strlen(local.sun_path);
|
||||
#endif
|
||||
#if defined(BSD44SOCKETS) || defined(SUN_LEN)
|
||||
namelen = SUN_LEN(&local);
|
||||
#else
|
||||
namelen = strlen(local.sun_path) +
|
||||
offsetof(struct sockaddr_un, sun_path);
|
||||
#endif
|
||||
|
||||
rc = bind(bfd->fd, (struct sockaddr *) &local, namelen);
|
||||
if (rc != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to bind '%s' errno: %d/%s\n",
|
||||
local.sun_path, errno, strerror(errno));
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (listen(bfd->fd, 0) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to listen: %d/%s\n", errno, strerror(errno));
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd->when = BSC_FD_READ;
|
||||
bfd->cb = rf_ctl_accept;
|
||||
bfd->data = rf;
|
||||
|
||||
if (bsc_register_fd(bfd) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to register bfd.\n");
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rf->gsm_network = net;
|
||||
rf->policy = S_RF_ON;
|
||||
|
||||
return rf;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
|
||||
void *tall_paging_ctx;
|
||||
|
||||
#define PAGING_TIMER 0, 500000
|
||||
|
||||
static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber *subscr)
|
||||
{
|
||||
int ccch_conf;
|
||||
@@ -96,6 +98,72 @@ static void page_ms(struct gsm_paging_request *request)
|
||||
request->chan_type);
|
||||
}
|
||||
|
||||
static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
|
||||
{
|
||||
if (llist_empty(&paging_bts->pending_requests))
|
||||
return;
|
||||
|
||||
if (!bsc_timer_pending(&paging_bts->work_timer))
|
||||
bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
|
||||
}
|
||||
|
||||
|
||||
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts);
|
||||
static void paging_give_credit(void *data)
|
||||
{
|
||||
struct gsm_bts_paging_state *paging_bts = data;
|
||||
|
||||
LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n", paging_bts->bts->nr);
|
||||
paging_bts->available_slots = 20;
|
||||
paging_handle_pending_requests(paging_bts);
|
||||
}
|
||||
|
||||
static int can_send_pag_req(struct gsm_bts *bts, int rsl_type)
|
||||
{
|
||||
struct pchan_load pl;
|
||||
int count;
|
||||
|
||||
memset(&pl, 0, sizeof(pl));
|
||||
bts_chan_load(&pl, bts);
|
||||
|
||||
switch (rsl_type) {
|
||||
case RSL_CHANNEED_TCH_F:
|
||||
case RSL_CHANNEED_TCH_ForH:
|
||||
goto count_tch;
|
||||
break;
|
||||
case RSL_CHANNEED_SDCCH:
|
||||
goto count_sdcch;
|
||||
break;
|
||||
case RSL_CHANNEED_ANY:
|
||||
default:
|
||||
if (bts->network->pag_any_tch)
|
||||
goto count_tch;
|
||||
else
|
||||
goto count_sdcch;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
/* could available SDCCH */
|
||||
count_sdcch:
|
||||
count = 0;
|
||||
count += pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].total
|
||||
- pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].used;
|
||||
count += pl.pchan[GSM_PCHAN_CCCH_SDCCH4].total
|
||||
- pl.pchan[GSM_PCHAN_CCCH_SDCCH4].used;
|
||||
return bts->paging.free_chans_need > count;
|
||||
|
||||
count_tch:
|
||||
count = 0;
|
||||
count += pl.pchan[GSM_PCHAN_TCH_F].total
|
||||
- pl.pchan[GSM_PCHAN_TCH_F].used;
|
||||
if (bts->network->neci)
|
||||
count += pl.pchan[GSM_PCHAN_TCH_H].total
|
||||
- pl.pchan[GSM_PCHAN_TCH_H].used;
|
||||
return bts->paging.free_chans_need > count;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is kicked by the periodic PAGING LOAD Indicator
|
||||
* coming from abis_rsl.c
|
||||
@@ -105,8 +173,7 @@ static void page_ms(struct gsm_paging_request *request)
|
||||
*/
|
||||
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts)
|
||||
{
|
||||
struct gsm_paging_request *initial_request = NULL;
|
||||
struct gsm_paging_request *current_request = NULL;
|
||||
struct gsm_paging_request *request = NULL;
|
||||
|
||||
/*
|
||||
* Determine if the pending_requests list is empty and
|
||||
@@ -118,39 +185,37 @@ static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_b
|
||||
}
|
||||
|
||||
/*
|
||||
* In case the BTS does not provide us with load indication just fill
|
||||
* up our slots for this round. We should be able to page 20 subscribers
|
||||
* every two seconds. So we will just give the BTS some extra credit.
|
||||
* We will have to see how often we run out of this credit, so we might
|
||||
* need a low watermark and then add credit or give 20 every run when
|
||||
* the bts sets an option for that.
|
||||
* In case the BTS does not provide us with load indication and we
|
||||
* ran out of slots, call an autofill routine. It might be that the
|
||||
* BTS did not like our paging messages and then we have counted down
|
||||
* to zero and we do not get any messages.
|
||||
*/
|
||||
if (paging_bts->available_slots == 0) {
|
||||
LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n",
|
||||
paging_bts->bts->nr);
|
||||
paging_bts->available_slots = 20;
|
||||
paging_bts->credit_timer.cb = paging_give_credit;
|
||||
paging_bts->credit_timer.data = paging_bts;
|
||||
bsc_schedule_timer(&paging_bts->credit_timer, 5, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
initial_request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
current_request = initial_request;
|
||||
request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
|
||||
do {
|
||||
/* handle the paging request now */
|
||||
page_ms(current_request);
|
||||
paging_bts->available_slots--;
|
||||
/* we need to determine the number of free channels */
|
||||
if (paging_bts->free_chans_need != -1) {
|
||||
if (can_send_pag_req(request->bts, request->chan_type) != 0)
|
||||
goto skip_paging;
|
||||
}
|
||||
|
||||
/* take the current and add it to the back */
|
||||
llist_del(¤t_request->entry);
|
||||
llist_add_tail(¤t_request->entry, &paging_bts->pending_requests);
|
||||
/* handle the paging request now */
|
||||
page_ms(request);
|
||||
paging_bts->available_slots--;
|
||||
|
||||
/* take the next request */
|
||||
current_request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
} while (paging_bts->available_slots > 0
|
||||
&& initial_request != current_request);
|
||||
/* take the current and add it to the back */
|
||||
llist_del(&request->entry);
|
||||
llist_add_tail(&request->entry, &paging_bts->pending_requests);
|
||||
|
||||
bsc_schedule_timer(&paging_bts->work_timer, 2, 0);
|
||||
skip_paging:
|
||||
bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
|
||||
}
|
||||
|
||||
static void paging_worker(void *data)
|
||||
@@ -233,9 +298,7 @@ static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
||||
req->T3113.data = req;
|
||||
bsc_schedule_timer(&req->T3113, bts->network->T3113, 0);
|
||||
llist_add_tail(&req->entry, &bts_entry->pending_requests);
|
||||
|
||||
if (!bsc_timer_pending(&bts_entry->work_timer))
|
||||
bsc_schedule_timer(&bts_entry->work_timer, 2, 0);
|
||||
paging_schedule_if_needed(bts_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -318,12 +381,26 @@ void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
|
||||
break;
|
||||
|
||||
/* Stop paging */
|
||||
if (bts != _bts)
|
||||
if (bts != _bts)
|
||||
_paging_request_stop(bts, subscr, NULL);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void paging_update_buffer_space(struct gsm_bts *bts, u_int16_t free_slots)
|
||||
{
|
||||
bsc_del_timer(&bts->paging.credit_timer);
|
||||
bts->paging.available_slots = free_slots;
|
||||
paging_schedule_if_needed(&bts->paging);
|
||||
}
|
||||
|
||||
unsigned int paging_pending_requests_nr(struct gsm_bts *bts)
|
||||
{
|
||||
unsigned int requests = 0;
|
||||
|
||||
struct gsm_paging_request *req;
|
||||
|
||||
llist_for_each_entry(req, &bts->paging.pending_requests, entry)
|
||||
++requests;
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
@@ -316,8 +316,16 @@ static int append_gprs_cell_opt(struct bitvec *bv,
|
||||
bitvec_set_bit(bv, 1);
|
||||
bitvec_set_uint(bv, gco->bs_cv_max, 4);
|
||||
|
||||
/* hard-code no PAN_{DEC,INC,MAX} */
|
||||
bitvec_set_bit(bv, 0);
|
||||
if (0) {
|
||||
/* hard-code no PAN_{DEC,INC,MAX} */
|
||||
bitvec_set_bit(bv, 0);
|
||||
} else {
|
||||
/* copied from ip.access BSC protocol trace */
|
||||
bitvec_set_bit(bv, 1);
|
||||
bitvec_set_uint(bv, 1, 3); /* DEC */
|
||||
bitvec_set_uint(bv, 1, 3); /* INC */
|
||||
bitvec_set_uint(bv, 15, 3); /* MAX */
|
||||
}
|
||||
|
||||
if (!gco->ext_info_present) {
|
||||
/* no extension information */
|
||||
|
||||
@@ -91,6 +91,9 @@ struct rtp_x_hdr {
|
||||
|
||||
#define RTP_VERSION 2
|
||||
|
||||
#define RTP_PT_GSM_FULL 3
|
||||
#define RTP_PT_GSM_EFR 97
|
||||
|
||||
/* decode an rtp frame and create a new buffer with payload */
|
||||
static int rtp_decode(struct msgb *msg, u_int32_t callref, struct msgb **data)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,7 @@ int gsm_silent_call_stop(struct gsm_subscriber *subscr)
|
||||
if (!conn->silent_call)
|
||||
return -EINVAL;
|
||||
|
||||
put_subscr_con(conn);
|
||||
put_subscr_con(conn, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -397,17 +397,17 @@ static int generate_si6(u_int8_t *output, struct gsm_bts *bts)
|
||||
|
||||
static struct gsm48_si13_info si13_default = {
|
||||
.cell_opts = {
|
||||
.nmo = GPRS_NMO_III,
|
||||
.t3168 = 1500,
|
||||
.t3192 = 500,
|
||||
.nmo = GPRS_NMO_II,
|
||||
.t3168 = 2000,
|
||||
.t3192 = 200,
|
||||
.drx_timer_max = 3,
|
||||
.bs_cv_max = 15,
|
||||
.ext_info_present = 0,
|
||||
.ext_info_present = 1,
|
||||
.ext_info = {
|
||||
/* The values below are just guesses ! */
|
||||
.egprs_supported = 0,
|
||||
.use_egprs_p_ch_req = 1,
|
||||
.bep_period = 4,
|
||||
.bep_period = 5,
|
||||
.pfc_supported = 0,
|
||||
.dtm_supported = 0,
|
||||
.bss_paging_coordination = 0,
|
||||
@@ -415,10 +415,10 @@ static struct gsm48_si13_info si13_default = {
|
||||
},
|
||||
.pwr_ctrl_pars = {
|
||||
.alpha = 10, /* a = 1.0 */
|
||||
.t_avg_w = 25,
|
||||
.t_avg_t = 25,
|
||||
.t_avg_w = 16,
|
||||
.t_avg_t = 16,
|
||||
.pc_meas_chan = 0, /* downling measured on CCCH */
|
||||
.n_avg_i = 15,
|
||||
.n_avg_i = 8,
|
||||
},
|
||||
.bcch_change_mark = 1,
|
||||
.si_change_field = 0,
|
||||
@@ -451,7 +451,8 @@ static int generate_si13(u_int8_t *output, struct gsm_bts *bts)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
si13->header.l2_plen = ret & 0xff;
|
||||
/* length is coded in bit 2 an up */
|
||||
si13->header.l2_plen = 0x01;
|
||||
|
||||
return sizeof (*si13) + ret;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openbsc/gsm_04_08.h>
|
||||
#include <openbsc/mncc.h>
|
||||
#include <openbsc/paging.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
|
||||
void *tall_trans_ctx;
|
||||
|
||||
@@ -95,14 +96,14 @@ void trans_free(struct gsm_trans *trans)
|
||||
break;
|
||||
}
|
||||
|
||||
if (trans->conn)
|
||||
put_subscr_con(trans->conn);
|
||||
|
||||
if (!trans->conn && trans->subscr && trans->subscr->net) {
|
||||
/* Stop paging on all bts' */
|
||||
paging_request_stop(NULL, trans->subscr, NULL);
|
||||
}
|
||||
|
||||
if (trans->conn)
|
||||
put_subscr_con(trans->conn, 0);
|
||||
|
||||
if (trans->subscr)
|
||||
subscr_put(trans->subscr);
|
||||
|
||||
@@ -159,7 +160,7 @@ int trans_lchan_change(struct gsm_subscriber_connection *conn_old,
|
||||
if (trans->conn == conn_old) {
|
||||
|
||||
/* drop old channel use count */
|
||||
put_subscr_con(conn_old);
|
||||
put_subscr_con(conn_old, 0);
|
||||
/* assign new channel */
|
||||
trans->conn = conn_new;
|
||||
/* bump new channel use count */
|
||||
|
||||
@@ -65,11 +65,11 @@ struct buffer_data {
|
||||
#define BUFFER_DATA_FREE(D) talloc_free((D))
|
||||
|
||||
/* Make new buffer. */
|
||||
struct buffer *buffer_new(size_t size)
|
||||
struct buffer *buffer_new(void *ctx, size_t size)
|
||||
{
|
||||
struct buffer *b;
|
||||
|
||||
b = talloc_zero(tall_vty_ctx, struct buffer);
|
||||
b = talloc_zero(ctx, struct buffer);
|
||||
|
||||
if (size)
|
||||
b->size = size;
|
||||
@@ -138,7 +138,7 @@ static struct buffer_data *buffer_add(struct buffer *b)
|
||||
{
|
||||
struct buffer_data *d;
|
||||
|
||||
d = _talloc_zero(tall_vty_ctx,
|
||||
d = _talloc_zero(b,
|
||||
offsetof(struct buffer_data, data[b->size]),
|
||||
"buffer_add");
|
||||
if (!d)
|
||||
|
||||
@@ -1949,6 +1949,11 @@ enum node_type vty_go_parent(struct vty *vty)
|
||||
subscr_put(vty->index);
|
||||
vty->index = NULL;
|
||||
break;
|
||||
case OML_NODE:
|
||||
vty->node = ENABLE_NODE;
|
||||
talloc_free(vty->index);
|
||||
vty->index = NULL;
|
||||
break;
|
||||
default:
|
||||
vty->node = CONFIG_NODE;
|
||||
}
|
||||
@@ -2365,6 +2370,12 @@ DEFUN(config_exit,
|
||||
case MGCP_NODE:
|
||||
vty->node = CONFIG_NODE;
|
||||
vty->index = NULL;
|
||||
break;
|
||||
case OML_NODE:
|
||||
vty->node = ENABLE_NODE;
|
||||
talloc_free(vty->index);
|
||||
vty->index = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ struct vty *vty_new()
|
||||
if (!new)
|
||||
goto out;
|
||||
|
||||
new->obuf = buffer_new(0); /* Use default buffer size. */
|
||||
new->obuf = buffer_new(new, 0); /* Use default buffer size. */
|
||||
if (!new->obuf)
|
||||
goto out_new;
|
||||
new->buf = _talloc_zero(tall_vty_ctx, VTY_BUFSIZ, "vty_new->buf");
|
||||
new->buf = _talloc_zero(new, VTY_BUFSIZ, "vty_new->buf");
|
||||
if (!new->buf)
|
||||
goto out_obuf;
|
||||
|
||||
@@ -170,8 +170,7 @@ void vty_close(struct vty *vty)
|
||||
/* Check configure. */
|
||||
vty_config_unlock(vty);
|
||||
|
||||
/* FIXME: memory leak. We need to call telnet_close_client() but don't
|
||||
* have bfd */
|
||||
/* VTY_CLOSED is handled by the telnet_interface */
|
||||
vty_event(VTY_CLOSED, vty->fd, vty);
|
||||
|
||||
/* OK free vty. */
|
||||
@@ -211,7 +210,7 @@ int vty_out(struct vty *vty, const char *format, ...)
|
||||
else
|
||||
size = size * 2;
|
||||
|
||||
p = talloc_realloc_size(tall_vty_ctx, p, size);
|
||||
p = talloc_realloc_size(vty, p, size);
|
||||
if (!p)
|
||||
return -1;
|
||||
|
||||
@@ -358,7 +357,7 @@ static void vty_ensure(struct vty *vty, int length)
|
||||
{
|
||||
if (vty->max <= length) {
|
||||
vty->max *= 2;
|
||||
vty->buf = talloc_realloc_size(tall_vty_ctx, vty->buf, vty->max);
|
||||
vty->buf = talloc_realloc_size(vty, vty->buf, vty->max);
|
||||
// FIXME: check return
|
||||
}
|
||||
}
|
||||
@@ -459,7 +458,7 @@ static void vty_hist_add(struct vty *vty)
|
||||
/* Insert history entry. */
|
||||
if (vty->hist[vty->hindex])
|
||||
talloc_free(vty->hist[vty->hindex]);
|
||||
vty->hist[vty->hindex] = talloc_strdup(tall_vty_ctx, vty->buf);
|
||||
vty->hist[vty->hindex] = talloc_strdup(vty, vty->buf);
|
||||
|
||||
/* History index rotation. */
|
||||
vty->hindex++;
|
||||
@@ -916,7 +915,7 @@ static void vty_complete_command(struct vty *vty)
|
||||
vty_backward_pure_word(vty);
|
||||
vty_insert_word_overwrite(vty, matched[0]);
|
||||
vty_self_insert(vty, ' ');
|
||||
//talloc_free(matched[0]);
|
||||
talloc_free(matched[0]);
|
||||
break;
|
||||
case CMD_COMPLETE_MATCH:
|
||||
vty_prompt(vty);
|
||||
@@ -924,8 +923,6 @@ static void vty_complete_command(struct vty *vty)
|
||||
vty_backward_pure_word(vty);
|
||||
vty_insert_word_overwrite(vty, matched[0]);
|
||||
talloc_free(matched[0]);
|
||||
vector_only_index_free(matched);
|
||||
return;
|
||||
break;
|
||||
case CMD_COMPLETE_LIST_MATCH:
|
||||
for (i = 0; matched[i] != NULL; i++) {
|
||||
@@ -966,7 +963,7 @@ vty_describe_fold(struct vty *vty, int cmd_width,
|
||||
return;
|
||||
}
|
||||
|
||||
buf = _talloc_zero(tall_vty_ctx, strlen(desc->str) + 1, "describe_fold");
|
||||
buf = _talloc_zero(vty, strlen(desc->str) + 1, "describe_fold");
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* OpenBSC interface to quagga VTY */
|
||||
/* ipenBSC interface to quagga VTY */
|
||||
/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <vty/vty.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <osmocore/linuxlist.h>
|
||||
#include <openbsc/gsm_data.h>
|
||||
@@ -39,9 +40,37 @@
|
||||
#include <osmocore/talloc.h>
|
||||
#include <openbsc/telnet_interface.h>
|
||||
#include <openbsc/vty.h>
|
||||
#include <openbsc/ipaccess.h>
|
||||
#include <openbsc/paging.h>
|
||||
|
||||
static struct gsm_network *gsmnet;
|
||||
|
||||
static struct value_string gprs_ns_timer_strs[] = {
|
||||
{ 0, "tns-block" },
|
||||
{ 1, "tns-block-retries" },
|
||||
{ 2, "tns-reset" },
|
||||
{ 3, "tns-reset-retries" },
|
||||
{ 4, "tns-test" },
|
||||
{ 5, "tns-alive" },
|
||||
{ 6, "tns-alive-retries" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static struct value_string gprs_bssgp_cfg_strs[] = {
|
||||
{ 0, "blocking-timer" },
|
||||
{ 1, "blocking-retries" },
|
||||
{ 2, "unblocking-retries" },
|
||||
{ 3, "reset-timer" },
|
||||
{ 4, "reset-retries" },
|
||||
{ 5, "suspend-timer" },
|
||||
{ 6, "suspend-retries" },
|
||||
{ 7, "resume-timer" },
|
||||
{ 8, "resume-retries" },
|
||||
{ 9, "capability-update-timer" },
|
||||
{ 10, "capability-update-retries" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
struct cmd_node net_node = {
|
||||
GSMNET_NODE,
|
||||
"%s(network)#",
|
||||
@@ -100,6 +129,7 @@ static void dump_pchan_load_vty(struct vty *vty, char *prefix,
|
||||
|
||||
static void net_dump_vty(struct vty *vty, struct gsm_network *net)
|
||||
{
|
||||
int i;
|
||||
struct pchan_load pl;
|
||||
|
||||
vty_out(vty, "BSC is on Country Code %u, Network Code %u "
|
||||
@@ -117,6 +147,8 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net)
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
|
||||
@@ -126,6 +158,12 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net)
|
||||
network_chan_load(&pl, net);
|
||||
vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
|
||||
dump_pchan_load_vty(vty, " ", &pl);
|
||||
|
||||
vty_out(vty, " Allowed Audio Codecs: ");
|
||||
for (i = 0; i < net->audio_length; ++i)
|
||||
vty_out(vty, "hr: %d ver: %d, ",
|
||||
net->audio_support[i]->hr, net->audio_support[i]->ver);
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
DEFUN(show_net, show_net_cmd, "show network",
|
||||
@@ -186,7 +224,8 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
|
||||
net_dump_nmstate(vty, &bts->nm_state);
|
||||
vty_out(vty, " Site Mgr NM State: ");
|
||||
net_dump_nmstate(vty, &bts->site_mgr.nm_state);
|
||||
vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
|
||||
vty_out(vty, " Paging: %u pending requests, %u free slots%s",
|
||||
paging_pending_requests_nr(bts),
|
||||
bts->paging.available_slots, VTY_NEWLINE);
|
||||
if (!is_ipaccess_bts(bts)) {
|
||||
vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
|
||||
@@ -224,6 +263,36 @@ DEFUN(show_bts, show_bts_cmd, "show bts [number]",
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(test_bts_lchan_alloc, test_bts_lchan_alloc_cmd, "test bts alloc (sdcch|tch_h|tch_f)",
|
||||
"Test command to allocate all channels. You will need to restart. To free these channels.\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
int bts_nr;
|
||||
|
||||
enum gsm_chan_t type = GSM_LCHAN_NONE;
|
||||
|
||||
if (strcmp("sdcch", argv[0]) == 0)
|
||||
type = GSM_LCHAN_SDCCH;
|
||||
else if (strcmp("tch_h", argv[0]) == 0)
|
||||
type = GSM_LCHAN_TCH_H;
|
||||
else if (strcmp("tch_f", argv[0]) == 0)
|
||||
type = GSM_LCHAN_TCH_F;
|
||||
else {
|
||||
vty_out(vty, "Unknown mode for allocation.%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
for (bts_nr = 0; bts_nr < net->num_bts; ++bts_nr) {
|
||||
struct gsm_bts *bts = gsm_bts_num(net, bts_nr);
|
||||
struct gsm_lchan *lchan;
|
||||
|
||||
/* alloc the channel */
|
||||
while ((lchan = lchan_alloc(bts, type, 0)) != NULL)
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* utility functions */
|
||||
static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
|
||||
const char *ts, const char *ss)
|
||||
@@ -279,10 +348,48 @@ static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
|
||||
config_write_ts_single(vty, &trx->ts[i]);
|
||||
}
|
||||
|
||||
static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
|
||||
{
|
||||
unsigned int i;
|
||||
vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
|
||||
VTY_NEWLINE);
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
return;
|
||||
|
||||
vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
|
||||
VTY_NEWLINE);
|
||||
for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
|
||||
vty_out(vty, " gprs cell timer %s %u%s",
|
||||
get_value_string(gprs_bssgp_cfg_strs, i),
|
||||
bts->gprs.cell.timer[i], VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
|
||||
VTY_NEWLINE);
|
||||
for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
|
||||
vty_out(vty, " gprs ns timer %s %u%s",
|
||||
get_value_string(gprs_ns_timer_strs, i),
|
||||
bts->gprs.nse.timer[i], VTY_NEWLINE);
|
||||
for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
|
||||
struct gsm_bts_gprs_nsvc *nsvc =
|
||||
&bts->gprs.nsvc[i];
|
||||
struct in_addr ia;
|
||||
|
||||
ia.s_addr = htonl(nsvc->remote_ip);
|
||||
vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
|
||||
nsvc->nsvci, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
|
||||
nsvc->local_port, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
|
||||
nsvc->remote_port, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
|
||||
inet_ntoa(ia), VTY_NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
|
||||
{
|
||||
struct gsm_bts_trx *trx;
|
||||
int i;
|
||||
|
||||
vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
|
||||
vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
|
||||
@@ -308,8 +415,17 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
|
||||
vty_out(vty, " rach max transmission %u%s",
|
||||
rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
|
||||
VTY_NEWLINE);
|
||||
|
||||
if (bts->rach_b_thresh != -1)
|
||||
vty_out(vty, " rach nm busy threshold %u%s",
|
||||
bts->rach_b_thresh, VTY_NEWLINE);
|
||||
if (bts->rach_ldavg_slots != -1)
|
||||
vty_out(vty, " rach nm load average %u%s",
|
||||
bts->rach_ldavg_slots, VTY_NEWLINE);
|
||||
if (bts->si_common.rach_control.cell_bar)
|
||||
vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
|
||||
if ((bts->si_common.rach_control.t2 & 0x4) == 0)
|
||||
vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
|
||||
if (is_ipaccess_bts(bts)) {
|
||||
vty_out(vty, " ip.access unit_id %u %u%s",
|
||||
bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
|
||||
@@ -318,31 +434,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
|
||||
config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
|
||||
vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
|
||||
}
|
||||
vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
|
||||
VTY_NEWLINE);
|
||||
if (bts->gprs.mode != BTS_GPRS_NONE) {
|
||||
vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
|
||||
VTY_NEWLINE);
|
||||
for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
|
||||
struct gsm_bts_gprs_nsvc *nsvc =
|
||||
&bts->gprs.nsvc[i];
|
||||
struct in_addr ia;
|
||||
|
||||
ia.s_addr = htonl(nsvc->remote_ip);
|
||||
vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
|
||||
nsvc->nsvci, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
|
||||
nsvc->local_port, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
|
||||
nsvc->remote_port, VTY_NEWLINE);
|
||||
vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
|
||||
inet_ntoa(ia), VTY_NEWLINE);
|
||||
}
|
||||
}
|
||||
config_write_bts_gprs(vty, bts);
|
||||
|
||||
/* if we have a limit, write it */
|
||||
if (bts->paging.free_chans_need >= 0)
|
||||
vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
|
||||
|
||||
|
||||
llist_for_each_entry(trx, &bts->trx_list, list)
|
||||
config_write_trx_single(vty, trx);
|
||||
@@ -362,7 +460,11 @@ static int config_write_net(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, "network%s", VTY_NEWLINE);
|
||||
vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
|
||||
if (gsmnet->core_country_code > 0)
|
||||
vty_out(vty, " core network country code %u%s", gsmnet->core_country_code, VTY_NEWLINE);
|
||||
vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
|
||||
if (gsmnet->core_network_code > 0)
|
||||
vty_out(vty, " core mobile network code %u%s", gsmnet->core_network_code, VTY_NEWLINE);
|
||||
vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
|
||||
vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
|
||||
vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
|
||||
@@ -370,6 +472,7 @@ static int config_write_net(struct vty *vty)
|
||||
gsmnet->reject_cause, VTY_NEWLINE);
|
||||
vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
|
||||
vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
|
||||
vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
|
||||
vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
|
||||
@@ -397,6 +500,39 @@ static int config_write_net(struct vty *vty)
|
||||
vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
|
||||
vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
|
||||
vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
|
||||
vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
|
||||
vty_out(vty, " ipacc rtp_payload %u%s", gsmnet->rtp_payload, VTY_NEWLINE);
|
||||
vty_out(vty, " rtp base %u%s", gsmnet->rtp_base_port, VTY_NEWLINE);
|
||||
|
||||
if (gsmnet->audio_length != 0) {
|
||||
int i;
|
||||
|
||||
vty_out(vty, " codec_list ");
|
||||
for (i = 0; i < gsmnet->audio_length; ++i) {
|
||||
printf("I... %d %d\n", i, gsmnet->audio_length);
|
||||
if (i != 0)
|
||||
vty_out(vty, ", ");
|
||||
|
||||
if (gsmnet->audio_support[i]->hr)
|
||||
vty_out(vty, "hr%.1u", gsmnet->audio_support[i]->ver);
|
||||
else
|
||||
vty_out(vty, "fr%.1u", gsmnet->audio_support[i]->ver);
|
||||
}
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
if (gsmnet->bsc_token)
|
||||
vty_out(vty, " bsc_token %s%s", gsmnet->bsc_token, VTY_NEWLINE);
|
||||
vty_out(vty, " msc ip %s%s", gsmnet->msc_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " msc port %d%s", gsmnet->msc_port, VTY_NEWLINE);
|
||||
vty_out(vty, " msc ip-dscp %d%s", gsmnet->msc_ip_dscp, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout ping %d%s", gsmnet->ping_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout pong %d%s", gsmnet->pong_timeout, VTY_NEWLINE);
|
||||
if (gsmnet->ussd_grace_txt)
|
||||
vty_out(vty, " bsc-grace-text %s%s", gsmnet->ussd_grace_txt, VTY_NEWLINE);
|
||||
if (gsmnet->ussd_welcome_txt)
|
||||
vty_out(vty, " bsc-welcome-text %s%s", gsmnet->ussd_welcome_txt, VTY_NEWLINE);
|
||||
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -594,7 +730,7 @@ static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
|
||||
meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
|
||||
}
|
||||
|
||||
static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
|
||||
static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
|
||||
{
|
||||
int idx;
|
||||
|
||||
@@ -629,37 +765,41 @@ static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
|
||||
meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
|
||||
}
|
||||
|
||||
#if 0
|
||||
TODO: callref and remote callref of call must be resolved to get gsm_trans object
|
||||
static void call_dump_vty(struct vty *vty, struct gsm_call *call)
|
||||
static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
|
||||
{
|
||||
vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
|
||||
call->type, call->state, call->transaction_id, VTY_NEWLINE);
|
||||
struct gsm_meas_rep *mr;
|
||||
int idx;
|
||||
|
||||
if (call->local_lchan) {
|
||||
vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
|
||||
lchan_dump_vty(vty, call->local_lchan);
|
||||
} else
|
||||
vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
|
||||
/* we want to report the last measurement report */
|
||||
idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
|
||||
lchan->meas_rep_idx, 1);
|
||||
mr = &lchan->meas_rep[idx];
|
||||
|
||||
if (call->remote_lchan) {
|
||||
vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
|
||||
lchan_dump_vty(vty, call->remote_lchan);
|
||||
} else
|
||||
vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
|
||||
|
||||
if (call->called_subscr) {
|
||||
vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
|
||||
subscr_dump_vty(vty, call->called_subscr);
|
||||
} else
|
||||
vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
|
||||
vty_out(vty, "Lchan: %u Timeslot: %u TRX: %u BTS: %u Type: %s - L1 MS Power: %u dBm "
|
||||
"RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
|
||||
lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
|
||||
lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
|
||||
mr->ms_l1.pwr,
|
||||
rxlev2dbm(mr->dl.full.rx_lev),
|
||||
rxlev2dbm(mr->ul.full.rx_lev),
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFUN(show_lchan,
|
||||
show_lchan_cmd,
|
||||
"show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
|
||||
SHOW_STR "Display information about a logical channel\n")
|
||||
static void lchan_dump_status_vty(struct vty *vty, struct gsm_lchan *lchan)
|
||||
{
|
||||
vty_out(vty, "Lchan: %u/%u/%u/%u Type: %s State: %s ref: %u HO: %d Subscriber: %d "
|
||||
"Time: %lu SAPI: %d/%d%s",
|
||||
lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
|
||||
lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
|
||||
gsm_lchans_name(lchan->state), lchan->conn.use_count,
|
||||
lchan->conn.hand_off,
|
||||
lchan->conn.subscr != NULL, (unsigned long) lchan->alloc_time.tv_sec,
|
||||
lchan->sapis[0], lchan->sapis[3],
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
|
||||
static int lchan_summary(struct vty *vty, int argc, const char **argv,
|
||||
void (*dump_cb)(struct vty *, struct gsm_lchan *))
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
struct gsm_bts *bts;
|
||||
@@ -704,7 +844,7 @@ DEFUN(show_lchan,
|
||||
return CMD_WARNING;
|
||||
}
|
||||
lchan = &ts->lchan[lchan_nr];
|
||||
lchan_dump_vty(vty, lchan);
|
||||
dump_cb(vty, lchan);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
|
||||
@@ -718,7 +858,7 @@ DEFUN(show_lchan,
|
||||
lchan = &ts->lchan[lchan_nr];
|
||||
if (lchan->type == GSM_LCHAN_NONE)
|
||||
continue;
|
||||
lchan_dump_vty(vty, lchan);
|
||||
dump_cb(vty, lchan);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -727,6 +867,31 @@ DEFUN(show_lchan,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DEFUN(show_lchan,
|
||||
show_lchan_cmd,
|
||||
"show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
|
||||
SHOW_STR "Display information about a logical channel\n")
|
||||
{
|
||||
return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
|
||||
}
|
||||
|
||||
DEFUN(show_lchan_summary,
|
||||
show_lchan_summary_cmd,
|
||||
"show lchan-summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
|
||||
SHOW_STR "Display a short summary about a logical channel\n")
|
||||
{
|
||||
return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
|
||||
}
|
||||
|
||||
DEFUN(show_lchan_status,
|
||||
show_lchan_status_cmd,
|
||||
"show lchan-status [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
|
||||
SHOW_STR "Display a short stat about a logical channel\n")
|
||||
{
|
||||
return lchan_summary(vty, argc, argv, lchan_dump_status_vty);
|
||||
}
|
||||
|
||||
static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
|
||||
{
|
||||
vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
|
||||
@@ -879,6 +1044,50 @@ DEFUN(show_paging,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(drop_bts,
|
||||
drop_bts_cmd,
|
||||
"drop bts connection <0-65535> (oml|rsl)",
|
||||
"Debug/Simulation command to drop ipaccess BTS\n")
|
||||
{
|
||||
struct gsm_bts_trx *trx;
|
||||
struct gsm_bts *bts;
|
||||
unsigned int bts_nr;
|
||||
|
||||
bts_nr = atoi(argv[0]);
|
||||
if (bts_nr >= gsmnet->num_bts) {
|
||||
vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
|
||||
gsmnet->num_bts, bts_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
bts = gsm_bts_num(gsmnet, bts_nr);
|
||||
if (!bts) {
|
||||
vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (!is_ipaccess_bts(bts)) {
|
||||
vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
|
||||
/* close all connections */
|
||||
if (strcmp(argv[1], "oml") == 0)
|
||||
ipaccess_drop_oml(bts);
|
||||
else if (strcmp(argv[1], "rsl") == 0) {
|
||||
/* close all rsl connections */
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
ipaccess_drop_rsl(trx);
|
||||
}
|
||||
} else {
|
||||
vty_out(vty, "Argument must be 'oml' or 'rsl'.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net,
|
||||
cfg_net_cmd,
|
||||
"network",
|
||||
@@ -901,6 +1110,16 @@ DEFUN(cfg_net_ncc,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_core_net_ncc,
|
||||
cfg_core_net_ncc_cmd,
|
||||
"core network country code <1-999>",
|
||||
"Set the GSM country code to be used in the MSC connection")
|
||||
{
|
||||
gsmnet->core_country_code = atoi(argv[0]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_mnc,
|
||||
cfg_net_mnc_cmd,
|
||||
"mobile network code <1-999>",
|
||||
@@ -911,6 +1130,16 @@ DEFUN(cfg_net_mnc,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_core_net_mnc,
|
||||
cfg_core_net_mnc_cmd,
|
||||
"core mobile network code <1-999>",
|
||||
"Set the GSM mobile network code to be used in the MSC connection")
|
||||
{
|
||||
gsmnet->core_network_code = atoi(argv[0]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_name_short,
|
||||
cfg_net_name_short_cmd,
|
||||
"short name NAME",
|
||||
@@ -975,6 +1204,7 @@ DEFUN(cfg_net_neci,
|
||||
"Set if NECI of cell selection is to be set")
|
||||
{
|
||||
gsmnet->neci = atoi(argv[0]);
|
||||
gsm_net_update_ctype(gsmnet);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1061,6 +1291,195 @@ DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_supported_codecs,
|
||||
cfg_net_supported_codecs_cmd,
|
||||
"codec_list .LIST",
|
||||
"Set the three preferred audio codecs.\n"
|
||||
"Codec List")
|
||||
{
|
||||
int saw_fr, saw_hr;
|
||||
int i;
|
||||
|
||||
saw_fr = saw_hr = 0;
|
||||
|
||||
/* free the old list... if it exists */
|
||||
if (gsmnet->audio_support) {
|
||||
talloc_free(gsmnet->audio_support);
|
||||
gsmnet->audio_support = NULL;
|
||||
gsmnet->audio_length = 0;
|
||||
}
|
||||
|
||||
/* create a new array */
|
||||
gsmnet->audio_support =
|
||||
talloc_zero_array(gsmnet, struct gsm_audio_support *, argc);
|
||||
gsmnet->audio_length = argc;
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
/* check for hrX or frX */
|
||||
if (strlen(argv[i]) != 3
|
||||
|| argv[i][1] != 'r'
|
||||
|| (argv[i][0] != 'h' && argv[i][0] != 'f')
|
||||
|| argv[i][2] < 0x30
|
||||
|| argv[i][2] > 0x39)
|
||||
goto error;
|
||||
|
||||
gsmnet->audio_support[i] = talloc_zero(gsmnet->audio_support,
|
||||
struct gsm_audio_support);
|
||||
gsmnet->audio_support[i]->ver = atoi(argv[i] + 2);
|
||||
|
||||
if (strncmp("hr", argv[i], 2) == 0) {
|
||||
gsmnet->audio_support[i]->hr = 1;
|
||||
saw_hr = 1;
|
||||
} else if (strncmp("fr", argv[i], 2) == 0) {
|
||||
gsmnet->audio_support[i]->hr = 0;
|
||||
saw_fr = 1;
|
||||
}
|
||||
|
||||
if (saw_hr && saw_fr) {
|
||||
vty_out(vty, "Can not have full-rate and half-rate codec.%s",
|
||||
VTY_NEWLINE);
|
||||
return CMD_ERR_INCOMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
||||
error:
|
||||
vty_out(vty, "Codec name must be hrX or frX. Was '%s'%s",
|
||||
argv[i], VTY_NEWLINE);
|
||||
return CMD_ERR_INCOMPLETE;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_ipacc_rtp_payload,
|
||||
cfg_net_ipacc_rtp_payload_cmd,
|
||||
"ipacc rtp_payload <0-256>",
|
||||
"Override the RTP payload to use")
|
||||
{
|
||||
gsmnet->rtp_payload = atoi(argv[0]) & 0xff;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_rtp_base_port,
|
||||
cfg_net_rtp_base_port_cmd,
|
||||
"rtp base <0-65534>",
|
||||
"Base port to use for MGCP RTP")
|
||||
{
|
||||
unsigned int port = atoi(argv[0]);
|
||||
if (port > 65534) {
|
||||
vty_out(vty, "%% wrong base port '%s'%s", argv[0], VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
gsmnet->rtp_base_port = port;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_bsc_token,
|
||||
cfg_net_bsc_token_cmd,
|
||||
"bsc_token TOKEN",
|
||||
"A token for the BSC to be sent to the MSC")
|
||||
{
|
||||
if (gsmnet->bsc_token)
|
||||
talloc_free(gsmnet->bsc_token);
|
||||
gsmnet->bsc_token = talloc_strdup(gsmnet, argv[0]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_pag_any_tch,
|
||||
cfg_net_pag_any_tch_cmd,
|
||||
"paging any use tch (0|1)",
|
||||
"Assign a TCH when receiving a Paging Any request")
|
||||
{
|
||||
gsmnet->pag_any_tch = atoi(argv[0]);
|
||||
gsm_net_update_ctype(gsmnet);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_msc_ip,
|
||||
cfg_net_msc_ip_cmd,
|
||||
"msc ip A.B.C.D",
|
||||
"Set the MSC/MUX IP address.")
|
||||
{
|
||||
if (gsmnet->msc_ip)
|
||||
talloc_free(gsmnet->msc_ip);
|
||||
gsmnet->msc_ip = talloc_strdup(gsmnet, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_msc_port,
|
||||
cfg_net_msc_port_cmd,
|
||||
"msc port <1-65000>",
|
||||
"Set the MSC/MUX port.")
|
||||
{
|
||||
gsmnet->msc_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_msc_prio,
|
||||
cfg_net_msc_prio_cmd,
|
||||
"msc ip-dscp <0-255>",
|
||||
"Set the IP_TOS socket attribite")
|
||||
{
|
||||
gsmnet->msc_ip_dscp = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
ALIAS_DEPRECATED(cfg_net_msc_prio, cfg_net_msc_ip_tos_cmd,
|
||||
"msc ip-tos <0-255>",
|
||||
"Set the IP_TOS socket attribite\n" "The DSCP to use.\n")
|
||||
|
||||
DEFUN(cfg_net_ping_time,
|
||||
cfg_net_ping_time_cmd,
|
||||
"timeout ping NR",
|
||||
"Set the PING interval, negative for not sending PING")
|
||||
{
|
||||
gsmnet->ping_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_pong_time,
|
||||
cfg_net_pong_time_cmd,
|
||||
"timeout pong NR",
|
||||
"Set the time to wait for a PONG.")
|
||||
{
|
||||
gsmnet->pong_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_grace_ussd,
|
||||
cfg_net_grace_ussd_cmd,
|
||||
"bsc-grace-text .TEXT",
|
||||
"Set the USSD notifcation to be send.\n" "Text to be sent\n")
|
||||
{
|
||||
char *data = argv_concat(argv, argc, 1);
|
||||
if (!data)
|
||||
return CMD_WARNING;
|
||||
|
||||
if (gsmnet->ussd_grace_txt)
|
||||
talloc_free(gsmnet->ussd_grace_txt);
|
||||
gsmnet->ussd_grace_txt = talloc_strdup(gsmnet, data);
|
||||
talloc_free(data);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_welcome_ussd,
|
||||
cfg_net_welcome_ussd_cmd,
|
||||
"bsc-welcome-text .TEXT",
|
||||
"Set the USSD notification to be sent.\n" "Text to be sent\n")
|
||||
{
|
||||
char *data = argv_concat(argv, argc, 1);
|
||||
if (!data)
|
||||
return CMD_WARNING;
|
||||
|
||||
if (gsmnet->ussd_welcome_txt)
|
||||
talloc_free(gsmnet->ussd_welcome_txt);
|
||||
gsmnet->ussd_welcome_txt = talloc_strdup(gsmnet, data);
|
||||
talloc_free(data);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
#define DECLARE_TIMER(number, doc) \
|
||||
DEFUN(cfg_net_T##number, \
|
||||
cfg_net_T##number##_cmd, \
|
||||
@@ -1071,7 +1490,7 @@ DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
|
||||
\
|
||||
if (value < 0 || value > 65535) { \
|
||||
vty_out(vty, "Timer value %s out of range.%s", \
|
||||
argv[0], VTY_NEWLINE); \
|
||||
argv[0], VTY_NEWLINE); \
|
||||
return CMD_WARNING; \
|
||||
} \
|
||||
\
|
||||
@@ -1084,13 +1503,22 @@ DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
|
||||
DECLARE_TIMER(3105, "Currently not used.")
|
||||
DECLARE_TIMER(3107, "Currently not used.")
|
||||
DECLARE_TIMER(3109, "Currently not used.")
|
||||
DECLARE_TIMER(3111, "Currently not used.")
|
||||
DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
|
||||
DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
|
||||
DECLARE_TIMER(3115, "Currently not used.")
|
||||
DECLARE_TIMER(3117, "Currently not used.")
|
||||
DECLARE_TIMER(3119, "Currently not used.")
|
||||
DECLARE_TIMER(3141, "Currently not used.")
|
||||
|
||||
DEFUN(cfg_net_dtx,
|
||||
cfg_net_dtx_cmd,
|
||||
"dtx-used (0|1)",
|
||||
"Enable the usage of DTX.\n"
|
||||
"DTX is enabled/disabled")
|
||||
{
|
||||
gsmnet->dtx_enabled = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* per-BTS configuration */
|
||||
DEFUN(cfg_bts,
|
||||
@@ -1337,6 +1765,26 @@ DEFUN(cfg_bts_rach_max_trans,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_rach_nm_b_thresh,
|
||||
cfg_bts_rach_nm_b_thresh_cmd,
|
||||
"rach nm busy threshold <0-255>",
|
||||
"Set the NM Busy Threshold in DB")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
bts->rach_b_thresh = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_rach_nm_ldavg,
|
||||
cfg_bts_rach_nm_ldavg_cmd,
|
||||
"rach nm load average <0-65535>",
|
||||
"Set the NM Loadaver Slots value")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
bts->rach_ldavg_slots = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
|
||||
"cell barred (0|1)",
|
||||
"Should this cell be barred from access?")
|
||||
@@ -1348,6 +1796,20 @@ DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
|
||||
"rach emergency call allowed (0|1)",
|
||||
"Should this cell allow emergency calls?")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
if (atoi(argv[0]) == 0)
|
||||
bts->si_common.rach_control.t2 |= 0x4;
|
||||
else
|
||||
bts->si_common.rach_control.t2 &= ~0x4;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
|
||||
"ms max power <0-40>",
|
||||
"Maximum transmit power of the MS")
|
||||
@@ -1495,6 +1957,64 @@ DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
#define GPRS_TEXT "GPRS Packet Network\n"
|
||||
#define NS_TIMERS "(tns-block|tns-block-retries|tns-reset|tns-reset-retries|tns-test|tns-alive|tns-alive-retries)"
|
||||
#define NS_TIMERS_HELP \
|
||||
"(un)blocking Timer (Tns-block) timeout\n" \
|
||||
"(un)blocking Timer (Tns-block) number of retries\n" \
|
||||
"Reset Timer (Tns-reset) timeout\n" \
|
||||
"Reset Timer (Tns-reset) number of retries\n" \
|
||||
"Test Timer (Tns-test) timeout\n" \
|
||||
|
||||
DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
|
||||
"gprs ns timer " NS_TIMERS " <0-255>",
|
||||
GPRS_TEXT "Network Service\n"
|
||||
"Network Service Timer\n"
|
||||
NS_TIMERS_HELP "Timer Value\n")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
|
||||
int val = atoi(argv[1]);
|
||||
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
|
||||
return CMD_WARNING;
|
||||
|
||||
bts->gprs.nse.timer[idx] = val;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
#define BSSGP_TIMERS "(blocking-timer|blocking-retries|unblocking-retries|reset-timer|reset-retries|suspend-timer|suspend-retries|resume-timer|resume-retries|capability-update-timer|capability-update-retries)"
|
||||
#define BSSGP_TIMERS_HELP ""
|
||||
|
||||
DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
|
||||
"gprs cell timer " BSSGP_TIMERS " <0-255>",
|
||||
GPRS_TEXT "Cell / BSSGP\n"
|
||||
"Cell/BSSGP Timer\n"
|
||||
BSSGP_TIMERS_HELP "Timer Value\n")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
|
||||
int val = atoi(argv[1]);
|
||||
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
|
||||
return CMD_WARNING;
|
||||
|
||||
bts->gprs.cell.timer[idx] = val;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
|
||||
"gprs routing area <0-255>",
|
||||
"GPRS Routing Area Code")
|
||||
@@ -1522,6 +2042,15 @@ DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
|
||||
"paging free FREE_NR",
|
||||
"Only page when having a certain amount of free slots. -1 to disable")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
bts->paging.free_chans_need = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* per TRX configuration */
|
||||
DEFUN(cfg_trx,
|
||||
@@ -1714,6 +2243,8 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(VIEW_NODE, &show_trx_cmd);
|
||||
install_element(VIEW_NODE, &show_ts_cmd);
|
||||
install_element(VIEW_NODE, &show_lchan_cmd);
|
||||
install_element(VIEW_NODE, &show_lchan_summary_cmd);
|
||||
install_element(VIEW_NODE, &show_lchan_status_cmd);
|
||||
|
||||
install_element(VIEW_NODE, &show_e1drv_cmd);
|
||||
install_element(VIEW_NODE, &show_e1line_cmd);
|
||||
@@ -1721,13 +2252,18 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
|
||||
install_element(VIEW_NODE, &show_paging_cmd);
|
||||
|
||||
openbsc_vty_add_cmds();
|
||||
install_element(VIEW_NODE, &drop_bts_cmd);
|
||||
install_element(VIEW_NODE, &test_bts_lchan_alloc_cmd);
|
||||
|
||||
openbsc_vty_add_cmds();
|
||||
|
||||
install_element(CONFIG_NODE, &cfg_net_cmd);
|
||||
install_node(&net_node, config_write_net);
|
||||
install_default(GSMNET_NODE);
|
||||
install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_core_net_ncc_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_core_net_mnc_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
|
||||
@@ -1743,6 +2279,9 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_supported_codecs_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_ipacc_rtp_payload_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_rtp_base_port_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
|
||||
@@ -1754,6 +2293,17 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_bsc_token_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_ip_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_port_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_ip_tos_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_prio_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_ping_time_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_pong_time_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_grace_ussd_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_welcome_ussd_cmd);
|
||||
|
||||
install_element(GSMNET_NODE, &cfg_bts_cmd);
|
||||
install_node(&bts_node, config_write_bts);
|
||||
@@ -1771,19 +2321,25 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(BTS_NODE, &cfg_bts_challoc_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
|
||||
|
||||
install_element(BTS_NODE, &cfg_trx_cmd);
|
||||
install_node(&trx_node, dummy_config_write);
|
||||
@@ -1801,6 +2357,8 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(TS_NODE, &cfg_ts_pchan_cmd);
|
||||
install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
|
||||
|
||||
abis_nm_vty_init();
|
||||
|
||||
bsc_vty_init_extra(net);
|
||||
|
||||
return 0;
|
||||
|
||||
95
openbsc/src/vty_interface_bsc.c
Normal file
95
openbsc/src/vty_interface_bsc.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* OpenBSC interface to quagga VTY - BSC options */
|
||||
/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <vty/command.h>
|
||||
#include <vty/buffer.h>
|
||||
#include <vty/vty.h>
|
||||
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/bsc_msc.h>
|
||||
#include <openbsc/vty.h>
|
||||
|
||||
#include <osmocom/sccp/sccp.h>
|
||||
|
||||
static struct gsm_network *gsmnet = NULL;
|
||||
|
||||
extern struct llist_head *bsc_sccp_connections();
|
||||
|
||||
DEFUN(show_bsc, show_bsc_cmd, "show bsc",
|
||||
SHOW_STR "Display information about the BSC\n")
|
||||
{
|
||||
struct bss_sccp_connection_data *con;
|
||||
|
||||
vty_out(vty, "BSC Information%s", VTY_NEWLINE);
|
||||
llist_for_each_entry(con, bsc_sccp_connections(), active_connections) {
|
||||
vty_out(vty, " Connection: LCHAN: %p sec LCHAN: 0x%p SCCP src: 0x%x dest: 0x%x%s",
|
||||
con->lchan, con->secondary_lchan,
|
||||
con->sccp ? (int) sccp_src_ref_to_int(&con->sccp->source_local_reference) : -1,
|
||||
con->sccp ? (int) sccp_src_ref_to_int(&con->sccp->destination_local_reference) : -1,
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_stats,
|
||||
show_stats_cmd,
|
||||
"show statistics",
|
||||
SHOW_STR "Display network statistics\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
|
||||
openbsc_vty_print_statistics(vty, net);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_msc,
|
||||
show_msc_cmd,
|
||||
"show msc connection",
|
||||
SHOW_STR "Show the status of the MSC connection.")
|
||||
{
|
||||
if (!gsmnet->msc_con) {
|
||||
vty_out(vty, "The MSC is not yet configured.\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
vty_out(vty, "MSC on %s:%d is connected: %d%s\n",
|
||||
gsmnet->msc_con->ip, gsmnet->msc_con->port,
|
||||
gsmnet->msc_con->is_connected, VTY_NEWLINE);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int bsc_vty_init_extra(struct gsm_network *net)
|
||||
{
|
||||
gsmnet = net;
|
||||
|
||||
/* get runtime information */
|
||||
install_element(VIEW_NODE, &show_bsc_cmd);
|
||||
install_element(VIEW_NODE, &show_stats_cmd);
|
||||
install_element(VIEW_NODE, &show_msc_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ static int dummy_config_write(struct vty *v)
|
||||
|
||||
static struct buffer *argv_to_buffer(int argc, const char *argv[], int base)
|
||||
{
|
||||
struct buffer *b = buffer_new(1024);
|
||||
struct buffer *b = buffer_new(NULL, 1024);
|
||||
int i;
|
||||
|
||||
if (!b)
|
||||
@@ -73,33 +73,6 @@ static struct buffer *argv_to_buffer(int argc, const char *argv[], int base)
|
||||
return b;
|
||||
}
|
||||
|
||||
static int hexparse(const char *str, u_int8_t *b, int max_len)
|
||||
|
||||
{
|
||||
int i, l, v;
|
||||
|
||||
l = strlen(str);
|
||||
if ((l&1) || ((l>>1) > max_len))
|
||||
return -1;
|
||||
|
||||
memset(b, 0x00, max_len);
|
||||
|
||||
for (i=0; i<l; i++) {
|
||||
char c = str[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
v = c - '0';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
v = 10 + (c - 'a');
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
v = 10 + (c - 'a');
|
||||
else
|
||||
return -1;
|
||||
b[i>>1] |= v << (i&1 ? 0 : 4);
|
||||
}
|
||||
|
||||
return i>>1;
|
||||
}
|
||||
|
||||
/* per-subscriber configuration */
|
||||
DEFUN(cfg_subscr,
|
||||
cfg_subscr_cmd,
|
||||
|
||||
@@ -1 +1 @@
|
||||
SUBDIRS = debug gsm0408 db channel sccp
|
||||
SUBDIRS = debug gsm0408 db channel
|
||||
|
||||
@@ -76,6 +76,8 @@ int main(int argc, char** argv)
|
||||
void nm_state_event() {}
|
||||
void input_event() {}
|
||||
void sms_alloc() {}
|
||||
void _lchan_release() {}
|
||||
void gsm_net_update_ctype(struct gsm_network *network) {}
|
||||
|
||||
struct tlv_definition nm_att_tlvdef;
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
INCLUDES = $(all_includes) -I$(top_srcdir)/include
|
||||
AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
|
||||
|
||||
noinst_PROGRAMS = sccp_test
|
||||
|
||||
sccp_test_SOURCES = sccp_test.c
|
||||
sccp_test_LDADD = $(top_builddir)/src/libsccp.a $(top_builddir)/src/libbsc.a $(LIBOSMOCORE_LIBS)
|
||||
|
||||
@@ -1,832 +0,0 @@
|
||||
/*
|
||||
* SCCP testing code
|
||||
*
|
||||
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2009 by On-Waves
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <osmocore/msgb.h>
|
||||
|
||||
#include <sccp/sccp.h>
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
/* BSC -> MSC */
|
||||
static const u_int8_t bssmap_reset[] = {
|
||||
0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe,
|
||||
0x02, 0x42, 0xfe, 0x06, 0x00, 0x04, 0x30, 0x04,
|
||||
0x01, 0x20,
|
||||
};
|
||||
|
||||
/* MSC -> BSC reset ack */
|
||||
static const u_int8_t bssmap_reset_ack[] = {
|
||||
0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
|
||||
0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x03,
|
||||
0x00, 0x01, 0x31,
|
||||
};
|
||||
|
||||
/* MSC -> BSC paging, connection less */
|
||||
static const u_int8_t bssmap_paging[] = {
|
||||
0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
|
||||
0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x10,
|
||||
0x00, 0x0e, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10,
|
||||
0x02, 0x01, 0x31, 0x97, 0x61, 0x1a, 0x01, 0x06,
|
||||
};
|
||||
|
||||
/* MSC -> BSC paging, UDT without PC */
|
||||
static const u_int8_t bssmap_udt[] = {
|
||||
0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe,
|
||||
0x02, 0x42, 0xfe, 0x10, 0x00, 0x0e, 0x52, 0x08,
|
||||
0x08, 0x29, 0x47, 0x10, 0x02, 0x01, 0x31, 0x97,
|
||||
0x61, 0x1a, 0x01, 0x06,
|
||||
};
|
||||
|
||||
/* BSC -> MSC connection open */
|
||||
static const u_int8_t bssmap_cr[] = {
|
||||
0x01, 0x01, 0x02, 0x03, 0x02, 0x02, 0x04, 0x02,
|
||||
0x42, 0xfe, 0x0f, 0x1f, 0x00, 0x1d, 0x57, 0x05,
|
||||
0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x12, 0xc3,
|
||||
0x50, 0x17, 0x10, 0x05, 0x24, 0x11, 0x03, 0x33,
|
||||
0x19, 0xa2, 0x08, 0x29, 0x47, 0x10, 0x02, 0x01,
|
||||
0x31, 0x97, 0x61, 0x00
|
||||
};
|
||||
|
||||
/* MSC -> BSC connection confirm */
|
||||
static const u_int8_t bssmap_cc[] = {
|
||||
0x02, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00,
|
||||
};
|
||||
|
||||
/* MSC -> BSC DTAP
|
||||
*
|
||||
* we fake a bit and make it BSC -> MSC... so the
|
||||
* payload does not make any sense..
|
||||
*/
|
||||
static const u_int8_t bssmap_dtap[] = {
|
||||
0x06, 0x00, 0x00, 0x03, 0x00, 0x01, 0x0f, 0x01, 0x00, 0x0c,
|
||||
0x03, 0x05, 0x5c, 0x08, 0x11, 0x81, 0x33, 0x66, 0x02, 0x13,
|
||||
0x45, 0xf4,
|
||||
};
|
||||
|
||||
/* MSC -> BSC clear command */
|
||||
static const u_int8_t bssmap_clear[] = {
|
||||
0x06, 0x00, 0x00, 0x03, 0x00, 0x01, 0x06, 0x00, 0x04, 0x20,
|
||||
0x04, 0x01, 0x09,
|
||||
};
|
||||
|
||||
/* MSC -> BSC released */
|
||||
static const u_int8_t bssmap_released[] = {
|
||||
0x04, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x00, 0x01, 0x0f,
|
||||
0x02, 0x23, 0x42, 0x00,
|
||||
};
|
||||
|
||||
/* BSC -> MSC released */
|
||||
static const u_int8_t bssmap_release_complete[] = {
|
||||
0x05, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03
|
||||
};
|
||||
|
||||
struct test_data {
|
||||
int length;
|
||||
const u_int8_t *data;
|
||||
int payload_start;
|
||||
int payload_length;
|
||||
u_int8_t first_byte;
|
||||
|
||||
/* in case it should trigger a sccp response */
|
||||
int write;
|
||||
const u_int8_t *response;
|
||||
int response_length;
|
||||
};
|
||||
|
||||
static const struct test_data test_data[] = {
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_reset),
|
||||
.data = &bssmap_reset[0],
|
||||
.payload_start = 12,
|
||||
.payload_length = ARRAY_SIZE(bssmap_reset) - 12,
|
||||
.first_byte = 0x0,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_reset_ack),
|
||||
.data = &bssmap_reset_ack[0],
|
||||
.payload_start = 16,
|
||||
.payload_length = ARRAY_SIZE(bssmap_reset_ack) - 16,
|
||||
.first_byte = 0x0,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_paging),
|
||||
.data = &bssmap_paging[0],
|
||||
.payload_start = 16,
|
||||
.payload_length = ARRAY_SIZE(bssmap_paging) - 16,
|
||||
.first_byte = 0x0,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_cr),
|
||||
.data = &bssmap_cr[0],
|
||||
.payload_start = 12,
|
||||
/* 0x00 is end of optional data, subtract this byte */
|
||||
.payload_length = 31,
|
||||
.first_byte = 0x0,
|
||||
|
||||
/* the connection request should trigger a connection confirm */
|
||||
.write = 1,
|
||||
.response = &bssmap_cc[0],
|
||||
.response_length= ARRAY_SIZE(bssmap_cc),
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_dtap),
|
||||
.data = &bssmap_dtap[0],
|
||||
.payload_start = 7,
|
||||
.payload_length = 15,
|
||||
.first_byte = 0x01,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_clear),
|
||||
.data = &bssmap_clear[0],
|
||||
.payload_start = 7,
|
||||
.payload_length = 6,
|
||||
.first_byte = 0x00,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_released),
|
||||
.data = &bssmap_released[0],
|
||||
.payload_length = 2,
|
||||
.payload_start = 11,
|
||||
.first_byte = 0x23,
|
||||
|
||||
.write = 1,
|
||||
.response = &bssmap_release_complete[0],
|
||||
.response_length= ARRAY_SIZE(bssmap_release_complete),
|
||||
},
|
||||
};
|
||||
|
||||
/* we will send UDTs and verify they look like this */
|
||||
static const struct test_data send_data[] = {
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_udt),
|
||||
.data = &bssmap_udt[0],
|
||||
.payload_start = 12,
|
||||
.payload_length = ARRAY_SIZE(bssmap_udt) - 12,
|
||||
.first_byte = 0x0,
|
||||
},
|
||||
{
|
||||
.length = ARRAY_SIZE(bssmap_reset),
|
||||
.data = &bssmap_reset[0],
|
||||
.payload_start = 12,
|
||||
.payload_length = ARRAY_SIZE(bssmap_reset) - 12,
|
||||
.first_byte = 0x0,
|
||||
},
|
||||
};
|
||||
|
||||
struct connection_test {
|
||||
/* should the connection be refused? */
|
||||
int refuse;
|
||||
|
||||
int with_data;
|
||||
|
||||
/* on which side to close the connection? */
|
||||
int close_side;
|
||||
int close_cause;
|
||||
};
|
||||
|
||||
/* sccp connection handling we want to test */
|
||||
static const struct connection_test connection_tests[] = {
|
||||
{
|
||||
.refuse = 1,
|
||||
},
|
||||
{
|
||||
.refuse = 1,
|
||||
.with_data = 1,
|
||||
},
|
||||
{
|
||||
.refuse = 0,
|
||||
.close_side = 0,
|
||||
.close_cause = 5,
|
||||
},
|
||||
{
|
||||
.refuse = 0,
|
||||
.close_side = 0,
|
||||
.close_cause = 5,
|
||||
.with_data = 1,
|
||||
},
|
||||
{
|
||||
.refuse = 0,
|
||||
.close_side = 1,
|
||||
.close_cause = 5,
|
||||
},
|
||||
{
|
||||
.refuse = 0,
|
||||
.close_side = 1,
|
||||
.close_cause = 5,
|
||||
.with_data = 1,
|
||||
},
|
||||
};
|
||||
|
||||
struct sccp_parse_header_result {
|
||||
/* results */
|
||||
int msg_type;
|
||||
int wanted_len;
|
||||
int src_ssn;
|
||||
int dst_ssn;
|
||||
|
||||
int has_src_ref, has_dst_ref;
|
||||
struct sccp_source_reference src_ref;
|
||||
struct sccp_source_reference dst_ref;
|
||||
|
||||
/* the input */
|
||||
const u_int8_t *input;
|
||||
int input_len;
|
||||
};
|
||||
|
||||
static const u_int8_t it_test[] = {
|
||||
0x10, 0x01, 0x07,
|
||||
0x94, 0x01, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00 };
|
||||
|
||||
static const struct sccp_parse_header_result parse_result[] = {
|
||||
{
|
||||
.msg_type = SCCP_MSG_TYPE_IT,
|
||||
.wanted_len = 0,
|
||||
.src_ssn = -1,
|
||||
.dst_ssn = -1,
|
||||
.has_src_ref = 1,
|
||||
.has_dst_ref = 1,
|
||||
|
||||
.src_ref = {
|
||||
.octet1 = 0x01,
|
||||
.octet2 = 0x04,
|
||||
.octet3 = 0x00
|
||||
},
|
||||
.dst_ref = {
|
||||
.octet1 = 0x01,
|
||||
.octet2 = 0x07,
|
||||
.octet3 = 0x94,
|
||||
},
|
||||
|
||||
.input = it_test,
|
||||
.input_len = sizeof(it_test),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/* testing procedure:
|
||||
* - we will use sccp_write and see what will be set in the
|
||||
* outgoing callback
|
||||
* - we will call sccp_system_incoming and see which calls
|
||||
* are made. And then compare it to the ones we expect. We
|
||||
* want the payload to arrive, or callbacks to be called.
|
||||
* - we will use sccp_connection_socket and sccp_connection_write
|
||||
* and verify state handling of connections
|
||||
*/
|
||||
|
||||
static int current_test;
|
||||
|
||||
/*
|
||||
* test state...
|
||||
*/
|
||||
static int called = 0;
|
||||
static int matched = 0;
|
||||
static int write_called = 0;
|
||||
|
||||
#define FAIL(x, args...) printf("FAILURE in %s:%d: " x, __FILE__, __LINE__, ## args)
|
||||
|
||||
/*
|
||||
* writing these packets and expecting a result
|
||||
*/
|
||||
int sccp_read_cb(struct msgb *data, unsigned len, void *context)
|
||||
{
|
||||
u_int16_t payload_length = test_data[current_test].payload_length;
|
||||
const u_int8_t *got, *wanted;
|
||||
int i;
|
||||
|
||||
called = 1;
|
||||
|
||||
if (msgb_l3len(data) < len) {
|
||||
/* this should never be reached */
|
||||
FAIL("Something horrible happened.. invalid packet..\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (len == 0 || len != payload_length) {
|
||||
FAIL("length mismatch: got: %d wanted: %d\n", msgb_l3len(data), payload_length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data->l3h[0] != test_data[current_test].first_byte) {
|
||||
FAIL("The first bytes of l3 do not match: 0x%x 0x%x\n",
|
||||
data->l3h[0], test_data[current_test].first_byte);
|
||||
return -1;
|
||||
}
|
||||
|
||||
got = &data->l3h[0];
|
||||
wanted = test_data[current_test].data + test_data[current_test].payload_start;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (got[i] != wanted[i]) {
|
||||
FAIL("Failed to compare byte. Got: 0x%x Wanted: 0x%x at %d\n",
|
||||
got[i], wanted[i], i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
matched = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sccp_write_cb(struct msgb *data, void *ctx)
|
||||
{
|
||||
int i = 0;
|
||||
const u_int8_t *got, *wanted;
|
||||
|
||||
if (test_data[current_test].response == NULL) {
|
||||
FAIL("Didn't expect write callback\n");
|
||||
goto exit;
|
||||
} else if (test_data[current_test].response_length != msgb_l2len(data)) {
|
||||
FAIL("Size does not match. Got: %d Wanted: %d\n",
|
||||
msgb_l2len(data), test_data[current_test].response_length);
|
||||
}
|
||||
|
||||
got = &data->l2h[0];
|
||||
wanted = test_data[current_test].response;
|
||||
|
||||
for (i = 0; i < msgb_l2len(data); ++i) {
|
||||
if (got[i] != wanted[i]) {
|
||||
FAIL("Failed to compare byte. Got: 0x%x Wanted: 0x%x at %d\n",
|
||||
got[i], wanted[i], i);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
write_called = 1;
|
||||
|
||||
exit:
|
||||
msgb_free(data);
|
||||
}
|
||||
|
||||
void sccp_c_read(struct sccp_connection *connection, struct msgb *msgb, unsigned int len)
|
||||
{
|
||||
sccp_read_cb(msgb, len, connection->data_ctx);
|
||||
}
|
||||
|
||||
void sccp_c_state(struct sccp_connection *connection, int old_state)
|
||||
{
|
||||
if (connection->connection_state >= SCCP_CONNECTION_STATE_RELEASE_COMPLETE)
|
||||
sccp_connection_free(connection);
|
||||
}
|
||||
|
||||
int sccp_accept_cb(struct sccp_connection *connection, void *user_data)
|
||||
{
|
||||
called = 1;
|
||||
unsigned int ref = 0;
|
||||
ref |= connection->destination_local_reference.octet1 << 24;
|
||||
ref |= connection->destination_local_reference.octet2 << 16;
|
||||
ref |= connection->destination_local_reference.octet3 << 8;
|
||||
ref = ntohl(ref);
|
||||
|
||||
connection->data_cb = sccp_c_read;
|
||||
connection->state_cb = sccp_c_state;
|
||||
|
||||
/* accept this */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sccp_udt_write_cb(struct msgb *data, void *context)
|
||||
{
|
||||
const u_int8_t *got, *wanted;
|
||||
int i;
|
||||
|
||||
write_called = 1;
|
||||
|
||||
if (send_data[current_test].length != msgb_l2len(data)) {
|
||||
FAIL("Size does not match. Got: %d Wanted: %d\n",
|
||||
msgb_l2len(data), send_data[current_test].length);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
got = &data->l2h[0];
|
||||
wanted = send_data[current_test].data;
|
||||
|
||||
for (i = 0; i < msgb_l2len(data); ++i) {
|
||||
if (got[i] != wanted[i]) {
|
||||
FAIL("Failed to compare byte. Got: 0x%x Wanted: 0x%x at %d\n",
|
||||
got[i], wanted[i], i);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
matched = 1;
|
||||
|
||||
exit:
|
||||
msgb_free(data);
|
||||
}
|
||||
|
||||
static void test_sccp_system(void)
|
||||
{
|
||||
sccp_system_init(sccp_write_cb, NULL);
|
||||
sccp_set_read(&sccp_ssn_bssap, sccp_read_cb, NULL);
|
||||
sccp_connection_set_incoming(&sccp_ssn_bssap, sccp_accept_cb, NULL);
|
||||
|
||||
for (current_test = 0; current_test < ARRAY_SIZE(test_data); ++current_test) {
|
||||
unsigned int length = test_data[current_test].length;
|
||||
struct msgb *msg = msgb_alloc_headroom(length + 2, 2, __func__);
|
||||
msg->l2h = msgb_put(msg, length);
|
||||
memcpy(msg->l2h, test_data[current_test].data, length);
|
||||
|
||||
called = matched = write_called = 0;
|
||||
printf("Testing packet: %d\n", current_test);
|
||||
sccp_system_incoming(msg);
|
||||
|
||||
if (!called || !matched || (test_data[current_test].write != write_called))
|
||||
FAIL("current test: %d called: %d matched: %d write: %d\n",
|
||||
current_test, called, matched, write_called);
|
||||
|
||||
msgb_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/* test sending of udt */
|
||||
static void test_sccp_send_udt(void)
|
||||
{
|
||||
sccp_system_init(sccp_udt_write_cb, NULL);
|
||||
sccp_set_read(NULL, NULL, NULL);
|
||||
sccp_connection_set_incoming(NULL, NULL, NULL);
|
||||
|
||||
for (current_test = 0; current_test < ARRAY_SIZE(send_data); ++current_test) {
|
||||
const struct test_data *test = &send_data[current_test];
|
||||
|
||||
struct msgb *msg = msgb_alloc(test->payload_length, __func__);
|
||||
msg->l3h = msgb_put(msg, test->payload_length);
|
||||
memcpy(msg->l3h, test->data + test->payload_start, test->payload_length);
|
||||
|
||||
matched = write_called = 0;
|
||||
printf("Testing packet: %d\n", current_test);
|
||||
sccp_write(msg, &sccp_ssn_bssap, &sccp_ssn_bssap, 0);
|
||||
|
||||
if (!matched || !write_called)
|
||||
FAIL("current test: %d matched: %d write: %d\n",
|
||||
current_test, matched, write_called);
|
||||
|
||||
msgb_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/* send udt from one end to another */
|
||||
static unsigned int test_value = 0x2442;
|
||||
static int sccp_udt_read(struct msgb *data, unsigned int len, void *context)
|
||||
{
|
||||
unsigned int *val;
|
||||
|
||||
if (len != 4) {
|
||||
FAIL("Wrong size: %d\n", msgb_l3len(data));
|
||||
return -1;
|
||||
}
|
||||
|
||||
val = (unsigned int*)data->l3h;
|
||||
matched = test_value == *val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sccp_write_loop(struct msgb *data, void *context)
|
||||
{
|
||||
/* send it back to us */
|
||||
sccp_system_incoming(data);
|
||||
msgb_free(data);
|
||||
}
|
||||
|
||||
static void test_sccp_udt_communication(void)
|
||||
{
|
||||
struct msgb *data;
|
||||
unsigned int *val;
|
||||
|
||||
sccp_system_init(sccp_write_loop, NULL);
|
||||
sccp_set_read(&sccp_ssn_bssap, sccp_udt_read, NULL);
|
||||
sccp_connection_set_incoming(NULL, NULL, NULL);
|
||||
|
||||
|
||||
data = msgb_alloc(4, "test data");
|
||||
data->l3h = &data->data[0];
|
||||
val = (unsigned int *)msgb_put(data, 4);
|
||||
*val = test_value;
|
||||
|
||||
matched = 0;
|
||||
sccp_write(data, &sccp_ssn_bssap, &sccp_ssn_bssap, 0);
|
||||
|
||||
if (!matched)
|
||||
FAIL("Talking with us didn't work\n");
|
||||
|
||||
msgb_free(data);
|
||||
}
|
||||
|
||||
|
||||
/* connection testing... open, send, close */
|
||||
static const struct connection_test *current_con_test;
|
||||
static struct sccp_connection *outgoing_con;
|
||||
static struct sccp_connection *incoming_con;
|
||||
static int outgoing_data, incoming_data, incoming_state, outgoing_state;
|
||||
|
||||
static struct msgb *test_data1, *test_data2, *test_data3;
|
||||
|
||||
static void sccp_conn_in_state(struct sccp_connection *conn, int old_state)
|
||||
{
|
||||
printf("\tincome: %d -> %d\n", old_state, conn->connection_state);
|
||||
if (conn->connection_state >= SCCP_CONNECTION_STATE_RELEASE_COMPLETE) {
|
||||
if (conn == incoming_con) {
|
||||
sccp_connection_free(conn);
|
||||
incoming_con = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sccp_conn_in_data(struct sccp_connection *conn, struct msgb *msg, unsigned int len)
|
||||
{
|
||||
/* compare the data */
|
||||
++incoming_data;
|
||||
printf("\tincoming data: %d\n", len);
|
||||
|
||||
/* compare the data */
|
||||
if (len != 4) {
|
||||
FAIL("Length of packet is wrong: %u %u\n", msgb_l3len(msg), len);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incoming_data == 1) {
|
||||
if (memcmp(msg->l3h, test_data1->l3h, len) != 0) {
|
||||
FAIL("Comparing the data failed: %d\n", incoming_data);
|
||||
incoming_state = 0;
|
||||
printf("Got: %s\n", hexdump(msg->l3h, len));
|
||||
printf("Wanted: %s\n", hexdump(test_data1->l3h, len));
|
||||
|
||||
}
|
||||
} else if (incoming_data == 2) {
|
||||
if (memcmp(msg->l3h, test_data2->l3h, len) != 0) {
|
||||
FAIL("Comparing the data failed: %d\n", incoming_data);
|
||||
incoming_state = 0;
|
||||
printf("Got: %s\n", hexdump(msg->l3h, len));
|
||||
printf("Wanted: %s\n", hexdump(test_data2->l3h, len));
|
||||
}
|
||||
}
|
||||
|
||||
/* sending out data */
|
||||
if (incoming_data == 2) {
|
||||
printf("\tReturning data3\n");
|
||||
sccp_connection_write(conn, test_data3);
|
||||
}
|
||||
}
|
||||
|
||||
static int sccp_conn_accept(struct sccp_connection *conn, void *ctx)
|
||||
{
|
||||
printf("\taccept: %p\n", conn);
|
||||
conn->state_cb = sccp_conn_in_state;
|
||||
conn->data_cb = sccp_conn_in_data;
|
||||
|
||||
if (current_con_test->refuse)
|
||||
return -1;
|
||||
|
||||
incoming_con = conn;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* callbacks for the outgoing side */
|
||||
static void sccp_conn_out_state(struct sccp_connection *conn, int old_state)
|
||||
{
|
||||
printf("\toutgoing: %p %d -> %d\n", conn, old_state, conn->connection_state);
|
||||
|
||||
if (conn->connection_state >= SCCP_CONNECTION_STATE_RELEASE_COMPLETE) {
|
||||
if (conn == outgoing_con) {
|
||||
sccp_connection_free(conn);
|
||||
outgoing_con = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sccp_conn_out_data(struct sccp_connection *conn, struct msgb *msg, unsigned int len)
|
||||
{
|
||||
++outgoing_data;
|
||||
printf("\toutgoing data: %p %d\n", conn, len);
|
||||
|
||||
if (len != 4)
|
||||
FAIL("Length of packet is wrong: %u %u\n", msgb_l3len(msg), len);
|
||||
|
||||
if (outgoing_data == 1) {
|
||||
if (memcmp(msg->l3h, test_data3->l3h, len) != 0) {
|
||||
FAIL("Comparing the data failed\n");
|
||||
outgoing_state = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void do_test_sccp_connection(const struct connection_test *test)
|
||||
{
|
||||
int ret;
|
||||
|
||||
current_con_test = test;
|
||||
outgoing_con = incoming_con = 0;
|
||||
|
||||
outgoing_con = sccp_connection_socket();
|
||||
if (!outgoing_con) {
|
||||
FAIL("Connection is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
outgoing_con->state_cb = sccp_conn_out_state;
|
||||
outgoing_con->data_cb = sccp_conn_out_data;
|
||||
outgoing_data = incoming_data = 0;
|
||||
incoming_state = outgoing_state = 1;
|
||||
|
||||
/* start testing */
|
||||
if (test->with_data) {
|
||||
if (sccp_connection_connect(outgoing_con, &sccp_ssn_bssap, test_data1) != 0)
|
||||
FAIL("Binding failed\n");
|
||||
} else {
|
||||
++incoming_data;
|
||||
if (sccp_connection_connect(outgoing_con, &sccp_ssn_bssap, NULL) != 0)
|
||||
FAIL("Binding failed\n");
|
||||
}
|
||||
|
||||
if (test->refuse) {
|
||||
if (outgoing_con)
|
||||
FAIL("Outgoing connection should have been refused.\n");
|
||||
} else {
|
||||
if (!incoming_con)
|
||||
FAIL("Creating incoming didn't work.\n");
|
||||
|
||||
printf("\tWriting test data2\n");
|
||||
sccp_connection_write(outgoing_con, test_data2);
|
||||
sccp_connection_send_it(outgoing_con);
|
||||
|
||||
/* closing connection */
|
||||
if (test->close_side == 0)
|
||||
ret = sccp_connection_close(outgoing_con, 0);
|
||||
else
|
||||
ret = sccp_connection_close(incoming_con, 0);
|
||||
|
||||
if (ret != 0)
|
||||
FAIL("Closing the connection failed\n");
|
||||
}
|
||||
|
||||
/* outgoing should be gone now */
|
||||
if (outgoing_con)
|
||||
FAIL("Outgoing connection was not properly closed\n");
|
||||
|
||||
if (incoming_con)
|
||||
FAIL("Incoming connection was not propery closed.\n");
|
||||
|
||||
if (test->refuse == 0) {
|
||||
if (outgoing_data != 1 || incoming_data != 2) {
|
||||
FAIL("Data sending failed: %d/%d %d/%d\n",
|
||||
outgoing_data, 1,
|
||||
incoming_data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!incoming_state || !outgoing_state)
|
||||
FAIL("Failure with the state transition. %d %d\n",
|
||||
outgoing_state, incoming_state);
|
||||
}
|
||||
|
||||
static void test_sccp_connection(void)
|
||||
{
|
||||
sccp_system_init(sccp_write_loop, NULL);
|
||||
sccp_set_read(NULL, NULL, NULL);
|
||||
sccp_connection_set_incoming(&sccp_ssn_bssap, sccp_conn_accept, NULL);
|
||||
|
||||
test_data1 = msgb_alloc(4, "data1");
|
||||
test_data1->l3h = msgb_put(test_data1, 4);
|
||||
*((unsigned int*)test_data1->l3h) = 0x23421122;
|
||||
|
||||
test_data2 = msgb_alloc(4, "data2");
|
||||
test_data2->l3h = msgb_put(test_data2, 4);
|
||||
*((unsigned int*)test_data2->l3h) = 0x42232211;
|
||||
|
||||
test_data3 = msgb_alloc(4, "data3");
|
||||
test_data3->l3h = msgb_put(test_data3, 4);
|
||||
*((unsigned int*)test_data3->l3h) = 0x2323ff55;
|
||||
|
||||
|
||||
for (current_test = 0; current_test < ARRAY_SIZE(connection_tests); ++current_test) {
|
||||
printf("Testing %d refuse: %d with_data: %d\n",
|
||||
current_test, connection_tests[current_test].refuse,
|
||||
connection_tests[current_test].with_data);
|
||||
do_test_sccp_connection(&connection_tests[current_test]);
|
||||
}
|
||||
|
||||
msgb_free(test_data1);
|
||||
msgb_free(test_data2);
|
||||
msgb_free(test_data3);
|
||||
}
|
||||
|
||||
/* invalid input */
|
||||
static void test_sccp_system_crash(void)
|
||||
{
|
||||
printf("trying to provoke a crash with invalid input\n");
|
||||
sccp_set_read(&sccp_ssn_bssap, sccp_read_cb, NULL);
|
||||
sccp_connection_set_incoming(&sccp_ssn_bssap, sccp_accept_cb, NULL);
|
||||
|
||||
for (current_test = 0; current_test < ARRAY_SIZE(test_data); ++current_test) {
|
||||
int original_length = test_data[current_test].length;
|
||||
int length = original_length + 2;
|
||||
int i;
|
||||
|
||||
printf("Testing packet: %d\n", current_test);
|
||||
|
||||
for (i = length; i >= 0; --i) {
|
||||
unsigned int length = MIN(test_data[current_test].length, i);
|
||||
struct msgb *msg = msgb_alloc_headroom(length + 2, 2, __func__);
|
||||
msg->l2h = msgb_put(msg, length);
|
||||
memcpy(msg->l2h, test_data[current_test].data, length);
|
||||
sccp_system_incoming(msg);
|
||||
msgb_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
printf("survived\n");
|
||||
}
|
||||
|
||||
static void test_sccp_parsing(void)
|
||||
{
|
||||
for (current_test = 0; current_test < ARRAY_SIZE(parse_result); ++current_test) {
|
||||
struct msgb *msg;
|
||||
struct sccp_parse_result result;
|
||||
|
||||
msg = msgb_alloc_headroom(1024, 128, "parse-test");
|
||||
msgb_put(msg, 1);
|
||||
msg->l2h = msgb_put(msg, parse_result[current_test].input_len);
|
||||
memcpy(msg->l2h, parse_result[current_test].input, msgb_l2len(msg));
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
if (sccp_parse_header(msg, &result) != 0) {
|
||||
fprintf(stderr, "Failed to parse test: %d\n", current_test);
|
||||
} else {
|
||||
if (parse_result[current_test].wanted_len != result.data_len) {
|
||||
fprintf(stderr, "Unexpected data length.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (parse_result[current_test].has_src_ref) {
|
||||
if (memcmp(result.source_local_reference,
|
||||
&parse_result[current_test].src_ref,
|
||||
sizeof(struct sccp_source_reference)) != 0) {
|
||||
fprintf(stderr, "SRC REF did not match\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_result[current_test].has_dst_ref) {
|
||||
if (memcmp(result.destination_local_reference,
|
||||
&parse_result[current_test].dst_ref,
|
||||
sizeof(struct sccp_source_reference)) != 0) {
|
||||
fprintf(stderr, "DST REF did not match\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_result[current_test].src_ssn != -1) {
|
||||
fprintf(stderr, "Not implemented.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (parse_result[current_test].dst_ssn != -1) {
|
||||
fprintf(stderr, "Not implemented.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
msgb_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_sccp_system();
|
||||
test_sccp_send_udt();
|
||||
test_sccp_udt_communication();
|
||||
test_sccp_connection();
|
||||
test_sccp_system_crash();
|
||||
test_sccp_parsing();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void db_store_counter() {}
|
||||
Reference in New Issue
Block a user