diff options
Diffstat (limited to 'src/ipcpd')
| -rw-r--r-- | src/ipcpd/broadcast/main.c | 30 | ||||
| -rw-r--r-- | src/ipcpd/eth/eth.c | 1 | ||||
| -rw-r--r-- | src/ipcpd/ipcp.c | 33 | ||||
| -rw-r--r-- | src/ipcpd/ipcp.h | 4 | ||||
| -rw-r--r-- | src/ipcpd/local/main.c | 1 | ||||
| -rw-r--r-- | src/ipcpd/normal/main.c | 1 | ||||
| -rw-r--r-- | src/ipcpd/raptor/main.c | 1 | ||||
| -rw-r--r-- | src/ipcpd/udp/main.c | 1 | 
8 files changed, 51 insertions, 21 deletions
| diff --git a/src/ipcpd/broadcast/main.c b/src/ipcpd/broadcast/main.c index 8c6bfa71..af39dd34 100644 --- a/src/ipcpd/broadcast/main.c +++ b/src/ipcpd/broadcast/main.c @@ -198,31 +198,18 @@ static int broadcast_ipcp_bootstrap(const struct ipcp_config * conf)          return -1;  } -static int broadcast_ipcp_query(const uint8_t * dst) +static int name_check(const uint8_t * dst)  {          uint8_t * buf;          size_t    len;          int       ret; -        char *    multicast_name; -        char *    suffix = ".mc";          len = hash_len(ipcpi.dir_hash_algo);          buf =  malloc(len);          if (buf == NULL)                  return -ENOMEM; -        multicast_name = malloc(strlen(ipcpi.layer_name) + strlen(suffix) + 1); -        if (multicast_name == NULL) { -                free(buf); -                return -ENOMEM; -        } - -        strcpy(multicast_name, ipcpi.layer_name); -        strcat(multicast_name, suffix); - -        str_hash(ipcpi.dir_hash_algo, buf, multicast_name); - -        free(multicast_name); +        str_hash(ipcpi.dir_hash_algo, buf, ipcpi.layer_name);          ret = memcmp(buf, dst, len); @@ -231,9 +218,9 @@ static int broadcast_ipcp_query(const uint8_t * dst)          return ret;  } -static int broadcast_ipcp_alloc(int             fd, -                                const uint8_t * dst, -                                qosspec_t       qs) +static int broadcast_ipcp_join(int             fd, +                               const uint8_t * dst, +                               qosspec_t       qs)  {          struct conn conn; @@ -243,7 +230,7 @@ static int broadcast_ipcp_alloc(int             fd,          conn.flow_info.fd = fd; -        if (broadcast_ipcp_query(dst) != 0) +        if (name_check(dst) != 0)                  return -1;          notifier_event(NOTIFY_DT_CONN_ADD, &conn); @@ -276,8 +263,9 @@ static struct ipcp_ops broadcast_ops = {          .ipcp_disconnect      = connmgr_ipcp_disconnect,          .ipcp_reg             = NULL,          .ipcp_unreg           = NULL, -        .ipcp_query           = broadcast_ipcp_query, -        .ipcp_flow_alloc      = broadcast_ipcp_alloc, +        .ipcp_query           = NULL, +        .ipcp_flow_alloc      = NULL, +        .ipcp_flow_join       = broadcast_ipcp_join,          .ipcp_flow_alloc_resp = NULL,          .ipcp_flow_dealloc    = broadcast_ipcp_dealloc  }; diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index f9691626..68f39c5d 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -1777,6 +1777,7 @@ static struct ipcp_ops eth_ops = {          .ipcp_unreg           = eth_ipcp_unreg,          .ipcp_query           = eth_ipcp_query,          .ipcp_flow_alloc      = eth_ipcp_flow_alloc, +        .ipcp_flow_join       = NULL,          .ipcp_flow_alloc_resp = eth_ipcp_flow_alloc_resp,          .ipcp_flow_dealloc    = eth_ipcp_flow_dealloc  }; diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 6376bedb..dced6f64 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -428,6 +428,39 @@ static void * mainloop(void * o)                                                             msg->hash.data,                                                             qs);                          break; +                case IPCP_MSG_CODE__IPCP_FLOW_JOIN: +                        ret_msg.has_result = true; + +                        if (ipcpi.ops->ipcp_flow_join == NULL) { +                                log_err("Broadcast unsupported."); +                                ret_msg.result = -ENOTSUP; +                                break; +                        } + +                        assert(msg->hash.len == ipcp_dir_hash_len()); + +                        if (ipcp_get_state() != IPCP_OPERATIONAL) { +                                log_err("IPCP in wrong state."); +                                ret_msg.result = -EIPCPSTATE; +                                break; +                        } + +                        qs = msg_to_spec(msg->qosspec); +                        fd = np1_flow_alloc(msg->pid, +                                            msg->flow_id, +                                            qs); +                        if (fd < 0) { +                                log_err("Failed allocating fd on flow_id %d.", +                                        msg->flow_id); +                                ret_msg.result = -1; +                                break; +                        } + +                        ret_msg.result = +                                ipcpi.ops->ipcp_flow_join(fd, +                                                          msg->hash.data, +                                                          qs); +                        break;                  case IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP:                          ret_msg.has_result = true;                          if (ipcpi.ops->ipcp_flow_alloc_resp == NULL) { diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index fabd35fe..b6e79413 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -62,6 +62,10 @@ struct ipcp_ops {                                    const uint8_t * dst,                                    qosspec_t       qs); +        int   (* ipcp_flow_join)(int             fd, +                                 const uint8_t * dst, +                                 qosspec_t       qs); +          int   (* ipcp_flow_alloc_resp)(int fd,                                         int response); diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index ab43f1f8..88cf2352 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -325,6 +325,7 @@ static struct ipcp_ops local_ops = {          .ipcp_unreg           = ipcp_local_unreg,          .ipcp_query           = ipcp_local_query,          .ipcp_flow_alloc      = ipcp_local_flow_alloc, +        .ipcp_flow_join       = NULL,          .ipcp_flow_alloc_resp = ipcp_local_flow_alloc_resp,          .ipcp_flow_dealloc    = ipcp_local_flow_dealloc  }; diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 3f05f421..5e013eb8 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -295,6 +295,7 @@ static struct ipcp_ops normal_ops = {          .ipcp_unreg           = dir_unreg,          .ipcp_query           = normal_ipcp_query,          .ipcp_flow_alloc      = fa_alloc, +        .ipcp_flow_join       = NULL,          .ipcp_flow_alloc_resp = fa_alloc_resp,          .ipcp_flow_dealloc    = fa_dealloc  }; diff --git a/src/ipcpd/raptor/main.c b/src/ipcpd/raptor/main.c index 8f578611..d3c9040e 100644 --- a/src/ipcpd/raptor/main.c +++ b/src/ipcpd/raptor/main.c @@ -1055,6 +1055,7 @@ static struct ipcp_ops raptor_ops = {          .ipcp_unreg           = raptor_unreg,          .ipcp_query           = raptor_query,          .ipcp_flow_alloc      = raptor_flow_alloc, +        .ipcp_flow_join       = NULL,          .ipcp_flow_alloc_resp = raptor_flow_alloc_resp,          .ipcp_flow_dealloc    = raptor_flow_dealloc  }; diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index a1af1e85..31e6166b 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -1183,6 +1183,7 @@ static struct ipcp_ops udp_ops = {          .ipcp_unreg           = ipcp_udp_unreg,          .ipcp_query           = ipcp_udp_query,          .ipcp_flow_alloc      = ipcp_udp_flow_alloc, +        .ipcp_flow_join       = NULL,          .ipcp_flow_alloc_resp = ipcp_udp_flow_alloc_resp,          .ipcp_flow_dealloc    = ipcp_udp_flow_dealloc  }; | 
