This repository has been archived by the owner on Apr 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
expression-test.php
65 lines (60 loc) · 1.53 KB
/
expression-test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require 'pcapFilterExpression.php';
$expr = new pcapFilterExpression();
// Simple test
try {
// initialize class
$expr->init();
// compile expression
$expr->begin()
->host('192.168.0.2')
->concate()
->port(5060)
->end();
// Echo the expression
echo $expr->getPcapFilterExpressionString() . "\r\n";
} catch (InvalidArgumentException $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
} catch (Exception $e) {
echo $e->getMessage();
}
// Port range test
try {
// initialize class
$expr->init();
// compile expression
$expr->begin()
->host('192.168.0.2')
->concate()
->port_range(5060, 5061)
->end();
// Echo the expression
echo $expr->getPcapFilterExpressionString() . "\r\n";
} catch (InvalidArgumentException $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
} catch (Exception $e) {
echo $e->getMessage();
}
// Two host test
try {
// initialize class
$expr->init();
// compile expression
$expr->begin()
->host('192.168.0.2')
->alternate()
->host('192.168.0.3')
->group()
->concate()
->port(5060)
->end();
// Echo the expression
echo $expr->getPcapFilterExpressionString() . "\r\n";
} catch (Exception $e) {
echo $e->getMessage();
} catch (InvalidArgumentException $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
} catch (Exception $e) {
echo $e->getMessage();
}
?>