Date: Fri, 12 Apr 2002 07:06:08 -0500 From: "gianluca " <jazzit@sociologist.com> To: freebsd-atm@FreeBSD.ORG Subject: Fore pca-200E adapter: connect to atm socket Message-ID: <20020412120609.1387.qmail@mail.com>
next in thread | raw e-mail | index | archive | help
Hi,
I am new.
I have a PC running freeBSD4.5 with
Fore 200E adapter. The aim is to build on
top of the ATM HARP socket part of the ss7
stack something like ATM/AAL5/SSCOP/SSCF/MTP3-B... I will only need to have some functionalities for every layer implemented.
My application will have to use only a fix PVC
value. In my set up I have now loopback the NIC (fiber connects Tx and RX). Through the
atm commands I have set pvc in the card and
IP address of a not-existing other end host.
When running ping towards the not existing
host I have the expected behaviour with the
route to host found but obviously not
response. So far so good.
I have now started to use the sample programs reported in the HARP source code and
modified as reported below, to use a fixed
PVC value. I'd like to do a simple client -server application to start practice with the
socket. The client program however doesn't
start because the function connect() returns
the error connect: Invalid argument.
I guess that the values of satm that I pass to
the function connect() are not correct.
Does anyone know what's wrong?
Do you know where I van find some more docs
and examples apart from what is available at
HARP site?
Thanks
Gianluca
*
* ATM API sample client application
*
* This application will open an ATM socket to a server, send a text string
* in a PDU and then read one PDU from the socket and print its contents.
*
*/
#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netatm/atm.h>
#define MAX_LEN 4096 /* Maximum PDU length */
#define MY_APPL "Client"
Atm_addr_pvc pvc_addr = {0,0,0,56}; //vpi 0, vci 56
static char message[] = "A message from the client";
main(argc, argv)
int argc;
char **argv;
{
struct sockaddr_atm satm;
struct t_atm_aal5 aal5;
struct t_atm_net_intf netintf;
struct t_atm_app_name appname;
char buffer[MAX_LEN+1];
int s, n, optlen;
/*
* Create socket
*/
s = socket(AF_ATM, SOCK_SEQPACKET, ATM_PROTO_AAL5);
if (s < 0) {
perror("socket");
exit(1);
}
/*
* Set up destination SAP
*/
bzero((caddr_t) &satm, sizeof(satm));
satm.satm_family = AF_ATM;
#if (defined(BSD) && (BSD >= 199103))
satm.satm_len = sizeof(satm);
#endif
/* PVC address */
satm.satm_addr.t_atm_sap_addr.SVE_tag_addr = T_ATM_PRESENT;
satm.satm_addr.t_atm_sap_addr.SVE_tag_selector = T_ATM_PRESENT;
satm.satm_addr.t_atm_sap_addr.address_format = T_ATM_PVC_ADDR;
satm.satm_addr.t_atm_sap_addr.address_length = sizeof(pvc_addr);
bcopy((caddr_t)&pvc_addr,
(caddr_t)satm.satm_addr.t_atm_sap_addr.address,
sizeof(Atm_addr_pvc));
/*
* Set up connection parameters
*/
aal5.forward_max_SDU_size = MAX_LEN;
aal5.backward_max_SDU_size = MAX_LEN;
aal5.SSCS_type = T_ATM_NULL;
optlen = sizeof(aal5);
if (setsockopt(s, T_ATM_SIGNALING, T_ATM_AAL5, (caddr_t)&aal5,
optlen) < 0) {
perror("setsockopt(aal5)");
exit(1);
}
strncpy(netintf.net_intf, "ni0", IFNAMSIZ);
optlen = sizeof(netintf);
if (setsockopt(s, T_ATM_SIGNALING, T_ATM_NET_INTF, (caddr_t)&netintf,
optlen) < 0) {
perror("setsockopt(net_intf)");
exit(1);
}
strncpy(appname.app_name, MY_APPL, T_ATM_APP_NAME_LEN);
optlen = sizeof(appname);
if (setsockopt(s, T_ATM_SIGNALING, T_ATM_APP_NAME, (caddr_t)&appname,
optlen) < 0) {
perror("setsockopt(app_name)");
exit(1);
}
/*
* Connect the socket
*/
if (connect(s, (struct sockaddr *) &satm, sizeof(satm)) < 0) {
perror("connect");
exit(1);
}
/*
* Exchange message with peer
*/
if (write(s, message, sizeof(message)) != sizeof(message)) {
perror("write");
exit(1);
}
if ((n = read(s, buffer, MAX_LEN)) < 0) {
perror("read");
exit(1);
}
buffer[n] = '\0';
printf("received %d bytes: <%s>\n", n, buffer);
/*
* Finish up
*/
if (close(s) < 0) {
perror("close");
exit(1);
}
exit(0);
}
--
_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
Looking for old school, college, work or military friends? Go to Classmates now!<http://www.classmates.com/index.tf?s=6010>http://www.classmates.com/index.tf?s=6010
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-atm" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020412120609.1387.qmail>
