#include <sys/time.h>
#include <frsh.h>
+long int udp_budget, udp_period;
typedef struct {
int udp_fd;
static int
udp_socket_create(UDPContext *s, struct sockaddr_in *addr, int *addr_len)
{
+ static long int netcont_num = 0;
int ret,udp_fd;
+ char netcont_name[20];
addr->sin_family = AF_INET;
addr->sin_addr.s_addr = htonl (INADDR_ANY);
*addr_len = sizeof(struct sockaddr_in);
/* set params for contract */
- frsh_network_bytes_to_budget(FRSH_NETPF_FWP, 8600000, &s->budget);
- s->period = fosa_msec_to_rel_time(100);
+ frsh_network_bytes_to_budget(FRSH_NETPF_FWP, udp_budget, &s->budget);
+ s->period = fosa_msec_to_rel_time(udp_period);
s->send_pinfo.body = NULL;
udp_fd = frsh_send_endpoint_create(FRSH_NETPF_FWP,
FRSH_CT_REGULAR);
//if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params");
if (ret) return -1;
- ret = frsh_contract_set_resource_and_label(&s->contract,FRSH_RT_NETWORK,
- FRSH_NETPF_FWP, "net_cont1");
+ snprintf(netcont_name, sizeof(netcont_name), "net_cont%d", ++netcont_num);
+ ret = frsh_contract_set_resource_and_label(&s->contract,FRSH_RT_NETWORK,
+ FRSH_NETPF_FWP, netcont_name);
//if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
if (ret) return -1;
static int udp_close(URLContext *h)
{
UDPContext *s = h->priv_data;
- int ret1, ret2;
+ int ret;
- ret1 = frsh_send_endpoint_destroy(s->sepoint);
- ret2 = frsh_receive_endpoint_destroy(s->repoint);
- return (ret1 || ret2);
+ frsh_send_endpoint_unbind(s->sepoint);
+ ret = frsh_contract_cancel(s->vres);
+ return ret;
}
URLProtocol udp_protocol = {