diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2012-06-23 10:33:16 +0200 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2012-06-23 10:33:16 +0200 |
commit | 0aed654ac735749be31e4119336808596136aac3 (patch) | |
tree | 3c43968af08245576fa42198814347700dd978b8 /src/pcu_main.cpp | |
parent | f6b7ca5dd4ba93c13307313c61f06509645b6bca (diff) |
Split of L1 interface to be used with OpenBTS or sysmo-BTS
The OpenBTS socket functions are moved from main to pcu_l1_if.cpp.
New sysmo_l1_if.cpp is introduced. It used special unix socket interface
to connect to sysmo-BTS. This is required to access CCCH/RACH and info
about cell layout. Traffic is also forwarded via this interface, but
it direct access of L1 baseband DSP will be added soon.
In order to handle ready-to-send requests above l1_if, the transmit
queue (for downlink blocks) is moved to gprs_rlcmac.cpp.
The TBF instance additionally holds TRX and TS info, but this is only
a hack currently. TBF instance requires more details about allocated
ressources in the future.
Diffstat (limited to 'src/pcu_main.cpp')
-rw-r--r-- | src/pcu_main.cpp | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index f26c6d86..329f669f 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -27,9 +27,6 @@ #define SGSN_IP "127.0.0.1" #define SGSN_PORT 23000 #define NSVCI 4 -#define PCU_L1_IF_PORT 5944 - -struct l1fwd_hdl *l1fh = talloc_zero(NULL, struct l1fwd_hdl); int sgsn_ns_cb(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msgb *msg, uint16_t bvci) { @@ -49,97 +46,6 @@ int sgsn_ns_cb(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msgb *msg, return rc; } -/* data has arrived on the udp socket */ -static int udp_read_cb(struct osmo_fd *ofd) -{ - struct msgb *msg = msgb_alloc_headroom(2048, 128, "udp_rx"); - struct l1fwd_hdl *l1fh = (l1fwd_hdl *)ofd->data; - struct femtol1_hdl *fl1h = l1fh->fl1h; - int rc; - - if (!msg) - return -ENOMEM; - - msg->l1h = msg->data; - - l1fh->remote_sa_len = sizeof(l1fh->remote_sa); - rc = recvfrom(ofd->fd, msg->l1h, msgb_tailroom(msg), 0, - (struct sockaddr *) &l1fh->remote_sa, &l1fh->remote_sa_len); - if (rc < 0) { - perror("read from udp"); - msgb_free(msg); - return rc; - } else if (rc == 0) { - perror("len=0 read from udp"); - msgb_free(msg); - return rc; - } - msgb_put(msg, rc); - - rc = pcu_l1if_handle_l1prim(fl1h, msg); - return rc; -} - -/* callback when we can write to the UDP socket */ -static int udp_write_cb(struct osmo_fd *ofd, struct msgb *msg) -{ - int rc; - struct l1fwd_hdl *l1fh = (l1fwd_hdl *)ofd->data; - - //DEBUGP(DGPRS, "UDP: Writing %u bytes for MQ_L1_WRITE queue\n", msgb_l1len(msg)); - - rc = sendto(ofd->fd, msg->l1h, msgb_l1len(msg), 0, - (const struct sockaddr *)&l1fh->remote_sa, l1fh->remote_sa_len); - if (rc < 0) { - LOGP(DPCU, LOGL_ERROR, "error writing to L1 msg_queue: %s\n", - strerror(errno)); - return rc; - } else if (rc < msgb_l1len(msg)) { - LOGP(DPCU, LOGL_ERROR, "short write to L1 msg_queue: " - "%u < %u\n", rc, msgb_l1len(msg)); - return -EIO; - } - - return 0; -} - -int pcu_l1if_open() -{ - //struct l1fwd_hdl *l1fh; - struct femtol1_hdl *fl1h; - int rc; - - /* allocate new femtol1_handle */ - fl1h = talloc_zero(NULL, struct femtol1_hdl); - INIT_LLIST_HEAD(&fl1h->wlc_list); - - l1fh->fl1h = fl1h; - fl1h->priv = l1fh; - - struct osmo_wqueue * queue = &((l1fh->fl1h)->write_q); - osmo_wqueue_init(queue, 10); - queue->bfd.when |= BSC_FD_READ; - queue->bfd.data = l1fh; - queue->bfd.priv_nr = 0; - - /* Open UDP */ - struct osmo_wqueue *wq = &l1fh->udp_wq; - - osmo_wqueue_init(wq, 10); - wq->write_cb = udp_write_cb; - wq->read_cb = udp_read_cb; - wq->bfd.when |= BSC_FD_READ; - wq->bfd.data = l1fh; - wq->bfd.priv_nr = 0; - rc = osmo_sock_init_ofd(&wq->bfd, AF_UNSPEC, SOCK_DGRAM, - IPPROTO_UDP, NULL, PCU_L1_IF_PORT, - OSMO_SOCK_F_BIND); - if (rc < 0) { - perror("sock_init"); - exit(1); - } -} - int main(int argc, char *argv[]) { uint16_t nsvci = NSVCI; |