Rewrite-Rules ред за обработка на заявките

 Rewrite-Rules ред за обработка на заявките

  Когато Pi-Star се постави в режим Gateway се работи по един конфигурационен файл достъпен през меню:

 Configuration -> Expert -> DMR GW

Ето го и самият файл копиран от работещ симплексен спот:

--------------------------------------------------------------------------------------------------------------------

[General]
RptAddress=127.0.0.1
RptPort=62032
LocalAddress=127.0.0.1
LocalPort=62031
RuleTrace=0
Daemon=1
Debug=0
RFTimeout=20
NetTimeout=20

[Log]
DisplayLevel=0
FileLevel=1
FilePath=/var/log/pi-star
FileRoot=DMRGateway

[Voice]
Enabled=1
Language=en_GB
Directory=/usr/local/etc/DMR_Audio

[Info]
Enabled=0
RXFrequency=439900000
TXFrequency=439900000
Power=1
Latitude=42.163358
Longitude=24.793430
Height=0
Location="OpenGD77"
Description="Bulgaria"
URL=https://www.qrz.com/db/LZХХХХ

[XLX Network]
Enabled=1
Id=1234567*
Startup=800
Module=B
File=/usr/local/etc/XLXHosts.txt
Port=62030
Password="passw0rd"
ReloadTime=60
Slot=2
TG=6
Base=64000
Relink=60
Debug=0
UserControl=1

[DMR Network 1]
Enabled=1
Id=123456701**
Address=2841.master.brandmeister.network
Port=62031
TGRewrite0=2,9,2,9,1
PCRewrite0=2,94000,2,4000,1001
TypeRewrite0=2,9990,2,9990
SrcRewrite0=2,4000,2,9,1001
PassAllPC0=1
PassAllTG0=1
PassAllPC1=2
PassAllTG1=2
Password="Password from BM"
Debug=0
Location=1
Name=BM_2841_Bulgaria

[DMR Network 2]
Enabled=1
Id=123456702**
Address=185.80.0.40
Password="PASSWORD"
Port=55555
TGRewrite0=2,8,2,9,1
TGRewrite20=2,284023,2,284,1
PCRewrite0=2,84000,2,4000,1001
Debug=0
Location=0
Name=DMR+_IPSC2-BG-Hotspot
Options="TS1_1=284;"

[DMR Network 3]
Id=123456703**
Enabled=1
Name=HBLink LZ5PN
Address=kario88.freeddns.com
Port=62031
Password="passw0rd"
Location=0
Debug=0
TGRewrite0=2,11,2,11,1
TGRewrite30=2,9999,2,9999,1

[DMR Network 4]
Enabled=1
Id=123456704**
#Name=FreeDMR_Bulgaria
#Address=sofia.freedmr.link
Name=FreeDMR LZ5PN-2
Address=75b7068e56f6.sn.mynetname.net
#Name=FreeDMR_Bulgaria
#Address=sofia.freedmr.link
Port=62031
Password="passw0rd"
Location=0
Debug=0
Options="TS1_1=284;"
TGRewrite201=2,284799,1,284,1

[GPSD]
Enable=0
Address=127.0.0.1
Port=2947

[APRS]
Enable=1
Address=127.0.0.1
Port=8673
Description=APRS for DMRGateway
Suffix=DMR

[Dynamic TG Control]
Enabled=1
Port=3769

--------------------------------------------------------------------------------------------------------------------

 * Да се замени със вашето ID което е 7 цифри а за репитер 6 цифри.

** Да се замени със вашето ID което е 7 цифри и се добавият още две цифри като разширение с което вашето ID става 9 цифри. Последните две цифри са в обхвата от 00 до 99. За всяка мрежа трябва да бъдат различни. Ако имате повече от един спот не трябва да се дублират. За репитер се използват само 6 цифри и не се добавя разширение. За всички мрежи репитрите използват само 6 цифрени IDта.

--------------------------------------------------------------------------------------------------------------------

Интерес тук представляват правилата TGRewrite и PassAllTG.

Правилата са описани тук:

 https://github-wiki-see.page/m/g4klx/DMRGateway/wiki/Rewrite-Rules

Има една особенност която не е описана а именно, редът по който се обработват правилата.

Както съм го описвал и в старият ми блог цифровата комуникация е пакетно предаване на данни при което на всеки пакет радиото поставя адрес на подателя и адрес на получателя. В тези пакети има само ID на подателя и TG на получателя.

За това кой пакет накъде ще се насочи се грижат TGRewrite и PassAllTG правилата следвайки следният ред:

1. TGRewrite

2. PassAllTG

И така ако TG на получателя не съвпада с нито едно от TGRewrite правилата то тогава пакетът се насочва към PassAllTG.

Тези правила, PassAllTG, са само две за целият конфигурационен файл, по едно за всеки слот.

Както може би забелязвате имаме секции [DMR Network Х]

Всяка една подобна секция се отнася за един DMR Network сървър.

 PassAllTG правила може да има само за първи и втори слот и то само за един DMR Network сървър в целият конфигурационен файл.

Допуска се PassAllTG правилото за единият от двата слота да бъде в секцията на единият от DMR Network сървърите а PassAllTG правилото за другият от двата слота да бъде в секцията на друг от DMR Network сървърите.

Какво означава това?

Примерно: 

[DMR Network 1] която има PassAllTG0=1 ще пренасочва всички заявки за TG не включени във TGRewrite правилата идващи от първи слот към [DMR Network 1]

[DMR Network 2] която има PassAllTG1=2 ще пренасочва всички заявки за TG не включени във TGRewrite правилата идващи от втори слот към [DMR Network 2]

Ако във конфигурационният файл няма PassAllTG правила за единият или другият слот то тогава заявките несъответстващи на нито едно TGRewrite правило се игнорират и не се обработват. 

Ето ги и самите правила:

Rewrite Rules - g4klx/DMRGateway GitHub Wiki

General Usage

DMR Gateway will only pass traffic to the different networks if it's referenced in a rewrite rule in the .ini file.

TGRewrite

TGRewrite allows you to translate one talk group ID to another, and to alter the time slot. TGRewrite can also be used to route a talk group and slot combination to a particular network. 'from' applies to DMR frames entering the Gateway via MMDVMHost (RF), and 'to' is where they are routed on the network side (Net). The rules apply to DMR frames traversing the gateway in both directions.

Syntax
TGRewrite=fromSlot,fromTG,toSlot,toTG,range
Examples

The rule below will translate a group call to talk group talk group 8 to talk group 9 on DMR Network 1.

[DMR Network 1] 

# Reflector TG on to slot 2 TG8
TGRewrite=2,8,2,9,1

The rules below will route a group call to 9990 on time slot 1 to DMR Network 1, and a group call to 9990 on time slot 2 to DMR Network 2.

[DMR Network 1]

# Echo on slot 1 TG9990
TGRewrite=1,9990,2,9990,1

[DMR Network 2]

# Echo on slot 2 TG9990
TGRewrite=2,9990,2,9990,1

PCRewrite

This is almost identical to the TGRewrite except it only operates on private calls. PCRewrite can be used to add a prefix on a private call to a reflector to 'steer' them to a particular network. The prefix will then be removed before being routed to the DMR network. The rules apply to DMR frames traversing the gateway in both directions. This rule only works on DMR frames passing from the RF side to the network.

Typically used to remap reflector control calls to a different local range to avoid clashes, and for permitting GPS position reports and private calls to a particular network.

Syntax
PCRewrite=fromSlot,fromId,toSlot,toId,range
Examples

The rules below will route any private calls on time slot 2 in the range 94000 - 95000 to 4000 - 5000 on DMR Network 1, and the range 84000 - 85000 to 4000 - 5000 on DMR Network 2.

[DMR Network 1]

# Reflector control command slot 2 94000->4000 to 95000->5000
PCRewrite=2,94000,2,4000,1001

[DMR Network 2]

# Reflector control command slot 2 84000->4000 to 85000->5000
PCRewrite=2,84000,2,4000,1001

SrcRewrite

SrcRewrite will rewrite the source/from Talk Group ID to another ID.

Syntax
SrcRewrite=fromSlot,fromId,toSlot,toTG,range
Examples

The rule below will rewrite calls from 4000-5000 on DMR Network 1, to talk group 9 on slot 2. This is useful for ensuring reflector announcements are heard on talk group 9. This rule only works on DMR frames passing from the network side to the RF side.

[DMR Network 1]

# Reflector status returns
SrcRewrite=2,4000,2,9,1001

TypeRewrite

TypeRewrite maps a group call to a private call. This rule only works on DMR frames passing from the RF side to the network side.

Syntax

TypeRewrite==fromSlot,fromId,toSlot,toId

Example

The rules below translate a group call to 9990 on slot 1, to a private call on DMR Network 1. The SrcRewrite rule then allows the reply to traverse the gateway.

This could be used for converting Brandmeister's private call echo service to a group call method like DMR+, to make the usage more uniform across the networks.

[DMR Network 1]

# Echo on RF slot 1 TG9990 to network slot 1 9990
TypeRewrite=1,9990,1,9990
SrcRewrite=1,9990,1,9990,1

PassAllTG

Passes all talk groups without specific matching rules, and can only be used on a single DMR network. The rules apply to DMR frames traversing the gateway in both directions.

Syntax

PassAllTG=Slot

Example

The rules below allow group calls to traverse from DMR network 2 to either time slot on the RF side.

[DMR Network 2]
# Pass all of the other talk group traffic on slot 1 and slot 2
PassAllTG=1
PassAllTG=2

PassAllPC

Passes all private calls without specific rules, and can only be used on a single DMR network. The rules apply to DMR frames traversing the gateway in both directions.

Syntax

PassAllPC=Slot

Example

The rules below allow private calls to traverse from DMR network 2 to either time slot on the RF side.

[DMR Network 2]
# Pass all of the other private traffic on slot 1 and slot 2
PassAllPC=1
PassAllPC=2

Ако имате въпроси по статията може да ме намерите на TG 284 или 284359 BrandMeister.

73 de LZ5PN