1 / 14

A RealTek Application

A RealTek Application. Using our own device-driver and a standard networking protocol to discover the ‘active’ workstations. Our ‘rxplustx.c’ driver. my_isr(). my_fops. ioctl. my_ioctl(). open. my_open(). read. my_read(). write. my_write(). release. my_release().

shayna
Télécharger la présentation

A RealTek Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A RealTek Application Using our own device-driver and a standard networking protocol to discover the ‘active’ workstations

  2. Our ‘rxplustx.c’ driver my_isr() my_fops ioctl my_ioctl() open my_open() read my_read() write my_write() release my_release() init_module() cleanup_module()

  3. Our ‘arpquery.cpp’ program parent-process Opens device-file Gets netaddress then forks Installs a signal-handler While-loop receives ARP replies until signaled child-process For-loop transmits ARP request to all stations on local network then signals parent and exits

  4. ARP request A B request C D E Station ‘A’ wants to know the Ethernet Address for station ‘B’ So ‘A’ broadcasts an ARP request-packet to all other stations

  5. ARP reply A B reply C D E Station ‘B’ recognizes that the request is for its Ethernet Address. So ‘B’ replies directly to ‘A’, and other stations ignore the request.

  6. Format for ARP Frames Destination MAC address Source MAC address 0x0806 HTYPE 0x0001 PTYPE 0x0800 HLEN 0x06 PLEN 0x04 ARP command Source hardware address Source protocol address Destination hardware address Destination protocol address Legend: ARP commands (0x0001=request, 0x0002=reply)

  7. ‘roomview.cpp’ 8 9 10 15 16 17 18 19 20 28 29 30 4 5 6 7 11 12 13 14 24 25 26 27 1 2 3 21 22 23

  8. Terminal ‘line graphics’ • Most text-mode terminals can draw ‘boxes’ by using an ‘alternate character set’ which includes the so-called ‘line graphic’ glyphs: Upper-Left: ┌ Upper-Right: ┐ Horizontal-bar: ─ Vertical-bar: │ Lower-left: └ Lower-right: ┘ ┌───────────────┐ └───────────────┘

  9. Uniform terminal interface • Because terminal hardware may differ, we need a standard software interface to get the same desired effects on all platforms • UNIX programming environments offer a long-established mechanism for doing this • Need this header-file: #include <term.h> • Need linkage with ‘ncurses’ function-library

  10. How ‘terminfo’ is used • Initialize with the ‘setupterm()’ function • Extract your terminal’s parameters (e.g., numbers or special control-strings) using the functions ‘tigetnum()’ and ‘tigetstr()’ • Parametrize control-strings with ‘tparm()’ • Output these control-strings with ‘putp()’ • Our ‘roomview.cpp’ demonstrates these

  11. Line-graphic character-codes • Your terminal’s mapping of the numbers for the line-graphics glyphs can be found by a string-search of terminfo’s database • This is illustrated in our ‘roomview’ demo • Examples: char *acsc = tigetstr( “acsc” ); char HZ = strchr( acsc, ‘q’ )[ 1 ]; char VT = strchr( scsc, ‘x’ )[ 1 ];

  12. Special terminal effects • You can enable (or disable) use of glyphs from the terminal’s alternate character set, by using special control-sequences: ‘smacs’ and ‘rmacs’ • You can put the cursor where you want it, by outputting a special control-sequence: ‘cup’ • You can draw characters in ‘reverse-video’, by outputting a special control-sequence: ‘rev’ • You can draw characters in ‘normal’ mode, by outputting a special control-sequence: ‘sgr0’

  13. ‘roomview.cpp’ 8 9 10 15 16 17 18 19 20 28 29 30 4 5 6 7 11 12 13 14 24 25 26 27 1 2 3 21 22 23

  14. In-class exercise • Combine the programming ideas used in ‘roomview.cpp’ and ‘arpquery.cpp’ so you get a view of all the Kudlick Classroom’s workstations, but with those that sent ARP reply-packets shown with ‘reverse-video’ so as to highlight their presence online

More Related