udp_genesis 1
udp_genesis 2
udp_genesis 3
udp_genesis 4
udp_genesis 5
udp_genesis 6
udp_genesis 7
udp_genesis 8
udp_genesis 9
udp_genesis 10
udp_genesis 11
udp_genesis 12
udp_genesis 13
udp_genesis 14
udp_genesis 15
udp_genesis 16
udp_genesis 17
udp_genesis 18
udp_genesis 19
udp_genesis 20 with Interfaces, Interfaces.C; use Interfaces, Interfaces.C;
udp_genesis 21 with System; use System;
udp_genesis 22
udp_genesis 23
udp_genesis 24 package UDP is
udp_genesis 25
udp_genesis 26 pragma Preelaborate;
udp_genesis 27
udp_genesis 28
udp_genesis 29 Payload_Size : constant Positive := 512;
udp_genesis 30
udp_genesis 31 type Payload is array(1 .. Payload_Size) of Unsigned_8;
udp_genesis 32
udp_genesis 33
udp_genesis 34 subtype IP_Address is Unsigned_32;
udp_genesis 35 subtype IP_Port is Unsigned_16;
udp_genesis 36
udp_genesis 37
udp_genesis 38 INADDR_ANY : constant Unsigned_32 := 0;
udp_genesis 39
udp_genesis 40
udp_genesis 41 type Endpoint is
udp_genesis 42 record
udp_genesis 43 Address : IP_Address;
udp_genesis 44 Port : IP_Port;
udp_genesis 45 end record;
udp_genesis 46
udp_genesis 47
udp_genesis 48
udp_genesis 49 subtype IP_Address_Text is String(1 .. 15);
udp_genesis 50
udp_genesis 51
udp_genesis 52 type Socket is private;
udp_genesis 53
udp_genesis 54
udp_genesis 55
udp_genesis 56
udp_genesis 57 function IP_To_String(IP : in IP_Address) return IP_Address_Text;
udp_genesis 58
udp_genesis 59
udp_genesis 60 function IP_From_String(IP_Text : in String) return IP_Address;
udp_genesis 61
udp_genesis 62
udp_genesis 63 procedure Open_Socket(S : out Socket;
udp_genesis 64 Local_Endpoint : in Endpoint);
udp_genesis 65
udp_genesis 66
udp_genesis 67 procedure Close_Socket(S : in out Socket);
udp_genesis 68
udp_genesis 69
udp_genesis 70 procedure Transmit(S : in out Socket;
udp_genesis 71 Destination : in Endpoint;
udp_genesis 72 Payload_Buf : in Payload);
udp_genesis 73
udp_genesis 74
udp_genesis 75
udp_genesis 76 procedure Receive(S : in out Socket;
udp_genesis 77 Origin : out Endpoint;
udp_genesis 78 Payload_Buf : out Payload;
udp_genesis 79 Valid : out Boolean);
udp_genesis 80
udp_genesis 81
udp_genesis 82 UDP_Invalid_Text_IP : exception;
udp_genesis 83 UDP_Failed_Open : exception;
udp_genesis 84 UDP_Failed_SetOpt : exception;
udp_genesis 85 UDP_Failed_Bind : exception;
udp_genesis 86 UDP_Failed_Transmit : exception;
udp_genesis 87 UDP_Failed_Receive : exception;
udp_genesis 88
udp_genesis 89 private
udp_genesis 90
udp_genesis 91
udp_genesis 92
udp_genesis 93
udp_genesis 94 type sockaddr_in is record
udp_genesis 95 family : Unsigned_16;
udp_genesis 96 port : Unsigned_16;
udp_genesis 97 sin_addr : Unsigned_32;
udp_genesis 98 padding : Unsigned_64;
udp_genesis 99 end record;
udp_genesis 100 pragma Convention(C, sockaddr_in);
udp_genesis 101
udp_genesis 102
udp_genesis 103 type Socket is
udp_genesis 104 record
udp_genesis 105 SA : sockaddr_in;
udp_genesis 106 FD : Interfaces.C.int;
udp_genesis 107 end record;
udp_genesis 108 pragma Convention(C, Socket);
udp_genesis 109
udp_genesis 110
udp_genesis 111
udp_genesis 112 procedure Unix_UDP_IP_To_String
udp_genesis 113 (IP : Unsigned_32;
udp_genesis 114 Output_Buffer : System.Address;
udp_genesis 115 Output_Buffer_Size : Unsigned_32);
udp_genesis 116 pragma Import(C, Unix_UDP_IP_To_String, "unix_udp_ip_to_string");
udp_genesis 117
udp_genesis 118 function Unix_UDP_String_To_IP
udp_genesis 119 (Input_Buffer : System.Address;
udp_genesis 120 IP : not null access Unsigned_32) return Interfaces.C.int;
udp_genesis 121 pragma Import(C, Unix_UDP_String_To_IP, "unix_udp_string_to_ip");
udp_genesis 122
udp_genesis 123 function Unix_UDP_Socket_Open
udp_genesis 124 (Socket : System.Address;
udp_genesis 125 Local_IP : Unsigned_32;
udp_genesis 126 Local_Port : Unsigned_16) return Interfaces.C.int;
udp_genesis 127 pragma Import(C, Unix_UDP_Socket_Open, "unix_udp_socket_open");
udp_genesis 128
udp_genesis 129 procedure Unix_UDP_Socket_Close
udp_genesis 130 (Socket : System.Address);
udp_genesis 131 pragma Import(C, Unix_UDP_Socket_Close, "unix_udp_socket_close");
udp_genesis 132
udp_genesis 133 function Unix_UDP_Socket_Transmit
udp_genesis 134 (Socket : System.Address;
udp_genesis 135 Remote_IP : Unsigned_32;
udp_genesis 136 Remote_Port : Unsigned_16;
udp_genesis 137 Payload_Buf : System.Address;
udp_genesis 138 Payload_Len : Unsigned_32) return Interfaces.C.int;
udp_genesis 139 pragma Import(C, Unix_UDP_Socket_Transmit, "unix_udp_socket_transmit");
udp_genesis 140
udp_genesis 141 function Unix_UDP_Socket_Receive
udp_genesis 142 (Socket : System.Address;
udp_genesis 143 Origin_IP : not null access Unsigned_32;
udp_genesis 144 Origin_Port : not null access Unsigned_16;
udp_genesis 145 Payload_Buf : System.Address;
udp_genesis 146 Payload_Len : Unsigned_32) return Interfaces.C.int;
udp_genesis 147 pragma Import(C, Unix_UDP_Socket_Receive, "unix_udp_socket_receive");
udp_genesis 148
udp_genesis 149 end UDP;