summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp.h3
-rw-r--r--src/ipcpd/shim-udp/main.c31
2 files changed, 11 insertions, 23 deletions
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 9decac8b..f640d78b 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -26,6 +26,9 @@
#include "ipcp-ops.h"
#include "ipcp-data.h"
+/* needed to run over shim DIFs */
+#define ANONYMOUS_AP "__ANONYMOUS__"
+
enum ipcp_state {
IPCP_INIT = 0,
IPCP_ENROLLING,
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 66513b02..9f33cf80 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -29,6 +29,7 @@
#include <ouroboros/utils.h>
#include <ouroboros/ipcp.h>
#include <ouroboros/dif_config.h>
+#include <ouroboros/sockets.h>
#define OUROBOROS_PREFIX "ipcpd/shim-udp"
@@ -43,14 +44,6 @@
#include <stdlib.h>
#include <pthread.h>
-#include "irmd_messages.pb-c.h"
-
-typedef IrmMsg irm_msg_t;
-
-#include "ipcpd_messages.pb-c.h"
-
-typedef IpcpMsg ipcp_msg_t;
-
#define THIS_TYPE IPCP_SHIM_UDP
#define LISTEN_PORT htons(0x0D1F)
#define SHIM_UDP_BUF_SIZE 256
@@ -159,9 +152,6 @@ void * ipcp_udp_listener()
irm_msg_t * ret_msg ;
while (true) {
- flow = malloc(sizeof *flow);
- if (flow == NULL)
- continue;
n = sizeof c_saddr;
n = recvfrom(sfd, buf, SHIM_UDP_BUF_SIZE, 0,
(struct sockaddr *) &c_saddr, (unsigned *) &n);
@@ -175,6 +165,9 @@ void * ipcp_udp_listener()
continue;
/* create a new socket for the server */
+ flow = malloc(sizeof *flow);
+ if (flow == NULL)
+ continue;
flow->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (flow->fd == -1) {
@@ -193,11 +186,6 @@ void * ipcp_udp_listener()
f_saddr.sin_port = 0;
- /* at least try to get the packet on the wire */
- while (sendto(flow->fd, buf, n, 0,
- (struct sockaddr *) &c_saddr, sizeof c_saddr) < 0)
- ;
-
/*
* store the remote address in the file descriptor
* this avoids having to store the sockaddr_in in
@@ -211,11 +199,10 @@ void * ipcp_udp_listener()
continue;
}
-
- /* GERONIMOO */
+ /* reply to IRM */
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
- msg.ap_name = "John Day";
+ msg.ap_name = ANONYMOUS_AP;
msg.ae_name = ""; /* no AE */
msg.has_reg_ap_id = true;
msg.reg_ap_id = ipcp_data_get_reg_ap_id(_ipcp->data, buf);
@@ -406,7 +393,6 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
return -1;
}
- /* get the remote IPv4 address using dns */
/* FIXME: use calls to specify DDNS server */
#define IP_ADDR 0x7f000001; /* localhost */
@@ -423,8 +409,7 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
while (sendto(flow->fd, dst_ap_name, n, 0,
(struct sockaddr *) &r_saddr, sizeof r_saddr) < 0)
- /* wait for the echo from the server */
- /* FIXME: do this in a different thread not to block the entire shim */
+ /* FIXME:move the client handling to thread pool */
n = sizeof r_saddr;
n = recvfrom(flow->fd, buf, SHIM_UDP_BUF_SIZE, 0,
(struct sockaddr *) &r_saddr, (unsigned *) &n);
@@ -476,7 +461,7 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
return -1;
}
- return flow->fd;
+ return 0;
}
int ipcp_udp_flow_alloc_resp(uint32_t port_id,
int response)