ãã©ã°ã€ã³ã¢ãŒããã¯ãã£ã®æŠèŠ
補åã®ä»¥åã®2çªç®ã®ããŒãžã§ã³ãšåæ§ã«ãIO Ninjaã®3çªç®ã®ããŒãžã§ã³ã®å®è¡å¯èœãã¡ã€ã«ã«ã¯ãå¿ èŠãªã³ã³ããŒãã³ãã®ãã¬ãŒã ã¯ãŒã¯ã®ã¿ãå«ãŸããŸãïŒUIãŠã£ãžã§ããããã®ã³ã°ãšã³ãžã³ãio.Socketãio.Serialãio.PCapãªã©ã®IOãæäœããããã®ã¯ã©ã¹ãå«ãïŒ .dãïŒã ç¹å®ã®ãã©ã³ã¹ããŒããæäœããããžãã¯ã¯ã Jancyèšèªã§èšè¿°ããããã©ã°ã€ã³ã«å«ãŸããŠããŸãã ãããã®ãã©ã°ã€ã³ã¯ãéžæããã¹ã¯ãªãããã©ã«ããŒã«ãœãŒã¹ã³ãŒãã®åœ¢åŒã§ããããŠãŒã¶ãŒã«ããã¬ãã¥ãŒãšç·šéã®äž¡æ¹ã«äœ¿çšã§ããŸãã
ãã«ãã€ã³ãã©ã°ã€ã³ã®å€æŽã«å ããŠã2çš®é¡ã®ã«ã¹ã¿ã ãã©ã°ã€ã³ã䜿çšããŠäžè¶³ããŠããæ©èœãè¿œå ããããšãã§ããŸãã
- ã»ãã·ã§ã³ãã©ã°ã€ã³-éã;
- ã¬ã€ã€ãŒãã©ã°ã€ã³ã¯è»œéã§ãã
ãã©ã°ã€ã³ã®æåã®ã¿ã€ãã¯ãã»ãã·ã§ã³ããŒãããäœæããæ¬æ Œçãªã»ãã·ã§ã³ãã©ã°ã€ã³ã§ãã äžè¬çãªã»ãã·ã§ã³ãã©ã°ã€ã³ã§å®è£ ããå¿ èŠããããã®ã¯æ¬¡ã®ãšããã§ãã
- ãã°ãšã³ããªã®åœ¢åŒã®æ±ºå®ãšãã°ã¬ããŒã¿ãŒã®äœæ-ãã°ãšã³ããªã人éãèªããæçµçãªè¡šçŸã«å€æããæ©èœã
- UI圢æïŒã¡ãã¥ãŒãããŒã«ããŒã®ãã¿ã³ãããããã£ãšãã£ã¿ãŒã®ããããã£ãªã©ïŒ;
- ãã©ã³ã¹ããŒãããã³ãã®ä»ã®IOãªããžã§ã¯ãïŒãœã±ãããããŒãããã¡ã€ã«ãªã©ïŒã®äœæ;
- UIãŠã£ãžã§ãããšIOãªããžã§ã¯ãããã®ã€ãã³ããåŠçãããã¹ãŠããªã³ã¯ããŸãã äŸãã°æ¥ç¶ãã¿ã³ãã¯ãªãã¯ããŠãæ¥ç¶èšå®ããã»ã¹ãéå§ããã³ãŒããstart-install-connectionããšãªã¢ãŒãããŒãã®ã¢ãã¬ã¹ã説æããããŒã¿ã§ãã°ã«èšé²ãäœæããå¿ èŠããããŸãã æ¥ç¶ã®æåŸã«ã察å¿ãããã°ãšã³ããªãäœæããUIãæŽæ°ããŸãïŒç¹ã«[éä¿¡]ãã¿ã³ã®éžæã解é€ããŸãïŒã
ååãšããŠãã»ãã·ã§ã³ãã©ã°ã€ã³ã䜿çšãããšããªã¯ãšã¹ãã¬ã¹ãã³ã¹ã®ç¹å®ã®ã·ãŒã±ã³ã¹ã®ãã¹ãããæ¬æ Œçãªãããã³ã«ã¢ãã©ã€ã¶ãŒãŸã§ãããããã¿ã¹ã¯ã®ãœãªã¥ãŒã·ã§ã³ãäœæã§ããŸãã ãã ããçµã¿èŸŒã¿ã®IOå¿è ã»ãã·ã§ã³ã®ãœãŒã¹ã³ãŒãã«ç²ŸéããŠããªããŠããæ¬æ Œçãªã»ãã·ã§ã³ã®äœæã¯ããªãæéã®ãããããã»ã¹ã§ãããã©ããããããã¿ã€ãã³ã°ãšãã²ããŸããããã¹ãã¹ã¯ãªããã®äœæã«ã¯ããŸãé©ããŠããŸããã ããã«ããã©ã³ã¹ããŒãæ¥ç¶ãæäœããããžãã¯ãåå®è£ ããããã³ããŒã¢ã³ãããŒã¹ããããããããããŸããã çµå±ã®ãšãããããã¯ãã¹ãŠæšæºãã©ã°ã€ã³ã§æ¢ã«è¡ãããŠããã®ã§ãããåå©çšã¯ã©ãã§ããããïŒ æåŸã«ããã«ã»ãã·ã§ã³ã倧èŠæš¡ã«èšè¿°ãããšããã¹ãŠã1ã€ã®ç¹å®ã®ãã©ã³ã¹ããŒãã«ãã€ã³ããããŸãããããšãã°ãè€æ°ã®ç°ãªããã©ã³ã¹ããŒãã§ç¹å®ã®ãªã¯ãšã¹ãã·ãŒã±ã³ã¹ãäžåºŠã«ãã§ãã¯ããå¿ èŠãããå ŽåããããŸãã åæ§ã«ããããã³ã«ã¢ãã©ã€ã¶ãŒã¯ãå€ãã®å Žåãé ä¿¡å ã®ãã©ã³ã¹ããŒãã«é¢ä¿ãªããããŒã¿ã解æããã ãã§æžã¿ãŸãã
äžèšã®ãã¹ãŠã®åé¡ã解決ããããã«ãIO Ninjaã¯2çªç®ã®ã¿ã€ãã®ãã©ã°ã€ã³-ç°¡åãªã¬ã€ã€ãŒãã©ã°ã€ã³ãæäŸããŸãã
ãã©ã°ã€ã³ã¬ã€ã€ãŒã¯åç¬ã§ã¯æ©èœããŸããã 代ããã«ããã£ãªã¢ã»ãã·ã§ã³ã«æ¥ç¶ããããã«å¿ããŠæ©èœãæ¡åŒµããŸãã 圌ã¯ãããè¡ãããšãã§ããŸãïŒ
- ãã°ã¬ããŒã¿ãŒã®å€æŽã
- ãã°ãã£ã«ã¿ãŒãæ·»ä»ããŠãäžèŠãª/èå³ã®ãªããšã³ããªãããã¹ã¯ãããŸãã
- ãããã³ã«ã¡ãã»ãŒãžããã³ãŒãããããã«ããã°ã³ã³ããŒã¿ãŒãæ¥ç¶ããŠã»ã«ã³ããªãã°ãçæããŸãïŒããã«ã¯éåžžããã°è¡šçŸã®å€æŽãå¿ èŠã§ãïŒã
- ãã£ãªã¢ã»ãã·ã§ã³ã®ã€ãã³ããç£èŠããå Žåã«ãã£ãŠã¯ããã€ãã®å¿çã¢ã¯ã·ã§ã³ãå®è¡ããããã®ãã°ãªã¹ããŒã®æ¥ç¶ã
- ãã£ãªã¢ã»ãã·ã§ã³ã®UIã«å ããŠãç¬èªã®UIèŠçŽ ãäœæããŸãã
ãã©ã°ã€ã³ã¬ã€ã€ãŒã¯ãã»ãšãã©ã®å®çšçãªã¿ã¹ã¯ã®ããã«èšè¿°ããå¿ èŠããããã®ã§ãã
IDE
Jancyã§ã®ãã¹ãŠã®çš®é¡ã®IO Ninjaãã©ã°ã€ã³ã®éçºã容æã«ããããã«ãIO Ninja IDEã®ãã€ãã£ãçµ±åéçºç°å¢ãæäŸããŸãã ãã®ç°å¢ã¯ã NetBeansãã©ãããã©ãŒã ã«åºã¥ããŠãããæ§æã®åŒ·èª¿è¡šç€ºãèªåè£å®ãªã¹ããåŒæ°ã®ãã³ããå®çŸ©ãžã®ç§»åãªã©ããã¹ãŠã®æšæºã³ãŒãã¢ã·ã¹ãããŒã«ãæäŸããŸãã ããã«ãå žåçãªãã©ã°ã€ã³ã®ãã³ãã¬ãŒããçæããããã®ãŠã£ã¶ãŒãããããŸãã
ãã®éçºç°å¢ã«ã¯2ã€ã®ããªãšãŒã·ã§ã³ããããŸãã 1ã€ã¯ç¬ç«ããIO Ninja IDEããã±ãŒãžã§ãã¹ã¿ã³ãã¢ãã³è£œåãšããŠã€ã³ã¹ããŒã«ãããŸãã 2çªç®ã®ããªãšãŒã·ã§ã³ã¯ããããžã§ã¯ãã«ãã§ã«NetBeansã䜿çšããŠããéçºè ã«é©ããŠããŸãïŒç§ãå«ãç§ãã¡ã®ãªãã£ã¹ã®è€æ°ã®ããã°ã©ããŒãªã©ïŒã ãã®å Žåãåå¥ã®IO Ninja IDEãã€ã³ã¹ããŒã«ãã代ããã«ãIO Ninjaçšã®NetBeansãã©ã°ã€ã³ãæ¢åã®NetBeansã€ã³ã¹ããŒã«ã«è¿œå ã§ããŸãã æåãš2çªç®ã®äž¡æ¹ã®ãªãã·ã§ã³ã¯ã http ïŒ //tibbo.com/ioninja/downloads.htmlã§ååŸã§ããŸãã
äœããã®çç±ã§NetBeansãæ°ã«å ¥ããªãããŸãã¯IDEãèªèããªãéçºè ã¯ããæ°ã«å ¥ãã®ããã¹ããšãã£ã¿ãŒïŒvimãemacsãsublimeãnotepadïŒã§ãã©ã°ã€ã³ã®éçºãäž»å°ã§ããŸãã
次ã«ãIO Ninja IDEã䜿çšããŠæšæºãã©ã°ã€ã³ããŒãããäœæããããã»ã¹ã瀺ããŸãã ãã©ã°ã€ã³ãæ©èœãããã¹ããããã³ã«ãšããŠãTibboããã°ã©ããã«ããã€ã¹ãã€ã³ã¿ã©ã¯ãã£ããªã¯ãã¹ãããã¬ãŒãšéä¿¡ããããã®å®éã®ãããã³ã«ã䜿çšããŸãã ãã¹ãã«ã¯ãTibboããã°ã©ããã«ããã€ã¹çšã®TIDEçµ±åéçºç°å¢ã®äžéšã§ããããã€ã¹ãšã¯ã¹ãããŒã©ãŒã䜿çšã§ããŸãïŒTIDEãŸãã¯å¥ã®ããã€ã¹ãšã¯ã¹ãããŒã©ãŒã¯ã http ïŒ //tibbo.com/downloads/basic/software.htmlããããŠã³ããŒãã§ããŸãïŒã
ããã§ã¯å§ããŸãããã
çå®çªé»è©±
æåã«äœæãããã©ã°ã€ã³ã¯ãç¹å®ã®ãããã³ã«ïŒãã®äŸã§ã¯Tibboããã°ã©ããã«ããã€ã¹ã®ãããã³ã«ïŒã®ãµãŒããŒããšãã¥ã¬ãŒããããã®ãããã³ã«ã®ã¯ã©ã€ã¢ã³ãéšåã®ãã¹ãã«åœ¹ç«ã¡ãŸãã ã€ãŸãããã©ã°ã€ã³ã¯çå®çªé»è©±ã®æ©èœãå®è¡ããŸããã€ãŸããããŒã¿ãåŸ æ©ãããã±ããã§åéããå¿çããŠäœããåæããŠéä¿¡ããŸãã
IO Ninja IDEïŒãŸãã¯IO Ninjaçšã®ãã©ã°ã€ã³ãåããNetBeansïŒãèµ·åããïŒãã¡ã€ã«ïŒ->ïŒæ°èŠãããžã§ã¯ãïŒã¡ãã¥ãŒé ç®ãã¯ãªãã¯ããŠããããžã§ã¯ãã«ããŽãªãéžæããŸãïŒã«ããŽãª-IO Ninjaããããžã§ã¯ã-ãã©ã°ã€ã³ãããžã§ã¯ãïŒåå¥ã®IO Ninja IDEã䜿çšãããå Žåããããã®ã«ããŽãªã¯å©çšã§ããå¯äžã®ãã®ïŒã 次ã®ç»é¢ã§ããã©ã°ã€ã³ã¿ã€ã-çå®çªé»è©±ãã©ã°ã€ã³ãã³ãã¬ãŒããéžæããæå³ã®ããååããããžã§ã¯ãåã«å ¥åããŠïŒããšãã°ãTiosEmuïŒã[次ãž]ãã¯ãªãã¯ããŸãã
æååèšè¿°åã®æ¬¡ã®ç»é¢ïŒã¬ã€ã€ãŒåãã¬ã€ã€ãŒã®èª¬æãªã©ïŒãå ¥åãã[å®äº]ãã¿ã³ãã¯ãªãã¯ãããšããã©ã°ã€ã³ã®äœæ¥ã³ã¢ãçæãããŸããåæãã©ãŒã ã§ã¯ããã©ã°ã€ã³ã¯ã³ãã³ããhelpãããaboutãããversionãæåCRïŒãã£ãªããžãªã¿ãŒã³ïŒãŸãã¯LFïŒæ¹è¡ïŒã§å®äºããŸãã
ãã©ã°ã€ã³ãå®è¡ããŠãåäœã確èªããŸãã äžèšã®ããã«ããã©ã°ã€ã³ã¬ã€ã€ãŒã¯åç¬ã§ã¯æ©èœããããã©ã³ã¹ããŒããæäŸãããã£ãªã¢ã»ãã·ã§ã³ãå¿ èŠã§ãã ãã©ã°ã€ã³ã¬ã€ã€ãŒãåããŠèµ·åãããšãIO Ninja IDEã¯ãã£ãªã¢ã»ãã·ã§ã³ãšããŠäœ¿çšãããã®ãå°ããŸãã
ãã¹ãã®ããã«ãTCPãªã¹ããŒãã¢ããã¿ãŒããã¹ãŠã®IPv6ã¢ããã¿ãŒããããŒã1001ãéžæããããªãã¹ã³ããã¯ãªãã¯ããŸãã TCPæ¥ç¶ã®2çªç®ã®ã»ãã·ã§ã³ãéããŸãããªã¢ãŒãã¢ãã¬ã¹ã¯ã[:: 1]ïŒ1001ãã[æ¥ç¶]ãã¯ãªãã¯ããŸãïŒãæ³åã®ãšãããããã¯ããŒãžã§ã³3.4.0ã§ç»å ŽããIPv6ãµããŒãã®æ§ãããªãã¢ã³ã¹ãã¬ãŒã·ã§ã³ã§ãã;ïŒ
ããã§ãã³ãã³ããhelpãããaboutãããŸãã¯ãversionãïŒããŒã¹ã䜿çšã§ããŸãïŒãéä¿¡ããçµæã楜ãã¿ãŸãïŒ
ãã©ã°ã€ã³ãå°ãåæããŠã¿ãŸãããã TiosEmuLayer.jncãã©ã°ã€ã³ã®åäžã®ãœãŒã¹ãã¡ã€ã«ãéããŸãã ãã©ã°ã€ã³ã¯åºæ¬çã«ãã¬ã€ã€ãŒãã©ã°ã€ã³ã®åºæ¬ã¯ã©ã¹ã§ããdoc.Layerããç¶æ¿ããã1ã€ã®TiosEmuLayerã¯ã©ã¹ã§æ§æãããŸãïŒCtrl +ã¯ãªãã¯ã䜿çšããŠãAPI宣èšãããŠã©ãŒã¯ã¹ã«ãŒãããå©çšå¯èœãªIO Ninjaã³ã³ããŒãã³ãã®ãã¬ãŒã ã¯ãŒã¯ã«æ £ããããšãã§ããŸãïŒã
ãã©ã°ã€ã³ã®ã³ã³ã¹ãã©ã¯ã¿ãŒãèŠãŠã¿ãŸãããã
construct (doc.PluginHost* pluginHost) { basetype.construct (pluginHost); m_rxScanner.construct (scanRx); pluginHost.m_log.attachListener (onLogRecord @ pluginHost.m_mainThreadScheduler); }
1è¡ç®ãš2è¡ç®ã¯ã³ã¡ã³ããªãã§æ確ã§ã-ããã¯ããæ³åã®ãšããã芪ã¯ã©ã¹ãšã¡ã³ããŒãã£ãŒã«ãã®ã³ã³ã¹ãã©ã¯ã¿ãŒã®åŒã³åºãã§ãã ãã ããæåŸã®è¡ã«ã¯èª¬æãå¿ èŠã§ãã
IO Ninjaã®ãã°ãã¡ã€ã«ã¯äžé£ã®ã¬ã³ãŒãã§ãããåã¬ã³ãŒãã«ã¯ã¿ã€ã ã¹ã¿ã³ããæŽæ°ã¬ã³ãŒãã³ãŒããããã³ïŒãªãã·ã§ã³ã§ïŒä»»æã®ãã€ããªããŒã¿ã®ãããã¯ãå«ãŸããŠããŸãã ããã«ããã®ãããã¯ã¯ããŠãŒã¶ãŒããã°ãŠã£ã³ããŠã«è¡šç€ºãã圢åŒã§ããã¹ãèªäœãéã°ãªãããšã«æ³šæããŸããããã®ããã¹ãã埩å ããããã«å¿ èŠãªãã©ã¡ãŒã¿ãŒïŒä»£è¡šçãªæ©èœã®å©ããåãããã°ã®ããã¹ãè¡ã®åŸ©å ã«ã€ããŠã¯ãã»ã¯ã·ã§ã³ã§è©³ãã説æããŸããããã³ã«ã¢ãã©ã€ã¶ãŒãã©ã°ã€ã³ã®äœæå°çšïŒã
ã»ãã·ã§ã³ãã©ã°ã€ã³ãããŒã¿ãåä¿¡ãŸãã¯éä¿¡ãããšã察å¿ãããšã³ããªããã°ã«è¿œå ãããŸãã ãã©ã°ã€ã³ã¬ã€ã€ãŒã¯ãæ°ãããšã³ããªã®ãã°ããç£èŠãããç®çã®ãšã³ããªïŒRXãªã©ïŒãéžæããããã«å¿ããŠããã€ãã®ã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸãã
ãã®ã¢ãã«-æåã¯ããäžèªç¶ã«èŠãããããããŸãããïŒãã°ã®ä»£ããã«ãœã±ããã§ã€ãã³ããããã«ç£èŠããªãã®ã¯ãªãã§ããïŒïŒãããã€ãã®ãã©ã¡ãŒã¿ãŒã«åŸã£ãŠéžæãããŸããïŒå®è£ ã容æã§ãééçã§äºæž¬å¯èœã§ãä»»æã®æ§è³ªã®ãã©ã°ã€ã³ã®çžäºäœçšã®æšæºåãæäŸããŸããåŠçã«ã¹ã±ãŒãã®äœæã匷åãªæ¥ç¶æ§ã®å°å ¥ãªã©ã ãã¡ããããã®ã¢ãã«ã«ã¯äžå®ã®å¶éããããŸãããããã§ã¯è©³ãã説æããŸããã
attachListenerã¡ãœããã¯ããã°ãªã¹ããŒãè¿œå ããã ãã§ãã 次ã®éèªæãªç¹ã¯ãç¬@ã®äœ¿çšã§ãã Jancyã§ã¯ãç¬@ïŒãã§èªããïŒã¯ãã€ããªã¬ã€ã¢ãŠãæŒç®åãæå®ããŠãæ£ããç°å¢ã§åŒã³åºãããããšãä¿èšŒãããŠããé¢æ°ãžã®ãã€ã³ã¿ãŒãäœæããŸãã ãã®å Žåããã©ã°ã€ã³ã®ã¡ã€ã³ã¹ã¬ããã§ãªã¹ããŒãåŒã³åºãå¿ èŠããããŸãã
ãªã¹ããŒå ã§ãèšé²ã³ãŒãã確èªãããããlog.StdRecordCode.RxïŒã€ãŸããçä¿¡ããŒã¿ïŒã§ããå Žåãããã«åŠçããããã«ãããæž¡ããŸããããã§ãªãå Žåã¯ç¡èŠããŸãã
onLogRecord ( uint64_t timestamp, uint_t recordCode, void const* p, size_t size ) { if (recordCode == log.StdRecordCode.Rx) try m_rxScanner.write (p, size); }
次ã«ããšãã¥ã¬ãŒã¿ãŒãšãããã³ã«ã¢ãã©ã€ã¶ãŒã§åä¿¡ããŒã¿ãåŠçããã¡ã«ããºã ã«ã€ããŠèª¬æããŸãã
éä¿¡ãããã³ã«ã¯ãOSIã¢ãã«ã®ãããã³ã«ã¬ãã«ãã¡ãã»ãŒãžæåãããã³ã«ããã³ã¹ããªãŒã æåãããã³ã«ããã€ããªããã³ããã¹ããªã©ãããŸããŸãªåºæºã«åŸã£ãŠæ¡ä»¶ä»ãã§ã«ããŽãªã«åé¡ã§ããŸãã
ãããã³ã«ã¢ãã©ã€ã¶ãŒãäœæãããšãã芳ç¹ããã¯ã2ã€ã®èŠçŽ ãæãéèŠã§ãã
- ãããã³ã«ãã¡ãã»ãŒãžå šäœã®é ä¿¡ã«äŸåããŠãããïŒãŸãã¯äºåèç©ãå¿ èŠãïŒ
- åºå®ããããŒã䜿çšãããã©ããïŒãŸãã¯ãèŠæ±ãšå¿çã®é·ããç°ãªããäžéšã®ããŒãµãŒã§èŠæ±/å¿çèšèªã®è§£æãå¿ èŠãã©ããïŒã
ããšãã°ããã©ã³ã¹ããŒãã¬ã€ã€ãŒãŸã§ã®TCP / IPã¹ã¿ãã¯ãããã³ã«ã¯ãå šäœãšããŠã¡ãã»ãŒãžé ä¿¡ã«äŸåããåºå®ããããŒã䜿çšããŸããããé«ãã¬ãã«ã§ã¯ããªãã·ã§ã³ãå¯èœã§ããããšãã°ãDHCPã¯å šäœãšããŠé ä¿¡ã«äŸåããããããŒã䜿çšããHTTPã¯ã¹ããªãŒã ã§åäœããããã¹ãã䜿çšããŸãèŠæ±/å¿çã
åºå®ããããŒã䜿çšãããå ŽåãJancyã«ããç¥ãããC / C ++ããã°ã©ããŒã«ãªãã¿ã®ããæ§é ããã€ã³ã¿ãŒãããã³ã¢ãã¬ã¹æŒç®ã®ã¡ã«ããºã ã䜿çšããŠãããã³ã«ã解æããã®ãæã䟿å©ã§ãã JancyãC / C ++ãšé«åºŠãªäºææ§ãæã£ãŠãããšããäºå®ã¯ãããã§éåžžã«åœ¹ç«ã¡ãŸã-ããã«ããããããªãã¯ãœãŒã¹ãããããã³ã«ããããŒã®Cå®çŸ©ãåçŽã«ã³ããŒããJancyã¹ã¯ãªããã«çŽæ¥è²Œãä»ããããšãã§ããŸãïŒå Žåã«ãã£ãŠã¯ãå粧åã®å€æŽãäžèŠã§ãïŒã
æ®å¿µãªããããã®ã¡ã«ããºã ã¯å察ã®ã«ããŽãªã«å±ããââãããã³ã«ã®è§£æã«ã¯å®å šã«äžé©åã§ããã€ãŸããããããŒæ§é ãééãã代ããã«ããªã¯ãšã¹ã/ã¬ã¹ãã³ã¹èšèªãåæããå¿ èŠãããå Žåã§ãã ãã®å Žåãç¹å®ã®ããŒãµãŒãå¿ èŠã§ããã€ãŸããã³ã³ãã€ã©ãŒã®ãã«ãã«äœ¿çšãããæ¹æ³è«ãé©çšããããšã¯è«ççã§ãã å ¬å¹³ã«ã¯ããããã³ã«ã®åçã®ã¯ãšãªèšèªã®ææ³ã¯ãååãšããŠãæãåå§çãªããã°ã©ãã³ã°èšèªã®ææ³ãããéåžžã«åçŽã§ããããšã«æ³šæããå¿ èŠããããŸãã
ã ããã ã³ã³ãã€ã«ã«ã¹ã±ãŒãã®æåã®æ®µéã¯ãåå¥è§£æïŒãŸãã¯ããŒã¯ã³åïŒãã€ãŸãããŒã¯ã³åããã³å ¥åæåã¹ããªãŒã ã®ããŒã¯ã³ã¹ããªãŒã ãžã®å€æã§ãã ãã®ã¿ã¹ã¯ãå®è¡ããã¢ãžã¥ãŒã«ã¯ãã¬ã¯ãµãŒïŒãŸãã¯ã¹ãã£ããŒïŒãšåŒã°ããŸãã ãã¡ã€ã«ã³ã³ãã€ã©ãšã¯ç°ãªããã¹ããªãŒãã³ã°ãããã³ã«çšã®ã¬ã¯ãµãŒã®äœæã¯ãå ¥åIOã¹ããªãŒã ãã³ã³ãã€ã«åäœã«åå²ããã®ãç°¡åã§ã¯ãªããšããäºå®ã«ãã£ãŠè€éã«ãªããŸãã
Jancyã§ã¯ãIO Ninjaã§äœ¿çšããããã«ç¹å¥ã«äœæãããèšèªã®ããã«ãIOã¹ããªãŒã ã解æããããã®äŸ¿å©ãªããŒã«ããããŸãã ã€ã³ã¯ãªã¡ã³ã¿ã«ãªåå¥è§£æåšã®çµã¿èŸŒã¿ãžã§ãã¬ãŒã¿ãŒã§ãã Lex ã Flex ã Ragelãªã©ã®æåãªããŒã«ã®åçã§åäœããŸãã ãŠã£ã¶ãŒãã«ãã£ãŠçæãããã³ãŒããèŠãŠã¿ãŸãããã
jnc.AutomatonResult automaton TiosEmuLayer.scanRx () { %% "about" [\r\n] try transmitString ("IO Ninja - Tios Emu\r\n"); %% "version" [\r\n] try transmitString ("Version 1.0.0\r\n"); %% "help" [\r\n] try transmitString ("This is a starting point for your test utility\r\n"); %% . // ignore everything else }
ãªãŒãããã³é¢æ°ã¯DFAã§ã³ã³ãã€ã«ãããããŒã¯ã³ãèªèããŸããåããŒã¯ã³ã¯æ£èŠè¡šçŸã䜿çšããŠèšè¿°ãããŸãã ãã·ã³ãããŒã¯ã³ãæ€åºãããšã察å¿ããã¢ã¯ã·ã§ã³ãå®è¡ããŸãã
èªåé¢æ°èªäœãçŽæ¥åŒã³åºãããšã¯ã§ããŸãã-çµå±ã®ãšãããèªåãã·ã³ã®ç¶æ ãã©ããã«ä¿åããå¿ èŠããããŸãïŒããŒã¯ã³ã®èç©éšåãå«ãïŒã jnc.Recognizerã¯ã©ã¹ã®ãªããžã§ã¯ãããã®ç®çã«äœ¿çšããããã§ã«æé»çã«ãªãŒãããã³ãåŒã³åºããç¶æ éã®å¿ èŠãªé·ç§»ãããŒã«ããã¯ãããŒã¯ã³ã®èç©ãªã©ãè¡ããŸãã
çæããããã©ã°ã€ã³ã®ãã®ã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ã¯æ¬¡ã®ãšããã§ãã
class TiosEmuLayer: doc.Layer { jnc.Recognizer m_rxScanner; // ... }
ãã¹ãŠã®äººã«æãããªé¡æšãšããŠã次ã®äŸãæããããšãã§ããŸãã ã²ãŒã ã³ã³ãœãŒã«ããããã²ãŒã ã®ãã£ã¹ã¯ããããŸãã ã²ãŒã ããã¬ã€ããã«ã¯ãã³ã³ãœãŒã«ã«ãã£ã¹ã¯ãæ¿å ¥ããå¿ èŠããããŸãã ãã®å Žåãééç¶æ ã¯ã³ã³ãœãŒã«ã®ããŒããã©ã€ãã«ä¿åããããããã²ãŒã ã¯æ®µéçã«ãã¬ã€ã§ããŸãã ãã®äŸã§ã¯ããã¬ãã£ãã¯ã¹ãjnc.Recognizerã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãèªåæ©èœã®ããã²ãŒã ãã£ã¹ã¯ãå ¥åã¹ããªãŒã ã®è§£æã§ã²ãŒã ãæž¡ãããšã§çœ®ãæãããšããã¹ãŠãé©åã«é 眮ãããŸãã
ããããååãªçè«ãç·Žç¿ã«åãæãããŸãããïŒTiOSã³ãã³ãèªèããã©ã°ã€ã³ã«è¿œå ããŸãããã
ãŸããTiOSã¯UDPãä»ããŠæ©èœããŸããã€ãŸããåä¿¡ããããŒã¿ã»ã°ã¡ã³ãéã®ç¶æ ä¿åã䌎ãå¢å解æã¯æå³ããªããªãããæ害ã§ãããããŸããã€ãŸãã1ã€ã®ããŒã¿ã°ã©ã -1ã€ã®ã³ãã³ãã§ãã ãããã£ãŠãjnc.Recognizer.writeã®ä»£ããã«ãjnc.Recognizer.recognizeã¡ãœããã䜿çšããŸãïŒã·ãŒã±ã³ã¹ãªã»ãããæžã蟌ã¿ãeofã«å±éãããŸãïŒã
ããã«ãåæç¶æ ã®TiOSããã€ã¹ã«ã¯IPã¢ãã¬ã¹ããŸã£ãããªãããïŒèšå®ãŸãã¯DHCPãµãŒããŒãããããã€ã¹äžã§å転ããã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠå²ãåœãŠãããå¿ èŠããããŸãïŒãIPã«ããçŽæ¥ã¢ãã¬ã¹æå®ã¯äžè¬ã«äžå¯èœã§ãã ãããã£ãŠãTiOSãããã³ã«ã¯ãããŒããã£ã¹ãIPã¢ãã¬ã¹ã䜿çšããŠããã€ã¹ãšéä¿¡ãããã±ããæ¬äœã®MACã¢ãã¬ã¹ã¯ãããŒããã£ã¹ãäžã«ããã€ã¹ãã¢ãã¬ã¹æå®ããããã«äœ¿çšãããŸãã
ã泚æ
ã¡ãªã¿ã«ãã€ãŒãµããããã¬ãŒã ã®MACã¢ãã¬ã¹ã¯ãããŒããã£ã¹ãããå¿
èŠã¯ãããŸããã ææ°ã®ã¹ã€ããã®å€ãã¯ããããŒããã£ã¹ããã©ãã£ãã¯ã®èš±å®¹é床ã人çºçã«å¶éããŠãããããã€ã³ã¿ã©ã¯ãã£ããªTIDEã¯ãã¹ãããã¬ãŒã¯PCapã䜿çšããŠãIPããããŒããã£ã¹ããããUDPãã¬ãŒã ãçæããŸãããMACã¯ããã€ã¹ã«åºæã§ãã
ãããŒããã€ã¹ã®MACãæã€ãã£ãŒã«ãããã©ã°ã€ã³ã¯ã©ã¹ã«è¿œå ããŸãïŒ16é²ãªãã©ã«ã«æ³šæããŠãã ãã-ã¢ã€ã³ã³ãã«ãŒãœã«ãå ¬éããŒãªã©ã®ãããŒãã³ãŒããããããã€ããªå®æ°ã䟿å©ã«èšå®ããããã®JancyèšèªããŒã«ïŒïŒ
typedef uchar_t MacAddress [6]; class TiosEmuLayer: doc.Layer { MacAddress m_macAddress = 0x"1 2 3 4 5 6"; char const* m_macAddressString = formatMacAddress (m_macAddress); // ... }
åä¿¡ããã³ãã³ãã®MACã¢ãã¬ã¹ã®ã³ã³ãã©ã€ã¢ã³ã¹ã確èªããå¿çãã±ããã«MACãè¿œå ããå¿ èŠããããããMACã¢ãã¬ã¹ãæäœããããã®ãã«ããŒãããã€ãäœæããŸãã
ãœãŒã¹ã³ãŒã
MacAddress parseMacAddress (char const* string) { MacAddress address; char const* p = string; for (size_t i = 0; i < 6; i++) { address [i] = (uchar_t) atoi (p); p = strchr (p, '.'); if (!p) break; p++; } return address; } char const* formatMacAddress (MacAddress address) { return $"%1.%2.%3.%4.%5.%6" ( address [0], address [1], address [2], address [3], address [4], address [5] ); }
MACãã¬ãã£ãã¯ã¹ã«å ããŠãTiOSãã±ããã«ã¯ããªã¯ãšã¹ããšã¬ã¹ãã³ã¹ïŒTCPã®ã·ãŒã±ã³ã¹çªå·/確èªçªå·ã®ç¹å®ã®é¡äŒŒç©ïŒãèå¥ããã³ç §åããããã®ãµãã£ãã¯ã¹ãè¿œå ã§ããŸã-ãªã¯ãšã¹ãã«ãã®ãããªãµãã£ãã¯ã¹ãå«ãŸããŠããå Žåããã®ãªã¯ãšã¹ãã«å¯Ÿããã¬ã¹ãã³ã¹ã«ã¯åããµãã£ãã¯ã¹ãå¿ èŠã§ãã
ãšãã¥ã¬ãŒã¿ãã©ã°ã€ã³ã¯ãïŒãããµããŒãããŸã ïŒãšã³ãŒïŒããXãïŒããã€ã¹ã¹ããŒã¿ã¹ã®ååŸïŒããPCãïŒVMã¹ããŒã¿ã¹ã®ååŸïŒããBãïŒããºïŒ-ããã¯ãTibbo Device Explorerãã確èªããã®ã«ååã§ãã æåã®ã³ãã³ãã¯ããŒã«ã«ã»ã°ã¡ã³ãã®ããã€ã¹ãèªåæ€åºããããã«äœ¿çšããã2çªç®ãš3çªç®ã®ã³ãã³ãã¯ããã€ã¹ãšä»®æ³ãã·ã³ã®æ¡åŒµã¹ããŒã¿ã¹ãè¿ããŸãã
ããã§ãèªåæ©èœã䜿çšããŠãã±ããã¢ãã©ã€ã¶ãŒãäœæããŸãã
TiosEmuLayer.onLogRecord ( uint64_t timestamp, uint_t recordCode, void const* p, size_t size ) { if (recordCode != log.StdRecordCode.Rx) return; bool result = try m_packetScanner.recognize (scanPacket, p, size); if (!result) m_reply = "C"; else if (!m_reply) return; char const* id = strchr (p, '|'); // find id - if there's any try transmitString ($"[$m_macAddressString]$m_reply$id"); } jnc.AutomatonResult automaton TiosEmuLayer.scanPacket (jnc.Recognizer* recognizer) { %% "_?" m_reply = "A"; %% "_[" (\d+ '.')* \d+ ']' MacAddress address = parseMacAddress (recognizer.m_lexeme + 2); if (memcmp (address, m_macAddress, sizeof (address)) != 0) { m_reply = null; return jnc.AutomatonResult.Stop; // don't scan further } recognizer.m_automatonFunc = scanCommand; // change automaton }
onLogRecordé¢æ°ã¯ãåæã®ããã«RXããŒã¿ãscanPacketãµããã·ã³é¢æ°ã«æž¡ããå¿çãã±ãããéä¿¡ããŸãïŒãŸãã¯ãå¿çãäžèŠãªå Žåã¯éãã«çµäºããŸãïŒã ãžã£ã³ã·ãŒãã©ãŒããããªãã©ã«ïŒPerlã®ãããªãã©ãŒãããïŒã¯ãå¿çãã±ããã圢æããããã«äœ¿çšãããŸãã
scanPacketãã·ã³ã¯ãå€èšèªå ¥åããŒã¿ïŒRagoã§è»ãå€æŽããããã®fgoto / fcallã®é¡äŒŒç©ïŒã解æããéåžžã«æçšãªæ©èœãå®èšŒããŸãã MACãã¬ãã£ãã¯ã¹ãå«ããã±ããã®æåã®éšåã解æããã³ãã§ãã¯ããåŸã2çªç®ã®ãã·ã³scanCommandã«ããžã£ã³ããããŠãå®éã®ã³ãã³ããšèå¥ãµãã£ãã¯ã¹ã§ãã±ããæ¬äœã解æããŸãã
jnc.AutomatonResult automaton TiosEmuLayer.scanCommand (jnc.Recognizer* recognizer) { %% id = '|' .* %% 'X' id? m_reply = "A<IONJ-3.4.0>/ec8ec901-bb4b-4468-bfb9-bf482589cc17/test!"; %% "PC" id? m_reply = "A*R*/00/&h A:0000,B:0000,PC:00000000,SP:00,FL:Z**/65535"; %% 'B' id? m_reply = "A"; }
2çªç®ã®ãã·ã³ã¯ãåŸã§äœ¿çšããããã«ååä»ãæ£èŠè¡šçŸãå®çŸ©ããæ©èœã瀺ããŠããŸãã ã¹ããŒã¹ã10é²æ°ãªã©ã®æšæºæåã¯ã©ã¹ã«æ³šæããŠãã ããã Perlã®ããã«ããšã¹ã±ãŒãã·ãŒã±ã³ã¹\ dã\ Dãsã\ Sã\ wã\ Wãä»ããŠç¹å¥ãªå®çŸ©ãå¿ èŠãšãããå©çšå¯èœã§ãã
UDPãã¹ãã»ãã·ã§ã³ã§ãã©ã°ã€ã³ãéå§ããããã¹ãŠã®IPv4ã¢ããã¿ãŒãã¢ããã¿ãŒãéžæããããŒã65535ãéããŸãããã©ã°ã€ã³ããªã¯ãšã¹ãã®éä¿¡å ã¢ãã¬ã¹ã«å¿çããããã«ããŸãã ïŒ æ¬¡ã«ãããã€ã¹ãšã¯ã¹ãããŒã©ãŒãå®è¡ããŠããšãã¥ã¬ãŒã¿ãŒã«ãã£ãŠçæããããããŒããã€ã¹ã確èªããŸãã ãã¡ã³ãã¡ãŒã¬ãæ¬ç€Œãæ»äœã
ãã©ã°ã€ã³ã®å šæã¯ããããããŠã³ããŒãã§ããŸãïŒ http : //tibbo.com/downloads/open/ioninja-plugin-samples/TiosEmu.zip
ãããã«
ãã¡ãããåãåã£ãåºåã¯ãæ¬æ ŒçãªTiOSãšãã¥ã¬ãŒã¿ãŒã§ã¯ãªãããããŒãã©ã³ã¯ã§ããã ããã«ãããããããããã¯ã³ã³ã»ããèªäœãå®èšŒããããã«æãäžããæ¹åãç解ããã®ã«ååãªã¯ãã§ã-ãã®ãšãã¥ã¬ãŒã¿ã¯ãç¹å®ã®ã±ãŒã¹ã§ããæçšãªãã¹ããŠãŒãã£ãªãã£ãæžãããã®åºçºç¹ãšããŠåœ¹ç«ã€ãããããŸããã
èšäºã®æ¬¡ã®éšåã§ã¯ããããã³ã«åæçšã®ãã©ã°ã€ã³ã¬ã€ã€ãŒã®äœæãæ€èšããŸãã