/*
Copyright 2009 Nathan Phillip Brink
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include "listen.h"
#include <list.h>
#include <malloc.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
/* local */
struct distrend_client
{
int sock;
int state;
};
struct distrend_clientset
{
LIST *clients;
};
int distrend_listen(struct distrend_config *config, struct distrend_clientset **clients)
{
int tmp;
struct sockaddr_in6 sockaddr =
{
.sin6_family = AF_INET6,
.sin6_port = 0,
.sin6_flowinfo = 0,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_scope_id = 0
};
*clients = malloc(sizeof(struct distrend_clientset));
(*clients)->clients = list_init();
sockaddr.sin6_port = htonl(4050);
config->listens->sock = socket(AF_INET6, SOCK_STREAM, 0);
tmp = bind(config->listens->sock, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
if(tmp == -1)
{
perror("bind");
free(*clients);
return 1;
}
tmp = listen(config->listens->sock, 1);
return 0;
}
int distrend_unlisten(struct distrend_listen *listens, struct distrend_clientset *clients)
{
fprintf(stderr, "%s:%d: I am a stub that needn't be implemented 'til later\n", __FILE__, __LINE__);
return 1;
}
/**
This is probably just NOT a placeholder for remotio
*/
void remotio_send_to_client()
{
fprintf(stderr, "%s:%d: I am futile! And I'm happy because of it :-D\n", __FILE__, __LINE__);
}