void JoinPBX::bridge(void)
{
struct join_relation *relation;
struct lcr_msg *message;
int numconnect = 0, relations = 0;
class Endpoint *epoint;
struct port_list *portlist;
class Port *port;
unsigned int bridge_id;
class Join *join_3pty;
class JoinPBX *joinpbx_3pty;
#ifdef DEBUG_COREBRIDGE
int allmISDN = 0; // never set for debug purpose
#else
int allmISDN = 1; // set until a non-mISDN relation is found
#endif
/* bridge id is the serial of join
* if we have a 3pty with another join, we always use the lowest brigde id.
* this way we use common ids, so both joins share same bridge */
if (j_3pty && j_3pty < j_serial)
bridge_id = j_3pty;
else
bridge_id = j_serial;
relation = j_relation;
while(relation) {
/* count all relations */
relations++;
/* check for relation's objects */
epoint = find_epoint_id(relation->epoint_id);
if (!epoint) {
PERROR("software error: relation without existing endpoints.\n");
relation = relation->next;
continue;
}
portlist = epoint->ep_portlist;
if (!portlist) {
PDEBUG(DEBUG_JOIN, "join%d ignoring relation without port object.\n", j_serial);
//#warning testing: keep on hold until single audio stream available
relation->channel_state = 0;
relation = relation->next;
continue;
}
if (portlist->next) {
PDEBUG(DEBUG_JOIN, "join%d ignoring relation with ep%d due to port_list.\n", j_serial, epoint->ep_serial);
//#warning testing: keep on hold until single audio stream available
relation->channel_state = 0;
relation = relation->next;
continue;
}
port = find_port_id(portlist->port_id);
if (!port) {
PDEBUG(DEBUG_JOIN, "join%d ignoring relation without existing port object.\n", j_serial);
relation = relation->next;
continue;
}
if ((port->p_type&PORT_CLASS_MASK)!=PORT_CLASS_mISDN) {
PDEBUG(DEBUG_JOIN, "join%d ignoring relation ep%d because it's port is not mISDN.\n", j_serial, epoint->ep_serial);
if (allmISDN) {
PDEBUG(DEBUG_JOIN, "join%d not all endpoints are mISDN.\n", j_serial);
allmISDN = 0;
}
relation = relation->next;
continue;
}
relation = relation->next;
}
/* check if 3pty members have no mISDN, so bridging via mISDN/lcr will be selected correctly */
join_3pty = find_join_id(j_3pty);
if (join_3pty && join_3pty->j_type == JOIN_TYPE_PBX) {
joinpbx_3pty = (class JoinPBX *)join_3pty;
relation = joinpbx_3pty->j_relation;
while(relation) {
#if 0
no need to count, because j_3pty is taken into account below when checking relations
/* count all relations */
relations++;
#endif
/* check for relation's objects */
epoint = find_epoint_id(relation->epoint_id);
if (!epoint) {
PERROR("software error: relation without existing endpoints.\n");
relation = relation->next;
continue;
}
portlist = epoint->ep_portlist;
if (!portlist) {
PDEBUG(DEBUG_JOIN, "other 3pty join %d: ignoring relation without port object.\n", joinpbx_3pty->j_serial);
//#warning testing: keep on hold until single audio stream available
relation->channel_state = 0;
relation = relation->next;
continue;
}
if (portlist->next) {
//.........这里部分代码省略.........
me8254_subdevice_t* me8254_constr(uint16_t device_id, void* reg_base, unsigned int me8254_idx, unsigned int ctr_idx,
me_lock_t* ctrl_reg_lock, me_lock_t* clk_src_reg_lock)
{
me8254_subdevice_t *subdevice;
PDEBUG("executed.\n");
/** @todo Checkings should be removed. We can safetly assume that data passed from upper level are correct.
*/
// Check if counter index is out of range
if (ctr_idx > 2)
{
PERROR("Counter index is out of range.\n");
return NULL;
}
// Check device specific values.
switch (device_id)
{
case PCI_DEVICE_ID_MEILHAUS_ME140A:
case PCI_DEVICE_ID_MEILHAUS_ME14EA:
case PCI_DEVICE_ID_MEILHAUS_ME4610:
case PCI_DEVICE_ID_MEILHAUS_ME4660:
case PCI_DEVICE_ID_MEILHAUS_ME4660I:
case PCI_DEVICE_ID_MEILHAUS_ME4660S:
case PCI_DEVICE_ID_MEILHAUS_ME4660IS:
case PCI_DEVICE_ID_MEILHAUS_ME4670:
case PCI_DEVICE_ID_MEILHAUS_ME4670I:
case PCI_DEVICE_ID_MEILHAUS_ME4670S:
case PCI_DEVICE_ID_MEILHAUS_ME4670IS:
case PCI_DEVICE_ID_MEILHAUS_ME4680:
case PCI_DEVICE_ID_MEILHAUS_ME4680I:
case PCI_DEVICE_ID_MEILHAUS_ME4680S:
case PCI_DEVICE_ID_MEILHAUS_ME4680IS:
case PCI_DEVICE_ID_MEILHAUS_ME4560:
case PCI_DEVICE_ID_MEILHAUS_ME4560I:
case PCI_DEVICE_ID_MEILHAUS_ME4560S:
case PCI_DEVICE_ID_MEILHAUS_ME4560IS:
case PCI_DEVICE_ID_MEILHAUS_ME4570:
case PCI_DEVICE_ID_MEILHAUS_ME4570I:
case PCI_DEVICE_ID_MEILHAUS_ME4570S:
case PCI_DEVICE_ID_MEILHAUS_ME4570IS:
case PCI_DEVICE_ID_MEILHAUS_ME4760:
case PCI_DEVICE_ID_MEILHAUS_ME4760I:
case PCI_DEVICE_ID_MEILHAUS_ME4760S:
case PCI_DEVICE_ID_MEILHAUS_ME4760IS:
case PCI_DEVICE_ID_MEILHAUS_ME4770:
case PCI_DEVICE_ID_MEILHAUS_ME4770I:
case PCI_DEVICE_ID_MEILHAUS_ME4770S:
case PCI_DEVICE_ID_MEILHAUS_ME4770IS:
case PCI_DEVICE_ID_MEILHAUS_ME4780:
case PCI_DEVICE_ID_MEILHAUS_ME4780I:
case PCI_DEVICE_ID_MEILHAUS_ME4780S:
case PCI_DEVICE_ID_MEILHAUS_ME4780IS:
case PCI_DEVICE_ID_MEILHAUS_ME4860:
case PCI_DEVICE_ID_MEILHAUS_ME4860I:
case PCI_DEVICE_ID_MEILHAUS_ME4860S:
case PCI_DEVICE_ID_MEILHAUS_ME4860IS:
case PCI_DEVICE_ID_MEILHAUS_ME4870:
case PCI_DEVICE_ID_MEILHAUS_ME4870I:
case PCI_DEVICE_ID_MEILHAUS_ME4870S:
case PCI_DEVICE_ID_MEILHAUS_ME4870IS:
case PCI_DEVICE_ID_MEILHAUS_ME4880:
case PCI_DEVICE_ID_MEILHAUS_ME4880I:
case PCI_DEVICE_ID_MEILHAUS_ME4880S:
case PCI_DEVICE_ID_MEILHAUS_ME4880IS:
case PCI_DEVICE_ID_MEILHAUS_ME0752:
case PCI_DEVICE_ID_MEILHAUS_ME0754:
case PCI_DEVICE_ID_MEILHAUS_ME0762:
case PCI_DEVICE_ID_MEILHAUS_ME0764:
case PCI_DEVICE_ID_MEILHAUS_ME0772:
case PCI_DEVICE_ID_MEILHAUS_ME0774:
case PCI_DEVICE_ID_MEILHAUS_ME0782:
case PCI_DEVICE_ID_MEILHAUS_ME0784:
case PCI_DEVICE_ID_MEILHAUS_ME8100_A:
case PCI_DEVICE_ID_MEILHAUS_ME8100_B:
if (me8254_idx > 0)
{
PERROR("8254 index is out of range. Must be 0.\n");
return NULL;
}
break;
case PCI_DEVICE_ID_MEILHAUS_ME140B:
case PCI_DEVICE_ID_MEILHAUS_ME14EB:
if (me8254_idx > 1)
{
PERROR("8254 index is out of range. Must be 0 or 1.\n");
return NULL;
}
break;
case PCI_DEVICE_ID_MEILHAUS_ME140C:
if (me8254_idx > 4)
//.........这里部分代码省略.........
开发者ID:imrehg,项目名称:meids,代码行数:101,代码来源:me8254.c
示例13: jpProcessos
//int __attribute__((__section__(".text.main")))
int jpProcessos(void)
{
int mypid,pid,ret;
char buffer[16];
int i;
int j;
int n;
int tics;
for(j=0; j<80*35; j++) write(1," ",1);
PRINTF("\n****JP: Procesos********************\n");
PRINTF("Probamos getpid\n");
mypid=getpid();
proso_itoa(mypid,buffer);
PRINTF("PID PADRE: ");
PRINTF(buffer);
PRINTF("\nCreacion primer proceso \n");
pid=fork();
if (pid==0){
PRINTF("HOLA SOY EL HIJO\n");
proso_itoa(getpid(),buffer);
PRINTF("El pid del hijo es ");
PRINTF(buffer);
PRINTF("\n");
PRINTF("Soy el hijo y ME SUICIDO\n");
exit();
}else if (pid==-1){
PERROR();
FINJP;
}else{
PRINTF("SOY EL PADRE: Creacion primer proceso OK\n");
}
PRINTF("Creamos una jerarquia: un hijo y un nieto\n");
switch(fork()){
case 0:switch(fork()){
case 0:PRINTF("SOY EL NIETO: ");
proso_itoa(getpid(),buffer);
PRINTF(buffer);
PRINTF("\n");
PRINTF("SOY EL NIETO y me suicido ");
exit();
case -1:FINJP;
default:PRINTF("SOY EL HIJO: ");
proso_itoa(getpid(),buffer);
PRINTF(buffer);
PRINTF("\n");
PRINTF("SOY EL HIJO y me suicido ");
exit();
break;
}
case -1:FINJP;break;
default:break;
}
PRINTF("Creo N procesos concurrentes\n");
for (i=0;i<4;i++){
if (getpid()==mypid) CERROR(fork());
}
for(i=0;i<100;i++){
buffer[0]='A'+(getpid()%4);
CERROR(write(1,buffer,1));
}
PRINTF("Dejo solo uno\n");
if (getpid()!=mypid){
PRINTF("SOY ");proso_itoa(getpid(),buffer);
PRINTF(buffer);PRINTF(" Y Me suicido\n");
exit();
}
PRINTF("Solo queda el proceso ");proso_itoa(getpid(),buffer);
PRINTF(buffer);
PRINTF(" y Deberia ser 0\n");
CHECK( nice(-1), -1, "Probando nice incorrecto(-1)");
CHECK( nice(0), -1, "Probando nice incorrecto(0)");
PRINTF("Probando nice correcto(10):");
n = nice(10);
if (n < 0) {PRINTF("ERROR"); PERROR();}
else {
CHECK( nice(5), 10, "Probando nice correcto(5)");
CHECK( get_stats(-1, &tics), -1, "Probando get_stats pid incorrecto(-1)");
CHECK( get_stats(mypid, (int*)0), -1, "Probando get_stats @tics=0");
CHECK( get_stats(mypid, (int*)10009999999999999999999), -1, "Probando get_stats @tics=1000");
CHECK( get_stats(mypid, &tics), 0, "Probando get_stats OK");
}
PRINTF("Creamos N procesos\n");
i=0;
#if 1
while(((ret=fork())>0)&& (i<100)){
PRINTF("Creo 1 proceso\n");
i++;
}
#endif
PRINTF("Matamos todos los procesos excepto el primero\n");
if (getpid()!=mypid) exit();
proso_itoa(i,buffer);
PRINTF("Hemos creado ");PRINTF(buffer);PRINTF("procesos\n");
PRINTF("\n**************FIN JP**************** PID: ");
//.........这里部分代码省略.........
开发者ID:Gawyn,项目名称:Zeos,代码行数:101,代码来源:userProc.c
示例14: capfs_file_create
/* capfs_file_create()
*/
int capfs_file_create(struct inode *dir, struct dentry *entry, int mode, struct nameidata *nd)
{
int error = 0, len_dir, len_file;
struct inode *inode;
struct capfs_meta meta;
struct capfs_phys phys;
struct capfs_inode *pinode, *parent_pinode = NULL;
char *ptr, *namebuf;
/* update the statistics */
if(capfs_collect_stats) capfs_vfs_stat.create++;
PENTRY;
parent_pinode = CAPFS_I(dir);
if((error = write_lock_inode(parent_pinode)) < 0) {
d_drop(entry);
PEXIT;
return error;
}
if((error = may_create(dir, entry, nd))) {
PDEBUG(D_FILE, "Not allowed to create file %d\n", error);
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
return error;
}
PDEBUG(D_FILE, "capfs_file_create called for %ld\n", dir->i_ino);
len_dir = strlen(CAPFS_I(dir)->name);
len_file = entry->d_name.len;
namebuf = (char *) kmalloc(len_dir + len_file + 2, GFP_KERNEL);
if (namebuf == NULL)
{
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
return -ENOMEM;
}
/* piece the whole file name together */
ptr = namebuf;
strcpy(ptr, CAPFS_I(dir)->name);
ptr += len_dir;
*ptr = '/';
ptr++;
strcpy(ptr, entry->d_name.name);
/* do the create */
meta.valid = V_MODE | V_UID | V_GID | V_TIMES;
meta.uid = current->fsuid;
meta.gid = current->fsgid;
meta.mode = mode;
meta.mtime = meta.atime = meta.ctime = CURRENT_TIME.tv_sec;
phys.blksize = DEFAULT_BLKSIZE;
phys.dist = DEFAULT_DIST;
phys.nodect = DEFAULT_NODECT;
PDEBUG(D_FILE, "capfs_file_create calling ll_capfs_create for %s [atime: %lu] [mtime: %lu] [ctime: %lu]\n", namebuf,
meta.atime, meta.mtime, meta.ctime);
if ((error = ll_capfs_create(CAPFS_SB(dir->i_sb), namebuf,
len_dir + len_file + 1, &meta, &phys)) < 0)
{
kfree(namebuf);
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
return error;
}
/* do a lookup so we can fill in the inode. not special */
if ((error = ll_capfs_lookup(CAPFS_SB(dir->i_sb), namebuf,
len_dir + len_file + 1, &meta, 0)) < 0)
{
kfree(namebuf);
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
return error;
}
/* fill in inode structure and remainder of capfs_inode */
if ((inode = iget(dir->i_sb, meta.handle)) == NULL)
{
kfree(namebuf);
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
return -ENOMEM;
}
pinode = CAPFS_I(inode);
if (pinode == NULL)
{
PERROR("found NULL pinode pointer\n");
iput(inode);
kfree(namebuf);
d_drop(entry);
write_unlock_inode(parent_pinode);
PEXIT;
//.........这里部分代码省略.........
开发者ID:mnv104,项目名称:capfs,代码行数:101,代码来源:file.c
示例15: handle_one_cmd
/*
* Return < 0 on error, 0 if OK, 1 on hangup.
*/
static
int handle_one_cmd(struct run_as_worker *worker)
{
int ret = 0;
struct run_as_data data;
ssize_t readlen, writelen;
struct run_as_ret sendret;
run_as_fct cmd;
uid_t prev_euid;
memset(&sendret, 0, sizeof(sendret));
sendret.fd = -1;
/*
* Stage 1: Receive run_as_data struct from the master.
* The structure contains the command type and all the parameters needed for
* its execution
*/
readlen = lttcomm_recv_unix_sock(worker->sockpair[1], &data,
sizeof(data));
if (readlen == 0) {
/* hang up */
ret = 1;
goto end;
}
if (readlen < sizeof(data)) {
PERROR("lttcomm_recv_unix_sock error");
ret = -1;
goto end;
}
cmd = run_as_enum_to_fct(data.cmd);
if (!cmd) {
ret = -1;
goto end;
}
/*
* Stage 2: Receive file descriptor from master.
* Some commands need a file descriptor as input so if it's needed we
* receive the fd using the Unix socket.
*/
ret = recv_fd_from_master(worker, data.cmd, &data.fd);
if (ret < 0) {
PERROR("recv_fd_from_master error");
ret = -1;
goto end;
}
prev_euid = getuid();
if (data.gid != getegid()) {
ret = setegid(data.gid);
if (ret < 0) {
sendret._error = true;
sendret._errno = errno;
PERROR("setegid");
goto write_return;
}
}
if (data.uid != prev_euid) {
ret = seteuid(data.uid);
if (ret < 0) {
sendret._error = true;
sendret._errno = errno;
PERROR("seteuid");
goto write_return;
}
}
/*
* Also set umask to 0 for mkdir executable bit.
*/
umask(0);
/*
* Stage 3: Execute the command
*/
ret = (*cmd)(&data, &sendret);
if (ret < 0) {
DBG("Execution of command returned an error");
}
write_return:
ret = cleanup_received_fd(data.cmd, data.fd);
if (ret < 0) {
ERR("Error cleaning up FD");
goto end;
}
/*
* Stage 4: Send run_as_ret structure to the master.
* This structure contain the return value of the command and the errno.
*/
writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret,
sizeof(sendret));
if (writelen < sizeof(sendret)) {
PERROR("lttcomm_send_unix_sock error");
//.........这里部分代码省略.........
请发表评论