/* Internal method that the other findFilesInFs can call after they * have opened FS_INFO. */ TSK_RETVAL_ENUM TskAuto::findFilesInFsInt(TSK_FS_INFO * a_fs_info, TSK_INUM_T a_inum) { TSK_FILTER_ENUM retval = filterFs(a_fs_info); if (retval == TSK_FILTER_STOP) return TSK_STOP; else if (retval == TSK_FILTER_SKIP) return TSK_OK; /* Walk the files, starting at the given inum */ if (tsk_fs_dir_walk(a_fs_info, a_inum, (TSK_FS_DIR_WALK_FLAG_ENUM) (TSK_FS_DIR_WALK_FLAG_RECURSE | m_fileFilterFlags), dirWalkCb, this)) { char msg[1024]; snprintf(msg, 1024, "Error walking directory in file system at offset %" PRIuOFF " (%s)", a_fs_info->offset, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); return TSK_ERR; } /* We could do some analysis of unallocated blocks at this point... */ return TSK_OK; }
/** * Starts in a specified byte offset of the opened disk images and looks for a * file system. Will start processing the file system at a specified * file system. Will call processFile() on each file * that is found in that directory. * * @param a_start Byte offset of file system starting location. * @param a_ftype Type of file system that will be analyzed. * @param a_inum inum to start walking files system at. * * @returns 1 on error and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_OFF_T a_start, TSK_FS_TYPE_ENUM a_ftype, TSK_INUM_T a_inum) { if (!m_img_info) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_NOTOPEN); tsk_error_set_errstr("findFilesInFs\n"); return 1; } TSK_FS_INFO *fs_info; /* Try it as a file system */ if ((fs_info = tsk_fs_open_img(m_img_info, a_start, a_ftype)) == NULL) { char msg[1024]; snprintf(msg, 1024, "Unable to open file system at offset %" PRIuOFF " (%s)", +a_start, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); /* We could do some carving on the volume data at this point */ return 1; } TSK_RETVAL_ENUM retval = findFilesInFsInt(fs_info, a_inum); tsk_fs_close(fs_info); if (retval == TSK_ERR) return 1; else return 0; }
//---------------------------------------------------------------------------------- //! Update internal module state after load or clone and enable notification handling again. //---------------------------------------------------------------------------------- void SegmentationEvaluationMetric::activateAttachments () { ML_TRACE_IN("SegmentationEvaluationMetric::activateAttachments ()"); // Update members to new field state here. // Call super class functionality to enable notification handling again. handleNotification(NULL); BaseOp::activateAttachments (); }
NSCAPI::nagiosReturn NSCPlugin::handleNotification(const char *channel, std::string &request, std::string &reply) { char *buffer = NULL; unsigned int len = 0; NSCAPI::nagiosReturn ret = handleNotification(channel, request.c_str(), request.size(), &buffer, &len); if (buffer != NULL) { reply = std::string(buffer, len); deleteBuffer(&buffer); } return ret; }
void tvFormStaticText::fillDlg() { tvFormObj::fillDlg(); tvFormText::fillDlg(); TFormObjDlg *dlg = (TFormObjDlg *)tvObject::dlg; dlg->textLine->setData( text ); handleNotification( dlg->fontSel ); }
/** * Starts in a specified byte offset of the opened disk images and looks for a * volume system or file system. Will call processFile() on each file * that is found. * @param a_start Byte offset to start analyzing from. * @param a_vtype Volume system type to analyze * @return 1 on error, 0 on success */ uint8_t TskAuto::findFilesInVs(TSK_OFF_T a_start, TSK_VS_TYPE_ENUM a_vtype) { if (!m_img_info) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_NOTOPEN); tsk_error_set_errstr("findFilesInVs\n"); return 1; } TSK_VS_INFO *vs_info; // USE mm_walk to get the volumes if ((vs_info = tsk_vs_open(m_img_info, a_start, a_vtype)) == NULL) { char msg[1024]; snprintf(msg, 1024, "Unable to open volume system at offset %" PRIuOFF " (%s)", a_start, tsk_error_get()); if (tsk_verbose) fprintf(stderr, "%s\n", msg); handleNotification(msg); /* There was no volume system, but there could be a file system */ tsk_error_reset(); if (findFilesInFs(a_start)) { return 1; } } else { TSK_FILTER_ENUM retval = filterVs(vs_info); if (retval == TSK_FILTER_STOP) return TSK_STOP; else if (retval == TSK_FILTER_SKIP) return TSK_OK; /* Walk the allocated volumes (skip metadata and unallocated volumes) */ if (tsk_vs_part_walk(vs_info, 0, vs_info->part_count - 1, m_volFilterFlags, vsWalkCb, this)) { tsk_vs_close(vs_info); return 1; } tsk_vs_close(vs_info); } return 0; }
/* * Class: sun_nio_ch_SctpChannelImpl * Method: receive0 * Signature: (ILsun/nio/ch/SctpResultContainer;J*Z)I */ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0 (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj, jlong address, jint length, jboolean peek) { SOCKADDR sa; int sa_len = sizeof(sa); ssize_t rv = 0; jlong *addr = jlong_to_ptr(address); struct iovec iov[1]; struct msghdr msg[1]; char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))]; int flags = peek == JNI_TRUE ? MSG_PEEK : 0; /* Set up the msghdr structure for receiving */ memset(msg, 0, sizeof (*msg)); msg->msg_name = &sa; msg->msg_namelen = sa_len; iov->iov_base = addr; iov->iov_len = length; msg->msg_iov = iov; msg->msg_iovlen = 1; msg->msg_control = cbuf; msg->msg_controllen = sizeof(cbuf); msg->msg_flags = 0; do { if ((rv = recvmsg(fd, msg, flags)) < 0) { if (errno == EWOULDBLOCK) { return IOS_UNAVAILABLE; } else if (errno == EINTR) { return IOS_INTERRUPTED; #ifdef __linux__ } else if (errno == ENOTCONN) { /* ENOTCONN when EOF reached */ rv = 0; /* there will be no control data */ msg->msg_controllen = 0; #endif /* __linux__ */ } else { handleSocketError(env, errno); return 0; } } if (msg->msg_flags & MSG_NOTIFICATION) { char *bufp = (char*)addr; union sctp_notification *snp; jboolean allocated = JNI_FALSE; if (rv > SCTP_NOTIFICATION_SIZE) { JNU_ThrowInternalError(env, "should not reach here"); return -1; } if (!(msg->msg_flags & MSG_EOR) && length < SCTP_NOTIFICATION_SIZE) { char* newBuf; int rvSAVE = rv; if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) { JNU_ThrowOutOfMemoryError(env, "Out of native heap space."); return -1; } allocated = JNI_TRUE; memcpy(newBuf, addr, rv); iov->iov_base = newBuf + rv; iov->iov_len = SCTP_NOTIFICATION_SIZE - rv; if ((rv = recvmsg(fd, msg, flags)) < 0) { handleSocketError(env, errno); return 0; } bufp = newBuf; rv += rvSAVE; } #ifdef __sparc else if ((intptr_t)addr & 0x3) { /* the given buffer is not 4 byte aligned */ char* newBuf; if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) { JNU_ThrowOutOfMemoryError(env, "Out of native heap space."); return -1; } allocated = JNI_TRUE; memcpy(newBuf, addr, rv); bufp = newBuf; } #endif snp = (union sctp_notification *) bufp; if (handleNotification(env, fd, resultContainerObj, snp, rv, (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa ) == JNI_TRUE) { /* We have received a notification that is of interest to to the Java API. The appropriate notification will be set in the result container. */ if (allocated == JNI_TRUE) { free(bufp); } return 0; } if (allocated == JNI_TRUE) { free(bufp); } // set iov back to addr, and reset msg_controllen iov->iov_base = addr; iov->iov_len = length; msg->msg_control = cbuf; msg->msg_controllen = sizeof(cbuf); } } while (msg->msg_flags & MSG_NOTIFICATION); handleMessage(env, resultContainerObj, msg, rv, (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa); return rv; }
/* * Class: sun_nio_ch_sctp_SctpChannelImpl * Method: receive0 * Signature: (ILsun/nio/ch/sctp/ResultContainer;J*Z)I */ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj, jlong address, jint length, jboolean peek) { SOCKADDR sa; int sa_len = sizeof(sa); ssize_t rv = 0; jlong *addr = jlong_to_ptr(address); struct iovec iov[1]; struct msghdr msg[1]; char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))]; int flags = peek == JNI_TRUE ? MSG_PEEK : 0; /* Set up the msghdr structure for receiving */ memset(msg, 0, sizeof (*msg)); msg->msg_name = &sa; msg->msg_namelen = sa_len; iov->iov_base = addr; iov->iov_len = length; msg->msg_iov = iov; msg->msg_iovlen = 1; msg->msg_control = cbuf; msg->msg_controllen = sizeof(cbuf); msg->msg_flags = 0; do { if ((rv = recvmsg(fd, msg, flags)) < 0) { if (errno == EWOULDBLOCK) { return IOS_UNAVAILABLE; } else if (errno == EINTR) { return IOS_INTERRUPTED; #ifdef __linux__ } else if (errno == ENOTCONN) { /* ENOTCONN when EOF reached */ rv = 0; /* there will be no control data */ msg->msg_controllen = 0; #endif /* __linux__ */ } else { handleSocketError(env, errno); return 0; } } if (msg->msg_flags & MSG_NOTIFICATION) { char *bufp = (char*)addr; union sctp_notification *snp; if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) { char buf[NOTIFICATION_BUFFER_SIZE]; int rvSAVE = rv; memcpy(buf, addr, rv); iov->iov_base = buf + rv; iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv; if ((rv = recvmsg(fd, msg, flags)) < 0) { handleSocketError(env, errno); return 0; } bufp = buf; rv += rvSAVE; } snp = (union sctp_notification *) bufp; if (handleNotification(env, fd, resultContainerObj, snp, rv, (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa ) == JNI_TRUE) { /* We have received a notification that is of interest to to the Java API. The appropriate notification will be set in the result container. */ return 0; } // set iov back to addr, and reset msg_controllen iov->iov_base = addr; iov->iov_len = length; msg->msg_control = cbuf; msg->msg_controllen = sizeof(cbuf); } } while (msg->msg_flags & MSG_NOTIFICATION); handleMessage(env, resultContainerObj, msg, rv, (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa); return rv; }
TNotificationClient::TNotificationClient(QString &serverHostname, quint16 serverPort){ this->serverHostname = serverHostname; this->serverPort = serverPort; connect(this,SIGNAL(notificationCame()),this,SLOT(handleNotification())); }