IF Commons GitHub

physical/tftp-server

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-netboot-physical FR-003

A read-only TFTP server for PXE: UEFI firmware fetches the shim over TFTP, the shim its GRUB, and GRUB its menu, kernel and initrd, all from the same server. Each read is answered by the same function as HTTP's, so PXE and HTTP boot get the same files. Each transfer runs on its own socket (the client's transfer id), one block in flight, retransmitting on a timeout; a write request is refused.

import { tftpServer } from "./tftp-server.ts";
// const s = await tftpServer({ port: 0, read: async (p) => (p === "/x" ? new Uint8Array([1]) : undefined) }); await s.stop();

Source: commons/netboot/src/physical/tftp-server.ts

1 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.TftpOptionstypeno test imports it
type TftpOptions = { readonly port: number; readonly hostname?: string; /** The bytes of a file of the served tree… (617 characters)
type TftpOptions = {
  readonly port: number;
  readonly hostname?: string;
  /** The bytes of a file of the served tree (a path with a leading slash), or nothing where there is none. */
  readonly read: (path: string, from: string) => Promise<Uint8Array | undefined>;
  /** Told of each transfer: its file, who asked and how it ended. */
  readonly onTransfer?: (e: { readonly file: string; readonly from: string; readonly outcome: "sent" | "refused" | "not-found" | "timed-out" }) => void;
  /** How many times a block is sent again before the transfer is given up (5 by default). */
  readonly retries?: number;
};

What the server is given.

physical.TftpServertypeno test imports it
type TftpServer = { readonly port: number; stop(): Promise<void> };

A running server.

physical.tftpServerfunctionno test imports it
function tftpServer(o: TftpOptions): Promise<TftpServer>

Starts the server.

TftpOptionstypeno test imports it
type TftpOptions = { readonly port: number; readonly hostname?: string; /** The bytes of a file of the served tree… (617 characters)
type TftpOptions = {
  readonly port: number;
  readonly hostname?: string;
  /** The bytes of a file of the served tree (a path with a leading slash), or nothing where there is none. */
  readonly read: (path: string, from: string) => Promise<Uint8Array | undefined>;
  /** Told of each transfer: its file, who asked and how it ended. */
  readonly onTransfer?: (e: { readonly file: string; readonly from: string; readonly outcome: "sent" | "refused" | "not-found" | "timed-out" }) => void;
  /** How many times a block is sent again before the transfer is given up (5 by default). */
  readonly retries?: number;
};

What the server is given.

TftpServertypeno test imports it
type TftpServer = { readonly port: number; stop(): Promise<void> };

A running server.

tftpServerfunction
function tftpServer(o: TftpOptions): Promise<TftpServer>

Starts the server.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.