Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Trema::PacketIn の拡張を別ファイルに分離

  • Loading branch information...
commit b0fd759d0b555a1ca142079a7e01a88a00554ac1 1 parent e6344b4
Yasuhito Takamiya authored

Showing 2 changed files with 38 additions and 31 deletions. Show diff stats Hide diff stats

  1. +37 0 lib/packet-in.rb
  2. +1 31 script/tabi.rb
37 lib/packet-in.rb
... ... @@ -0,0 +1,37 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Trema::PacketIn にいくつか便利メソッドを追加
  3 +class Trema::PacketIn
  4 + def http?
  5 + tcp_dst_port == 80 or tcp_dst_port == 3000
  6 + end
  7 +
  8 +
  9 + def https?
  10 + tcp_dst_port == 443
  11 + end
  12 +
  13 +
  14 + def dhcp?
  15 + ( udp_src_port == 67 and udp_dst_port == 68 ) or ( udp_src_port == 68 and udp_dst_port == 67 )
  16 + end
  17 +
  18 +
  19 + def dhcp_pack?
  20 + # [TODO] ちゃんとパーズする
  21 + if udp_src_port == 67 and udp_dst_port == 68
  22 + data.unpack( "H*" )[ 0 ][ -116, 2 ] == "05"
  23 + end
  24 + end
  25 +
  26 +
  27 + def dns?
  28 + udp_dst_port == 53
  29 + end
  30 +end
  31 +
  32 +
  33 +### Local variables:
  34 +### mode: Ruby
  35 +### coding: utf-8
  36 +### indent-tabs-mode: nil
  37 +### End:
32 script/tabi.rb
@@ -4,40 +4,10 @@
4 4
5 5 require "config"
6 6 require "fdb"
  7 +require "packet-in"
7 8 require "user-db"
8 9
9 10
10   -# Trema::PacketIn にいくつか便利メソッドを追加
11   -class Trema::PacketIn
12   - def http?
13   - tcp_dst_port == 80 or tcp_dst_port == 3000
14   - end
15   -
16   -
17   - def https?
18   - tcp_dst_port == 443
19   - end
20   -
21   -
22   - def dhcp?
23   - ( udp_src_port == 67 and udp_dst_port == 68 ) or ( udp_src_port == 68 and udp_dst_port == 67 )
24   - end
25   -
26   -
27   - def dhcp_pack?
28   - # [TODO] ちゃんとパーズする
29   - if udp_src_port == 67 and udp_dst_port == 68
30   - data.unpack( "H*" )[ 0 ][ -116, 2 ] == "05"
31   - end
32   - end
33   -
34   -
35   - def dns?
36   - udp_dst_port == 53
37   - end
38   -end
39   -
40   -
41 11 # Facebook を使った認証 VLAN っぽいことをするための OpenFlow コントローラ
42 12 class Tabi < Controller
43 13 SERVICE_VM_PORT = 1

0 comments on commit b0fd759

Please sign in to comment.
Something went wrong with that request. Please try again.