Networking: Save the IP domain in the connection structure
This commit is contained in:
parent
4a0eb1f0b1
commit
94f9312150
@ -97,7 +97,7 @@ struct devif_callback_s; /* Forward reference */
|
||||
struct socket
|
||||
{
|
||||
int16_t s_crefs; /* Reference count on the socket */
|
||||
uint8_t s_domain; /* Domain: PF_INET, PF_INET6, or PF_PACKET */
|
||||
uint8_t s_domain; /* IP domain: PF_INET, PF_INET6, or PF_PACKET */
|
||||
uint8_t s_type; /* Protocol type: Only SOCK_STREAM or SOCK_DGRAM */
|
||||
uint8_t s_flags; /* See _SF_* definitions */
|
||||
|
||||
|
@ -192,7 +192,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
* socket instance.
|
||||
*/
|
||||
|
||||
FAR struct tcp_conn_s *conn = tcp_alloc();
|
||||
FAR struct tcp_conn_s *conn = tcp_alloc(domain);
|
||||
if (!conn)
|
||||
{
|
||||
/* Failed to reserve a connection structure */
|
||||
@ -219,7 +219,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
* socket instance.
|
||||
*/
|
||||
|
||||
FAR struct udp_conn_s *conn = udp_alloc();
|
||||
FAR struct udp_conn_s *conn = udp_alloc(domain);
|
||||
if (!conn)
|
||||
{
|
||||
/* Failed to reserve a connection structure */
|
||||
|
@ -112,6 +112,7 @@ struct tcp_conn_s
|
||||
* receive next */
|
||||
uint8_t sndseq[4]; /* The sequence number that was last sent by us */
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
||||
uint8_t sa; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
uint8_t sv; /* Retransmission time-out calculation state
|
||||
@ -290,7 +291,7 @@ void tcp_initialize(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct tcp_conn_s *tcp_alloc(void);
|
||||
FAR struct tcp_conn_s *tcp_alloc(uint8_t domain);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tcp_free
|
||||
|
@ -277,7 +277,7 @@ void tcp_initialize(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct tcp_conn_s *tcp_alloc(void)
|
||||
FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
|
||||
{
|
||||
FAR struct tcp_conn_s *conn;
|
||||
net_lock_t flags;
|
||||
@ -374,6 +374,7 @@ FAR struct tcp_conn_s *tcp_alloc(void)
|
||||
{
|
||||
memset(conn, 0, sizeof(struct tcp_conn_s));
|
||||
conn->tcpstateflags = TCP_ALLOCATED;
|
||||
conn->domain = domain;
|
||||
}
|
||||
|
||||
return conn;
|
||||
@ -587,7 +588,11 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
|
||||
FAR struct net_iphdr_s *ip = IPv4;
|
||||
FAR struct tcp_conn_s *conn;
|
||||
|
||||
conn = tcp_alloc();
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
conn = tcp_alloc(PF_INET);
|
||||
#else
|
||||
conn = tcp_alloc(PF_INET6);
|
||||
#endif
|
||||
if (conn)
|
||||
{
|
||||
/* Fill in the necessary fields for the new connection. */
|
||||
|
@ -70,6 +70,7 @@ struct udp_conn_s
|
||||
union ip_binding_u u; /* IP address binding */
|
||||
uint16_t lport; /* Bound local port number (network byte order) */
|
||||
uint16_t rport; /* Remote port number (network byte order) */
|
||||
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
||||
uint8_t ttl; /* Default time-to-live */
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
|
||||
@ -99,7 +100,7 @@ struct udp_iphdr_s; /* Forward reference */
|
||||
|
||||
/* Defined in udp_conn.c ****************************************************/
|
||||
/****************************************************************************
|
||||
* Name: udp_initialize()
|
||||
* Name: udp_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the UDP connection structures. Called once and only from
|
||||
@ -110,7 +111,7 @@ struct udp_iphdr_s; /* Forward reference */
|
||||
void udp_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_alloc()
|
||||
* Name: udp_alloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate a new, uninitialized UDP connection structure. This is
|
||||
@ -118,10 +119,10 @@ void udp_initialize(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct udp_conn_s *udp_alloc(void);
|
||||
FAR struct udp_conn_s *udp_alloc(uint8_t domain);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_free()
|
||||
* Name: udp_free
|
||||
*
|
||||
* Description:
|
||||
* Free a UDP connection structure that is no longer in use. This should be
|
||||
@ -132,7 +133,7 @@ FAR struct udp_conn_s *udp_alloc(void);
|
||||
void udp_free(FAR struct udp_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_active()
|
||||
* Name: udp_active
|
||||
*
|
||||
* Description:
|
||||
* Find a connection structure that is the appropriate
|
||||
@ -147,7 +148,7 @@ FAR struct udp_conn_s *udp_active(FAR struct net_driver_s *dev,
|
||||
FAR struct udp_hdr_s *udp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_nextconn()
|
||||
* Name: udp_nextconn
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of allocated UDP connections
|
||||
@ -160,7 +161,7 @@ FAR struct udp_conn_s *udp_active(FAR struct net_driver_s *dev,
|
||||
FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_bind()
|
||||
* Name: udp_bind
|
||||
*
|
||||
* Description:
|
||||
* This function implements the low-level parts of the standard UDP bind()
|
||||
@ -178,7 +179,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_connect()
|
||||
* Name: udp_connect
|
||||
*
|
||||
* Description:
|
||||
* This function sets up a new UDP connection. The function will
|
||||
|
@ -242,7 +242,7 @@ static uint16_t udp_select_port(void)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_initialize()
|
||||
* Name: udp_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the UDP connection structures. Called once and only from
|
||||
@ -272,7 +272,7 @@ void udp_initialize(void)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_alloc()
|
||||
* Name: udp_alloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate a new, uninitialized UDP connection structure. This is
|
||||
@ -280,7 +280,7 @@ void udp_initialize(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct udp_conn_s *udp_alloc(void)
|
||||
FAR struct udp_conn_s *udp_alloc(uint8_t domain)
|
||||
{
|
||||
FAR struct udp_conn_s *conn;
|
||||
|
||||
@ -294,6 +294,7 @@ FAR struct udp_conn_s *udp_alloc(void)
|
||||
{
|
||||
/* Make sure that the connection is marked as uninitialized */
|
||||
|
||||
conn->domain = domain;
|
||||
conn->lport = 0;
|
||||
|
||||
/* Enqueue the connection into the active list */
|
||||
@ -306,7 +307,7 @@ FAR struct udp_conn_s *udp_alloc(void)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_free()
|
||||
* Name: udp_free
|
||||
*
|
||||
* Description:
|
||||
* Free a UDP connection structure that is no longer in use. This should be
|
||||
@ -336,7 +337,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_active()
|
||||
* Name: udp_active
|
||||
*
|
||||
* Description:
|
||||
* Find a connection structure that is the appropriate
|
||||
@ -402,7 +403,7 @@ FAR struct udp_conn_s *udp_active(FAR struct net_driver_s *dev,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_nextconn()
|
||||
* Name: udp_nextconn
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of allocated UDP connections
|
||||
@ -426,7 +427,7 @@ FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_bind()
|
||||
* Name: udp_bind
|
||||
*
|
||||
* Description:
|
||||
* This function implements the low level parts of the standard UDP
|
||||
@ -509,7 +510,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_connect()
|
||||
* Name: udp_connect
|
||||
*
|
||||
* Description:
|
||||
* This function simply assigns a remote address to UDP "connection"
|
||||
|
Loading…
x
Reference in New Issue
Block a user