Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PicoTCP by
pico_protocol.h
00001 /********************************************************************* 00002 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved. 00003 See LICENSE and COPYING for usage. 00004 00005 *********************************************************************/ 00006 #ifndef _INCLUDE_PICO_PROTOCOL 00007 #define _INCLUDE_PICO_PROTOCOL 00008 #include <stdint.h> 00009 #include "pico_queue.h" 00010 00011 #define PICO_LOOP_DIR_IN 1 00012 #define PICO_LOOP_DIR_OUT 2 00013 00014 enum pico_layer { 00015 PICO_LAYER_DATALINK = 2, /* Ethernet only. */ 00016 PICO_LAYER_NETWORK = 3, /* IPv4, IPv6, ARP. Arp is there because it communicates with L2 */ 00017 PICO_LAYER_TRANSPORT = 4, /* UDP, TCP, ICMP */ 00018 PICO_LAYER_SOCKET = 5 /* Socket management */ 00019 }; 00020 00021 enum pico_err_e { 00022 PICO_ERR_NOERR = 0, 00023 PICO_ERR_EPERM, 00024 PICO_ERR_ENOENT, 00025 /* ... */ 00026 PICO_ERR_EINTR = 4, 00027 PICO_ERR_EIO, 00028 PICO_ERR_ENXIO, 00029 /* ... */ 00030 PICO_ERR_EAGAIN = 11, 00031 PICO_ERR_ENOMEM, 00032 PICO_ERR_EACCESS, 00033 PICO_ERR_EFAULT, 00034 /* ... */ 00035 PICO_ERR_EBUSY = 16, 00036 PICO_ERR_EEXIST = 17, 00037 /* ... */ 00038 PICO_ERR_EINVAL = 22, 00039 /* ... */ 00040 PICO_ERR_EPROTO = 71, 00041 PICO_ERR_ENOPROTOOPT = 92, 00042 PICO_ERR_EPROTONOSUPPORT = 93, 00043 00044 /* ... */ 00045 PICO_ERR_EADDRINUSE = 98, 00046 PICO_ERR_EADDRNOTAVAIL, 00047 PICO_ERR_ENETUNREACH, 00048 00049 /* ... */ 00050 PICO_ERR_ECONNRESET = 104, 00051 00052 /* ... */ 00053 PICO_ERR_EISCONN = 106, 00054 PICO_ERR_ENOTCONN, 00055 PICO_ERR_ESHUTDOWN, 00056 /* ... */ 00057 PICO_ERR_ETIMEDOUT = 110, 00058 PICO_ERR_ECONNREFUSED = 111, 00059 PICO_ERR_EHOSTDOWN, 00060 PICO_ERR_EHOSTUNREACH, 00061 /* ... */ 00062 PICO_ERR_EOPNOTSUPP = 122, 00063 00064 }; 00065 00066 typedef enum pico_err_e pico_err_t; 00067 extern volatile pico_err_t pico_err; 00068 00069 #define IS_IPV6(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x60) 00070 #define IS_IPV4(f) ((((uint8_t *)(f->net_hdr))[0] & 0xf0) == 0x40) 00071 00072 #define MAX_PROTOCOL_NAME 16 00073 00074 struct pico_protocol { 00075 char name[MAX_PROTOCOL_NAME]; 00076 uint32_t hash; 00077 enum pico_layer layer; 00078 int proto_number; 00079 struct pico_queue *q_in; 00080 struct pico_queue *q_out; 00081 struct pico_frame *(*alloc)(struct pico_protocol *self, int size); /* Frame allocation. */ 00082 int (*push) (struct pico_protocol *self, struct pico_frame *p); /* Push function, for active outgoing pkts from above */ 00083 int (*process_out)(struct pico_protocol *self, struct pico_frame *p); /* Send loop. */ 00084 int (*process_in)(struct pico_protocol *self, struct pico_frame *p); /* Recv loop. */ 00085 }; 00086 00087 int pico_protocols_loop(int loop_score); 00088 void pico_protocol_init(struct pico_protocol *p); 00089 00090 int pico_protocol_datalink_loop(int loop_score, int direction); 00091 int pico_protocol_network_loop(int loop_score, int direction); 00092 int pico_protocol_transport_loop(int loop_score, int direction); 00093 int pico_protocol_socket_loop(int loop_score, int direction); 00094 00095 #endif
Generated on Thu Jul 14 2022 08:24:59 by
 1.7.2
 1.7.2 
    