-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.web.ajOnuMenu(Bdcom_epon)_setVlan.pl
More file actions
41 lines (40 loc) · 2.04 KB
/
patch.web.ajOnuMenu(Bdcom_epon)_setVlan.pl
File metadata and controls
41 lines (40 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'menu_settings', after=>['Ponmon']
push @menuItems, { order => 50, title => L('!test_SetVlan'), act=>'setvlanOnuBdcom' } if lc($p{vendor}) =~ 'bdcom' && (lc($p{model}) =~ '33' || lc($p{model}) =~ m/^p36/i);
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'subs', after=>['Ponmon']
sub act_setvlanOnuBdcom {
# 2024.08.31
# https://t.me/MrMethod
my $attr = shift;
my $sn = $attr->{sn};
$sn =~ s/[\:\-\.]//g;
$sn =~ s/(....)(?=.)/$1\./g if $attr->{pon_type} eq 'epon';
$attr->{snx} = $sn;
debug $sn;
debug('pre', $attr);
my $form = _('[p][p][p]', L('Enter vlan id'), v::tag('input', type=>'number', name=>'vlan', size=>16, min=>1, max=>4095, autofocus=>1, 'required'), v::submit($lang::btn_Execute));
return $ajax_url->form(-class=>'ajax', act=>'reconfOnuBdcom', -method=>'post', $form) unless (ses::input_int('vlan'));
my $vlan = ses::input_int('vlan');
ToLog(L('Call reconfOnuBdcom [] sn=[]', $attr->{reconfType}, $sn));
my $tc = _telnetConnect($attr);
_tnCmd($tc, "\n");
debug $tc->last_prompt();
if ($tc->last_prompt() =~ m/\#$/) {
_tnCmd($tc, "config");
if ($tc->last_prompt() =~ m/config\#$/) {
_tnCmd($tc, "interface $attr->{name}");
if ($tc->last_prompt() =~ m/\Qconfig_$attr->{name}#\E$/i) {
_tnCmd($tc, "epon onu port 1 ctc vlan mode tag $vlan priority 0");
_tnCmd($tc, "exit");
_tnCmd($tc, "write all");
_tnCmd($tc, "write");
$attr->{reconf}{ok} = "set vlan $vlan for onu sn=$sn";
} else { $attr->{reconf}{err} = "Something went wrong: ".$tc->last_cmd; }
_tnCmd($tc, "exit");
} else { $attr->{reconf}{err} = "Something went wrong: ".$tc->last_cmd; }
_tnCmd($tc, "exit");
} else { $attr->{reconf}{err} = "not in 'enable' mode"; }
_telnetClose($tc);
return $attr->{reconf}{err} if defined $attr->{reconf}{err};
return $attr->{reconf}{ok} if defined $attr->{reconf}{ok};
return "Backend not defined";
}