Commit 94230760 authored by Pekka Pessi's avatar Pekka Pessi

Updated SigComp interface in tport_stub_sigcomp.c and tport_sigcomp.c.

darcs-hash:20060426172555-65a35-f93086747ce30a1b0559658a858d411c67c206bd.gz
parent bea219c9
......@@ -50,8 +50,14 @@
typedef struct tport_sigcomp_handler tport_sigcomp_handler_t;
/** Per end-point SigComp data */
struct tport_compressor {
struct sigcomp_state_handler *msc_state_handler;
struct sigcomp_compartment *msc_compartment;
};
/** Per-socket SigComp data */
struct tport_sigcomp {
struct tport_comp {
struct sigcomp_udvm *sc_udvm;
struct sigcomp_compartment *sc_cc;
struct sigcomp_compressor *sc_compressor;
......@@ -69,34 +75,56 @@ struct tport_sigcomp {
};
struct sigcomp_compartment *vsc_master_init_sigcomp(tport_master_t *mr,
char const *algorithm)
tport_compressor_t *vsc_master_init_sigcomp(tport_t *mr,
char const *algorithm)
{
tport_compressor_t *retval = NLL;
stuct sigcomp_state_handler *sh = NULL;
struct sigcomp_algorithm *a = NULL;
struct sigcomp_compartment *cc = NULL;
#if 0
struct sigcomp_algorithm const *algorithm = self->sa_algorithm;
if (algorithm == NULL)
algorithm = sigcomp_algorithm_by_name(getenv("SIGCOMP_ALGORITHM"));
algorithm = getenv("SIGCOMP_ALGORITHM");
self->sa_state_handler = sigcomp_state_handler_create();
retval = su_zalloc((su_home_t *)mr, sizeof *retval);
if (retval == NULL)
return retval;
if (self->sa_state_handler)
self->sa_compartment =
sigcomp_compartment_create(algorithm, self->sa_state_handler, 0,
"", 0, NULL, 0);
sh = sigcomp_state_handler_create();
if (sh == NULL) {
SU_DEBUG_1(("tport: initializing SigComp state handler: %s\n",
strerror(errno)));
vsc_master_deinit_sigcomp(mr, retval), retval = NULL;
return retval;
}
retval->msc_state_handler = sh;
a = sigcomp_algorithm_by_name(algorithm);
cc = sigcomp_compartment_create(a, sh, 0, "", 0, NULL, 0);
if (cc == NULL) {
SU_DEBUG_1(("tport: initializing SigComp master compartment: %s\n",
strerror(errno)));
vsc_master_deinit_sigcomp(mr, retval), retval = NULL;
return retval;
}
self->msc_compartment = cc;
return retval;
}
if (self->sa_compartment) {
agent_sigcomp_options(self, self->sa_compartment);
sigcomp_compartment_option(self->sa_compartment, "stateless");
}
else
SU_DEBUG_1(("nta: initializing SigComp: %s\n", strerror(errno)));
if (mr->mr_compartment)
sigcomp_compartment_unref(mt->mr_compartment);
mr->mr_compartment = sigcomp_compartment_ref(cc);
#endif
return cc;
}
......
......@@ -66,6 +66,10 @@ int tport_init_compressor(tport_t *tp,
if (tp->tp_comp)
return 0;
comp_name = tport_canonize_comp(comp_name);
if (comp_name == NULL)
return 0;
tcc = su_zalloc(tp->tp_home, vsc->vsc_sizeof_context);
if (tcc == NULL)
......@@ -77,6 +81,7 @@ int tport_init_compressor(tport_t *tp,
}
tp->tp_comp = tcc;
return 0;
}
......@@ -168,8 +173,14 @@ int tport_sigcomp_assign(tport_t *self, struct sigcomp_compartment *cc)
{
tport_comp_vtable_t const *vsc = tport_comp_vtable;
if (vsc)
return vsc->vsc_sigcomp_assign(self, &self->tp_comp, cc);
if (!vsc)
return 0;
if (tport_is_connection_oriented(self) &&
tport_is_secondary(self) &&
self->tp_socket != SOCKET_ERROR) {
return vsc->vsc_set_compartment(self, self->tp_comp, cc);
}
return 0;
}
......@@ -180,10 +191,18 @@ tport_sigcomp_assign_if_needed(tport_t *self,
{
tport_comp_vtable_t const *vsc = tport_comp_vtable;
if (vsc)
return vsc->vsc_sigcomp_assign_if_needed(self, cc);
return NULL;
if (!vsc)
return NULL;
if (!self->tp_name->tpn_comp)
return NULL;
if (cc) {
tport_sigcomp_assign(self, cc);
return cc;
}
return vsc->vsc_get_compartment(self, self->tp_comp);
}
......@@ -237,19 +256,18 @@ struct sigcomp_udvm **tport_get_udvm_slot(tport_t *self)
}
/** Receive data from datagram using SigComp. */
int tport_recv_comp_dgram(tport_t *self, int N)
int tport_recv_comp_dgram(tport_t const *self,
tport_compressor_t *sc,
msg_t **in_out_msg)
{
tport_comp_vtable_t const *vsc = tport_comp_vtable;
char dummy[1];
int error = EBADMSG;
if (vsc)
return vsc->vsc_recv_comp(self, N);
return vsc->vsc_recv_comp(self, sc, in_out_msg);
recv(self->tp_socket, dummy, 1, 0); /* remove msg from socket */
msg_destroy(*in_out_msg), *in_out_msg = NULL;
return su_seterrno(error);
return su_seterrno(EBADMSG);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment