Mercurial > hg > freeDiameter
comparison libfdcore/fdcore-internal.h @ 706:4ffbc9f1e922
Large UNTESTED commit with the following changes:
* Improved DiameterIdentity handling (esp. interationalization issues),
and improve efficiency of some string operations in peers, sessions,
and dictionary modules (closes #7)
* Cleanup in the session module to free only unreferenced sessions (#16)
* Removed fd_cpu_flush_cache(), replaced by more robust alternatives.
* Improved peer state machine algorithm to counter SCTP multistream race
condition.
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 09 Feb 2011 15:26:58 +0900 |
parents | 2e94ef0515d7 |
children | 4a9f08d6b6ba |
comparison
equal
deleted
inserted
replaced
705:f0cb8f465763 | 706:4ffbc9f1e922 |
---|---|
135 #define EYEC_PEER 0x373C9336 | 135 #define EYEC_PEER 0x373C9336 |
136 | 136 |
137 /* Origin of this peer object, for debug */ | 137 /* Origin of this peer object, for debug */ |
138 char *p_dbgorig; | 138 char *p_dbgorig; |
139 | 139 |
140 /* State of the peer, and its lock */ | |
141 enum peer_state p_state; | |
142 pthread_mutex_t p_state_mtx; | |
143 | |
140 /* Chaining in peers sublists */ | 144 /* Chaining in peers sublists */ |
141 struct fd_list p_actives; /* list of peers in the STATE_OPEN state -- used by routing */ | 145 struct fd_list p_actives; /* list of peers in the STATE_OPEN state -- used by routing */ |
142 struct fd_list p_expiry; /* list of expiring peers, ordered by their timeout value */ | 146 struct fd_list p_expiry; /* list of expiring peers, ordered by their timeout value */ |
143 struct timespec p_exp_timer; /* Timestamp where the peer will expire; updated each time activity is seen on the peer (except DW) */ | 147 struct timespec p_exp_timer; /* Timestamp where the peer will expire; updated each time activity is seen on the peer (except DW) */ |
144 | 148 |
145 /* Some flags influencing the peer state machine */ | 149 /* Some flags influencing the peer state machine */ |
146 struct { | 150 struct { |
147 unsigned pf_responder : 1; /* The peer has been created to handle incoming connection */ | 151 unsigned pf_responder : 1; /* The peer has been created to handle incoming connection */ |
148 unsigned pf_delete : 1; /* Destroy the peer when the connection is terminated */ | 152 unsigned pf_delete : 1; /* Destroy the peer when the connection is terminated */ |
153 unsigned pf_localterm : 1; /* If the latest DPR/DPA was initiated from this side */ | |
149 | 154 |
150 unsigned pf_dw_pending : 1; /* A DWR message was sent and not answered yet */ | 155 unsigned pf_dw_pending : 1; /* A DWR message was sent and not answered yet */ |
151 | 156 |
152 unsigned pf_cnx_pb : 1; /* The peer was disconnected because of watchdogs; must exchange 3 watchdogs before putting back to normal */ | 157 unsigned pf_cnx_pb : 1; /* The peer was disconnected because of watchdogs; must exchange 3 watchdogs before putting back to normal */ |
153 unsigned pf_reopen_cnt : 2; /* remaining DW to be exchanged after re-established connection */ | 158 unsigned pf_reopen_cnt : 2; /* remaining DW to be exchanged after re-established connection */ |
189 void *p_cb_data; | 194 void *p_cb_data; |
190 | 195 |
191 }; | 196 }; |
192 #define CHECK_PEER( _p ) \ | 197 #define CHECK_PEER( _p ) \ |
193 (((_p) != NULL) && (((struct fd_peer *)(_p))->p_eyec == EYEC_PEER)) | 198 (((_p) != NULL) && (((struct fd_peer *)(_p))->p_eyec == EYEC_PEER)) |
199 | |
200 #define fd_peer_getstate(peer) fd_peer_get_state((struct peer_hdr *)(peer)) | |
201 | |
194 | 202 |
195 /* Events codespace for struct fd_peer->p_events */ | 203 /* Events codespace for struct fd_peer->p_events */ |
196 enum { | 204 enum { |
197 /* Dump all info about this peer in the debug log */ | 205 /* Dump all info about this peer in the debug log */ |
198 FDEVP_DUMP_ALL = 1500 | 206 FDEVP_DUMP_ALL = 1500 |
305 int fd_p_dw_handle(struct msg ** msg, int req, struct fd_peer * peer); | 313 int fd_p_dw_handle(struct msg ** msg, int req, struct fd_peer * peer); |
306 int fd_p_dw_timeout(struct fd_peer * peer); | 314 int fd_p_dw_timeout(struct fd_peer * peer); |
307 int fd_p_dw_reopen(struct fd_peer * peer); | 315 int fd_p_dw_reopen(struct fd_peer * peer); |
308 int fd_p_dp_handle(struct msg ** msg, int req, struct fd_peer * peer); | 316 int fd_p_dp_handle(struct msg ** msg, int req, struct fd_peer * peer); |
309 int fd_p_dp_initiate(struct fd_peer * peer, char * reason); | 317 int fd_p_dp_initiate(struct fd_peer * peer, char * reason); |
318 int fd_p_dp_newdelay(struct fd_peer * peer); | |
310 | 319 |
311 /* Active peers -- routing process should only ever take the read lock, the write lock is managed by PSMs */ | 320 /* Active peers -- routing process should only ever take the read lock, the write lock is managed by PSMs */ |
312 extern struct fd_list fd_g_activ_peers; | 321 extern struct fd_list fd_g_activ_peers; |
313 extern pthread_rwlock_t fd_g_activ_peers_rw; /* protect the list */ | 322 extern pthread_rwlock_t fd_g_activ_peers_rw; /* protect the list */ |
314 | 323 |
324 int fd_cnx_serv_listen(struct cnxctx * conn); | 333 int fd_cnx_serv_listen(struct cnxctx * conn); |
325 struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv); | 334 struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv); |
326 struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen); | 335 struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen); |
327 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list); | 336 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list); |
328 int fd_cnx_start_clear(struct cnxctx * conn, int loop); | 337 int fd_cnx_start_clear(struct cnxctx * conn, int loop); |
329 void fd_cnx_sethostname(struct cnxctx * conn, char * hn); | 338 void fd_cnx_sethostname(struct cnxctx * conn, DiamId_t hn); |
330 int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority, void * alt_creds); | 339 int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority, void * alt_creds); |
331 char * fd_cnx_getid(struct cnxctx * conn); | 340 char * fd_cnx_getid(struct cnxctx * conn); |
332 int fd_cnx_getproto(struct cnxctx * conn); | 341 int fd_cnx_getproto(struct cnxctx * conn); |
333 int fd_cnx_getTLS(struct cnxctx * conn); | 342 int fd_cnx_getTLS(struct cnxctx * conn); |
343 int fd_cnx_isMultichan(struct cnxctx * conn); | |
334 int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size); | 344 int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size); |
335 int fd_cnx_get_local_eps(struct fd_list * list); | 345 int fd_cnx_get_local_eps(struct fd_list * list); |
336 int fd_cnx_getremoteeps(struct cnxctx * conn, struct fd_list * eps); | 346 int fd_cnx_getremoteeps(struct cnxctx * conn, struct fd_list * eps); |
337 char * fd_cnx_getremoteid(struct cnxctx * conn); | 347 char * fd_cnx_getremoteid(struct cnxctx * conn); |
338 int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len); | 348 int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len); |
340 int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len, uint32_t flags); | 350 int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len, uint32_t flags); |
341 void fd_cnx_destroy(struct cnxctx * conn); | 351 void fd_cnx_destroy(struct cnxctx * conn); |
342 | 352 |
343 /* Flags for the fd_cnx_send function : */ | 353 /* Flags for the fd_cnx_send function : */ |
344 #define FD_CNX_ORDERED (1 << 0) /* All messages sent with this flag set will be delivered in the same order. No guarantee on other messages */ | 354 #define FD_CNX_ORDERED (1 << 0) /* All messages sent with this flag set will be delivered in the same order. No guarantee on other messages */ |
345 #define FD_CNX_BROADCAST (1 << 1) /* The message is sent over all stream pairs, in case of SCTP. No effect on TCP */ | |
346 | 355 |
347 #endif /* _FDCORE_INTERNAL_H */ | 356 #endif /* _FDCORE_INTERNAL_H */ |