aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/pxe.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/pxe.h')
-rw-r--r--core/include/pxe.h213
1 files changed, 213 insertions, 0 deletions
diff --git a/core/include/pxe.h b/core/include/pxe.h
index 7f30f9a6..b9c71dfb 100644
--- a/core/include/pxe.h
+++ b/core/include/pxe.h
@@ -154,4 +154,217 @@
#define PXENV_STATUS_LOADER_UNDI_START 0xca
#define PXENV_STATUS_LOADER_BC_START 0xcb
+
+
+
+/*
+ * some other defines
+ */
+#define PKTBUF_SIZE (65536 / MAX_OPEN)
+
+#define TFTP_BLOCKSIZE_LG2 9
+#define TFTP_BLOCKSIZE (1 << TFTP_BLOCKSIZE_LG2)
+#define PKTBUF_SEG 0x4000
+#define DNS_MAX_SERVERS 4
+
+#define is_digit(c) (((c) >= '0') && ((c) <= '9'))
+#define htons(x) ( ( ((x) & 0xff) << 8) + ( ((x) &0xff00) >> 8) )
+#define ntohs(x) htons(x)
+#define htonl(x) ( ( ((x) & 0xff) << 24) + ( ((x) & 0xff00) << 8 ) + \
+ ( ((x) & 0xff0000) >> 8 ) + ( ((x) & 0xff000000) >> 24) )
+#define ntohl(x) htonl(x)
+
+/*
+ * TFTP operation codes
+ */
+#define TFTP_RRQ htons(1) // Read rest
+#define TFTP_WRQ htons(2) // Write rest
+#define TFTP_DATA htons(3) // Data packet
+#define TFTP_ACK htons(4) // ACK packet
+#define TFTP_ERROR htons(5) // ERROR packet
+#define TFTP_OACK htons(6) // OACK packet
+
+/*
+ * TFTP error codes
+ */
+#define TFTP_EUNDEF htons(0) // Unspecified error
+#define TFTP_ENOTFOUND htons(1) // File not found
+#define TFTP_EACCESS htons(2) // Access violation
+#define TFTP_ENOSPACE htons(3) // Disk full
+#define TFTP_EBADOP htons(4) // Invalid TFTP operation
+#define TFTP_EBADID htons(5) // Unknown transfer
+#define TFTP_EEXISTS htons(6) // File exists
+#define TFTP_ENOUSER htons(7) // No such user
+#define TFTP_EOPTNEG htons(8) // Option negotiation failure
+
+#define BOOTP_OPTION_MAGIC htonl(0x63825363)
+
+
+/*
+ * structures
+ */
+struct bootp_t {
+ uint8_t opcode; /* BOOTP/DHCP "opcode" */
+ uint8_t hardware; /* ARP hreadware type */
+ uint8_t hardlen; /* Hardware address length */
+ uint8_t gatehops; /* Used by forwarders */
+ uint32_t ident; /* Transaction ID */
+ uint16_t seconds; /* Seconds elapsed */
+ uint16_t flags; /* Broadcast flags */
+ uint32_t cip; /* Cient IP */
+ uint32_t yip; /* "Your" IP */
+ uint32_t sip; /* Next Server IP */
+ uint32_t gip; /* Relay agent IP */
+ uint8_t macaddr[16]; /* Client MAC address */
+ uint8_t sname[64]; /* Server name (optional) */
+ char bootfile[128]; /* Boot file name */
+ uint32_t option_magic; /* Vendor option magic cookie */
+ uint8_t options[1260]; /* Vendor options */
+} __attribute__ ((packed));
+
+struct open_file_t {
+ uint16_t tftp_localport; /* Local port number (0=not in us)*/
+ uint16_t tftp_remoteport; /* Remote port number */
+ uint32_t tftp_remoteip; /* Remote IP address */
+ uint32_t tftp_filepos; /* bytes downloaded (includeing buffer) */
+ uint32_t tftp_filesize; /* Total file size(*) */
+ uint32_t tftp_blksize; /* Block size for this connection(*) */
+ uint16_t tftp_bytesleft; /* Unclaimed data bytes */
+ uint16_t tftp_lastpkt; /* Sequence number of last packet (NBO) */
+ uint16_t tftp_dataptr; /* Pointer to available data */
+ uint8_t tftp_goteof; /* 1 if the EOF packet received */
+ uint8_t tftp_unused[3]; /* Currently unused */
+ uint16_t tftp_pktbuf; /* Packet buffer offset */
+} __attribute__ ((packed));
+extern char Files[];
+
+struct pxe_udp_write_pkt {
+ uint16_t status;
+ uint32_t sip;
+ uint32_t gip;
+ uint16_t lport;
+ uint16_t rport;
+ uint16_t buffersize;
+ uint16_t buffer[2];
+} __attribute__ ((packed));
+
+struct pxe_udp_read_pkt {
+ uint16_t status;
+ uint32_t sip;
+ uint32_t dip;
+ uint16_t rport;
+ uint16_t lport;
+ uint16_t buffersize;
+ uint16_t buffer[2];
+} __attribute__ ((packed));
+
+struct pxe_bootp_query_pkt {
+ uint16_t status;
+ uint16_t packettype;
+ uint16_t buffersize;
+ uint16_t buffer[2];
+ uint16_t bufferlimit;
+} __attribute__ ((packed));
+
+struct pxe_udp_open_pkt {
+ uint16_t status;
+ uint32_t sip;
+} __attribute__ ((packed));
+
+struct gpxe_file_api_check {
+ uint16_t status;
+ uint16_t size;
+ uint32_t magic;
+ uint32_t provider;
+ uint32_t apimask;
+ uint32_t flags;
+} __attribute__ ((packed));
+
+struct gpxe_file_open {
+ uint16_t status;
+ uint16_t filehandle;
+ uint16_t filename[2];
+ uint32_t reserved;
+} __attribute__ ((packed));
+
+struct gpxe_get_file_size {
+ uint16_t status;
+ uint16_t filehandle;
+ uint32_t filesize;
+} __attribute__ ((packed));
+
+struct gpxe_file_read {
+ uint16_t status;
+ uint16_t filehandle;
+ uint16_t buffersize;
+ uint16_t buffer[2];
+} __attribute__ ((packed));
+
+/*
+ * externs
+ */
+extern uint32_t ServerIP;
+extern uint32_t MyIP;
+extern uint32_t Netmask;
+extern uint32_t Gateway;
+extern uint32_t ServerPort;
+
+#define MAC_MAX 32
+extern char MACStr[]; /* MAC address as a string */
+extern char MAC[]; /* Actual MAC address */
+extern char BOOTIFStr[]; /* Space for "BOOTIF=" */
+extern uint8_t MACLen; /* MAC address len */
+extern uint8_t MACType; /* MAC address type */
+
+
+extern uint8_t DHCPMagic;
+extern uint8_t OverLoad;
+extern uint32_t RebootTime;
+
+
+/* TFTP ACK packet */
+extern uint16_t ack_packet_buf[];
+
+extern void kaboom(void);
+extern void dns_mangle(void);
+extern char trackbuf[];
+extern char BootFile[];
+extern char PathPrefix[];
+extern char CurrentDirName[];
+extern char LocalDomain[];
+
+extern char packet_buf[];
+
+extern char IPOption[];
+extern char DotQuadBuf[];
+
+
+extern uint32_t DNSServers[];
+extern uint16_t LastDNSServer;
+
+extern char ConfigName[];
+
+extern uint16_t RealBaseMem;
+extern uint16_t APIVer;
+extern far_ptr_t PXEEntry;
+
+extern far_ptr_t InitStack;
+
+extern int HaveUUID;
+extern uint8_t UUIDType;
+extern char UUID[];
+
+extern volatile uint16_t BIOS_timer;
+
+
+/*
+ * functions
+ */
+int ip_ok(uint32_t);
+void parse_dhcp(int);
+void parse_dhcp_options(void *, int, int);
+
+
+
+
#endif /* pxe.h */